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