1
22
23 package com.liferay.portlet.messageboards.service.persistence;
24
25 import com.liferay.portal.NoSuchModelException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.annotation.BeanReference;
28 import com.liferay.portal.kernel.cache.CacheRegistry;
29 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
30 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32 import com.liferay.portal.kernel.dao.orm.FinderPath;
33 import com.liferay.portal.kernel.dao.orm.Query;
34 import com.liferay.portal.kernel.dao.orm.QueryPos;
35 import com.liferay.portal.kernel.dao.orm.QueryUtil;
36 import com.liferay.portal.kernel.dao.orm.Session;
37 import com.liferay.portal.kernel.log.Log;
38 import com.liferay.portal.kernel.log.LogFactoryUtil;
39 import com.liferay.portal.kernel.util.GetterUtil;
40 import com.liferay.portal.kernel.util.OrderByComparator;
41 import com.liferay.portal.kernel.util.StringBundler;
42 import com.liferay.portal.kernel.util.StringPool;
43 import com.liferay.portal.kernel.util.StringUtil;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.service.persistence.BatchSessionUtil;
46 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47
48 import com.liferay.portlet.messageboards.NoSuchStatsUserException;
49 import com.liferay.portlet.messageboards.model.MBStatsUser;
50 import com.liferay.portlet.messageboards.model.impl.MBStatsUserImpl;
51 import com.liferay.portlet.messageboards.model.impl.MBStatsUserModelImpl;
52
53 import java.io.Serializable;
54
55 import java.util.ArrayList;
56 import java.util.Collections;
57 import java.util.List;
58
59
72 public class MBStatsUserPersistenceImpl extends BasePersistenceImpl<MBStatsUser>
73 implements MBStatsUserPersistence {
74 public static final String FINDER_CLASS_NAME_ENTITY = MBStatsUserImpl.class.getName();
75 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
76 ".List";
77 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
78 MBStatsUserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
79 "findByGroupId", new String[] { Long.class.getName() });
80 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
81 MBStatsUserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
82 "findByGroupId",
83 new String[] {
84 Long.class.getName(),
85
86 "java.lang.Integer", "java.lang.Integer",
87 "com.liferay.portal.kernel.util.OrderByComparator"
88 });
89 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
90 MBStatsUserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
91 "countByGroupId", new String[] { Long.class.getName() });
92 public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
93 MBStatsUserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
94 "findByUserId", new String[] { Long.class.getName() });
95 public static final FinderPath FINDER_PATH_FIND_BY_OBC_USERID = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
96 MBStatsUserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
97 "findByUserId",
98 new String[] {
99 Long.class.getName(),
100
101 "java.lang.Integer", "java.lang.Integer",
102 "com.liferay.portal.kernel.util.OrderByComparator"
103 });
104 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
105 MBStatsUserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
106 "countByUserId", new String[] { Long.class.getName() });
107 public static final FinderPath FINDER_PATH_FETCH_BY_G_U = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
108 MBStatsUserModelImpl.FINDER_CACHE_ENABLED,
109 FINDER_CLASS_NAME_ENTITY, "fetchByG_U",
110 new String[] { Long.class.getName(), Long.class.getName() });
111 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
112 MBStatsUserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
113 "countByG_U",
114 new String[] { Long.class.getName(), Long.class.getName() });
115 public static final FinderPath FINDER_PATH_FIND_BY_G_M = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
116 MBStatsUserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
117 "findByG_M",
118 new String[] { Long.class.getName(), Integer.class.getName() });
119 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_M = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
120 MBStatsUserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
121 "findByG_M",
122 new String[] {
123 Long.class.getName(), Integer.class.getName(),
124
125 "java.lang.Integer", "java.lang.Integer",
126 "com.liferay.portal.kernel.util.OrderByComparator"
127 });
128 public static final FinderPath FINDER_PATH_COUNT_BY_G_M = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
129 MBStatsUserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
130 "countByG_M",
131 new String[] { Long.class.getName(), Integer.class.getName() });
132 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
133 MBStatsUserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
134 "findAll", new String[0]);
135 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
136 MBStatsUserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
137 "countAll", new String[0]);
138
139 public void cacheResult(MBStatsUser mbStatsUser) {
140 EntityCacheUtil.putResult(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
141 MBStatsUserImpl.class, mbStatsUser.getPrimaryKey(), mbStatsUser);
142
143 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
144 new Object[] {
145 new Long(mbStatsUser.getGroupId()),
146 new Long(mbStatsUser.getUserId())
147 }, mbStatsUser);
148 }
149
150 public void cacheResult(List<MBStatsUser> mbStatsUsers) {
151 for (MBStatsUser mbStatsUser : mbStatsUsers) {
152 if (EntityCacheUtil.getResult(
153 MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
154 MBStatsUserImpl.class, mbStatsUser.getPrimaryKey(), this) == null) {
155 cacheResult(mbStatsUser);
156 }
157 }
158 }
159
160 public void clearCache() {
161 CacheRegistry.clear(MBStatsUserImpl.class.getName());
162 EntityCacheUtil.clearCache(MBStatsUserImpl.class.getName());
163 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
164 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
165 }
166
167 public MBStatsUser create(long statsUserId) {
168 MBStatsUser mbStatsUser = new MBStatsUserImpl();
169
170 mbStatsUser.setNew(true);
171 mbStatsUser.setPrimaryKey(statsUserId);
172
173 return mbStatsUser;
174 }
175
176 public MBStatsUser remove(Serializable primaryKey)
177 throws NoSuchModelException, SystemException {
178 return remove(((Long)primaryKey).longValue());
179 }
180
181 public MBStatsUser remove(long statsUserId)
182 throws NoSuchStatsUserException, SystemException {
183 Session session = null;
184
185 try {
186 session = openSession();
187
188 MBStatsUser mbStatsUser = (MBStatsUser)session.get(MBStatsUserImpl.class,
189 new Long(statsUserId));
190
191 if (mbStatsUser == null) {
192 if (_log.isWarnEnabled()) {
193 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsUserId);
194 }
195
196 throw new NoSuchStatsUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
197 statsUserId);
198 }
199
200 return remove(mbStatsUser);
201 }
202 catch (NoSuchStatsUserException nsee) {
203 throw nsee;
204 }
205 catch (Exception e) {
206 throw processException(e);
207 }
208 finally {
209 closeSession(session);
210 }
211 }
212
213 public MBStatsUser remove(MBStatsUser mbStatsUser)
214 throws SystemException {
215 for (ModelListener<MBStatsUser> listener : listeners) {
216 listener.onBeforeRemove(mbStatsUser);
217 }
218
219 mbStatsUser = removeImpl(mbStatsUser);
220
221 for (ModelListener<MBStatsUser> listener : listeners) {
222 listener.onAfterRemove(mbStatsUser);
223 }
224
225 return mbStatsUser;
226 }
227
228 protected MBStatsUser removeImpl(MBStatsUser mbStatsUser)
229 throws SystemException {
230 mbStatsUser = toUnwrappedModel(mbStatsUser);
231
232 Session session = null;
233
234 try {
235 session = openSession();
236
237 if (mbStatsUser.isCachedModel() || BatchSessionUtil.isEnabled()) {
238 Object staleObject = session.get(MBStatsUserImpl.class,
239 mbStatsUser.getPrimaryKeyObj());
240
241 if (staleObject != null) {
242 session.evict(staleObject);
243 }
244 }
245
246 session.delete(mbStatsUser);
247
248 session.flush();
249 }
250 catch (Exception e) {
251 throw processException(e);
252 }
253 finally {
254 closeSession(session);
255 }
256
257 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
258
259 MBStatsUserModelImpl mbStatsUserModelImpl = (MBStatsUserModelImpl)mbStatsUser;
260
261 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U,
262 new Object[] {
263 new Long(mbStatsUserModelImpl.getOriginalGroupId()),
264 new Long(mbStatsUserModelImpl.getOriginalUserId())
265 });
266
267 EntityCacheUtil.removeResult(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
268 MBStatsUserImpl.class, mbStatsUser.getPrimaryKey());
269
270 return mbStatsUser;
271 }
272
273
276 public MBStatsUser update(MBStatsUser mbStatsUser)
277 throws SystemException {
278 if (_log.isWarnEnabled()) {
279 _log.warn(
280 "Using the deprecated update(MBStatsUser mbStatsUser) method. Use update(MBStatsUser mbStatsUser, boolean merge) instead.");
281 }
282
283 return update(mbStatsUser, false);
284 }
285
286 public MBStatsUser updateImpl(
287 com.liferay.portlet.messageboards.model.MBStatsUser mbStatsUser,
288 boolean merge) throws SystemException {
289 mbStatsUser = toUnwrappedModel(mbStatsUser);
290
291 boolean isNew = mbStatsUser.isNew();
292
293 MBStatsUserModelImpl mbStatsUserModelImpl = (MBStatsUserModelImpl)mbStatsUser;
294
295 Session session = null;
296
297 try {
298 session = openSession();
299
300 BatchSessionUtil.update(session, mbStatsUser, merge);
301
302 mbStatsUser.setNew(false);
303 }
304 catch (Exception e) {
305 throw processException(e);
306 }
307 finally {
308 closeSession(session);
309 }
310
311 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
312
313 EntityCacheUtil.putResult(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
314 MBStatsUserImpl.class, mbStatsUser.getPrimaryKey(), mbStatsUser);
315
316 if (!isNew &&
317 ((mbStatsUser.getGroupId() != mbStatsUserModelImpl.getOriginalGroupId()) ||
318 (mbStatsUser.getUserId() != mbStatsUserModelImpl.getOriginalUserId()))) {
319 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U,
320 new Object[] {
321 new Long(mbStatsUserModelImpl.getOriginalGroupId()),
322 new Long(mbStatsUserModelImpl.getOriginalUserId())
323 });
324 }
325
326 if (isNew ||
327 ((mbStatsUser.getGroupId() != mbStatsUserModelImpl.getOriginalGroupId()) ||
328 (mbStatsUser.getUserId() != mbStatsUserModelImpl.getOriginalUserId()))) {
329 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
330 new Object[] {
331 new Long(mbStatsUser.getGroupId()),
332 new Long(mbStatsUser.getUserId())
333 }, mbStatsUser);
334 }
335
336 return mbStatsUser;
337 }
338
339 protected MBStatsUser toUnwrappedModel(MBStatsUser mbStatsUser) {
340 if (mbStatsUser instanceof MBStatsUserImpl) {
341 return mbStatsUser;
342 }
343
344 MBStatsUserImpl mbStatsUserImpl = new MBStatsUserImpl();
345
346 mbStatsUserImpl.setNew(mbStatsUser.isNew());
347 mbStatsUserImpl.setPrimaryKey(mbStatsUser.getPrimaryKey());
348
349 mbStatsUserImpl.setStatsUserId(mbStatsUser.getStatsUserId());
350 mbStatsUserImpl.setGroupId(mbStatsUser.getGroupId());
351 mbStatsUserImpl.setUserId(mbStatsUser.getUserId());
352 mbStatsUserImpl.setMessageCount(mbStatsUser.getMessageCount());
353 mbStatsUserImpl.setLastPostDate(mbStatsUser.getLastPostDate());
354
355 return mbStatsUserImpl;
356 }
357
358 public MBStatsUser findByPrimaryKey(Serializable primaryKey)
359 throws NoSuchModelException, SystemException {
360 return findByPrimaryKey(((Long)primaryKey).longValue());
361 }
362
363 public MBStatsUser findByPrimaryKey(long statsUserId)
364 throws NoSuchStatsUserException, SystemException {
365 MBStatsUser mbStatsUser = fetchByPrimaryKey(statsUserId);
366
367 if (mbStatsUser == null) {
368 if (_log.isWarnEnabled()) {
369 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsUserId);
370 }
371
372 throw new NoSuchStatsUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
373 statsUserId);
374 }
375
376 return mbStatsUser;
377 }
378
379 public MBStatsUser fetchByPrimaryKey(Serializable primaryKey)
380 throws SystemException {
381 return fetchByPrimaryKey(((Long)primaryKey).longValue());
382 }
383
384 public MBStatsUser fetchByPrimaryKey(long statsUserId)
385 throws SystemException {
386 MBStatsUser mbStatsUser = (MBStatsUser)EntityCacheUtil.getResult(MBStatsUserModelImpl.ENTITY_CACHE_ENABLED,
387 MBStatsUserImpl.class, statsUserId, this);
388
389 if (mbStatsUser == null) {
390 Session session = null;
391
392 try {
393 session = openSession();
394
395 mbStatsUser = (MBStatsUser)session.get(MBStatsUserImpl.class,
396 new Long(statsUserId));
397 }
398 catch (Exception e) {
399 throw processException(e);
400 }
401 finally {
402 if (mbStatsUser != null) {
403 cacheResult(mbStatsUser);
404 }
405
406 closeSession(session);
407 }
408 }
409
410 return mbStatsUser;
411 }
412
413 public List<MBStatsUser> findByGroupId(long groupId)
414 throws SystemException {
415 Object[] finderArgs = new Object[] { new Long(groupId) };
416
417 List<MBStatsUser> list = (List<MBStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
418 finderArgs, this);
419
420 if (list == null) {
421 Session session = null;
422
423 try {
424 session = openSession();
425
426 StringBundler query = new StringBundler(3);
427
428 query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
429
430 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
431
432 query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
433
434 String sql = query.toString();
435
436 Query q = session.createQuery(sql);
437
438 QueryPos qPos = QueryPos.getInstance(q);
439
440 qPos.add(groupId);
441
442 list = q.list();
443 }
444 catch (Exception e) {
445 throw processException(e);
446 }
447 finally {
448 if (list == null) {
449 list = new ArrayList<MBStatsUser>();
450 }
451
452 cacheResult(list);
453
454 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
455 finderArgs, list);
456
457 closeSession(session);
458 }
459 }
460
461 return list;
462 }
463
464 public List<MBStatsUser> findByGroupId(long groupId, int start, int end)
465 throws SystemException {
466 return findByGroupId(groupId, start, end, null);
467 }
468
469 public List<MBStatsUser> findByGroupId(long groupId, int start, int end,
470 OrderByComparator obc) throws SystemException {
471 Object[] finderArgs = new Object[] {
472 new Long(groupId),
473
474 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
475 };
476
477 List<MBStatsUser> list = (List<MBStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
478 finderArgs, this);
479
480 if (list == null) {
481 Session session = null;
482
483 try {
484 session = openSession();
485
486 StringBundler query = null;
487
488 if (obc != null) {
489 query = new StringBundler(3 +
490 (obc.getOrderByFields().length * 3));
491 }
492 else {
493 query = new StringBundler(3);
494 }
495
496 query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
497
498 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
499
500 if (obc != null) {
501 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
502 }
503
504 else {
505 query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
506 }
507
508 String sql = query.toString();
509
510 Query q = session.createQuery(sql);
511
512 QueryPos qPos = QueryPos.getInstance(q);
513
514 qPos.add(groupId);
515
516 list = (List<MBStatsUser>)QueryUtil.list(q, getDialect(),
517 start, end);
518 }
519 catch (Exception e) {
520 throw processException(e);
521 }
522 finally {
523 if (list == null) {
524 list = new ArrayList<MBStatsUser>();
525 }
526
527 cacheResult(list);
528
529 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
530 finderArgs, list);
531
532 closeSession(session);
533 }
534 }
535
536 return list;
537 }
538
539 public MBStatsUser findByGroupId_First(long groupId, OrderByComparator obc)
540 throws NoSuchStatsUserException, SystemException {
541 List<MBStatsUser> list = findByGroupId(groupId, 0, 1, obc);
542
543 if (list.isEmpty()) {
544 StringBundler msg = new StringBundler(4);
545
546 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
547
548 msg.append("groupId=");
549 msg.append(groupId);
550
551 msg.append(StringPool.CLOSE_CURLY_BRACE);
552
553 throw new NoSuchStatsUserException(msg.toString());
554 }
555 else {
556 return list.get(0);
557 }
558 }
559
560 public MBStatsUser findByGroupId_Last(long groupId, OrderByComparator obc)
561 throws NoSuchStatsUserException, SystemException {
562 int count = countByGroupId(groupId);
563
564 List<MBStatsUser> list = findByGroupId(groupId, count - 1, count, obc);
565
566 if (list.isEmpty()) {
567 StringBundler msg = new StringBundler(4);
568
569 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
570
571 msg.append("groupId=");
572 msg.append(groupId);
573
574 msg.append(StringPool.CLOSE_CURLY_BRACE);
575
576 throw new NoSuchStatsUserException(msg.toString());
577 }
578 else {
579 return list.get(0);
580 }
581 }
582
583 public MBStatsUser[] findByGroupId_PrevAndNext(long statsUserId,
584 long groupId, OrderByComparator obc)
585 throws NoSuchStatsUserException, SystemException {
586 MBStatsUser mbStatsUser = findByPrimaryKey(statsUserId);
587
588 int count = countByGroupId(groupId);
589
590 Session session = null;
591
592 try {
593 session = openSession();
594
595 StringBundler query = null;
596
597 if (obc != null) {
598 query = new StringBundler(3 +
599 (obc.getOrderByFields().length * 3));
600 }
601 else {
602 query = new StringBundler(3);
603 }
604
605 query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
606
607 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
608
609 if (obc != null) {
610 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
611 }
612
613 else {
614 query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
615 }
616
617 String sql = query.toString();
618
619 Query q = session.createQuery(sql);
620
621 QueryPos qPos = QueryPos.getInstance(q);
622
623 qPos.add(groupId);
624
625 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
626 mbStatsUser);
627
628 MBStatsUser[] array = new MBStatsUserImpl[3];
629
630 array[0] = (MBStatsUser)objArray[0];
631 array[1] = (MBStatsUser)objArray[1];
632 array[2] = (MBStatsUser)objArray[2];
633
634 return array;
635 }
636 catch (Exception e) {
637 throw processException(e);
638 }
639 finally {
640 closeSession(session);
641 }
642 }
643
644 public List<MBStatsUser> findByUserId(long userId)
645 throws SystemException {
646 Object[] finderArgs = new Object[] { new Long(userId) };
647
648 List<MBStatsUser> list = (List<MBStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
649 finderArgs, this);
650
651 if (list == null) {
652 Session session = null;
653
654 try {
655 session = openSession();
656
657 StringBundler query = new StringBundler(3);
658
659 query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
660
661 query.append(_FINDER_COLUMN_USERID_USERID_2);
662
663 query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
664
665 String sql = query.toString();
666
667 Query q = session.createQuery(sql);
668
669 QueryPos qPos = QueryPos.getInstance(q);
670
671 qPos.add(userId);
672
673 list = q.list();
674 }
675 catch (Exception e) {
676 throw processException(e);
677 }
678 finally {
679 if (list == null) {
680 list = new ArrayList<MBStatsUser>();
681 }
682
683 cacheResult(list);
684
685 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
686 finderArgs, list);
687
688 closeSession(session);
689 }
690 }
691
692 return list;
693 }
694
695 public List<MBStatsUser> findByUserId(long userId, int start, int end)
696 throws SystemException {
697 return findByUserId(userId, start, end, null);
698 }
699
700 public List<MBStatsUser> findByUserId(long userId, int start, int end,
701 OrderByComparator obc) throws SystemException {
702 Object[] finderArgs = new Object[] {
703 new Long(userId),
704
705 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
706 };
707
708 List<MBStatsUser> list = (List<MBStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_USERID,
709 finderArgs, this);
710
711 if (list == null) {
712 Session session = null;
713
714 try {
715 session = openSession();
716
717 StringBundler query = null;
718
719 if (obc != null) {
720 query = new StringBundler(3 +
721 (obc.getOrderByFields().length * 3));
722 }
723 else {
724 query = new StringBundler(3);
725 }
726
727 query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
728
729 query.append(_FINDER_COLUMN_USERID_USERID_2);
730
731 if (obc != null) {
732 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
733 }
734
735 else {
736 query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
737 }
738
739 String sql = query.toString();
740
741 Query q = session.createQuery(sql);
742
743 QueryPos qPos = QueryPos.getInstance(q);
744
745 qPos.add(userId);
746
747 list = (List<MBStatsUser>)QueryUtil.list(q, getDialect(),
748 start, end);
749 }
750 catch (Exception e) {
751 throw processException(e);
752 }
753 finally {
754 if (list == null) {
755 list = new ArrayList<MBStatsUser>();
756 }
757
758 cacheResult(list);
759
760 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_USERID,
761 finderArgs, list);
762
763 closeSession(session);
764 }
765 }
766
767 return list;
768 }
769
770 public MBStatsUser findByUserId_First(long userId, OrderByComparator obc)
771 throws NoSuchStatsUserException, SystemException {
772 List<MBStatsUser> list = findByUserId(userId, 0, 1, obc);
773
774 if (list.isEmpty()) {
775 StringBundler msg = new StringBundler(4);
776
777 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
778
779 msg.append("userId=");
780 msg.append(userId);
781
782 msg.append(StringPool.CLOSE_CURLY_BRACE);
783
784 throw new NoSuchStatsUserException(msg.toString());
785 }
786 else {
787 return list.get(0);
788 }
789 }
790
791 public MBStatsUser findByUserId_Last(long userId, OrderByComparator obc)
792 throws NoSuchStatsUserException, SystemException {
793 int count = countByUserId(userId);
794
795 List<MBStatsUser> list = findByUserId(userId, count - 1, count, obc);
796
797 if (list.isEmpty()) {
798 StringBundler msg = new StringBundler(4);
799
800 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
801
802 msg.append("userId=");
803 msg.append(userId);
804
805 msg.append(StringPool.CLOSE_CURLY_BRACE);
806
807 throw new NoSuchStatsUserException(msg.toString());
808 }
809 else {
810 return list.get(0);
811 }
812 }
813
814 public MBStatsUser[] findByUserId_PrevAndNext(long statsUserId,
815 long userId, OrderByComparator obc)
816 throws NoSuchStatsUserException, SystemException {
817 MBStatsUser mbStatsUser = findByPrimaryKey(statsUserId);
818
819 int count = countByUserId(userId);
820
821 Session session = null;
822
823 try {
824 session = openSession();
825
826 StringBundler query = null;
827
828 if (obc != null) {
829 query = new StringBundler(3 +
830 (obc.getOrderByFields().length * 3));
831 }
832 else {
833 query = new StringBundler(3);
834 }
835
836 query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
837
838 query.append(_FINDER_COLUMN_USERID_USERID_2);
839
840 if (obc != null) {
841 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
842 }
843
844 else {
845 query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
846 }
847
848 String sql = query.toString();
849
850 Query q = session.createQuery(sql);
851
852 QueryPos qPos = QueryPos.getInstance(q);
853
854 qPos.add(userId);
855
856 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
857 mbStatsUser);
858
859 MBStatsUser[] array = new MBStatsUserImpl[3];
860
861 array[0] = (MBStatsUser)objArray[0];
862 array[1] = (MBStatsUser)objArray[1];
863 array[2] = (MBStatsUser)objArray[2];
864
865 return array;
866 }
867 catch (Exception e) {
868 throw processException(e);
869 }
870 finally {
871 closeSession(session);
872 }
873 }
874
875 public MBStatsUser findByG_U(long groupId, long userId)
876 throws NoSuchStatsUserException, SystemException {
877 MBStatsUser mbStatsUser = fetchByG_U(groupId, userId);
878
879 if (mbStatsUser == null) {
880 StringBundler msg = new StringBundler(6);
881
882 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
883
884 msg.append("groupId=");
885 msg.append(groupId);
886
887 msg.append(", userId=");
888 msg.append(userId);
889
890 msg.append(StringPool.CLOSE_CURLY_BRACE);
891
892 if (_log.isWarnEnabled()) {
893 _log.warn(msg.toString());
894 }
895
896 throw new NoSuchStatsUserException(msg.toString());
897 }
898
899 return mbStatsUser;
900 }
901
902 public MBStatsUser fetchByG_U(long groupId, long userId)
903 throws SystemException {
904 return fetchByG_U(groupId, userId, true);
905 }
906
907 public MBStatsUser fetchByG_U(long groupId, long userId,
908 boolean retrieveFromCache) throws SystemException {
909 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
910
911 Object result = null;
912
913 if (retrieveFromCache) {
914 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_U,
915 finderArgs, this);
916 }
917
918 if (result == null) {
919 Session session = null;
920
921 try {
922 session = openSession();
923
924 StringBundler query = new StringBundler(4);
925
926 query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
927
928 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
929
930 query.append(_FINDER_COLUMN_G_U_USERID_2);
931
932 query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
933
934 String sql = query.toString();
935
936 Query q = session.createQuery(sql);
937
938 QueryPos qPos = QueryPos.getInstance(q);
939
940 qPos.add(groupId);
941
942 qPos.add(userId);
943
944 List<MBStatsUser> list = q.list();
945
946 result = list;
947
948 MBStatsUser mbStatsUser = null;
949
950 if (list.isEmpty()) {
951 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
952 finderArgs, list);
953 }
954 else {
955 mbStatsUser = list.get(0);
956
957 cacheResult(mbStatsUser);
958
959 if ((mbStatsUser.getGroupId() != groupId) ||
960 (mbStatsUser.getUserId() != userId)) {
961 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
962 finderArgs, mbStatsUser);
963 }
964 }
965
966 return mbStatsUser;
967 }
968 catch (Exception e) {
969 throw processException(e);
970 }
971 finally {
972 if (result == null) {
973 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U,
974 finderArgs, new ArrayList<MBStatsUser>());
975 }
976
977 closeSession(session);
978 }
979 }
980 else {
981 if (result instanceof List<?>) {
982 return null;
983 }
984 else {
985 return (MBStatsUser)result;
986 }
987 }
988 }
989
990 public List<MBStatsUser> findByG_M(long groupId, int messageCount)
991 throws SystemException {
992 Object[] finderArgs = new Object[] {
993 new Long(groupId), new Integer(messageCount)
994 };
995
996 List<MBStatsUser> list = (List<MBStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_M,
997 finderArgs, this);
998
999 if (list == null) {
1000 Session session = null;
1001
1002 try {
1003 session = openSession();
1004
1005 StringBundler query = new StringBundler(4);
1006
1007 query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
1008
1009 query.append(_FINDER_COLUMN_G_M_GROUPID_2);
1010
1011 query.append(_FINDER_COLUMN_G_M_MESSAGECOUNT_2);
1012
1013 query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
1014
1015 String sql = query.toString();
1016
1017 Query q = session.createQuery(sql);
1018
1019 QueryPos qPos = QueryPos.getInstance(q);
1020
1021 qPos.add(groupId);
1022
1023 qPos.add(messageCount);
1024
1025 list = q.list();
1026 }
1027 catch (Exception e) {
1028 throw processException(e);
1029 }
1030 finally {
1031 if (list == null) {
1032 list = new ArrayList<MBStatsUser>();
1033 }
1034
1035 cacheResult(list);
1036
1037 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_M, finderArgs,
1038 list);
1039
1040 closeSession(session);
1041 }
1042 }
1043
1044 return list;
1045 }
1046
1047 public List<MBStatsUser> findByG_M(long groupId, int messageCount,
1048 int start, int end) throws SystemException {
1049 return findByG_M(groupId, messageCount, start, end, null);
1050 }
1051
1052 public List<MBStatsUser> findByG_M(long groupId, int messageCount,
1053 int start, int end, OrderByComparator obc) throws SystemException {
1054 Object[] finderArgs = new Object[] {
1055 new Long(groupId), new Integer(messageCount),
1056
1057 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1058 };
1059
1060 List<MBStatsUser> list = (List<MBStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_M,
1061 finderArgs, this);
1062
1063 if (list == null) {
1064 Session session = null;
1065
1066 try {
1067 session = openSession();
1068
1069 StringBundler query = null;
1070
1071 if (obc != null) {
1072 query = new StringBundler(4 +
1073 (obc.getOrderByFields().length * 3));
1074 }
1075 else {
1076 query = new StringBundler(4);
1077 }
1078
1079 query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
1080
1081 query.append(_FINDER_COLUMN_G_M_GROUPID_2);
1082
1083 query.append(_FINDER_COLUMN_G_M_MESSAGECOUNT_2);
1084
1085 if (obc != null) {
1086 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1087 }
1088
1089 else {
1090 query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
1091 }
1092
1093 String sql = query.toString();
1094
1095 Query q = session.createQuery(sql);
1096
1097 QueryPos qPos = QueryPos.getInstance(q);
1098
1099 qPos.add(groupId);
1100
1101 qPos.add(messageCount);
1102
1103 list = (List<MBStatsUser>)QueryUtil.list(q, getDialect(),
1104 start, end);
1105 }
1106 catch (Exception e) {
1107 throw processException(e);
1108 }
1109 finally {
1110 if (list == null) {
1111 list = new ArrayList<MBStatsUser>();
1112 }
1113
1114 cacheResult(list);
1115
1116 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_M,
1117 finderArgs, list);
1118
1119 closeSession(session);
1120 }
1121 }
1122
1123 return list;
1124 }
1125
1126 public MBStatsUser findByG_M_First(long groupId, int messageCount,
1127 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1128 List<MBStatsUser> list = findByG_M(groupId, messageCount, 0, 1, obc);
1129
1130 if (list.isEmpty()) {
1131 StringBundler msg = new StringBundler(6);
1132
1133 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1134
1135 msg.append("groupId=");
1136 msg.append(groupId);
1137
1138 msg.append(", messageCount=");
1139 msg.append(messageCount);
1140
1141 msg.append(StringPool.CLOSE_CURLY_BRACE);
1142
1143 throw new NoSuchStatsUserException(msg.toString());
1144 }
1145 else {
1146 return list.get(0);
1147 }
1148 }
1149
1150 public MBStatsUser findByG_M_Last(long groupId, int messageCount,
1151 OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1152 int count = countByG_M(groupId, messageCount);
1153
1154 List<MBStatsUser> list = findByG_M(groupId, messageCount, count - 1,
1155 count, obc);
1156
1157 if (list.isEmpty()) {
1158 StringBundler msg = new StringBundler(6);
1159
1160 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1161
1162 msg.append("groupId=");
1163 msg.append(groupId);
1164
1165 msg.append(", messageCount=");
1166 msg.append(messageCount);
1167
1168 msg.append(StringPool.CLOSE_CURLY_BRACE);
1169
1170 throw new NoSuchStatsUserException(msg.toString());
1171 }
1172 else {
1173 return list.get(0);
1174 }
1175 }
1176
1177 public MBStatsUser[] findByG_M_PrevAndNext(long statsUserId, long groupId,
1178 int messageCount, OrderByComparator obc)
1179 throws NoSuchStatsUserException, SystemException {
1180 MBStatsUser mbStatsUser = findByPrimaryKey(statsUserId);
1181
1182 int count = countByG_M(groupId, messageCount);
1183
1184 Session session = null;
1185
1186 try {
1187 session = openSession();
1188
1189 StringBundler query = null;
1190
1191 if (obc != null) {
1192 query = new StringBundler(4 +
1193 (obc.getOrderByFields().length * 3));
1194 }
1195 else {
1196 query = new StringBundler(4);
1197 }
1198
1199 query.append(_SQL_SELECT_MBSTATSUSER_WHERE);
1200
1201 query.append(_FINDER_COLUMN_G_M_GROUPID_2);
1202
1203 query.append(_FINDER_COLUMN_G_M_MESSAGECOUNT_2);
1204
1205 if (obc != null) {
1206 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1207 }
1208
1209 else {
1210 query.append(MBStatsUserModelImpl.ORDER_BY_JPQL);
1211 }
1212
1213 String sql = query.toString();
1214
1215 Query q = session.createQuery(sql);
1216
1217 QueryPos qPos = QueryPos.getInstance(q);
1218
1219 qPos.add(groupId);
1220
1221 qPos.add(messageCount);
1222
1223 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1224 mbStatsUser);
1225
1226 MBStatsUser[] array = new MBStatsUserImpl[3];
1227
1228 array[0] = (MBStatsUser)objArray[0];
1229 array[1] = (MBStatsUser)objArray[1];
1230 array[2] = (MBStatsUser)objArray[2];
1231
1232 return array;
1233 }
1234 catch (Exception e) {
1235 throw processException(e);
1236 }
1237 finally {
1238 closeSession(session);
1239 }
1240 }
1241
1242 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1243 throws SystemException {
1244 Session session = null;
1245
1246 try {
1247 session = openSession();
1248
1249 dynamicQuery.compile(session);
1250
1251 return dynamicQuery.list();
1252 }
1253 catch (Exception e) {
1254 throw processException(e);
1255 }
1256 finally {
1257 closeSession(session);
1258 }
1259 }
1260
1261 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1262 int start, int end) throws SystemException {
1263 Session session = null;
1264
1265 try {
1266 session = openSession();
1267
1268 dynamicQuery.setLimit(start, end);
1269
1270 dynamicQuery.compile(session);
1271
1272 return dynamicQuery.list();
1273 }
1274 catch (Exception e) {
1275 throw processException(e);
1276 }
1277 finally {
1278 closeSession(session);
1279 }
1280 }
1281
1282 public List<MBStatsUser> findAll() throws SystemException {
1283 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1284 }
1285
1286 public List<MBStatsUser> findAll(int start, int end)
1287 throws SystemException {
1288 return findAll(start, end, null);
1289 }
1290
1291 public List<MBStatsUser> findAll(int start, int end, OrderByComparator obc)
1292 throws SystemException {
1293 Object[] finderArgs = new Object[] {
1294 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1295 };
1296
1297 List<MBStatsUser> list = (List<MBStatsUser>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1298 finderArgs, this);
1299
1300 if (list == null) {
1301 Session session = null;
1302
1303 try {
1304 session = openSession();
1305
1306 StringBundler query = null;
1307 String sql = null;
1308
1309 if (obc != null) {
1310 query = new StringBundler(2 +
1311 (obc.getOrderByFields().length * 3));
1312
1313 query.append(_SQL_SELECT_MBSTATSUSER);
1314
1315 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1316
1317 sql = query.toString();
1318 }
1319
1320 else {
1321 sql = _SQL_SELECT_MBSTATSUSER.concat(MBStatsUserModelImpl.ORDER_BY_JPQL);
1322 }
1323
1324 Query q = session.createQuery(sql);
1325
1326 if (obc == null) {
1327 list = (List<MBStatsUser>)QueryUtil.list(q, getDialect(),
1328 start, end, false);
1329
1330 Collections.sort(list);
1331 }
1332 else {
1333 list = (List<MBStatsUser>)QueryUtil.list(q, getDialect(),
1334 start, end);
1335 }
1336 }
1337 catch (Exception e) {
1338 throw processException(e);
1339 }
1340 finally {
1341 if (list == null) {
1342 list = new ArrayList<MBStatsUser>();
1343 }
1344
1345 cacheResult(list);
1346
1347 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1348
1349 closeSession(session);
1350 }
1351 }
1352
1353 return list;
1354 }
1355
1356 public void removeByGroupId(long groupId) throws SystemException {
1357 for (MBStatsUser mbStatsUser : findByGroupId(groupId)) {
1358 remove(mbStatsUser);
1359 }
1360 }
1361
1362 public void removeByUserId(long userId) throws SystemException {
1363 for (MBStatsUser mbStatsUser : findByUserId(userId)) {
1364 remove(mbStatsUser);
1365 }
1366 }
1367
1368 public void removeByG_U(long groupId, long userId)
1369 throws NoSuchStatsUserException, SystemException {
1370 MBStatsUser mbStatsUser = findByG_U(groupId, userId);
1371
1372 remove(mbStatsUser);
1373 }
1374
1375 public void removeByG_M(long groupId, int messageCount)
1376 throws SystemException {
1377 for (MBStatsUser mbStatsUser : findByG_M(groupId, messageCount)) {
1378 remove(mbStatsUser);
1379 }
1380 }
1381
1382 public void removeAll() throws SystemException {
1383 for (MBStatsUser mbStatsUser : findAll()) {
1384 remove(mbStatsUser);
1385 }
1386 }
1387
1388 public int countByGroupId(long groupId) throws SystemException {
1389 Object[] finderArgs = new Object[] { new Long(groupId) };
1390
1391 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1392 finderArgs, this);
1393
1394 if (count == null) {
1395 Session session = null;
1396
1397 try {
1398 session = openSession();
1399
1400 StringBundler query = new StringBundler(2);
1401
1402 query.append(_SQL_COUNT_MBSTATSUSER_WHERE);
1403
1404 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1405
1406 String sql = query.toString();
1407
1408 Query q = session.createQuery(sql);
1409
1410 QueryPos qPos = QueryPos.getInstance(q);
1411
1412 qPos.add(groupId);
1413
1414 count = (Long)q.uniqueResult();
1415 }
1416 catch (Exception e) {
1417 throw processException(e);
1418 }
1419 finally {
1420 if (count == null) {
1421 count = Long.valueOf(0);
1422 }
1423
1424 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1425 finderArgs, count);
1426
1427 closeSession(session);
1428 }
1429 }
1430
1431 return count.intValue();
1432 }
1433
1434 public int countByUserId(long userId) throws SystemException {
1435 Object[] finderArgs = new Object[] { new Long(userId) };
1436
1437 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1438 finderArgs, this);
1439
1440 if (count == null) {
1441 Session session = null;
1442
1443 try {
1444 session = openSession();
1445
1446 StringBundler query = new StringBundler(2);
1447
1448 query.append(_SQL_COUNT_MBSTATSUSER_WHERE);
1449
1450 query.append(_FINDER_COLUMN_USERID_USERID_2);
1451
1452 String sql = query.toString();
1453
1454 Query q = session.createQuery(sql);
1455
1456 QueryPos qPos = QueryPos.getInstance(q);
1457
1458 qPos.add(userId);
1459
1460 count = (Long)q.uniqueResult();
1461 }
1462 catch (Exception e) {
1463 throw processException(e);
1464 }
1465 finally {
1466 if (count == null) {
1467 count = Long.valueOf(0);
1468 }
1469
1470 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1471 finderArgs, count);
1472
1473 closeSession(session);
1474 }
1475 }
1476
1477 return count.intValue();
1478 }
1479
1480 public int countByG_U(long groupId, long userId) throws SystemException {
1481 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1482
1483 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
1484 finderArgs, this);
1485
1486 if (count == null) {
1487 Session session = null;
1488
1489 try {
1490 session = openSession();
1491
1492 StringBundler query = new StringBundler(3);
1493
1494 query.append(_SQL_COUNT_MBSTATSUSER_WHERE);
1495
1496 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1497
1498 query.append(_FINDER_COLUMN_G_U_USERID_2);
1499
1500 String sql = query.toString();
1501
1502 Query q = session.createQuery(sql);
1503
1504 QueryPos qPos = QueryPos.getInstance(q);
1505
1506 qPos.add(groupId);
1507
1508 qPos.add(userId);
1509
1510 count = (Long)q.uniqueResult();
1511 }
1512 catch (Exception e) {
1513 throw processException(e);
1514 }
1515 finally {
1516 if (count == null) {
1517 count = Long.valueOf(0);
1518 }
1519
1520 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
1521 count);
1522
1523 closeSession(session);
1524 }
1525 }
1526
1527 return count.intValue();
1528 }
1529
1530 public int countByG_M(long groupId, int messageCount)
1531 throws SystemException {
1532 Object[] finderArgs = new Object[] {
1533 new Long(groupId), new Integer(messageCount)
1534 };
1535
1536 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_M,
1537 finderArgs, this);
1538
1539 if (count == null) {
1540 Session session = null;
1541
1542 try {
1543 session = openSession();
1544
1545 StringBundler query = new StringBundler(3);
1546
1547 query.append(_SQL_COUNT_MBSTATSUSER_WHERE);
1548
1549 query.append(_FINDER_COLUMN_G_M_GROUPID_2);
1550
1551 query.append(_FINDER_COLUMN_G_M_MESSAGECOUNT_2);
1552
1553 String sql = query.toString();
1554
1555 Query q = session.createQuery(sql);
1556
1557 QueryPos qPos = QueryPos.getInstance(q);
1558
1559 qPos.add(groupId);
1560
1561 qPos.add(messageCount);
1562
1563 count = (Long)q.uniqueResult();
1564 }
1565 catch (Exception e) {
1566 throw processException(e);
1567 }
1568 finally {
1569 if (count == null) {
1570 count = Long.valueOf(0);
1571 }
1572
1573 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_M, finderArgs,
1574 count);
1575
1576 closeSession(session);
1577 }
1578 }
1579
1580 return count.intValue();
1581 }
1582
1583 public int countAll() throws SystemException {
1584 Object[] finderArgs = new Object[0];
1585
1586 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1587 finderArgs, this);
1588
1589 if (count == null) {
1590 Session session = null;
1591
1592 try {
1593 session = openSession();
1594
1595 Query q = session.createQuery(_SQL_COUNT_MBSTATSUSER);
1596
1597 count = (Long)q.uniqueResult();
1598 }
1599 catch (Exception e) {
1600 throw processException(e);
1601 }
1602 finally {
1603 if (count == null) {
1604 count = Long.valueOf(0);
1605 }
1606
1607 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1608 count);
1609
1610 closeSession(session);
1611 }
1612 }
1613
1614 return count.intValue();
1615 }
1616
1617 public void afterPropertiesSet() {
1618 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1619 com.liferay.portal.util.PropsUtil.get(
1620 "value.object.listener.com.liferay.portlet.messageboards.model.MBStatsUser")));
1621
1622 if (listenerClassNames.length > 0) {
1623 try {
1624 List<ModelListener<MBStatsUser>> listenersList = new ArrayList<ModelListener<MBStatsUser>>();
1625
1626 for (String listenerClassName : listenerClassNames) {
1627 listenersList.add((ModelListener<MBStatsUser>)Class.forName(
1628 listenerClassName).newInstance());
1629 }
1630
1631 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1632 }
1633 catch (Exception e) {
1634 _log.error(e);
1635 }
1636 }
1637 }
1638
1639 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBBanPersistence")
1640 protected com.liferay.portlet.messageboards.service.persistence.MBBanPersistence mbBanPersistence;
1641 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence")
1642 protected com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence mbCategoryPersistence;
1643 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence")
1644 protected com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence mbDiscussionPersistence;
1645 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMailingListPersistence")
1646 protected com.liferay.portlet.messageboards.service.persistence.MBMailingListPersistence mbMailingListPersistence;
1647 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence")
1648 protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
1649 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence")
1650 protected com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence mbMessageFlagPersistence;
1651 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence")
1652 protected com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence mbStatsUserPersistence;
1653 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence")
1654 protected com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence mbThreadPersistence;
1655 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
1656 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1657 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
1658 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1659 private static final String _SQL_SELECT_MBSTATSUSER = "SELECT mbStatsUser FROM MBStatsUser mbStatsUser";
1660 private static final String _SQL_SELECT_MBSTATSUSER_WHERE = "SELECT mbStatsUser FROM MBStatsUser mbStatsUser WHERE ";
1661 private static final String _SQL_COUNT_MBSTATSUSER = "SELECT COUNT(mbStatsUser) FROM MBStatsUser mbStatsUser";
1662 private static final String _SQL_COUNT_MBSTATSUSER_WHERE = "SELECT COUNT(mbStatsUser) FROM MBStatsUser mbStatsUser WHERE ";
1663 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbStatsUser.groupId = ?";
1664 private static final String _FINDER_COLUMN_USERID_USERID_2 = "mbStatsUser.userId = ?";
1665 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "mbStatsUser.groupId = ? AND ";
1666 private static final String _FINDER_COLUMN_G_U_USERID_2 = "mbStatsUser.userId = ?";
1667 private static final String _FINDER_COLUMN_G_M_GROUPID_2 = "mbStatsUser.groupId = ? AND ";
1668 private static final String _FINDER_COLUMN_G_M_MESSAGECOUNT_2 = "mbStatsUser.messageCount != ?";
1669 private static final String _ORDER_BY_ENTITY_ALIAS = "mbStatsUser.";
1670 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBStatsUser exists with the primary key ";
1671 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBStatsUser exists with the key {";
1672 private static Log _log = LogFactoryUtil.getLog(MBStatsUserPersistenceImpl.class);
1673}