001
014
015 package com.liferay.portlet.blogs.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.CalendarUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.service.persistence.BatchSessionUtil;
039 import com.liferay.portal.service.persistence.GroupPersistence;
040 import com.liferay.portal.service.persistence.ResourcePersistence;
041 import com.liferay.portal.service.persistence.UserPersistence;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import com.liferay.portlet.blogs.NoSuchStatsUserException;
045 import com.liferay.portlet.blogs.model.BlogsStatsUser;
046 import com.liferay.portlet.blogs.model.impl.BlogsStatsUserImpl;
047 import com.liferay.portlet.blogs.model.impl.BlogsStatsUserModelImpl;
048
049 import java.io.Serializable;
050
051 import java.util.ArrayList;
052 import java.util.Collections;
053 import java.util.Date;
054 import java.util.List;
055
056
072 public class BlogsStatsUserPersistenceImpl extends BasePersistenceImpl<BlogsStatsUser>
073 implements BlogsStatsUserPersistence {
074 public static final String FINDER_CLASS_NAME_ENTITY = BlogsStatsUserImpl.class.getName();
075 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
076 ".List";
077 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
078 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
079 FINDER_CLASS_NAME_LIST, "findByGroupId",
080 new String[] {
081 Long.class.getName(),
082
083 "java.lang.Integer", "java.lang.Integer",
084 "com.liferay.portal.kernel.util.OrderByComparator"
085 });
086 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
087 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
088 FINDER_CLASS_NAME_LIST, "countByGroupId",
089 new String[] { Long.class.getName() });
090 public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
091 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
092 FINDER_CLASS_NAME_LIST, "findByUserId",
093 new String[] {
094 Long.class.getName(),
095
096 "java.lang.Integer", "java.lang.Integer",
097 "com.liferay.portal.kernel.util.OrderByComparator"
098 });
099 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
100 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
101 FINDER_CLASS_NAME_LIST, "countByUserId",
102 new String[] { Long.class.getName() });
103 public static final FinderPath FINDER_PATH_FETCH_BY_G_U = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
104 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
105 FINDER_CLASS_NAME_ENTITY, "fetchByG_U",
106 new String[] { Long.class.getName(), Long.class.getName() });
107 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
108 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
109 FINDER_CLASS_NAME_LIST, "countByG_U",
110 new String[] { Long.class.getName(), Long.class.getName() });
111 public static final FinderPath FINDER_PATH_FIND_BY_G_NOTE = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
112 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
113 FINDER_CLASS_NAME_LIST, "findByG_NotE",
114 new String[] {
115 Long.class.getName(), Integer.class.getName(),
116
117 "java.lang.Integer", "java.lang.Integer",
118 "com.liferay.portal.kernel.util.OrderByComparator"
119 });
120 public static final FinderPath FINDER_PATH_COUNT_BY_G_NOTE = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
121 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
122 FINDER_CLASS_NAME_LIST, "countByG_NotE",
123 new String[] { Long.class.getName(), Integer.class.getName() });
124 public static final FinderPath FINDER_PATH_FIND_BY_C_NOTE = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
125 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
126 FINDER_CLASS_NAME_LIST, "findByC_NotE",
127 new String[] {
128 Long.class.getName(), Integer.class.getName(),
129
130 "java.lang.Integer", "java.lang.Integer",
131 "com.liferay.portal.kernel.util.OrderByComparator"
132 });
133 public static final FinderPath FINDER_PATH_COUNT_BY_C_NOTE = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
134 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
135 FINDER_CLASS_NAME_LIST, "countByC_NotE",
136 new String[] { Long.class.getName(), Integer.class.getName() });
137 public static final FinderPath FINDER_PATH_FIND_BY_U_L = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
138 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
139 FINDER_CLASS_NAME_LIST, "findByU_L",
140 new String[] {
141 Long.class.getName(), Date.class.getName(),
142
143 "java.lang.Integer", "java.lang.Integer",
144 "com.liferay.portal.kernel.util.OrderByComparator"
145 });
146 public static final FinderPath FINDER_PATH_COUNT_BY_U_L = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
147 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
148 FINDER_CLASS_NAME_LIST, "countByU_L",
149 new String[] { Long.class.getName(), Date.class.getName() });
150 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
151 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
152 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
153 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
154 BlogsStatsUserModelImpl.FINDER_CACHE_ENABLED,
155 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
156
157
162 public void cacheResult(BlogsStatsUser blogsStatsUser) {
163 EntityCacheUtil.putResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
164 BlogsStatsUserImpl.class, blogsStatsUser.getPrimaryKey(),
165 blogsStatsUser);
166
167 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
168 new Object[] {
169 new Long(blogsStatsUser.getGroupId()),
170 new Long(blogsStatsUser.getUserId())
171 }, blogsStatsUser);
172 }
173
174
179 public void cacheResult(List<BlogsStatsUser> blogsStatsUsers) {
180 for (BlogsStatsUser blogsStatsUser : blogsStatsUsers) {
181 if (EntityCacheUtil.getResult(
182 BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
183 BlogsStatsUserImpl.class,
184 blogsStatsUser.getPrimaryKey(), this) == null) {
185 cacheResult(blogsStatsUser);
186 }
187 }
188 }
189
190
197 public void clearCache() {
198 CacheRegistryUtil.clear(BlogsStatsUserImpl.class.getName());
199 EntityCacheUtil.clearCache(BlogsStatsUserImpl.class.getName());
200 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
201 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
202 }
203
204
211 public void clearCache(BlogsStatsUser blogsStatsUser) {
212 EntityCacheUtil.removeResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
213 BlogsStatsUserImpl.class, blogsStatsUser.getPrimaryKey());
214
215 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U,
216 new Object[] {
217 new Long(blogsStatsUser.getGroupId()),
218 new Long(blogsStatsUser.getUserId())
219 });
220 }
221
222
228 public BlogsStatsUser create(long statsUserId) {
229 BlogsStatsUser blogsStatsUser = new BlogsStatsUserImpl();
230
231 blogsStatsUser.setNew(true);
232 blogsStatsUser.setPrimaryKey(statsUserId);
233
234 return blogsStatsUser;
235 }
236
237
245 public BlogsStatsUser remove(Serializable primaryKey)
246 throws NoSuchModelException, SystemException {
247 return remove(((Long)primaryKey).longValue());
248 }
249
250
258 public BlogsStatsUser remove(long statsUserId)
259 throws NoSuchStatsUserException, SystemException {
260 Session session = null;
261
262 try {
263 session = openSession();
264
265 BlogsStatsUser blogsStatsUser = (BlogsStatsUser)session.get(BlogsStatsUserImpl.class,
266 new Long(statsUserId));
267
268 if (blogsStatsUser == null) {
269 if (_log.isWarnEnabled()) {
270 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsUserId);
271 }
272
273 throw new NoSuchStatsUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
274 statsUserId);
275 }
276
277 return remove(blogsStatsUser);
278 }
279 catch (NoSuchStatsUserException nsee) {
280 throw nsee;
281 }
282 catch (Exception e) {
283 throw processException(e);
284 }
285 finally {
286 closeSession(session);
287 }
288 }
289
290 protected BlogsStatsUser removeImpl(BlogsStatsUser blogsStatsUser)
291 throws SystemException {
292 blogsStatsUser = toUnwrappedModel(blogsStatsUser);
293
294 Session session = null;
295
296 try {
297 session = openSession();
298
299 if (blogsStatsUser.isCachedModel() || BatchSessionUtil.isEnabled()) {
300 Object staleObject = session.get(BlogsStatsUserImpl.class,
301 blogsStatsUser.getPrimaryKeyObj());
302
303 if (staleObject != null) {
304 session.evict(staleObject);
305 }
306 }
307
308 session.delete(blogsStatsUser);
309
310 session.flush();
311 }
312 catch (Exception e) {
313 throw processException(e);
314 }
315 finally {
316 closeSession(session);
317 }
318
319 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
320
321 BlogsStatsUserModelImpl blogsStatsUserModelImpl = (BlogsStatsUserModelImpl)blogsStatsUser;
322
323 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U,
324 new Object[] {
325 new Long(blogsStatsUserModelImpl.getOriginalGroupId()),
326 new Long(blogsStatsUserModelImpl.getOriginalUserId())
327 });
328
329 EntityCacheUtil.removeResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
330 BlogsStatsUserImpl.class, blogsStatsUser.getPrimaryKey());
331
332 return blogsStatsUser;
333 }
334
335 public BlogsStatsUser updateImpl(
336 com.liferay.portlet.blogs.model.BlogsStatsUser blogsStatsUser,
337 boolean merge) throws SystemException {
338 blogsStatsUser = toUnwrappedModel(blogsStatsUser);
339
340 boolean isNew = blogsStatsUser.isNew();
341
342 BlogsStatsUserModelImpl blogsStatsUserModelImpl = (BlogsStatsUserModelImpl)blogsStatsUser;
343
344 Session session = null;
345
346 try {
347 session = openSession();
348
349 BatchSessionUtil.update(session, blogsStatsUser, merge);
350
351 blogsStatsUser.setNew(false);
352 }
353 catch (Exception e) {
354 throw processException(e);
355 }
356 finally {
357 closeSession(session);
358 }
359
360 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
361
362 EntityCacheUtil.putResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
363 BlogsStatsUserImpl.class, blogsStatsUser.getPrimaryKey(),
364 blogsStatsUser);
365
366 if (!isNew &&
367 ((blogsStatsUser.getGroupId() != blogsStatsUserModelImpl.getOriginalGroupId()) ||
368 (blogsStatsUser.getUserId() != blogsStatsUserModelImpl.getOriginalUserId()))) {
369 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U,
370 new Object[] {
371 new Long(blogsStatsUserModelImpl.getOriginalGroupId()),
372 new Long(blogsStatsUserModelImpl.getOriginalUserId())
373 });
374 }
375
376 if (isNew ||
377 ((blogsStatsUser.getGroupId() != blogsStatsUserModelImpl.getOriginalGroupId()) ||
378 (blogsStatsUser.getUserId() != blogsStatsUserModelImpl.getOriginalUserId()))) {
379 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
380 new Object[] {
381 new Long(blogsStatsUser.getGroupId()),
382 new Long(blogsStatsUser.getUserId())
383 }, blogsStatsUser);
384 }
385
386 return blogsStatsUser;
387 }
388
389 protected BlogsStatsUser toUnwrappedModel(BlogsStatsUser blogsStatsUser) {
390 if (blogsStatsUser instanceof BlogsStatsUserImpl) {
391 return blogsStatsUser;
392 }
393
394 BlogsStatsUserImpl blogsStatsUserImpl = new BlogsStatsUserImpl();
395
396 blogsStatsUserImpl.setNew(blogsStatsUser.isNew());
397 blogsStatsUserImpl.setPrimaryKey(blogsStatsUser.getPrimaryKey());
398
399 blogsStatsUserImpl.setStatsUserId(blogsStatsUser.getStatsUserId());
400 blogsStatsUserImpl.setGroupId(blogsStatsUser.getGroupId());
401 blogsStatsUserImpl.setCompanyId(blogsStatsUser.getCompanyId());
402 blogsStatsUserImpl.setUserId(blogsStatsUser.getUserId());
403 blogsStatsUserImpl.setEntryCount(blogsStatsUser.getEntryCount());
404 blogsStatsUserImpl.setLastPostDate(blogsStatsUser.getLastPostDate());
405 blogsStatsUserImpl.setRatingsTotalEntries(blogsStatsUser.getRatingsTotalEntries());
406 blogsStatsUserImpl.setRatingsTotalScore(blogsStatsUser.getRatingsTotalScore());
407 blogsStatsUserImpl.setRatingsAverageScore(blogsStatsUser.getRatingsAverageScore());
408
409 return blogsStatsUserImpl;
410 }
411
412
420 public BlogsStatsUser findByPrimaryKey(Serializable primaryKey)
421 throws NoSuchModelException, SystemException {
422 return findByPrimaryKey(((Long)primaryKey).longValue());
423 }
424
425
433 public BlogsStatsUser findByPrimaryKey(long statsUserId)
434 throws NoSuchStatsUserException, SystemException {
435 BlogsStatsUser blogsStatsUser = fetchByPrimaryKey(statsUserId);
436
437 if (blogsStatsUser == null) {
438 if (_log.isWarnEnabled()) {
439 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsUserId);
440 }
441
442 throw new NoSuchStatsUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
443 statsUserId);
444 }
445
446 return blogsStatsUser;
447 }
448
449
456 public BlogsStatsUser fetchByPrimaryKey(Serializable primaryKey)
457 throws SystemException {
458 return fetchByPrimaryKey(((Long)primaryKey).longValue());
459 }
460
461
468 public BlogsStatsUser fetchByPrimaryKey(long statsUserId)
469 throws SystemException {
470 BlogsStatsUser blogsStatsUser = (BlogsStatsUser)EntityCacheUtil.getResult(BlogsStatsUserModelImpl.ENTITY_CACHE_ENABLED,
471 BlogsStatsUserImpl.class, statsUserId, this);
472
473 if (blogsStatsUser == null) {
474 Session session = null;
475
476 try {
477 session = openSession();
478
479 blogsStatsUser = (BlogsStatsUser)session.get(BlogsStatsUserImpl.class,
480 new Long(statsUserId));
481 }
482 catch (Exception e) {
483 throw processException(e);
484 }
485 finally {
486 if (blogsStatsUser != null) {
487 cacheResult(blogsStatsUser);
488 }
489
490 closeSession(session);
491 }
492 }
493
494 return blogsStatsUser;
495 }
496
497
504 public List<BlogsStatsUser> findByGroupId(long groupId)
505 throws SystemException {
506 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
507 }
508
509
522 public List<BlogsStatsUser> findByGroupId(long groupId, int start, int end)
523 throws SystemException {
524 return findByGroupId(groupId, start, end, null);
525 }
526
527
541 public List<BlogsStatsUser> findByGroupId(long groupId, int start, int end,
542 OrderByComparator orderByComparator) throws SystemException {
543 Object[] finderArgs = new Object[] {
544 groupId,
545
546 String.valueOf(start), String.valueOf(end),
547 String.valueOf(orderByComparator)
548 };
549
550 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
551 finderArgs, this);
552
553 if (list == null) {
554 Session session = null;
555
556 try {
557 session = openSession();
558
559 StringBundler query = null;
560
561 if (orderByComparator != null) {
562 query = new StringBundler(3 +
563 (orderByComparator.getOrderByFields().length * 3));
564 }
565 else {
566 query = new StringBundler(3);
567 }
568
569 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
570
571 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
572
573 if (orderByComparator != null) {
574 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
575 orderByComparator);
576 }
577
578 else {
579 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
580 }
581
582 String sql = query.toString();
583
584 Query q = session.createQuery(sql);
585
586 QueryPos qPos = QueryPos.getInstance(q);
587
588 qPos.add(groupId);
589
590 list = (List<BlogsStatsUser>)QueryUtil.list(q, getDialect(),
591 start, end);
592 }
593 catch (Exception e) {
594 throw processException(e);
595 }
596 finally {
597 if (list == null) {
598 list = new ArrayList<BlogsStatsUser>();
599 }
600
601 cacheResult(list);
602
603 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
604 finderArgs, list);
605
606 closeSession(session);
607 }
608 }
609
610 return list;
611 }
612
613
626 public BlogsStatsUser findByGroupId_First(long groupId,
627 OrderByComparator orderByComparator)
628 throws NoSuchStatsUserException, SystemException {
629 List<BlogsStatsUser> list = findByGroupId(groupId, 0, 1,
630 orderByComparator);
631
632 if (list.isEmpty()) {
633 StringBundler msg = new StringBundler(4);
634
635 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
636
637 msg.append("groupId=");
638 msg.append(groupId);
639
640 msg.append(StringPool.CLOSE_CURLY_BRACE);
641
642 throw new NoSuchStatsUserException(msg.toString());
643 }
644 else {
645 return list.get(0);
646 }
647 }
648
649
662 public BlogsStatsUser findByGroupId_Last(long groupId,
663 OrderByComparator orderByComparator)
664 throws NoSuchStatsUserException, SystemException {
665 int count = countByGroupId(groupId);
666
667 List<BlogsStatsUser> list = findByGroupId(groupId, count - 1, count,
668 orderByComparator);
669
670 if (list.isEmpty()) {
671 StringBundler msg = new StringBundler(4);
672
673 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
674
675 msg.append("groupId=");
676 msg.append(groupId);
677
678 msg.append(StringPool.CLOSE_CURLY_BRACE);
679
680 throw new NoSuchStatsUserException(msg.toString());
681 }
682 else {
683 return list.get(0);
684 }
685 }
686
687
701 public BlogsStatsUser[] findByGroupId_PrevAndNext(long statsUserId,
702 long groupId, OrderByComparator orderByComparator)
703 throws NoSuchStatsUserException, SystemException {
704 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
705
706 Session session = null;
707
708 try {
709 session = openSession();
710
711 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
712
713 array[0] = getByGroupId_PrevAndNext(session, blogsStatsUser,
714 groupId, orderByComparator, true);
715
716 array[1] = blogsStatsUser;
717
718 array[2] = getByGroupId_PrevAndNext(session, blogsStatsUser,
719 groupId, orderByComparator, false);
720
721 return array;
722 }
723 catch (Exception e) {
724 throw processException(e);
725 }
726 finally {
727 closeSession(session);
728 }
729 }
730
731 protected BlogsStatsUser getByGroupId_PrevAndNext(Session session,
732 BlogsStatsUser blogsStatsUser, long groupId,
733 OrderByComparator orderByComparator, boolean previous) {
734 StringBundler query = null;
735
736 if (orderByComparator != null) {
737 query = new StringBundler(6 +
738 (orderByComparator.getOrderByFields().length * 6));
739 }
740 else {
741 query = new StringBundler(3);
742 }
743
744 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
745
746 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
747
748 if (orderByComparator != null) {
749 String[] orderByFields = orderByComparator.getOrderByFields();
750
751 if (orderByFields.length > 0) {
752 query.append(WHERE_AND);
753 }
754
755 for (int i = 0; i < orderByFields.length; i++) {
756 query.append(_ORDER_BY_ENTITY_ALIAS);
757 query.append(orderByFields[i]);
758
759 if ((i + 1) < orderByFields.length) {
760 if (orderByComparator.isAscending() ^ previous) {
761 query.append(WHERE_GREATER_THAN_HAS_NEXT);
762 }
763 else {
764 query.append(WHERE_LESSER_THAN_HAS_NEXT);
765 }
766 }
767 else {
768 if (orderByComparator.isAscending() ^ previous) {
769 query.append(WHERE_GREATER_THAN);
770 }
771 else {
772 query.append(WHERE_LESSER_THAN);
773 }
774 }
775 }
776
777 query.append(ORDER_BY_CLAUSE);
778
779 for (int i = 0; i < orderByFields.length; i++) {
780 query.append(_ORDER_BY_ENTITY_ALIAS);
781 query.append(orderByFields[i]);
782
783 if ((i + 1) < orderByFields.length) {
784 if (orderByComparator.isAscending() ^ previous) {
785 query.append(ORDER_BY_ASC_HAS_NEXT);
786 }
787 else {
788 query.append(ORDER_BY_DESC_HAS_NEXT);
789 }
790 }
791 else {
792 if (orderByComparator.isAscending() ^ previous) {
793 query.append(ORDER_BY_ASC);
794 }
795 else {
796 query.append(ORDER_BY_DESC);
797 }
798 }
799 }
800 }
801
802 else {
803 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
804 }
805
806 String sql = query.toString();
807
808 Query q = session.createQuery(sql);
809
810 q.setFirstResult(0);
811 q.setMaxResults(2);
812
813 QueryPos qPos = QueryPos.getInstance(q);
814
815 qPos.add(groupId);
816
817 if (orderByComparator != null) {
818 Object[] values = orderByComparator.getOrderByValues(blogsStatsUser);
819
820 for (Object value : values) {
821 qPos.add(value);
822 }
823 }
824
825 List<BlogsStatsUser> list = q.list();
826
827 if (list.size() == 2) {
828 return list.get(1);
829 }
830 else {
831 return null;
832 }
833 }
834
835
842 public List<BlogsStatsUser> findByUserId(long userId)
843 throws SystemException {
844 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
845 }
846
847
860 public List<BlogsStatsUser> findByUserId(long userId, int start, int end)
861 throws SystemException {
862 return findByUserId(userId, start, end, null);
863 }
864
865
879 public List<BlogsStatsUser> findByUserId(long userId, int start, int end,
880 OrderByComparator orderByComparator) throws SystemException {
881 Object[] finderArgs = new Object[] {
882 userId,
883
884 String.valueOf(start), String.valueOf(end),
885 String.valueOf(orderByComparator)
886 };
887
888 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
889 finderArgs, this);
890
891 if (list == null) {
892 Session session = null;
893
894 try {
895 session = openSession();
896
897 StringBundler query = null;
898
899 if (orderByComparator != null) {
900 query = new StringBundler(3 +
901 (orderByComparator.getOrderByFields().length * 3));
902 }
903 else {
904 query = new StringBundler(3);
905 }
906
907 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
908
909 query.append(_FINDER_COLUMN_USERID_USERID_2);
910
911 if (orderByComparator != null) {
912 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
913 orderByComparator);
914 }
915
916 else {
917 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
918 }
919
920 String sql = query.toString();
921
922 Query q = session.createQuery(sql);
923
924 QueryPos qPos = QueryPos.getInstance(q);
925
926 qPos.add(userId);
927
928 list = (List<BlogsStatsUser>)QueryUtil.list(q, getDialect(),
929 start, end);
930 }
931 catch (Exception e) {
932 throw processException(e);
933 }
934 finally {
935 if (list == null) {
936 list = new ArrayList<BlogsStatsUser>();
937 }
938
939 cacheResult(list);
940
941 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
942 finderArgs, list);
943
944 closeSession(session);
945 }
946 }
947
948 return list;
949 }
950
951
964 public BlogsStatsUser findByUserId_First(long userId,
965 OrderByComparator orderByComparator)
966 throws NoSuchStatsUserException, SystemException {
967 List<BlogsStatsUser> list = findByUserId(userId, 0, 1, orderByComparator);
968
969 if (list.isEmpty()) {
970 StringBundler msg = new StringBundler(4);
971
972 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
973
974 msg.append("userId=");
975 msg.append(userId);
976
977 msg.append(StringPool.CLOSE_CURLY_BRACE);
978
979 throw new NoSuchStatsUserException(msg.toString());
980 }
981 else {
982 return list.get(0);
983 }
984 }
985
986
999 public BlogsStatsUser findByUserId_Last(long userId,
1000 OrderByComparator orderByComparator)
1001 throws NoSuchStatsUserException, SystemException {
1002 int count = countByUserId(userId);
1003
1004 List<BlogsStatsUser> list = findByUserId(userId, count - 1, count,
1005 orderByComparator);
1006
1007 if (list.isEmpty()) {
1008 StringBundler msg = new StringBundler(4);
1009
1010 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1011
1012 msg.append("userId=");
1013 msg.append(userId);
1014
1015 msg.append(StringPool.CLOSE_CURLY_BRACE);
1016
1017 throw new NoSuchStatsUserException(msg.toString());
1018 }
1019 else {
1020 return list.get(0);
1021 }
1022 }
1023
1024
1038 public BlogsStatsUser[] findByUserId_PrevAndNext(long statsUserId,
1039 long userId, OrderByComparator orderByComparator)
1040 throws NoSuchStatsUserException, SystemException {
1041 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
1042
1043 Session session = null;
1044
1045 try {
1046 session = openSession();
1047
1048 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
1049
1050 array[0] = getByUserId_PrevAndNext(session, blogsStatsUser, userId,
1051 orderByComparator, true);
1052
1053 array[1] = blogsStatsUser;
1054
1055 array[2] = getByUserId_PrevAndNext(session, blogsStatsUser, userId,
1056 orderByComparator, false);
1057
1058 return array;
1059 }
1060 catch (Exception e) {
1061 throw processException(e);
1062 }
1063 finally {
1064 closeSession(session);
1065 }
1066 }
1067
1068 protected BlogsStatsUser getByUserId_PrevAndNext(Session session,
1069 BlogsStatsUser blogsStatsUser, long userId,
1070 OrderByComparator orderByComparator, boolean previous) {
1071 StringBundler query = null;
1072
1073 if (orderByComparator != null) {
1074 query = new StringBundler(6 +
1075 (orderByComparator.getOrderByFields().length * 6));
1076 }
1077 else {
1078 query = new StringBundler(3);
1079 }
1080
1081 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1082
1083 query.append(_FINDER_COLUMN_USERID_USERID_2);
1084
1085 if (orderByComparator != null) {
1086 String[] orderByFields = orderByComparator.getOrderByFields();
1087
1088 if (orderByFields.length > 0) {
1089 query.append(WHERE_AND);
1090 }
1091
1092 for (int i = 0; i < orderByFields.length; i++) {
1093 query.append(_ORDER_BY_ENTITY_ALIAS);
1094 query.append(orderByFields[i]);
1095
1096 if ((i + 1) < orderByFields.length) {
1097 if (orderByComparator.isAscending() ^ previous) {
1098 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1099 }
1100 else {
1101 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1102 }
1103 }
1104 else {
1105 if (orderByComparator.isAscending() ^ previous) {
1106 query.append(WHERE_GREATER_THAN);
1107 }
1108 else {
1109 query.append(WHERE_LESSER_THAN);
1110 }
1111 }
1112 }
1113
1114 query.append(ORDER_BY_CLAUSE);
1115
1116 for (int i = 0; i < orderByFields.length; i++) {
1117 query.append(_ORDER_BY_ENTITY_ALIAS);
1118 query.append(orderByFields[i]);
1119
1120 if ((i + 1) < orderByFields.length) {
1121 if (orderByComparator.isAscending() ^ previous) {
1122 query.append(ORDER_BY_ASC_HAS_NEXT);
1123 }
1124 else {
1125 query.append(ORDER_BY_DESC_HAS_NEXT);
1126 }
1127 }
1128 else {
1129 if (orderByComparator.isAscending() ^ previous) {
1130 query.append(ORDER_BY_ASC);
1131 }
1132 else {
1133 query.append(ORDER_BY_DESC);
1134 }
1135 }
1136 }
1137 }
1138
1139 else {
1140 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1141 }
1142
1143 String sql = query.toString();
1144
1145 Query q = session.createQuery(sql);
1146
1147 q.setFirstResult(0);
1148 q.setMaxResults(2);
1149
1150 QueryPos qPos = QueryPos.getInstance(q);
1151
1152 qPos.add(userId);
1153
1154 if (orderByComparator != null) {
1155 Object[] values = orderByComparator.getOrderByValues(blogsStatsUser);
1156
1157 for (Object value : values) {
1158 qPos.add(value);
1159 }
1160 }
1161
1162 List<BlogsStatsUser> list = q.list();
1163
1164 if (list.size() == 2) {
1165 return list.get(1);
1166 }
1167 else {
1168 return null;
1169 }
1170 }
1171
1172
1181 public BlogsStatsUser findByG_U(long groupId, long userId)
1182 throws NoSuchStatsUserException, SystemException {
1183 BlogsStatsUser blogsStatsUser = fetchByG_U(groupId, userId);
1184
1185 if (blogsStatsUser == null) {
1186 StringBundler msg = new StringBundler(6);
1187
1188 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1189
1190 msg.append("groupId=");
1191 msg.append(groupId);
1192
1193 msg.append(", userId=");
1194 msg.append(userId);
1195
1196 msg.append(StringPool.CLOSE_CURLY_BRACE);
1197
1198 if (_log.isWarnEnabled()) {
1199 _log.warn(msg.toString());
1200 }
1201
1202 throw new NoSuchStatsUserException(msg.toString());
1203 }
1204
1205 return blogsStatsUser;
1206 }
1207
1208
1216 public BlogsStatsUser fetchByG_U(long groupId, long userId)
1217 throws SystemException {
1218 return fetchByG_U(groupId, userId, true);
1219 }
1220
1221
1229 public BlogsStatsUser fetchByG_U(long groupId, long userId,
1230 boolean retrieveFromCache) throws SystemException {
1231 Object[] finderArgs = new Object[] { groupId, userId };
1232
1233 Object result = null;
1234
1235 if (retrieveFromCache) {
1236 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_U,
1237 finderArgs, this);
1238 }
1239
1240 if (result == null) {
1241 Session session = null;
1242
1243 try {
1244 session = openSession();
1245
1246 StringBundler query = new StringBundler(4);
1247
1248 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1249
1250 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1251
1252 query.append(_FINDER_COLUMN_G_U_USERID_2);
1253
1254 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1255
1256 String sql = query.toString();
1257
1258 Query q = session.createQuery(sql);
1259
1260 QueryPos qPos = QueryPos.getInstance(q);
1261
1262 qPos.add(groupId);
1263
1264 qPos.add(userId);
1265
1266 List<BlogsStatsUser> list = q.list();
1267
1268 result = list;
1269
1270 BlogsStatsUser blogsStatsUser = null;
1271
1272 if (list.isEmpty()) {
1273 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
1274 finderArgs, list);
1275 }
1276 else {
1277 blogsStatsUser = list.get(0);
1278
1279 cacheResult(blogsStatsUser);
1280
1281 if ((blogsStatsUser.getGroupId() != groupId) ||
1282 (blogsStatsUser.getUserId() != userId)) {
1283 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
1284 finderArgs, blogsStatsUser);
1285 }
1286 }
1287
1288 return blogsStatsUser;
1289 }
1290 catch (Exception e) {
1291 throw processException(e);
1292 }
1293 finally {
1294 if (result == null) {
1295 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
1296 finderArgs, new ArrayList<BlogsStatsUser>());
1297 }
1298
1299 closeSession(session);
1300 }
1301 }
1302 else {
1303 if (result instanceof List<?>) {
1304 return null;
1305 }
1306 else {
1307 return (BlogsStatsUser)result;
1308 }
1309 }
1310 }
1311
1312
1320 public List<BlogsStatsUser> findByG_NotE(long groupId, int entryCount)
1321 throws SystemException {
1322 return findByG_NotE(groupId, entryCount, QueryUtil.ALL_POS,
1323 QueryUtil.ALL_POS, null);
1324 }
1325
1326
1340 public List<BlogsStatsUser> findByG_NotE(long groupId, int entryCount,
1341 int start, int end) throws SystemException {
1342 return findByG_NotE(groupId, entryCount, start, end, null);
1343 }
1344
1345
1360 public List<BlogsStatsUser> findByG_NotE(long groupId, int entryCount,
1361 int start, int end, OrderByComparator orderByComparator)
1362 throws SystemException {
1363 Object[] finderArgs = new Object[] {
1364 groupId, entryCount,
1365
1366 String.valueOf(start), String.valueOf(end),
1367 String.valueOf(orderByComparator)
1368 };
1369
1370 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_NOTE,
1371 finderArgs, this);
1372
1373 if (list == null) {
1374 Session session = null;
1375
1376 try {
1377 session = openSession();
1378
1379 StringBundler query = null;
1380
1381 if (orderByComparator != null) {
1382 query = new StringBundler(4 +
1383 (orderByComparator.getOrderByFields().length * 3));
1384 }
1385 else {
1386 query = new StringBundler(4);
1387 }
1388
1389 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1390
1391 query.append(_FINDER_COLUMN_G_NOTE_GROUPID_2);
1392
1393 query.append(_FINDER_COLUMN_G_NOTE_ENTRYCOUNT_2);
1394
1395 if (orderByComparator != null) {
1396 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1397 orderByComparator);
1398 }
1399
1400 else {
1401 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1402 }
1403
1404 String sql = query.toString();
1405
1406 Query q = session.createQuery(sql);
1407
1408 QueryPos qPos = QueryPos.getInstance(q);
1409
1410 qPos.add(groupId);
1411
1412 qPos.add(entryCount);
1413
1414 list = (List<BlogsStatsUser>)QueryUtil.list(q, getDialect(),
1415 start, end);
1416 }
1417 catch (Exception e) {
1418 throw processException(e);
1419 }
1420 finally {
1421 if (list == null) {
1422 list = new ArrayList<BlogsStatsUser>();
1423 }
1424
1425 cacheResult(list);
1426
1427 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_NOTE,
1428 finderArgs, list);
1429
1430 closeSession(session);
1431 }
1432 }
1433
1434 return list;
1435 }
1436
1437
1451 public BlogsStatsUser findByG_NotE_First(long groupId, int entryCount,
1452 OrderByComparator orderByComparator)
1453 throws NoSuchStatsUserException, SystemException {
1454 List<BlogsStatsUser> list = findByG_NotE(groupId, entryCount, 0, 1,
1455 orderByComparator);
1456
1457 if (list.isEmpty()) {
1458 StringBundler msg = new StringBundler(6);
1459
1460 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1461
1462 msg.append("groupId=");
1463 msg.append(groupId);
1464
1465 msg.append(", entryCount=");
1466 msg.append(entryCount);
1467
1468 msg.append(StringPool.CLOSE_CURLY_BRACE);
1469
1470 throw new NoSuchStatsUserException(msg.toString());
1471 }
1472 else {
1473 return list.get(0);
1474 }
1475 }
1476
1477
1491 public BlogsStatsUser findByG_NotE_Last(long groupId, int entryCount,
1492 OrderByComparator orderByComparator)
1493 throws NoSuchStatsUserException, SystemException {
1494 int count = countByG_NotE(groupId, entryCount);
1495
1496 List<BlogsStatsUser> list = findByG_NotE(groupId, entryCount,
1497 count - 1, count, orderByComparator);
1498
1499 if (list.isEmpty()) {
1500 StringBundler msg = new StringBundler(6);
1501
1502 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1503
1504 msg.append("groupId=");
1505 msg.append(groupId);
1506
1507 msg.append(", entryCount=");
1508 msg.append(entryCount);
1509
1510 msg.append(StringPool.CLOSE_CURLY_BRACE);
1511
1512 throw new NoSuchStatsUserException(msg.toString());
1513 }
1514 else {
1515 return list.get(0);
1516 }
1517 }
1518
1519
1534 public BlogsStatsUser[] findByG_NotE_PrevAndNext(long statsUserId,
1535 long groupId, int entryCount, OrderByComparator orderByComparator)
1536 throws NoSuchStatsUserException, SystemException {
1537 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
1538
1539 Session session = null;
1540
1541 try {
1542 session = openSession();
1543
1544 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
1545
1546 array[0] = getByG_NotE_PrevAndNext(session, blogsStatsUser,
1547 groupId, entryCount, orderByComparator, true);
1548
1549 array[1] = blogsStatsUser;
1550
1551 array[2] = getByG_NotE_PrevAndNext(session, blogsStatsUser,
1552 groupId, entryCount, orderByComparator, false);
1553
1554 return array;
1555 }
1556 catch (Exception e) {
1557 throw processException(e);
1558 }
1559 finally {
1560 closeSession(session);
1561 }
1562 }
1563
1564 protected BlogsStatsUser getByG_NotE_PrevAndNext(Session session,
1565 BlogsStatsUser blogsStatsUser, long groupId, int entryCount,
1566 OrderByComparator orderByComparator, boolean previous) {
1567 StringBundler query = null;
1568
1569 if (orderByComparator != null) {
1570 query = new StringBundler(6 +
1571 (orderByComparator.getOrderByFields().length * 6));
1572 }
1573 else {
1574 query = new StringBundler(3);
1575 }
1576
1577 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1578
1579 query.append(_FINDER_COLUMN_G_NOTE_GROUPID_2);
1580
1581 query.append(_FINDER_COLUMN_G_NOTE_ENTRYCOUNT_2);
1582
1583 if (orderByComparator != null) {
1584 String[] orderByFields = orderByComparator.getOrderByFields();
1585
1586 if (orderByFields.length > 0) {
1587 query.append(WHERE_AND);
1588 }
1589
1590 for (int i = 0; i < orderByFields.length; i++) {
1591 query.append(_ORDER_BY_ENTITY_ALIAS);
1592 query.append(orderByFields[i]);
1593
1594 if ((i + 1) < orderByFields.length) {
1595 if (orderByComparator.isAscending() ^ previous) {
1596 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1597 }
1598 else {
1599 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1600 }
1601 }
1602 else {
1603 if (orderByComparator.isAscending() ^ previous) {
1604 query.append(WHERE_GREATER_THAN);
1605 }
1606 else {
1607 query.append(WHERE_LESSER_THAN);
1608 }
1609 }
1610 }
1611
1612 query.append(ORDER_BY_CLAUSE);
1613
1614 for (int i = 0; i < orderByFields.length; i++) {
1615 query.append(_ORDER_BY_ENTITY_ALIAS);
1616 query.append(orderByFields[i]);
1617
1618 if ((i + 1) < orderByFields.length) {
1619 if (orderByComparator.isAscending() ^ previous) {
1620 query.append(ORDER_BY_ASC_HAS_NEXT);
1621 }
1622 else {
1623 query.append(ORDER_BY_DESC_HAS_NEXT);
1624 }
1625 }
1626 else {
1627 if (orderByComparator.isAscending() ^ previous) {
1628 query.append(ORDER_BY_ASC);
1629 }
1630 else {
1631 query.append(ORDER_BY_DESC);
1632 }
1633 }
1634 }
1635 }
1636
1637 else {
1638 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1639 }
1640
1641 String sql = query.toString();
1642
1643 Query q = session.createQuery(sql);
1644
1645 q.setFirstResult(0);
1646 q.setMaxResults(2);
1647
1648 QueryPos qPos = QueryPos.getInstance(q);
1649
1650 qPos.add(groupId);
1651
1652 qPos.add(entryCount);
1653
1654 if (orderByComparator != null) {
1655 Object[] values = orderByComparator.getOrderByValues(blogsStatsUser);
1656
1657 for (Object value : values) {
1658 qPos.add(value);
1659 }
1660 }
1661
1662 List<BlogsStatsUser> list = q.list();
1663
1664 if (list.size() == 2) {
1665 return list.get(1);
1666 }
1667 else {
1668 return null;
1669 }
1670 }
1671
1672
1680 public List<BlogsStatsUser> findByC_NotE(long companyId, int entryCount)
1681 throws SystemException {
1682 return findByC_NotE(companyId, entryCount, QueryUtil.ALL_POS,
1683 QueryUtil.ALL_POS, null);
1684 }
1685
1686
1700 public List<BlogsStatsUser> findByC_NotE(long companyId, int entryCount,
1701 int start, int end) throws SystemException {
1702 return findByC_NotE(companyId, entryCount, start, end, null);
1703 }
1704
1705
1720 public List<BlogsStatsUser> findByC_NotE(long companyId, int entryCount,
1721 int start, int end, OrderByComparator orderByComparator)
1722 throws SystemException {
1723 Object[] finderArgs = new Object[] {
1724 companyId, entryCount,
1725
1726 String.valueOf(start), String.valueOf(end),
1727 String.valueOf(orderByComparator)
1728 };
1729
1730 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_NOTE,
1731 finderArgs, this);
1732
1733 if (list == null) {
1734 Session session = null;
1735
1736 try {
1737 session = openSession();
1738
1739 StringBundler query = null;
1740
1741 if (orderByComparator != null) {
1742 query = new StringBundler(4 +
1743 (orderByComparator.getOrderByFields().length * 3));
1744 }
1745 else {
1746 query = new StringBundler(4);
1747 }
1748
1749 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1750
1751 query.append(_FINDER_COLUMN_C_NOTE_COMPANYID_2);
1752
1753 query.append(_FINDER_COLUMN_C_NOTE_ENTRYCOUNT_2);
1754
1755 if (orderByComparator != null) {
1756 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1757 orderByComparator);
1758 }
1759
1760 else {
1761 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1762 }
1763
1764 String sql = query.toString();
1765
1766 Query q = session.createQuery(sql);
1767
1768 QueryPos qPos = QueryPos.getInstance(q);
1769
1770 qPos.add(companyId);
1771
1772 qPos.add(entryCount);
1773
1774 list = (List<BlogsStatsUser>)QueryUtil.list(q, getDialect(),
1775 start, end);
1776 }
1777 catch (Exception e) {
1778 throw processException(e);
1779 }
1780 finally {
1781 if (list == null) {
1782 list = new ArrayList<BlogsStatsUser>();
1783 }
1784
1785 cacheResult(list);
1786
1787 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_NOTE,
1788 finderArgs, list);
1789
1790 closeSession(session);
1791 }
1792 }
1793
1794 return list;
1795 }
1796
1797
1811 public BlogsStatsUser findByC_NotE_First(long companyId, int entryCount,
1812 OrderByComparator orderByComparator)
1813 throws NoSuchStatsUserException, SystemException {
1814 List<BlogsStatsUser> list = findByC_NotE(companyId, entryCount, 0, 1,
1815 orderByComparator);
1816
1817 if (list.isEmpty()) {
1818 StringBundler msg = new StringBundler(6);
1819
1820 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1821
1822 msg.append("companyId=");
1823 msg.append(companyId);
1824
1825 msg.append(", entryCount=");
1826 msg.append(entryCount);
1827
1828 msg.append(StringPool.CLOSE_CURLY_BRACE);
1829
1830 throw new NoSuchStatsUserException(msg.toString());
1831 }
1832 else {
1833 return list.get(0);
1834 }
1835 }
1836
1837
1851 public BlogsStatsUser findByC_NotE_Last(long companyId, int entryCount,
1852 OrderByComparator orderByComparator)
1853 throws NoSuchStatsUserException, SystemException {
1854 int count = countByC_NotE(companyId, entryCount);
1855
1856 List<BlogsStatsUser> list = findByC_NotE(companyId, entryCount,
1857 count - 1, count, orderByComparator);
1858
1859 if (list.isEmpty()) {
1860 StringBundler msg = new StringBundler(6);
1861
1862 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1863
1864 msg.append("companyId=");
1865 msg.append(companyId);
1866
1867 msg.append(", entryCount=");
1868 msg.append(entryCount);
1869
1870 msg.append(StringPool.CLOSE_CURLY_BRACE);
1871
1872 throw new NoSuchStatsUserException(msg.toString());
1873 }
1874 else {
1875 return list.get(0);
1876 }
1877 }
1878
1879
1894 public BlogsStatsUser[] findByC_NotE_PrevAndNext(long statsUserId,
1895 long companyId, int entryCount, OrderByComparator orderByComparator)
1896 throws NoSuchStatsUserException, SystemException {
1897 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
1898
1899 Session session = null;
1900
1901 try {
1902 session = openSession();
1903
1904 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
1905
1906 array[0] = getByC_NotE_PrevAndNext(session, blogsStatsUser,
1907 companyId, entryCount, orderByComparator, true);
1908
1909 array[1] = blogsStatsUser;
1910
1911 array[2] = getByC_NotE_PrevAndNext(session, blogsStatsUser,
1912 companyId, entryCount, orderByComparator, false);
1913
1914 return array;
1915 }
1916 catch (Exception e) {
1917 throw processException(e);
1918 }
1919 finally {
1920 closeSession(session);
1921 }
1922 }
1923
1924 protected BlogsStatsUser getByC_NotE_PrevAndNext(Session session,
1925 BlogsStatsUser blogsStatsUser, long companyId, int entryCount,
1926 OrderByComparator orderByComparator, boolean previous) {
1927 StringBundler query = null;
1928
1929 if (orderByComparator != null) {
1930 query = new StringBundler(6 +
1931 (orderByComparator.getOrderByFields().length * 6));
1932 }
1933 else {
1934 query = new StringBundler(3);
1935 }
1936
1937 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
1938
1939 query.append(_FINDER_COLUMN_C_NOTE_COMPANYID_2);
1940
1941 query.append(_FINDER_COLUMN_C_NOTE_ENTRYCOUNT_2);
1942
1943 if (orderByComparator != null) {
1944 String[] orderByFields = orderByComparator.getOrderByFields();
1945
1946 if (orderByFields.length > 0) {
1947 query.append(WHERE_AND);
1948 }
1949
1950 for (int i = 0; i < orderByFields.length; i++) {
1951 query.append(_ORDER_BY_ENTITY_ALIAS);
1952 query.append(orderByFields[i]);
1953
1954 if ((i + 1) < orderByFields.length) {
1955 if (orderByComparator.isAscending() ^ previous) {
1956 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1957 }
1958 else {
1959 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1960 }
1961 }
1962 else {
1963 if (orderByComparator.isAscending() ^ previous) {
1964 query.append(WHERE_GREATER_THAN);
1965 }
1966 else {
1967 query.append(WHERE_LESSER_THAN);
1968 }
1969 }
1970 }
1971
1972 query.append(ORDER_BY_CLAUSE);
1973
1974 for (int i = 0; i < orderByFields.length; i++) {
1975 query.append(_ORDER_BY_ENTITY_ALIAS);
1976 query.append(orderByFields[i]);
1977
1978 if ((i + 1) < orderByFields.length) {
1979 if (orderByComparator.isAscending() ^ previous) {
1980 query.append(ORDER_BY_ASC_HAS_NEXT);
1981 }
1982 else {
1983 query.append(ORDER_BY_DESC_HAS_NEXT);
1984 }
1985 }
1986 else {
1987 if (orderByComparator.isAscending() ^ previous) {
1988 query.append(ORDER_BY_ASC);
1989 }
1990 else {
1991 query.append(ORDER_BY_DESC);
1992 }
1993 }
1994 }
1995 }
1996
1997 else {
1998 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
1999 }
2000
2001 String sql = query.toString();
2002
2003 Query q = session.createQuery(sql);
2004
2005 q.setFirstResult(0);
2006 q.setMaxResults(2);
2007
2008 QueryPos qPos = QueryPos.getInstance(q);
2009
2010 qPos.add(companyId);
2011
2012 qPos.add(entryCount);
2013
2014 if (orderByComparator != null) {
2015 Object[] values = orderByComparator.getOrderByValues(blogsStatsUser);
2016
2017 for (Object value : values) {
2018 qPos.add(value);
2019 }
2020 }
2021
2022 List<BlogsStatsUser> list = q.list();
2023
2024 if (list.size() == 2) {
2025 return list.get(1);
2026 }
2027 else {
2028 return null;
2029 }
2030 }
2031
2032
2040 public List<BlogsStatsUser> findByU_L(long userId, Date lastPostDate)
2041 throws SystemException {
2042 return findByU_L(userId, lastPostDate, QueryUtil.ALL_POS,
2043 QueryUtil.ALL_POS, null);
2044 }
2045
2046
2060 public List<BlogsStatsUser> findByU_L(long userId, Date lastPostDate,
2061 int start, int end) throws SystemException {
2062 return findByU_L(userId, lastPostDate, start, end, null);
2063 }
2064
2065
2080 public List<BlogsStatsUser> findByU_L(long userId, Date lastPostDate,
2081 int start, int end, OrderByComparator orderByComparator)
2082 throws SystemException {
2083 Object[] finderArgs = new Object[] {
2084 userId, lastPostDate,
2085
2086 String.valueOf(start), String.valueOf(end),
2087 String.valueOf(orderByComparator)
2088 };
2089
2090 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_U_L,
2091 finderArgs, this);
2092
2093 if (list == null) {
2094 Session session = null;
2095
2096 try {
2097 session = openSession();
2098
2099 StringBundler query = null;
2100
2101 if (orderByComparator != null) {
2102 query = new StringBundler(4 +
2103 (orderByComparator.getOrderByFields().length * 3));
2104 }
2105 else {
2106 query = new StringBundler(4);
2107 }
2108
2109 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
2110
2111 query.append(_FINDER_COLUMN_U_L_USERID_2);
2112
2113 if (lastPostDate == null) {
2114 query.append(_FINDER_COLUMN_U_L_LASTPOSTDATE_1);
2115 }
2116 else {
2117 query.append(_FINDER_COLUMN_U_L_LASTPOSTDATE_2);
2118 }
2119
2120 if (orderByComparator != null) {
2121 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2122 orderByComparator);
2123 }
2124
2125 else {
2126 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
2127 }
2128
2129 String sql = query.toString();
2130
2131 Query q = session.createQuery(sql);
2132
2133 QueryPos qPos = QueryPos.getInstance(q);
2134
2135 qPos.add(userId);
2136
2137 if (lastPostDate != null) {
2138 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
2139 }
2140
2141 list = (List<BlogsStatsUser>)QueryUtil.list(q, getDialect(),
2142 start, end);
2143 }
2144 catch (Exception e) {
2145 throw processException(e);
2146 }
2147 finally {
2148 if (list == null) {
2149 list = new ArrayList<BlogsStatsUser>();
2150 }
2151
2152 cacheResult(list);
2153
2154 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_U_L, finderArgs,
2155 list);
2156
2157 closeSession(session);
2158 }
2159 }
2160
2161 return list;
2162 }
2163
2164
2178 public BlogsStatsUser findByU_L_First(long userId, Date lastPostDate,
2179 OrderByComparator orderByComparator)
2180 throws NoSuchStatsUserException, SystemException {
2181 List<BlogsStatsUser> list = findByU_L(userId, lastPostDate, 0, 1,
2182 orderByComparator);
2183
2184 if (list.isEmpty()) {
2185 StringBundler msg = new StringBundler(6);
2186
2187 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2188
2189 msg.append("userId=");
2190 msg.append(userId);
2191
2192 msg.append(", lastPostDate=");
2193 msg.append(lastPostDate);
2194
2195 msg.append(StringPool.CLOSE_CURLY_BRACE);
2196
2197 throw new NoSuchStatsUserException(msg.toString());
2198 }
2199 else {
2200 return list.get(0);
2201 }
2202 }
2203
2204
2218 public BlogsStatsUser findByU_L_Last(long userId, Date lastPostDate,
2219 OrderByComparator orderByComparator)
2220 throws NoSuchStatsUserException, SystemException {
2221 int count = countByU_L(userId, lastPostDate);
2222
2223 List<BlogsStatsUser> list = findByU_L(userId, lastPostDate, count - 1,
2224 count, orderByComparator);
2225
2226 if (list.isEmpty()) {
2227 StringBundler msg = new StringBundler(6);
2228
2229 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2230
2231 msg.append("userId=");
2232 msg.append(userId);
2233
2234 msg.append(", lastPostDate=");
2235 msg.append(lastPostDate);
2236
2237 msg.append(StringPool.CLOSE_CURLY_BRACE);
2238
2239 throw new NoSuchStatsUserException(msg.toString());
2240 }
2241 else {
2242 return list.get(0);
2243 }
2244 }
2245
2246
2261 public BlogsStatsUser[] findByU_L_PrevAndNext(long statsUserId,
2262 long userId, Date lastPostDate, OrderByComparator orderByComparator)
2263 throws NoSuchStatsUserException, SystemException {
2264 BlogsStatsUser blogsStatsUser = findByPrimaryKey(statsUserId);
2265
2266 Session session = null;
2267
2268 try {
2269 session = openSession();
2270
2271 BlogsStatsUser[] array = new BlogsStatsUserImpl[3];
2272
2273 array[0] = getByU_L_PrevAndNext(session, blogsStatsUser, userId,
2274 lastPostDate, orderByComparator, true);
2275
2276 array[1] = blogsStatsUser;
2277
2278 array[2] = getByU_L_PrevAndNext(session, blogsStatsUser, userId,
2279 lastPostDate, orderByComparator, false);
2280
2281 return array;
2282 }
2283 catch (Exception e) {
2284 throw processException(e);
2285 }
2286 finally {
2287 closeSession(session);
2288 }
2289 }
2290
2291 protected BlogsStatsUser getByU_L_PrevAndNext(Session session,
2292 BlogsStatsUser blogsStatsUser, long userId, Date lastPostDate,
2293 OrderByComparator orderByComparator, boolean previous) {
2294 StringBundler query = null;
2295
2296 if (orderByComparator != null) {
2297 query = new StringBundler(6 +
2298 (orderByComparator.getOrderByFields().length * 6));
2299 }
2300 else {
2301 query = new StringBundler(3);
2302 }
2303
2304 query.append(_SQL_SELECT_BLOGSSTATSUSER_WHERE);
2305
2306 query.append(_FINDER_COLUMN_U_L_USERID_2);
2307
2308 if (lastPostDate == null) {
2309 query.append(_FINDER_COLUMN_U_L_LASTPOSTDATE_1);
2310 }
2311 else {
2312 query.append(_FINDER_COLUMN_U_L_LASTPOSTDATE_2);
2313 }
2314
2315 if (orderByComparator != null) {
2316 String[] orderByFields = orderByComparator.getOrderByFields();
2317
2318 if (orderByFields.length > 0) {
2319 query.append(WHERE_AND);
2320 }
2321
2322 for (int i = 0; i < orderByFields.length; i++) {
2323 query.append(_ORDER_BY_ENTITY_ALIAS);
2324 query.append(orderByFields[i]);
2325
2326 if ((i + 1) < orderByFields.length) {
2327 if (orderByComparator.isAscending() ^ previous) {
2328 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2329 }
2330 else {
2331 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2332 }
2333 }
2334 else {
2335 if (orderByComparator.isAscending() ^ previous) {
2336 query.append(WHERE_GREATER_THAN);
2337 }
2338 else {
2339 query.append(WHERE_LESSER_THAN);
2340 }
2341 }
2342 }
2343
2344 query.append(ORDER_BY_CLAUSE);
2345
2346 for (int i = 0; i < orderByFields.length; i++) {
2347 query.append(_ORDER_BY_ENTITY_ALIAS);
2348 query.append(orderByFields[i]);
2349
2350 if ((i + 1) < orderByFields.length) {
2351 if (orderByComparator.isAscending() ^ previous) {
2352 query.append(ORDER_BY_ASC_HAS_NEXT);
2353 }
2354 else {
2355 query.append(ORDER_BY_DESC_HAS_NEXT);
2356 }
2357 }
2358 else {
2359 if (orderByComparator.isAscending() ^ previous) {
2360 query.append(ORDER_BY_ASC);
2361 }
2362 else {
2363 query.append(ORDER_BY_DESC);
2364 }
2365 }
2366 }
2367 }
2368
2369 else {
2370 query.append(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
2371 }
2372
2373 String sql = query.toString();
2374
2375 Query q = session.createQuery(sql);
2376
2377 q.setFirstResult(0);
2378 q.setMaxResults(2);
2379
2380 QueryPos qPos = QueryPos.getInstance(q);
2381
2382 qPos.add(userId);
2383
2384 if (lastPostDate != null) {
2385 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
2386 }
2387
2388 if (orderByComparator != null) {
2389 Object[] values = orderByComparator.getOrderByValues(blogsStatsUser);
2390
2391 for (Object value : values) {
2392 qPos.add(value);
2393 }
2394 }
2395
2396 List<BlogsStatsUser> list = q.list();
2397
2398 if (list.size() == 2) {
2399 return list.get(1);
2400 }
2401 else {
2402 return null;
2403 }
2404 }
2405
2406
2412 public List<BlogsStatsUser> findAll() throws SystemException {
2413 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2414 }
2415
2416
2428 public List<BlogsStatsUser> findAll(int start, int end)
2429 throws SystemException {
2430 return findAll(start, end, null);
2431 }
2432
2433
2446 public List<BlogsStatsUser> findAll(int start, int end,
2447 OrderByComparator orderByComparator) throws SystemException {
2448 Object[] finderArgs = new Object[] {
2449 String.valueOf(start), String.valueOf(end),
2450 String.valueOf(orderByComparator)
2451 };
2452
2453 List<BlogsStatsUser> list = (List<BlogsStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2454 finderArgs, this);
2455
2456 if (list == null) {
2457 Session session = null;
2458
2459 try {
2460 session = openSession();
2461
2462 StringBundler query = null;
2463 String sql = null;
2464
2465 if (orderByComparator != null) {
2466 query = new StringBundler(2 +
2467 (orderByComparator.getOrderByFields().length * 3));
2468
2469 query.append(_SQL_SELECT_BLOGSSTATSUSER);
2470
2471 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2472 orderByComparator);
2473
2474 sql = query.toString();
2475 }
2476 else {
2477 sql = _SQL_SELECT_BLOGSSTATSUSER.concat(BlogsStatsUserModelImpl.ORDER_BY_JPQL);
2478 }
2479
2480 Query q = session.createQuery(sql);
2481
2482 if (orderByComparator == null) {
2483 list = (List<BlogsStatsUser>)QueryUtil.list(q,
2484 getDialect(), start, end, false);
2485
2486 Collections.sort(list);
2487 }
2488 else {
2489 list = (List<BlogsStatsUser>)QueryUtil.list(q,
2490 getDialect(), start, end);
2491 }
2492 }
2493 catch (Exception e) {
2494 throw processException(e);
2495 }
2496 finally {
2497 if (list == null) {
2498 list = new ArrayList<BlogsStatsUser>();
2499 }
2500
2501 cacheResult(list);
2502
2503 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2504
2505 closeSession(session);
2506 }
2507 }
2508
2509 return list;
2510 }
2511
2512
2518 public void removeByGroupId(long groupId) throws SystemException {
2519 for (BlogsStatsUser blogsStatsUser : findByGroupId(groupId)) {
2520 remove(blogsStatsUser);
2521 }
2522 }
2523
2524
2530 public void removeByUserId(long userId) throws SystemException {
2531 for (BlogsStatsUser blogsStatsUser : findByUserId(userId)) {
2532 remove(blogsStatsUser);
2533 }
2534 }
2535
2536
2543 public void removeByG_U(long groupId, long userId)
2544 throws NoSuchStatsUserException, SystemException {
2545 BlogsStatsUser blogsStatsUser = findByG_U(groupId, userId);
2546
2547 remove(blogsStatsUser);
2548 }
2549
2550
2557 public void removeByG_NotE(long groupId, int entryCount)
2558 throws SystemException {
2559 for (BlogsStatsUser blogsStatsUser : findByG_NotE(groupId, entryCount)) {
2560 remove(blogsStatsUser);
2561 }
2562 }
2563
2564
2571 public void removeByC_NotE(long companyId, int entryCount)
2572 throws SystemException {
2573 for (BlogsStatsUser blogsStatsUser : findByC_NotE(companyId, entryCount)) {
2574 remove(blogsStatsUser);
2575 }
2576 }
2577
2578
2585 public void removeByU_L(long userId, Date lastPostDate)
2586 throws SystemException {
2587 for (BlogsStatsUser blogsStatsUser : findByU_L(userId, lastPostDate)) {
2588 remove(blogsStatsUser);
2589 }
2590 }
2591
2592
2597 public void removeAll() throws SystemException {
2598 for (BlogsStatsUser blogsStatsUser : findAll()) {
2599 remove(blogsStatsUser);
2600 }
2601 }
2602
2603
2610 public int countByGroupId(long groupId) throws SystemException {
2611 Object[] finderArgs = new Object[] { groupId };
2612
2613 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2614 finderArgs, this);
2615
2616 if (count == null) {
2617 Session session = null;
2618
2619 try {
2620 session = openSession();
2621
2622 StringBundler query = new StringBundler(2);
2623
2624 query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
2625
2626 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2627
2628 String sql = query.toString();
2629
2630 Query q = session.createQuery(sql);
2631
2632 QueryPos qPos = QueryPos.getInstance(q);
2633
2634 qPos.add(groupId);
2635
2636 count = (Long)q.uniqueResult();
2637 }
2638 catch (Exception e) {
2639 throw processException(e);
2640 }
2641 finally {
2642 if (count == null) {
2643 count = Long.valueOf(0);
2644 }
2645
2646 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2647 finderArgs, count);
2648
2649 closeSession(session);
2650 }
2651 }
2652
2653 return count.intValue();
2654 }
2655
2656
2663 public int countByUserId(long userId) throws SystemException {
2664 Object[] finderArgs = new Object[] { userId };
2665
2666 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2667 finderArgs, this);
2668
2669 if (count == null) {
2670 Session session = null;
2671
2672 try {
2673 session = openSession();
2674
2675 StringBundler query = new StringBundler(2);
2676
2677 query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
2678
2679 query.append(_FINDER_COLUMN_USERID_USERID_2);
2680
2681 String sql = query.toString();
2682
2683 Query q = session.createQuery(sql);
2684
2685 QueryPos qPos = QueryPos.getInstance(q);
2686
2687 qPos.add(userId);
2688
2689 count = (Long)q.uniqueResult();
2690 }
2691 catch (Exception e) {
2692 throw processException(e);
2693 }
2694 finally {
2695 if (count == null) {
2696 count = Long.valueOf(0);
2697 }
2698
2699 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2700 finderArgs, count);
2701
2702 closeSession(session);
2703 }
2704 }
2705
2706 return count.intValue();
2707 }
2708
2709
2717 public int countByG_U(long groupId, long userId) throws SystemException {
2718 Object[] finderArgs = new Object[] { groupId, userId };
2719
2720 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
2721 finderArgs, this);
2722
2723 if (count == null) {
2724 Session session = null;
2725
2726 try {
2727 session = openSession();
2728
2729 StringBundler query = new StringBundler(3);
2730
2731 query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
2732
2733 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2734
2735 query.append(_FINDER_COLUMN_G_U_USERID_2);
2736
2737 String sql = query.toString();
2738
2739 Query q = session.createQuery(sql);
2740
2741 QueryPos qPos = QueryPos.getInstance(q);
2742
2743 qPos.add(groupId);
2744
2745 qPos.add(userId);
2746
2747 count = (Long)q.uniqueResult();
2748 }
2749 catch (Exception e) {
2750 throw processException(e);
2751 }
2752 finally {
2753 if (count == null) {
2754 count = Long.valueOf(0);
2755 }
2756
2757 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
2758 count);
2759
2760 closeSession(session);
2761 }
2762 }
2763
2764 return count.intValue();
2765 }
2766
2767
2775 public int countByG_NotE(long groupId, int entryCount)
2776 throws SystemException {
2777 Object[] finderArgs = new Object[] { groupId, entryCount };
2778
2779 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_NOTE,
2780 finderArgs, this);
2781
2782 if (count == null) {
2783 Session session = null;
2784
2785 try {
2786 session = openSession();
2787
2788 StringBundler query = new StringBundler(3);
2789
2790 query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
2791
2792 query.append(_FINDER_COLUMN_G_NOTE_GROUPID_2);
2793
2794 query.append(_FINDER_COLUMN_G_NOTE_ENTRYCOUNT_2);
2795
2796 String sql = query.toString();
2797
2798 Query q = session.createQuery(sql);
2799
2800 QueryPos qPos = QueryPos.getInstance(q);
2801
2802 qPos.add(groupId);
2803
2804 qPos.add(entryCount);
2805
2806 count = (Long)q.uniqueResult();
2807 }
2808 catch (Exception e) {
2809 throw processException(e);
2810 }
2811 finally {
2812 if (count == null) {
2813 count = Long.valueOf(0);
2814 }
2815
2816 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_NOTE,
2817 finderArgs, count);
2818
2819 closeSession(session);
2820 }
2821 }
2822
2823 return count.intValue();
2824 }
2825
2826
2834 public int countByC_NotE(long companyId, int entryCount)
2835 throws SystemException {
2836 Object[] finderArgs = new Object[] { companyId, entryCount };
2837
2838 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_NOTE,
2839 finderArgs, this);
2840
2841 if (count == null) {
2842 Session session = null;
2843
2844 try {
2845 session = openSession();
2846
2847 StringBundler query = new StringBundler(3);
2848
2849 query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
2850
2851 query.append(_FINDER_COLUMN_C_NOTE_COMPANYID_2);
2852
2853 query.append(_FINDER_COLUMN_C_NOTE_ENTRYCOUNT_2);
2854
2855 String sql = query.toString();
2856
2857 Query q = session.createQuery(sql);
2858
2859 QueryPos qPos = QueryPos.getInstance(q);
2860
2861 qPos.add(companyId);
2862
2863 qPos.add(entryCount);
2864
2865 count = (Long)q.uniqueResult();
2866 }
2867 catch (Exception e) {
2868 throw processException(e);
2869 }
2870 finally {
2871 if (count == null) {
2872 count = Long.valueOf(0);
2873 }
2874
2875 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_NOTE,
2876 finderArgs, count);
2877
2878 closeSession(session);
2879 }
2880 }
2881
2882 return count.intValue();
2883 }
2884
2885
2893 public int countByU_L(long userId, Date lastPostDate)
2894 throws SystemException {
2895 Object[] finderArgs = new Object[] { userId, lastPostDate };
2896
2897 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_L,
2898 finderArgs, this);
2899
2900 if (count == null) {
2901 Session session = null;
2902
2903 try {
2904 session = openSession();
2905
2906 StringBundler query = new StringBundler(3);
2907
2908 query.append(_SQL_COUNT_BLOGSSTATSUSER_WHERE);
2909
2910 query.append(_FINDER_COLUMN_U_L_USERID_2);
2911
2912 if (lastPostDate == null) {
2913 query.append(_FINDER_COLUMN_U_L_LASTPOSTDATE_1);
2914 }
2915 else {
2916 query.append(_FINDER_COLUMN_U_L_LASTPOSTDATE_2);
2917 }
2918
2919 String sql = query.toString();
2920
2921 Query q = session.createQuery(sql);
2922
2923 QueryPos qPos = QueryPos.getInstance(q);
2924
2925 qPos.add(userId);
2926
2927 if (lastPostDate != null) {
2928 qPos.add(CalendarUtil.getTimestamp(lastPostDate));
2929 }
2930
2931 count = (Long)q.uniqueResult();
2932 }
2933 catch (Exception e) {
2934 throw processException(e);
2935 }
2936 finally {
2937 if (count == null) {
2938 count = Long.valueOf(0);
2939 }
2940
2941 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_L, finderArgs,
2942 count);
2943
2944 closeSession(session);
2945 }
2946 }
2947
2948 return count.intValue();
2949 }
2950
2951
2957 public int countAll() throws SystemException {
2958 Object[] finderArgs = new Object[0];
2959
2960 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2961 finderArgs, this);
2962
2963 if (count == null) {
2964 Session session = null;
2965
2966 try {
2967 session = openSession();
2968
2969 Query q = session.createQuery(_SQL_COUNT_BLOGSSTATSUSER);
2970
2971 count = (Long)q.uniqueResult();
2972 }
2973 catch (Exception e) {
2974 throw processException(e);
2975 }
2976 finally {
2977 if (count == null) {
2978 count = Long.valueOf(0);
2979 }
2980
2981 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2982 count);
2983
2984 closeSession(session);
2985 }
2986 }
2987
2988 return count.intValue();
2989 }
2990
2991
2994 public void afterPropertiesSet() {
2995 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2996 com.liferay.portal.util.PropsUtil.get(
2997 "value.object.listener.com.liferay.portlet.blogs.model.BlogsStatsUser")));
2998
2999 if (listenerClassNames.length > 0) {
3000 try {
3001 List<ModelListener<BlogsStatsUser>> listenersList = new ArrayList<ModelListener<BlogsStatsUser>>();
3002
3003 for (String listenerClassName : listenerClassNames) {
3004 listenersList.add((ModelListener<BlogsStatsUser>)InstanceFactory.newInstance(
3005 listenerClassName));
3006 }
3007
3008 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3009 }
3010 catch (Exception e) {
3011 _log.error(e);
3012 }
3013 }
3014 }
3015
3016 @BeanReference(type = BlogsEntryPersistence.class)
3017 protected BlogsEntryPersistence blogsEntryPersistence;
3018 @BeanReference(type = BlogsStatsUserPersistence.class)
3019 protected BlogsStatsUserPersistence blogsStatsUserPersistence;
3020 @BeanReference(type = GroupPersistence.class)
3021 protected GroupPersistence groupPersistence;
3022 @BeanReference(type = ResourcePersistence.class)
3023 protected ResourcePersistence resourcePersistence;
3024 @BeanReference(type = UserPersistence.class)
3025 protected UserPersistence userPersistence;
3026 private static final String _SQL_SELECT_BLOGSSTATSUSER = "SELECT blogsStatsUser FROM BlogsStatsUser blogsStatsUser";
3027 private static final String _SQL_SELECT_BLOGSSTATSUSER_WHERE = "SELECT blogsStatsUser FROM BlogsStatsUser blogsStatsUser WHERE ";
3028 private static final String _SQL_COUNT_BLOGSSTATSUSER = "SELECT COUNT(blogsStatsUser) FROM BlogsStatsUser blogsStatsUser";
3029 private static final String _SQL_COUNT_BLOGSSTATSUSER_WHERE = "SELECT COUNT(blogsStatsUser) FROM BlogsStatsUser blogsStatsUser WHERE ";
3030 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsStatsUser.groupId = ?";
3031 private static final String _FINDER_COLUMN_USERID_USERID_2 = "blogsStatsUser.userId = ?";
3032 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "blogsStatsUser.groupId = ? AND ";
3033 private static final String _FINDER_COLUMN_G_U_USERID_2 = "blogsStatsUser.userId = ?";
3034 private static final String _FINDER_COLUMN_G_NOTE_GROUPID_2 = "blogsStatsUser.groupId = ? AND ";
3035 private static final String _FINDER_COLUMN_G_NOTE_ENTRYCOUNT_2 = "blogsStatsUser.entryCount != ?";
3036 private static final String _FINDER_COLUMN_C_NOTE_COMPANYID_2 = "blogsStatsUser.companyId = ? AND ";
3037 private static final String _FINDER_COLUMN_C_NOTE_ENTRYCOUNT_2 = "blogsStatsUser.entryCount != ?";
3038 private static final String _FINDER_COLUMN_U_L_USERID_2 = "blogsStatsUser.userId = ? AND ";
3039 private static final String _FINDER_COLUMN_U_L_LASTPOSTDATE_1 = "blogsStatsUser.lastPostDate IS NULL";
3040 private static final String _FINDER_COLUMN_U_L_LASTPOSTDATE_2 = "blogsStatsUser.lastPostDate = ?";
3041 private static final String _ORDER_BY_ENTITY_ALIAS = "blogsStatsUser.";
3042 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsStatsUser exists with the primary key ";
3043 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsStatsUser exists with the key {";
3044 private static Log _log = LogFactoryUtil.getLog(BlogsStatsUserPersistenceImpl.class);
3045 }