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