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