1
22
23 package com.liferay.portlet.blogs.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
27 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
28 import com.liferay.portal.kernel.dao.orm.Query;
29 import com.liferay.portal.kernel.dao.orm.QueryPos;
30 import com.liferay.portal.kernel.dao.orm.QueryUtil;
31 import com.liferay.portal.kernel.dao.orm.Session;
32 import com.liferay.portal.kernel.util.GetterUtil;
33 import com.liferay.portal.kernel.util.ListUtil;
34 import com.liferay.portal.kernel.util.OrderByComparator;
35 import com.liferay.portal.kernel.util.StringPool;
36 import com.liferay.portal.kernel.util.StringUtil;
37 import com.liferay.portal.model.ModelListener;
38 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
39
40 import com.liferay.portlet.blogs.NoSuchStatsUserException;
41 import com.liferay.portlet.blogs.model.BlogsStatsUser;
42 import com.liferay.portlet.blogs.model.impl.BlogsStatsUserImpl;
43 import com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl;
44
45 import org.apache.commons.logging.Log;
46 import org.apache.commons.logging.LogFactory;
47
48 import java.util.ArrayList;
49 import java.util.Collections;
50 import java.util.Iterator;
51 import java.util.List;
52
53
59 public class BlogsStatsUserPersistenceImpl extends BasePersistenceImpl
60 implements BlogsStatsUserPersistence {
61 public BlogsStatsUser create(long statsUserId) {
62 BlogsStatsUser blogsStatsUser = new BlogsStatsUserImpl();
63
64 blogsStatsUser.setNew(true);
65 blogsStatsUser.setPrimaryKey(statsUserId);
66
67 return blogsStatsUser;
68 }
69
70 public BlogsStatsUser remove(long statsUserId)
71 throws NoSuchStatsUserException, SystemException {
72 Session session = null;
73
74 try {
75 session = openSession();
76
77 BlogsStatsUser blogsStatsUser = (BlogsStatsUser)session.get(BlogsStatsUserImpl.class,
78 new Long(statsUserId));
79
80 if (blogsStatsUser == null) {
81 if (_log.isWarnEnabled()) {
82 _log.warn("No BlogsStatsUser exists with the primary key " +
83 statsUserId);
84 }
85
86 throw new NoSuchStatsUserException(
87 "No BlogsStatsUser exists with the primary key " +
88 statsUserId);
89 }
90
91 return remove(blogsStatsUser);
92 }
93 catch (NoSuchStatsUserException nsee) {
94 throw nsee;
95 }
96 catch (Exception e) {
97 throw processException(e);
98 }
99 finally {
100 closeSession(session);
101 }
102 }
103
104 public BlogsStatsUser remove(BlogsStatsUser blogsStatsUser)
105 throws SystemException {
106 if (_listeners.length > 0) {
107 for (ModelListener listener : _listeners) {
108 listener.onBeforeRemove(blogsStatsUser);
109 }
110 }
111
112 blogsStatsUser = removeImpl(blogsStatsUser);
113
114 if (_listeners.length > 0) {
115 for (ModelListener listener : _listeners) {
116 listener.onAfterRemove(blogsStatsUser);
117 }
118 }
119
120 return blogsStatsUser;
121 }
122
123 protected BlogsStatsUser removeImpl(BlogsStatsUser blogsStatsUser)
124 throws SystemException {
125 Session session = null;
126
127 try {
128 session = openSession();
129
130 session.delete(blogsStatsUser);
131
132 session.flush();
133
134 return blogsStatsUser;
135 }
136 catch (Exception e) {
137 throw processException(e);
138 }
139 finally {
140 closeSession(session);
141
142 FinderCacheUtil.clearCache(BlogsStatsUser.class.getName());
143 }
144 }
145
146
149 public BlogsStatsUser update(BlogsStatsUser blogsStatsUser)
150 throws SystemException {
151 if (_log.isWarnEnabled()) {
152 _log.warn(
153 "Using the deprecated update(BlogsStatsUser blogsStatsUser) method. Use update(BlogsStatsUser blogsStatsUser, boolean merge) instead.");
154 }
155
156 return update(blogsStatsUser, false);
157 }
158
159
172 public BlogsStatsUser update(BlogsStatsUser blogsStatsUser, boolean merge)
173 throws SystemException {
174 boolean isNew = blogsStatsUser.isNew();
175
176 if (_listeners.length > 0) {
177 for (ModelListener listener : _listeners) {
178 if (isNew) {
179 listener.onBeforeCreate(blogsStatsUser);
180 }
181 else {
182 listener.onBeforeUpdate(blogsStatsUser);
183 }
184 }
185 }
186
187 blogsStatsUser = updateImpl(blogsStatsUser, merge);
188
189 if (_listeners.length > 0) {
190 for (ModelListener listener : _listeners) {
191 if (isNew) {
192 listener.onAfterCreate(blogsStatsUser);
193 }
194 else {
195 listener.onAfterUpdate(blogsStatsUser);
196 }
197 }
198 }
199
200 return blogsStatsUser;
201 }
202
203 public BlogsStatsUser updateImpl(
204 com.liferay.portlet.blogs.model.BlogsStatsUser blogsStatsUser,
205 boolean merge) throws SystemException {
206 Session session = null;
207
208 try {
209 session = openSession();
210
211 if (merge) {
212 session.merge(blogsStatsUser);
213 }
214 else {
215 if (blogsStatsUser.isNew()) {
216 session.save(blogsStatsUser);
217 }
218 }
219
220 session.flush();
221
222 blogsStatsUser.setNew(false);
223
224 return blogsStatsUser;
225 }
226 catch (Exception e) {
227 throw processException(e);
228 }
229 finally {
230 closeSession(session);
231
232 FinderCacheUtil.clearCache(BlogsStatsUser.class.getName());
233 }
234 }
235
236 public BlogsStatsUser findByPrimaryKey(long statsUserId)
237 throws NoSuchStatsUserException, SystemException {
238 BlogsStatsUser blogsStatsUser = fetchByPrimaryKey(statsUserId);
239
240 if (blogsStatsUser == null) {
241 if (_log.isWarnEnabled()) {
242 _log.warn("No BlogsStatsUser exists with the primary key " +
243 statsUserId);
244 }
245
246 throw new NoSuchStatsUserException(
247 "No BlogsStatsUser exists with the primary key " + statsUserId);
248 }
249
250 return blogsStatsUser;
251 }
252
253 public BlogsStatsUser fetchByPrimaryKey(long statsUserId)
254 throws SystemException {
255 Session session = null;
256
257 try {
258 session = openSession();
259
260 return (BlogsStatsUser)session.get(BlogsStatsUserImpl.class,
261 new Long(statsUserId));
262 }
263 catch (Exception e) {
264 throw processException(e);
265 }
266 finally {
267 closeSession(session);
268 }
269 }
270
271 public List<BlogsStatsUser> findByGroupId(long groupId)
272 throws SystemException {
273 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
274 String finderClassName = BlogsStatsUser.class.getName();
275 String finderMethodName = "findByGroupId";
276 String[] finderParams = new String[] { Long.class.getName() };
277 Object[] finderArgs = new Object[] { new Long(groupId) };
278
279 Object result = null;
280
281 if (finderClassNameCacheEnabled) {
282 result = FinderCacheUtil.getResult(finderClassName,
283 finderMethodName, finderParams, finderArgs, this);
284 }
285
286 if (result == null) {
287 Session session = null;
288
289 try {
290 session = openSession();
291
292 StringBuilder query = new StringBuilder();
293
294 query.append(
295 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
296
297 query.append("groupId = ?");
298
299 query.append(" ");
300
301 query.append("ORDER BY ");
302
303 query.append("entryCount DESC");
304
305 Query q = session.createQuery(query.toString());
306
307 QueryPos qPos = QueryPos.getInstance(q);
308
309 qPos.add(groupId);
310
311 List<BlogsStatsUser> list = q.list();
312
313 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
314 finderClassName, finderMethodName, finderParams,
315 finderArgs, list);
316
317 return list;
318 }
319 catch (Exception e) {
320 throw processException(e);
321 }
322 finally {
323 closeSession(session);
324 }
325 }
326 else {
327 return (List<BlogsStatsUser>)result;
328 }
329 }
330
331 public List<BlogsStatsUser> findByGroupId(long groupId, int start, int end)
332 throws SystemException {
333 return findByGroupId(groupId, start, end, null);
334 }
335
336 public List<BlogsStatsUser> findByGroupId(long groupId, int start, int end,
337 OrderByComparator obc) throws SystemException {
338 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
339 String finderClassName = BlogsStatsUser.class.getName();
340 String finderMethodName = "findByGroupId";
341 String[] finderParams = new String[] {
342 Long.class.getName(),
343
344 "java.lang.Integer", "java.lang.Integer",
345 "com.liferay.portal.kernel.util.OrderByComparator"
346 };
347 Object[] finderArgs = new Object[] {
348 new Long(groupId),
349
350 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
351 };
352
353 Object result = null;
354
355 if (finderClassNameCacheEnabled) {
356 result = FinderCacheUtil.getResult(finderClassName,
357 finderMethodName, finderParams, finderArgs, this);
358 }
359
360 if (result == null) {
361 Session session = null;
362
363 try {
364 session = openSession();
365
366 StringBuilder query = new StringBuilder();
367
368 query.append(
369 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
370
371 query.append("groupId = ?");
372
373 query.append(" ");
374
375 if (obc != null) {
376 query.append("ORDER BY ");
377 query.append(obc.getOrderBy());
378 }
379
380 else {
381 query.append("ORDER BY ");
382
383 query.append("entryCount DESC");
384 }
385
386 Query q = session.createQuery(query.toString());
387
388 QueryPos qPos = QueryPos.getInstance(q);
389
390 qPos.add(groupId);
391
392 List<BlogsStatsUser> list = (List<BlogsStatsUser>)QueryUtil.list(q,
393 getDialect(), start, end);
394
395 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
396 finderClassName, finderMethodName, finderParams,
397 finderArgs, list);
398
399 return list;
400 }
401 catch (Exception e) {
402 throw processException(e);
403 }
404 finally {
405 closeSession(session);
406 }
407 }
408 else {
409 return (List<BlogsStatsUser>)result;
410 }
411 }
412
413 public BlogsStatsUser findByGroupId_First(long groupId,
414 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
415 List<BlogsStatsUser> list = findByGroupId(groupId, 0, 1, obc);
416
417 if (list.size() == 0) {
418 StringBuilder msg = new StringBuilder();
419
420 msg.append("No BlogsStatsUser exists with the key {");
421
422 msg.append("groupId=" + groupId);
423
424 msg.append(StringPool.CLOSE_CURLY_BRACE);
425
426 throw new NoSuchStatsUserException(msg.toString());
427 }
428 else {
429 return list.get(0);
430 }
431 }
432
433 public BlogsStatsUser findByGroupId_Last(long groupId, OrderByComparator obc)
434 throws NoSuchStatsUserException, SystemException {
435 int count = countByGroupId(groupId);
436
437 List<BlogsStatsUser> list = findByGroupId(groupId, count - 1, count, obc);
438
439 if (list.size() == 0) {
440 StringBuilder msg = new StringBuilder();
441
442 msg.append("No BlogsStatsUser exists with the key {");
443
444 msg.append("groupId=" + groupId);
445
446 msg.append(StringPool.CLOSE_CURLY_BRACE);
447
448 throw new NoSuchStatsUserException(msg.toString());
449 }
450 else {
451 return list.get(0);
452 }
453 }
454
455 public BlogsStatsUser[] findByGroupId_PrevAndNext(long statsUserId,
456 long groupId, OrderByComparator obc)
457 throws NoSuchStatsUserException, SystemException {
458 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
459
460 int count = countByGroupId(groupId);
461
462 Session session = null;
463
464 try {
465 session = openSession();
466
467 StringBuilder query = new StringBuilder();
468
469 query.append(
470 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
471
472 query.append("groupId = ?");
473
474 query.append(" ");
475
476 if (obc != null) {
477 query.append("ORDER BY ");
478 query.append(obc.getOrderBy());
479 }
480
481 else {
482 query.append("ORDER BY ");
483
484 query.append("entryCount DESC");
485 }
486
487 Query q = session.createQuery(query.toString());
488
489 QueryPos qPos = QueryPos.getInstance(q);
490
491 qPos.add(groupId);
492
493 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
494 blogsStatsUser);
495
496 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
497
498 array[0] = (BlogsStatsUser)objArray[0];
499 array[1] = (BlogsStatsUser)objArray[1];
500 array[2] = (BlogsStatsUser)objArray[2];
501
502 return array;
503 }
504 catch (Exception e) {
505 throw processException(e);
506 }
507 finally {
508 closeSession(session);
509 }
510 }
511
512 public List<BlogsStatsUser> findByUserId(long userId)
513 throws SystemException {
514 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
515 String finderClassName = BlogsStatsUser.class.getName();
516 String finderMethodName = "findByUserId";
517 String[] finderParams = new String[] { Long.class.getName() };
518 Object[] finderArgs = new Object[] { new Long(userId) };
519
520 Object result = null;
521
522 if (finderClassNameCacheEnabled) {
523 result = FinderCacheUtil.getResult(finderClassName,
524 finderMethodName, finderParams, finderArgs, this);
525 }
526
527 if (result == null) {
528 Session session = null;
529
530 try {
531 session = openSession();
532
533 StringBuilder query = new StringBuilder();
534
535 query.append(
536 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
537
538 query.append("userId = ?");
539
540 query.append(" ");
541
542 query.append("ORDER BY ");
543
544 query.append("entryCount DESC");
545
546 Query q = session.createQuery(query.toString());
547
548 QueryPos qPos = QueryPos.getInstance(q);
549
550 qPos.add(userId);
551
552 List<BlogsStatsUser> list = q.list();
553
554 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
555 finderClassName, finderMethodName, finderParams,
556 finderArgs, list);
557
558 return list;
559 }
560 catch (Exception e) {
561 throw processException(e);
562 }
563 finally {
564 closeSession(session);
565 }
566 }
567 else {
568 return (List<BlogsStatsUser>)result;
569 }
570 }
571
572 public List<BlogsStatsUser> findByUserId(long userId, int start, int end)
573 throws SystemException {
574 return findByUserId(userId, start, end, null);
575 }
576
577 public List<BlogsStatsUser> findByUserId(long userId, int start, int end,
578 OrderByComparator obc) throws SystemException {
579 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
580 String finderClassName = BlogsStatsUser.class.getName();
581 String finderMethodName = "findByUserId";
582 String[] finderParams = new String[] {
583 Long.class.getName(),
584
585 "java.lang.Integer", "java.lang.Integer",
586 "com.liferay.portal.kernel.util.OrderByComparator"
587 };
588 Object[] finderArgs = new Object[] {
589 new Long(userId),
590
591 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
592 };
593
594 Object result = null;
595
596 if (finderClassNameCacheEnabled) {
597 result = FinderCacheUtil.getResult(finderClassName,
598 finderMethodName, finderParams, finderArgs, this);
599 }
600
601 if (result == null) {
602 Session session = null;
603
604 try {
605 session = openSession();
606
607 StringBuilder query = new StringBuilder();
608
609 query.append(
610 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
611
612 query.append("userId = ?");
613
614 query.append(" ");
615
616 if (obc != null) {
617 query.append("ORDER BY ");
618 query.append(obc.getOrderBy());
619 }
620
621 else {
622 query.append("ORDER BY ");
623
624 query.append("entryCount DESC");
625 }
626
627 Query q = session.createQuery(query.toString());
628
629 QueryPos qPos = QueryPos.getInstance(q);
630
631 qPos.add(userId);
632
633 List<BlogsStatsUser> list = (List<BlogsStatsUser>)QueryUtil.list(q,
634 getDialect(), start, end);
635
636 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
637 finderClassName, finderMethodName, finderParams,
638 finderArgs, list);
639
640 return list;
641 }
642 catch (Exception e) {
643 throw processException(e);
644 }
645 finally {
646 closeSession(session);
647 }
648 }
649 else {
650 return (List<BlogsStatsUser>)result;
651 }
652 }
653
654 public BlogsStatsUser findByUserId_First(long userId, OrderByComparator obc)
655 throws NoSuchStatsUserException, SystemException {
656 List<BlogsStatsUser> list = findByUserId(userId, 0, 1, obc);
657
658 if (list.size() == 0) {
659 StringBuilder msg = new StringBuilder();
660
661 msg.append("No BlogsStatsUser exists with the key {");
662
663 msg.append("userId=" + userId);
664
665 msg.append(StringPool.CLOSE_CURLY_BRACE);
666
667 throw new NoSuchStatsUserException(msg.toString());
668 }
669 else {
670 return list.get(0);
671 }
672 }
673
674 public BlogsStatsUser findByUserId_Last(long userId, OrderByComparator obc)
675 throws NoSuchStatsUserException, SystemException {
676 int count = countByUserId(userId);
677
678 List<BlogsStatsUser> list = findByUserId(userId, count - 1, count, obc);
679
680 if (list.size() == 0) {
681 StringBuilder msg = new StringBuilder();
682
683 msg.append("No BlogsStatsUser exists with the key {");
684
685 msg.append("userId=" + userId);
686
687 msg.append(StringPool.CLOSE_CURLY_BRACE);
688
689 throw new NoSuchStatsUserException(msg.toString());
690 }
691 else {
692 return list.get(0);
693 }
694 }
695
696 public BlogsStatsUser[] findByUserId_PrevAndNext(long statsUserId,
697 long userId, OrderByComparator obc)
698 throws NoSuchStatsUserException, SystemException {
699 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
700
701 int count = countByUserId(userId);
702
703 Session session = null;
704
705 try {
706 session = openSession();
707
708 StringBuilder query = new StringBuilder();
709
710 query.append(
711 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
712
713 query.append("userId = ?");
714
715 query.append(" ");
716
717 if (obc != null) {
718 query.append("ORDER BY ");
719 query.append(obc.getOrderBy());
720 }
721
722 else {
723 query.append("ORDER BY ");
724
725 query.append("entryCount DESC");
726 }
727
728 Query q = session.createQuery(query.toString());
729
730 QueryPos qPos = QueryPos.getInstance(q);
731
732 qPos.add(userId);
733
734 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
735 blogsStatsUser);
736
737 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
738
739 array[0] = (BlogsStatsUser)objArray[0];
740 array[1] = (BlogsStatsUser)objArray[1];
741 array[2] = (BlogsStatsUser)objArray[2];
742
743 return array;
744 }
745 catch (Exception e) {
746 throw processException(e);
747 }
748 finally {
749 closeSession(session);
750 }
751 }
752
753 public BlogsStatsUser findByG_U(long groupId, long userId)
754 throws NoSuchStatsUserException, SystemException {
755 BlogsStatsUser blogsStatsUser = fetchByG_U(groupId, userId);
756
757 if (blogsStatsUser == null) {
758 StringBuilder msg = new StringBuilder();
759
760 msg.append("No BlogsStatsUser exists with the key {");
761
762 msg.append("groupId=" + groupId);
763
764 msg.append(", ");
765 msg.append("userId=" + userId);
766
767 msg.append(StringPool.CLOSE_CURLY_BRACE);
768
769 if (_log.isWarnEnabled()) {
770 _log.warn(msg.toString());
771 }
772
773 throw new NoSuchStatsUserException(msg.toString());
774 }
775
776 return blogsStatsUser;
777 }
778
779 public BlogsStatsUser fetchByG_U(long groupId, long userId)
780 throws SystemException {
781 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
782 String finderClassName = BlogsStatsUser.class.getName();
783 String finderMethodName = "fetchByG_U";
784 String[] finderParams = new String[] {
785 Long.class.getName(), Long.class.getName()
786 };
787 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
788
789 Object result = null;
790
791 if (finderClassNameCacheEnabled) {
792 result = FinderCacheUtil.getResult(finderClassName,
793 finderMethodName, finderParams, finderArgs, this);
794 }
795
796 if (result == null) {
797 Session session = null;
798
799 try {
800 session = openSession();
801
802 StringBuilder query = new StringBuilder();
803
804 query.append(
805 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
806
807 query.append("groupId = ?");
808
809 query.append(" AND ");
810
811 query.append("userId = ?");
812
813 query.append(" ");
814
815 query.append("ORDER BY ");
816
817 query.append("entryCount DESC");
818
819 Query q = session.createQuery(query.toString());
820
821 QueryPos qPos = QueryPos.getInstance(q);
822
823 qPos.add(groupId);
824
825 qPos.add(userId);
826
827 List<BlogsStatsUser> list = q.list();
828
829 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
830 finderClassName, finderMethodName, finderParams,
831 finderArgs, list);
832
833 if (list.size() == 0) {
834 return null;
835 }
836 else {
837 return list.get(0);
838 }
839 }
840 catch (Exception e) {
841 throw processException(e);
842 }
843 finally {
844 closeSession(session);
845 }
846 }
847 else {
848 List<BlogsStatsUser> list = (List<BlogsStatsUser>)result;
849
850 if (list.size() == 0) {
851 return null;
852 }
853 else {
854 return list.get(0);
855 }
856 }
857 }
858
859 public List<BlogsStatsUser> findByG_E(long groupId, int entryCount)
860 throws SystemException {
861 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
862 String finderClassName = BlogsStatsUser.class.getName();
863 String finderMethodName = "findByG_E";
864 String[] finderParams = new String[] {
865 Long.class.getName(), Integer.class.getName()
866 };
867 Object[] finderArgs = new Object[] {
868 new Long(groupId), new Integer(entryCount)
869 };
870
871 Object result = null;
872
873 if (finderClassNameCacheEnabled) {
874 result = FinderCacheUtil.getResult(finderClassName,
875 finderMethodName, finderParams, finderArgs, this);
876 }
877
878 if (result == null) {
879 Session session = null;
880
881 try {
882 session = openSession();
883
884 StringBuilder query = new StringBuilder();
885
886 query.append(
887 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
888
889 query.append("groupId = ?");
890
891 query.append(" AND ");
892
893 query.append("entryCount != ?");
894
895 query.append(" ");
896
897 query.append("ORDER BY ");
898
899 query.append("entryCount DESC");
900
901 Query q = session.createQuery(query.toString());
902
903 QueryPos qPos = QueryPos.getInstance(q);
904
905 qPos.add(groupId);
906
907 qPos.add(entryCount);
908
909 List<BlogsStatsUser> list = q.list();
910
911 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
912 finderClassName, finderMethodName, finderParams,
913 finderArgs, list);
914
915 return list;
916 }
917 catch (Exception e) {
918 throw processException(e);
919 }
920 finally {
921 closeSession(session);
922 }
923 }
924 else {
925 return (List<BlogsStatsUser>)result;
926 }
927 }
928
929 public List<BlogsStatsUser> findByG_E(long groupId, int entryCount,
930 int start, int end) throws SystemException {
931 return findByG_E(groupId, entryCount, start, end, null);
932 }
933
934 public List<BlogsStatsUser> findByG_E(long groupId, int entryCount,
935 int start, int end, OrderByComparator obc) throws SystemException {
936 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
937 String finderClassName = BlogsStatsUser.class.getName();
938 String finderMethodName = "findByG_E";
939 String[] finderParams = new String[] {
940 Long.class.getName(), Integer.class.getName(),
941
942 "java.lang.Integer", "java.lang.Integer",
943 "com.liferay.portal.kernel.util.OrderByComparator"
944 };
945 Object[] finderArgs = new Object[] {
946 new Long(groupId), new Integer(entryCount),
947
948 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
949 };
950
951 Object result = null;
952
953 if (finderClassNameCacheEnabled) {
954 result = FinderCacheUtil.getResult(finderClassName,
955 finderMethodName, finderParams, finderArgs, this);
956 }
957
958 if (result == null) {
959 Session session = null;
960
961 try {
962 session = openSession();
963
964 StringBuilder query = new StringBuilder();
965
966 query.append(
967 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
968
969 query.append("groupId = ?");
970
971 query.append(" AND ");
972
973 query.append("entryCount != ?");
974
975 query.append(" ");
976
977 if (obc != null) {
978 query.append("ORDER BY ");
979 query.append(obc.getOrderBy());
980 }
981
982 else {
983 query.append("ORDER BY ");
984
985 query.append("entryCount DESC");
986 }
987
988 Query q = session.createQuery(query.toString());
989
990 QueryPos qPos = QueryPos.getInstance(q);
991
992 qPos.add(groupId);
993
994 qPos.add(entryCount);
995
996 List<BlogsStatsUser> list = (List<BlogsStatsUser>)QueryUtil.list(q,
997 getDialect(), start, end);
998
999 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1000 finderClassName, finderMethodName, finderParams,
1001 finderArgs, list);
1002
1003 return list;
1004 }
1005 catch (Exception e) {
1006 throw processException(e);
1007 }
1008 finally {
1009 closeSession(session);
1010 }
1011 }
1012 else {
1013 return (List<BlogsStatsUser>)result;
1014 }
1015 }
1016
1017 public BlogsStatsUser findByG_E_First(long groupId, int entryCount,
1018 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1019 List<BlogsStatsUser> list = findByG_E(groupId, entryCount, 0, 1, obc);
1020
1021 if (list.size() == 0) {
1022 StringBuilder msg = new StringBuilder();
1023
1024 msg.append("No BlogsStatsUser exists with the key {");
1025
1026 msg.append("groupId=" + groupId);
1027
1028 msg.append(", ");
1029 msg.append("entryCount=" + entryCount);
1030
1031 msg.append(StringPool.CLOSE_CURLY_BRACE);
1032
1033 throw new NoSuchStatsUserException(msg.toString());
1034 }
1035 else {
1036 return list.get(0);
1037 }
1038 }
1039
1040 public BlogsStatsUser findByG_E_Last(long groupId, int entryCount,
1041 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1042 int count = countByG_E(groupId, entryCount);
1043
1044 List<BlogsStatsUser> list = findByG_E(groupId, entryCount, count - 1,
1045 count, obc);
1046
1047 if (list.size() == 0) {
1048 StringBuilder msg = new StringBuilder();
1049
1050 msg.append("No BlogsStatsUser exists with the key {");
1051
1052 msg.append("groupId=" + groupId);
1053
1054 msg.append(", ");
1055 msg.append("entryCount=" + entryCount);
1056
1057 msg.append(StringPool.CLOSE_CURLY_BRACE);
1058
1059 throw new NoSuchStatsUserException(msg.toString());
1060 }
1061 else {
1062 return list.get(0);
1063 }
1064 }
1065
1066 public BlogsStatsUser[] findByG_E_PrevAndNext(long statsUserId,
1067 long groupId, int entryCount, OrderByComparator obc)
1068 throws NoSuchStatsUserException, SystemException {
1069 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
1070
1071 int count = countByG_E(groupId, entryCount);
1072
1073 Session session = null;
1074
1075 try {
1076 session = openSession();
1077
1078 StringBuilder query = new StringBuilder();
1079
1080 query.append(
1081 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1082
1083 query.append("groupId = ?");
1084
1085 query.append(" AND ");
1086
1087 query.append("entryCount != ?");
1088
1089 query.append(" ");
1090
1091 if (obc != null) {
1092 query.append("ORDER BY ");
1093 query.append(obc.getOrderBy());
1094 }
1095
1096 else {
1097 query.append("ORDER BY ");
1098
1099 query.append("entryCount DESC");
1100 }
1101
1102 Query q = session.createQuery(query.toString());
1103
1104 QueryPos qPos = QueryPos.getInstance(q);
1105
1106 qPos.add(groupId);
1107
1108 qPos.add(entryCount);
1109
1110 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1111 blogsStatsUser);
1112
1113 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
1114
1115 array[0] = (BlogsStatsUser)objArray[0];
1116 array[1] = (BlogsStatsUser)objArray[1];
1117 array[2] = (BlogsStatsUser)objArray[2];
1118
1119 return array;
1120 }
1121 catch (Exception e) {
1122 throw processException(e);
1123 }
1124 finally {
1125 closeSession(session);
1126 }
1127 }
1128
1129 public List<BlogsStatsUser> findByC_E(long companyId, int entryCount)
1130 throws SystemException {
1131 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
1132 String finderClassName = BlogsStatsUser.class.getName();
1133 String finderMethodName = "findByC_E";
1134 String[] finderParams = new String[] {
1135 Long.class.getName(), Integer.class.getName()
1136 };
1137 Object[] finderArgs = new Object[] {
1138 new Long(companyId), new Integer(entryCount)
1139 };
1140
1141 Object result = null;
1142
1143 if (finderClassNameCacheEnabled) {
1144 result = FinderCacheUtil.getResult(finderClassName,
1145 finderMethodName, finderParams, finderArgs, this);
1146 }
1147
1148 if (result == null) {
1149 Session session = null;
1150
1151 try {
1152 session = openSession();
1153
1154 StringBuilder query = new StringBuilder();
1155
1156 query.append(
1157 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1158
1159 query.append("companyId = ?");
1160
1161 query.append(" AND ");
1162
1163 query.append("entryCount != ?");
1164
1165 query.append(" ");
1166
1167 query.append("ORDER BY ");
1168
1169 query.append("entryCount DESC");
1170
1171 Query q = session.createQuery(query.toString());
1172
1173 QueryPos qPos = QueryPos.getInstance(q);
1174
1175 qPos.add(companyId);
1176
1177 qPos.add(entryCount);
1178
1179 List<BlogsStatsUser> list = q.list();
1180
1181 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1182 finderClassName, finderMethodName, finderParams,
1183 finderArgs, list);
1184
1185 return list;
1186 }
1187 catch (Exception e) {
1188 throw processException(e);
1189 }
1190 finally {
1191 closeSession(session);
1192 }
1193 }
1194 else {
1195 return (List<BlogsStatsUser>)result;
1196 }
1197 }
1198
1199 public List<BlogsStatsUser> findByC_E(long companyId, int entryCount,
1200 int start, int end) throws SystemException {
1201 return findByC_E(companyId, entryCount, start, end, null);
1202 }
1203
1204 public List<BlogsStatsUser> findByC_E(long companyId, int entryCount,
1205 int start, int end, OrderByComparator obc) throws SystemException {
1206 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
1207 String finderClassName = BlogsStatsUser.class.getName();
1208 String finderMethodName = "findByC_E";
1209 String[] finderParams = new String[] {
1210 Long.class.getName(), Integer.class.getName(),
1211
1212 "java.lang.Integer", "java.lang.Integer",
1213 "com.liferay.portal.kernel.util.OrderByComparator"
1214 };
1215 Object[] finderArgs = new Object[] {
1216 new Long(companyId), new Integer(entryCount),
1217
1218 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1219 };
1220
1221 Object result = null;
1222
1223 if (finderClassNameCacheEnabled) {
1224 result = FinderCacheUtil.getResult(finderClassName,
1225 finderMethodName, finderParams, finderArgs, this);
1226 }
1227
1228 if (result == null) {
1229 Session session = null;
1230
1231 try {
1232 session = openSession();
1233
1234 StringBuilder query = new StringBuilder();
1235
1236 query.append(
1237 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1238
1239 query.append("companyId = ?");
1240
1241 query.append(" AND ");
1242
1243 query.append("entryCount != ?");
1244
1245 query.append(" ");
1246
1247 if (obc != null) {
1248 query.append("ORDER BY ");
1249 query.append(obc.getOrderBy());
1250 }
1251
1252 else {
1253 query.append("ORDER BY ");
1254
1255 query.append("entryCount DESC");
1256 }
1257
1258 Query q = session.createQuery(query.toString());
1259
1260 QueryPos qPos = QueryPos.getInstance(q);
1261
1262 qPos.add(companyId);
1263
1264 qPos.add(entryCount);
1265
1266 List<BlogsStatsUser> list = (List<BlogsStatsUser>)QueryUtil.list(q,
1267 getDialect(), start, end);
1268
1269 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1270 finderClassName, finderMethodName, finderParams,
1271 finderArgs, list);
1272
1273 return list;
1274 }
1275 catch (Exception e) {
1276 throw processException(e);
1277 }
1278 finally {
1279 closeSession(session);
1280 }
1281 }
1282 else {
1283 return (List<BlogsStatsUser>)result;
1284 }
1285 }
1286
1287 public BlogsStatsUser findByC_E_First(long companyId, int entryCount,
1288 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1289 List<BlogsStatsUser> list = findByC_E(companyId, entryCount, 0, 1, obc);
1290
1291 if (list.size() == 0) {
1292 StringBuilder msg = new StringBuilder();
1293
1294 msg.append("No BlogsStatsUser exists with the key {");
1295
1296 msg.append("companyId=" + companyId);
1297
1298 msg.append(", ");
1299 msg.append("entryCount=" + entryCount);
1300
1301 msg.append(StringPool.CLOSE_CURLY_BRACE);
1302
1303 throw new NoSuchStatsUserException(msg.toString());
1304 }
1305 else {
1306 return list.get(0);
1307 }
1308 }
1309
1310 public BlogsStatsUser findByC_E_Last(long companyId, int entryCount,
1311 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1312 int count = countByC_E(companyId, entryCount);
1313
1314 List<BlogsStatsUser> list = findByC_E(companyId, entryCount, count - 1,
1315 count, obc);
1316
1317 if (list.size() == 0) {
1318 StringBuilder msg = new StringBuilder();
1319
1320 msg.append("No BlogsStatsUser exists with the key {");
1321
1322 msg.append("companyId=" + companyId);
1323
1324 msg.append(", ");
1325 msg.append("entryCount=" + entryCount);
1326
1327 msg.append(StringPool.CLOSE_CURLY_BRACE);
1328
1329 throw new NoSuchStatsUserException(msg.toString());
1330 }
1331 else {
1332 return list.get(0);
1333 }
1334 }
1335
1336 public BlogsStatsUser[] findByC_E_PrevAndNext(long statsUserId,
1337 long companyId, int entryCount, OrderByComparator obc)
1338 throws NoSuchStatsUserException, SystemException {
1339 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
1340
1341 int count = countByC_E(companyId, entryCount);
1342
1343 Session session = null;
1344
1345 try {
1346 session = openSession();
1347
1348 StringBuilder query = new StringBuilder();
1349
1350 query.append(
1351 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1352
1353 query.append("companyId = ?");
1354
1355 query.append(" AND ");
1356
1357 query.append("entryCount != ?");
1358
1359 query.append(" ");
1360
1361 if (obc != null) {
1362 query.append("ORDER BY ");
1363 query.append(obc.getOrderBy());
1364 }
1365
1366 else {
1367 query.append("ORDER BY ");
1368
1369 query.append("entryCount DESC");
1370 }
1371
1372 Query q = session.createQuery(query.toString());
1373
1374 QueryPos qPos = QueryPos.getInstance(q);
1375
1376 qPos.add(companyId);
1377
1378 qPos.add(entryCount);
1379
1380 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1381 blogsStatsUser);
1382
1383 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
1384
1385 array[0] = (BlogsStatsUser)objArray[0];
1386 array[1] = (BlogsStatsUser)objArray[1];
1387 array[2] = (BlogsStatsUser)objArray[2];
1388
1389 return array;
1390 }
1391 catch (Exception e) {
1392 throw processException(e);
1393 }
1394 finally {
1395 closeSession(session);
1396 }
1397 }
1398
1399 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1400 throws SystemException {
1401 Session session = null;
1402
1403 try {
1404 session = openSession();
1405
1406 dynamicQuery.compile(session);
1407
1408 return dynamicQuery.list();
1409 }
1410 catch (Exception e) {
1411 throw processException(e);
1412 }
1413 finally {
1414 closeSession(session);
1415 }
1416 }
1417
1418 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1419 int start, int end) throws SystemException {
1420 Session session = null;
1421
1422 try {
1423 session = openSession();
1424
1425 dynamicQuery.setLimit(start, end);
1426
1427 dynamicQuery.compile(session);
1428
1429 return dynamicQuery.list();
1430 }
1431 catch (Exception e) {
1432 throw processException(e);
1433 }
1434 finally {
1435 closeSession(session);
1436 }
1437 }
1438
1439 public List<BlogsStatsUser> findAll() throws SystemException {
1440 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1441 }
1442
1443 public List<BlogsStatsUser> findAll(int start, int end)
1444 throws SystemException {
1445 return findAll(start, end, null);
1446 }
1447
1448 public List<BlogsStatsUser> findAll(int start, int end,
1449 OrderByComparator obc) throws SystemException {
1450 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
1451 String finderClassName = BlogsStatsUser.class.getName();
1452 String finderMethodName = "findAll";
1453 String[] finderParams = new String[] {
1454 "java.lang.Integer", "java.lang.Integer",
1455 "com.liferay.portal.kernel.util.OrderByComparator"
1456 };
1457 Object[] finderArgs = new Object[] {
1458 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1459 };
1460
1461 Object result = null;
1462
1463 if (finderClassNameCacheEnabled) {
1464 result = FinderCacheUtil.getResult(finderClassName,
1465 finderMethodName, finderParams, finderArgs, this);
1466 }
1467
1468 if (result == null) {
1469 Session session = null;
1470
1471 try {
1472 session = openSession();
1473
1474 StringBuilder query = new StringBuilder();
1475
1476 query.append(
1477 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser ");
1478
1479 if (obc != null) {
1480 query.append("ORDER BY ");
1481 query.append(obc.getOrderBy());
1482 }
1483
1484 else {
1485 query.append("ORDER BY ");
1486
1487 query.append("entryCount DESC");
1488 }
1489
1490 Query q = session.createQuery(query.toString());
1491
1492 List<BlogsStatsUser> list = (List<BlogsStatsUser>)QueryUtil.list(q,
1493 getDialect(), start, end);
1494
1495 if (obc == null) {
1496 Collections.sort(list);
1497 }
1498
1499 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1500 finderClassName, finderMethodName, finderParams,
1501 finderArgs, list);
1502
1503 return list;
1504 }
1505 catch (Exception e) {
1506 throw processException(e);
1507 }
1508 finally {
1509 closeSession(session);
1510 }
1511 }
1512 else {
1513 return (List<BlogsStatsUser>)result;
1514 }
1515 }
1516
1517 public void removeByGroupId(long groupId) throws SystemException {
1518 for (BlogsStatsUser blogsStatsUser : findByGroupId(groupId)) {
1519 remove(blogsStatsUser);
1520 }
1521 }
1522
1523 public void removeByUserId(long userId) throws SystemException {
1524 for (BlogsStatsUser blogsStatsUser : findByUserId(userId)) {
1525 remove(blogsStatsUser);
1526 }
1527 }
1528
1529 public void removeByG_U(long groupId, long userId)
1530 throws NoSuchStatsUserException, SystemException {
1531 BlogsStatsUser blogsStatsUser = findByG_U(groupId, userId);
1532
1533 remove(blogsStatsUser);
1534 }
1535
1536 public void removeByG_E(long groupId, int entryCount)
1537 throws SystemException {
1538 for (BlogsStatsUser blogsStatsUser : findByG_E(groupId, entryCount)) {
1539 remove(blogsStatsUser);
1540 }
1541 }
1542
1543 public void removeByC_E(long companyId, int entryCount)
1544 throws SystemException {
1545 for (BlogsStatsUser blogsStatsUser : findByC_E(companyId, entryCount)) {
1546 remove(blogsStatsUser);
1547 }
1548 }
1549
1550 public void removeAll() throws SystemException {
1551 for (BlogsStatsUser blogsStatsUser : findAll()) {
1552 remove(blogsStatsUser);
1553 }
1554 }
1555
1556 public int countByGroupId(long groupId) throws SystemException {
1557 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
1558 String finderClassName = BlogsStatsUser.class.getName();
1559 String finderMethodName = "countByGroupId";
1560 String[] finderParams = new String[] { Long.class.getName() };
1561 Object[] finderArgs = new Object[] { new Long(groupId) };
1562
1563 Object result = null;
1564
1565 if (finderClassNameCacheEnabled) {
1566 result = FinderCacheUtil.getResult(finderClassName,
1567 finderMethodName, finderParams, finderArgs, this);
1568 }
1569
1570 if (result == null) {
1571 Session session = null;
1572
1573 try {
1574 session = openSession();
1575
1576 StringBuilder query = new StringBuilder();
1577
1578 query.append("SELECT COUNT(*) ");
1579 query.append(
1580 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1581
1582 query.append("groupId = ?");
1583
1584 query.append(" ");
1585
1586 Query q = session.createQuery(query.toString());
1587
1588 QueryPos qPos = QueryPos.getInstance(q);
1589
1590 qPos.add(groupId);
1591
1592 Long count = null;
1593
1594 Iterator<Long> itr = q.list().iterator();
1595
1596 if (itr.hasNext()) {
1597 count = itr.next();
1598 }
1599
1600 if (count == null) {
1601 count = new Long(0);
1602 }
1603
1604 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1605 finderClassName, finderMethodName, finderParams,
1606 finderArgs, count);
1607
1608 return count.intValue();
1609 }
1610 catch (Exception e) {
1611 throw processException(e);
1612 }
1613 finally {
1614 closeSession(session);
1615 }
1616 }
1617 else {
1618 return ((Long)result).intValue();
1619 }
1620 }
1621
1622 public int countByUserId(long userId) throws SystemException {
1623 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
1624 String finderClassName = BlogsStatsUser.class.getName();
1625 String finderMethodName = "countByUserId";
1626 String[] finderParams = new String[] { Long.class.getName() };
1627 Object[] finderArgs = new Object[] { new Long(userId) };
1628
1629 Object result = null;
1630
1631 if (finderClassNameCacheEnabled) {
1632 result = FinderCacheUtil.getResult(finderClassName,
1633 finderMethodName, finderParams, finderArgs, this);
1634 }
1635
1636 if (result == null) {
1637 Session session = null;
1638
1639 try {
1640 session = openSession();
1641
1642 StringBuilder query = new StringBuilder();
1643
1644 query.append("SELECT COUNT(*) ");
1645 query.append(
1646 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1647
1648 query.append("userId = ?");
1649
1650 query.append(" ");
1651
1652 Query q = session.createQuery(query.toString());
1653
1654 QueryPos qPos = QueryPos.getInstance(q);
1655
1656 qPos.add(userId);
1657
1658 Long count = null;
1659
1660 Iterator<Long> itr = q.list().iterator();
1661
1662 if (itr.hasNext()) {
1663 count = itr.next();
1664 }
1665
1666 if (count == null) {
1667 count = new Long(0);
1668 }
1669
1670 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1671 finderClassName, finderMethodName, finderParams,
1672 finderArgs, count);
1673
1674 return count.intValue();
1675 }
1676 catch (Exception e) {
1677 throw processException(e);
1678 }
1679 finally {
1680 closeSession(session);
1681 }
1682 }
1683 else {
1684 return ((Long)result).intValue();
1685 }
1686 }
1687
1688 public int countByG_U(long groupId, long userId) throws SystemException {
1689 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
1690 String finderClassName = BlogsStatsUser.class.getName();
1691 String finderMethodName = "countByG_U";
1692 String[] finderParams = new String[] {
1693 Long.class.getName(), Long.class.getName()
1694 };
1695 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1696
1697 Object result = null;
1698
1699 if (finderClassNameCacheEnabled) {
1700 result = FinderCacheUtil.getResult(finderClassName,
1701 finderMethodName, finderParams, finderArgs, this);
1702 }
1703
1704 if (result == null) {
1705 Session session = null;
1706
1707 try {
1708 session = openSession();
1709
1710 StringBuilder query = new StringBuilder();
1711
1712 query.append("SELECT COUNT(*) ");
1713 query.append(
1714 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1715
1716 query.append("groupId = ?");
1717
1718 query.append(" AND ");
1719
1720 query.append("userId = ?");
1721
1722 query.append(" ");
1723
1724 Query q = session.createQuery(query.toString());
1725
1726 QueryPos qPos = QueryPos.getInstance(q);
1727
1728 qPos.add(groupId);
1729
1730 qPos.add(userId);
1731
1732 Long count = null;
1733
1734 Iterator<Long> itr = q.list().iterator();
1735
1736 if (itr.hasNext()) {
1737 count = itr.next();
1738 }
1739
1740 if (count == null) {
1741 count = new Long(0);
1742 }
1743
1744 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1745 finderClassName, finderMethodName, finderParams,
1746 finderArgs, count);
1747
1748 return count.intValue();
1749 }
1750 catch (Exception e) {
1751 throw processException(e);
1752 }
1753 finally {
1754 closeSession(session);
1755 }
1756 }
1757 else {
1758 return ((Long)result).intValue();
1759 }
1760 }
1761
1762 public int countByG_E(long groupId, int entryCount)
1763 throws SystemException {
1764 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
1765 String finderClassName = BlogsStatsUser.class.getName();
1766 String finderMethodName = "countByG_E";
1767 String[] finderParams = new String[] {
1768 Long.class.getName(), Integer.class.getName()
1769 };
1770 Object[] finderArgs = new Object[] {
1771 new Long(groupId), new Integer(entryCount)
1772 };
1773
1774 Object result = null;
1775
1776 if (finderClassNameCacheEnabled) {
1777 result = FinderCacheUtil.getResult(finderClassName,
1778 finderMethodName, finderParams, finderArgs, this);
1779 }
1780
1781 if (result == null) {
1782 Session session = null;
1783
1784 try {
1785 session = openSession();
1786
1787 StringBuilder query = new StringBuilder();
1788
1789 query.append("SELECT COUNT(*) ");
1790 query.append(
1791 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1792
1793 query.append("groupId = ?");
1794
1795 query.append(" AND ");
1796
1797 query.append("entryCount != ?");
1798
1799 query.append(" ");
1800
1801 Query q = session.createQuery(query.toString());
1802
1803 QueryPos qPos = QueryPos.getInstance(q);
1804
1805 qPos.add(groupId);
1806
1807 qPos.add(entryCount);
1808
1809 Long count = null;
1810
1811 Iterator<Long> itr = q.list().iterator();
1812
1813 if (itr.hasNext()) {
1814 count = itr.next();
1815 }
1816
1817 if (count == null) {
1818 count = new Long(0);
1819 }
1820
1821 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1822 finderClassName, finderMethodName, finderParams,
1823 finderArgs, count);
1824
1825 return count.intValue();
1826 }
1827 catch (Exception e) {
1828 throw processException(e);
1829 }
1830 finally {
1831 closeSession(session);
1832 }
1833 }
1834 else {
1835 return ((Long)result).intValue();
1836 }
1837 }
1838
1839 public int countByC_E(long companyId, int entryCount)
1840 throws SystemException {
1841 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
1842 String finderClassName = BlogsStatsUser.class.getName();
1843 String finderMethodName = "countByC_E";
1844 String[] finderParams = new String[] {
1845 Long.class.getName(), Integer.class.getName()
1846 };
1847 Object[] finderArgs = new Object[] {
1848 new Long(companyId), new Integer(entryCount)
1849 };
1850
1851 Object result = null;
1852
1853 if (finderClassNameCacheEnabled) {
1854 result = FinderCacheUtil.getResult(finderClassName,
1855 finderMethodName, finderParams, finderArgs, this);
1856 }
1857
1858 if (result == null) {
1859 Session session = null;
1860
1861 try {
1862 session = openSession();
1863
1864 StringBuilder query = new StringBuilder();
1865
1866 query.append("SELECT COUNT(*) ");
1867 query.append(
1868 "FROM com.liferay.portlet.blogs.model.BlogsStatsUser WHERE ");
1869
1870 query.append("companyId = ?");
1871
1872 query.append(" AND ");
1873
1874 query.append("entryCount != ?");
1875
1876 query.append(" ");
1877
1878 Query q = session.createQuery(query.toString());
1879
1880 QueryPos qPos = QueryPos.getInstance(q);
1881
1882 qPos.add(companyId);
1883
1884 qPos.add(entryCount);
1885
1886 Long count = null;
1887
1888 Iterator<Long> itr = q.list().iterator();
1889
1890 if (itr.hasNext()) {
1891 count = itr.next();
1892 }
1893
1894 if (count == null) {
1895 count = new Long(0);
1896 }
1897
1898 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1899 finderClassName, finderMethodName, finderParams,
1900 finderArgs, count);
1901
1902 return count.intValue();
1903 }
1904 catch (Exception e) {
1905 throw processException(e);
1906 }
1907 finally {
1908 closeSession(session);
1909 }
1910 }
1911 else {
1912 return ((Long)result).intValue();
1913 }
1914 }
1915
1916 public int countAll() throws SystemException {
1917 boolean finderClassNameCacheEnabled = BlogsStatsUserModelImpl.CACHE_ENABLED;
1918 String finderClassName = BlogsStatsUser.class.getName();
1919 String finderMethodName = "countAll";
1920 String[] finderParams = new String[] { };
1921 Object[] finderArgs = new Object[] { };
1922
1923 Object result = null;
1924
1925 if (finderClassNameCacheEnabled) {
1926 result = FinderCacheUtil.getResult(finderClassName,
1927 finderMethodName, finderParams, finderArgs, this);
1928 }
1929
1930 if (result == null) {
1931 Session session = null;
1932
1933 try {
1934 session = openSession();
1935
1936 Query q = session.createQuery(
1937 "SELECT COUNT(*) FROM com.liferay.portlet.blogs.model.BlogsStatsUser");
1938
1939 Long count = null;
1940
1941 Iterator<Long> itr = q.list().iterator();
1942
1943 if (itr.hasNext()) {
1944 count = itr.next();
1945 }
1946
1947 if (count == null) {
1948 count = new Long(0);
1949 }
1950
1951 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1952 finderClassName, finderMethodName, finderParams,
1953 finderArgs, count);
1954
1955 return count.intValue();
1956 }
1957 catch (Exception e) {
1958 throw processException(e);
1959 }
1960 finally {
1961 closeSession(session);
1962 }
1963 }
1964 else {
1965 return ((Long)result).intValue();
1966 }
1967 }
1968
1969 public void registerListener(ModelListener listener) {
1970 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
1971
1972 listeners.add(listener);
1973
1974 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1975 }
1976
1977 public void unregisterListener(ModelListener listener) {
1978 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
1979
1980 listeners.remove(listener);
1981
1982 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1983 }
1984
1985 public void afterPropertiesSet() {
1986 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1987 com.liferay.portal.util.PropsUtil.get(
1988 "value.object.listener.com.liferay.portlet.blogs.model.BlogsStatsUser")));
1989
1990 if (listenerClassNames.length > 0) {
1991 try {
1992 List<ModelListener> listeners = new ArrayList<ModelListener>();
1993
1994 for (String listenerClassName : listenerClassNames) {
1995 listeners.add((ModelListener)Class.forName(
1996 listenerClassName).newInstance());
1997 }
1998
1999 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
2000 }
2001 catch (Exception e) {
2002 _log.error(e);
2003 }
2004 }
2005 }
2006
2007 private static Log _log = LogFactory.getLog(BlogsStatsUserPersistenceImpl.class);
2008 private ModelListener[] _listeners = new ModelListener[0];
2009}