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