001
014
015 package com.liferay.portlet.messageboards.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.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.model.ModelListener;
037 import com.liferay.portal.service.persistence.BatchSessionUtil;
038 import com.liferay.portal.service.persistence.ResourcePersistence;
039 import com.liferay.portal.service.persistence.UserPersistence;
040 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041
042 import com.liferay.portlet.messageboards.NoSuchBanException;
043 import com.liferay.portlet.messageboards.model.MBBan;
044 import com.liferay.portlet.messageboards.model.impl.MBBanImpl;
045 import com.liferay.portlet.messageboards.model.impl.MBBanModelImpl;
046
047 import java.io.Serializable;
048
049 import java.util.ArrayList;
050 import java.util.Collections;
051 import java.util.List;
052
053
069 public class MBBanPersistenceImpl extends BasePersistenceImpl<MBBan>
070 implements MBBanPersistence {
071 public static final String FINDER_CLASS_NAME_ENTITY = MBBanImpl.class.getName();
072 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
073 ".List";
074 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
075 MBBanModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
076 "findByGroupId",
077 new String[] {
078 Long.class.getName(),
079
080 "java.lang.Integer", "java.lang.Integer",
081 "com.liferay.portal.kernel.util.OrderByComparator"
082 });
083 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
084 MBBanModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
085 "countByGroupId", new String[] { Long.class.getName() });
086 public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
087 MBBanModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
088 "findByUserId",
089 new String[] {
090 Long.class.getName(),
091
092 "java.lang.Integer", "java.lang.Integer",
093 "com.liferay.portal.kernel.util.OrderByComparator"
094 });
095 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
096 MBBanModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
097 "countByUserId", new String[] { Long.class.getName() });
098 public static final FinderPath FINDER_PATH_FIND_BY_BANUSERID = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
099 MBBanModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100 "findByBanUserId",
101 new String[] {
102 Long.class.getName(),
103
104 "java.lang.Integer", "java.lang.Integer",
105 "com.liferay.portal.kernel.util.OrderByComparator"
106 });
107 public static final FinderPath FINDER_PATH_COUNT_BY_BANUSERID = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
108 MBBanModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
109 "countByBanUserId", new String[] { Long.class.getName() });
110 public static final FinderPath FINDER_PATH_FETCH_BY_G_B = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
111 MBBanModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
112 "fetchByG_B",
113 new String[] { Long.class.getName(), Long.class.getName() });
114 public static final FinderPath FINDER_PATH_COUNT_BY_G_B = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
115 MBBanModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
116 "countByG_B",
117 new String[] { Long.class.getName(), Long.class.getName() });
118 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
119 MBBanModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
120 "findAll", new String[0]);
121 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBBanModelImpl.ENTITY_CACHE_ENABLED,
122 MBBanModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
123 "countAll", new String[0]);
124
125
130 public void cacheResult(MBBan mbBan) {
131 EntityCacheUtil.putResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
132 MBBanImpl.class, mbBan.getPrimaryKey(), mbBan);
133
134 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_B,
135 new Object[] {
136 new Long(mbBan.getGroupId()), new Long(mbBan.getBanUserId())
137 }, mbBan);
138 }
139
140
145 public void cacheResult(List<MBBan> mbBans) {
146 for (MBBan mbBan : mbBans) {
147 if (EntityCacheUtil.getResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
148 MBBanImpl.class, mbBan.getPrimaryKey(), this) == null) {
149 cacheResult(mbBan);
150 }
151 }
152 }
153
154
161 public void clearCache() {
162 CacheRegistryUtil.clear(MBBanImpl.class.getName());
163 EntityCacheUtil.clearCache(MBBanImpl.class.getName());
164 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
165 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
166 }
167
168
175 public void clearCache(MBBan mbBan) {
176 EntityCacheUtil.removeResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
177 MBBanImpl.class, mbBan.getPrimaryKey());
178
179 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_B,
180 new Object[] {
181 new Long(mbBan.getGroupId()), new Long(mbBan.getBanUserId())
182 });
183 }
184
185
191 public MBBan create(long banId) {
192 MBBan mbBan = new MBBanImpl();
193
194 mbBan.setNew(true);
195 mbBan.setPrimaryKey(banId);
196
197 return mbBan;
198 }
199
200
208 public MBBan remove(Serializable primaryKey)
209 throws NoSuchModelException, SystemException {
210 return remove(((Long)primaryKey).longValue());
211 }
212
213
221 public MBBan remove(long banId) throws NoSuchBanException, SystemException {
222 Session session = null;
223
224 try {
225 session = openSession();
226
227 MBBan mbBan = (MBBan)session.get(MBBanImpl.class, new Long(banId));
228
229 if (mbBan == null) {
230 if (_log.isWarnEnabled()) {
231 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + banId);
232 }
233
234 throw new NoSuchBanException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
235 banId);
236 }
237
238 return remove(mbBan);
239 }
240 catch (NoSuchBanException nsee) {
241 throw nsee;
242 }
243 catch (Exception e) {
244 throw processException(e);
245 }
246 finally {
247 closeSession(session);
248 }
249 }
250
251 protected MBBan removeImpl(MBBan mbBan) throws SystemException {
252 mbBan = toUnwrappedModel(mbBan);
253
254 Session session = null;
255
256 try {
257 session = openSession();
258
259 BatchSessionUtil.delete(session, mbBan);
260 }
261 catch (Exception e) {
262 throw processException(e);
263 }
264 finally {
265 closeSession(session);
266 }
267
268 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
269
270 MBBanModelImpl mbBanModelImpl = (MBBanModelImpl)mbBan;
271
272 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_B,
273 new Object[] {
274 new Long(mbBanModelImpl.getOriginalGroupId()),
275 new Long(mbBanModelImpl.getOriginalBanUserId())
276 });
277
278 EntityCacheUtil.removeResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
279 MBBanImpl.class, mbBan.getPrimaryKey());
280
281 return mbBan;
282 }
283
284 public MBBan updateImpl(
285 com.liferay.portlet.messageboards.model.MBBan mbBan, boolean merge)
286 throws SystemException {
287 mbBan = toUnwrappedModel(mbBan);
288
289 boolean isNew = mbBan.isNew();
290
291 MBBanModelImpl mbBanModelImpl = (MBBanModelImpl)mbBan;
292
293 Session session = null;
294
295 try {
296 session = openSession();
297
298 BatchSessionUtil.update(session, mbBan, merge);
299
300 mbBan.setNew(false);
301 }
302 catch (Exception e) {
303 throw processException(e);
304 }
305 finally {
306 closeSession(session);
307 }
308
309 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
310
311 EntityCacheUtil.putResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
312 MBBanImpl.class, mbBan.getPrimaryKey(), mbBan);
313
314 if (!isNew &&
315 ((mbBan.getGroupId() != mbBanModelImpl.getOriginalGroupId()) ||
316 (mbBan.getBanUserId() != mbBanModelImpl.getOriginalBanUserId()))) {
317 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_B,
318 new Object[] {
319 new Long(mbBanModelImpl.getOriginalGroupId()),
320 new Long(mbBanModelImpl.getOriginalBanUserId())
321 });
322 }
323
324 if (isNew ||
325 ((mbBan.getGroupId() != mbBanModelImpl.getOriginalGroupId()) ||
326 (mbBan.getBanUserId() != mbBanModelImpl.getOriginalBanUserId()))) {
327 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_B,
328 new Object[] {
329 new Long(mbBan.getGroupId()), new Long(mbBan.getBanUserId())
330 }, mbBan);
331 }
332
333 return mbBan;
334 }
335
336 protected MBBan toUnwrappedModel(MBBan mbBan) {
337 if (mbBan instanceof MBBanImpl) {
338 return mbBan;
339 }
340
341 MBBanImpl mbBanImpl = new MBBanImpl();
342
343 mbBanImpl.setNew(mbBan.isNew());
344 mbBanImpl.setPrimaryKey(mbBan.getPrimaryKey());
345
346 mbBanImpl.setBanId(mbBan.getBanId());
347 mbBanImpl.setGroupId(mbBan.getGroupId());
348 mbBanImpl.setCompanyId(mbBan.getCompanyId());
349 mbBanImpl.setUserId(mbBan.getUserId());
350 mbBanImpl.setUserName(mbBan.getUserName());
351 mbBanImpl.setCreateDate(mbBan.getCreateDate());
352 mbBanImpl.setModifiedDate(mbBan.getModifiedDate());
353 mbBanImpl.setBanUserId(mbBan.getBanUserId());
354
355 return mbBanImpl;
356 }
357
358
366 public MBBan findByPrimaryKey(Serializable primaryKey)
367 throws NoSuchModelException, SystemException {
368 return findByPrimaryKey(((Long)primaryKey).longValue());
369 }
370
371
379 public MBBan findByPrimaryKey(long banId)
380 throws NoSuchBanException, SystemException {
381 MBBan mbBan = fetchByPrimaryKey(banId);
382
383 if (mbBan == null) {
384 if (_log.isWarnEnabled()) {
385 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + banId);
386 }
387
388 throw new NoSuchBanException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
389 banId);
390 }
391
392 return mbBan;
393 }
394
395
402 public MBBan fetchByPrimaryKey(Serializable primaryKey)
403 throws SystemException {
404 return fetchByPrimaryKey(((Long)primaryKey).longValue());
405 }
406
407
414 public MBBan fetchByPrimaryKey(long banId) throws SystemException {
415 MBBan mbBan = (MBBan)EntityCacheUtil.getResult(MBBanModelImpl.ENTITY_CACHE_ENABLED,
416 MBBanImpl.class, banId, this);
417
418 if (mbBan == null) {
419 Session session = null;
420
421 try {
422 session = openSession();
423
424 mbBan = (MBBan)session.get(MBBanImpl.class, new Long(banId));
425 }
426 catch (Exception e) {
427 throw processException(e);
428 }
429 finally {
430 if (mbBan != null) {
431 cacheResult(mbBan);
432 }
433
434 closeSession(session);
435 }
436 }
437
438 return mbBan;
439 }
440
441
448 public List<MBBan> findByGroupId(long groupId) throws SystemException {
449 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
450 }
451
452
465 public List<MBBan> findByGroupId(long groupId, int start, int end)
466 throws SystemException {
467 return findByGroupId(groupId, start, end, null);
468 }
469
470
484 public List<MBBan> findByGroupId(long groupId, int start, int end,
485 OrderByComparator orderByComparator) throws SystemException {
486 Object[] finderArgs = new Object[] {
487 groupId,
488
489 String.valueOf(start), String.valueOf(end),
490 String.valueOf(orderByComparator)
491 };
492
493 List<MBBan> list = (List<MBBan>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
494 finderArgs, this);
495
496 if (list == null) {
497 Session session = null;
498
499 try {
500 session = openSession();
501
502 StringBundler query = null;
503
504 if (orderByComparator != null) {
505 query = new StringBundler(3 +
506 (orderByComparator.getOrderByFields().length * 3));
507 }
508 else {
509 query = new StringBundler(2);
510 }
511
512 query.append(_SQL_SELECT_MBBAN_WHERE);
513
514 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
515
516 if (orderByComparator != null) {
517 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
518 orderByComparator);
519 }
520
521 String sql = query.toString();
522
523 Query q = session.createQuery(sql);
524
525 QueryPos qPos = QueryPos.getInstance(q);
526
527 qPos.add(groupId);
528
529 list = (List<MBBan>)QueryUtil.list(q, getDialect(), start, end);
530 }
531 catch (Exception e) {
532 throw processException(e);
533 }
534 finally {
535 if (list == null) {
536 list = new ArrayList<MBBan>();
537 }
538
539 cacheResult(list);
540
541 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
542 finderArgs, list);
543
544 closeSession(session);
545 }
546 }
547
548 return list;
549 }
550
551
564 public MBBan findByGroupId_First(long groupId,
565 OrderByComparator orderByComparator)
566 throws NoSuchBanException, SystemException {
567 List<MBBan> list = findByGroupId(groupId, 0, 1, orderByComparator);
568
569 if (list.isEmpty()) {
570 StringBundler msg = new StringBundler(4);
571
572 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
573
574 msg.append("groupId=");
575 msg.append(groupId);
576
577 msg.append(StringPool.CLOSE_CURLY_BRACE);
578
579 throw new NoSuchBanException(msg.toString());
580 }
581 else {
582 return list.get(0);
583 }
584 }
585
586
599 public MBBan findByGroupId_Last(long groupId,
600 OrderByComparator orderByComparator)
601 throws NoSuchBanException, SystemException {
602 int count = countByGroupId(groupId);
603
604 List<MBBan> list = findByGroupId(groupId, count - 1, count,
605 orderByComparator);
606
607 if (list.isEmpty()) {
608 StringBundler msg = new StringBundler(4);
609
610 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
611
612 msg.append("groupId=");
613 msg.append(groupId);
614
615 msg.append(StringPool.CLOSE_CURLY_BRACE);
616
617 throw new NoSuchBanException(msg.toString());
618 }
619 else {
620 return list.get(0);
621 }
622 }
623
624
638 public MBBan[] findByGroupId_PrevAndNext(long banId, long groupId,
639 OrderByComparator orderByComparator)
640 throws NoSuchBanException, SystemException {
641 MBBan mbBan = findByPrimaryKey(banId);
642
643 Session session = null;
644
645 try {
646 session = openSession();
647
648 MBBan[] array = new MBBanImpl[3];
649
650 array[0] = getByGroupId_PrevAndNext(session, mbBan, groupId,
651 orderByComparator, true);
652
653 array[1] = mbBan;
654
655 array[2] = getByGroupId_PrevAndNext(session, mbBan, groupId,
656 orderByComparator, false);
657
658 return array;
659 }
660 catch (Exception e) {
661 throw processException(e);
662 }
663 finally {
664 closeSession(session);
665 }
666 }
667
668 protected MBBan getByGroupId_PrevAndNext(Session session, MBBan mbBan,
669 long groupId, OrderByComparator orderByComparator, boolean previous) {
670 StringBundler query = null;
671
672 if (orderByComparator != null) {
673 query = new StringBundler(6 +
674 (orderByComparator.getOrderByFields().length * 6));
675 }
676 else {
677 query = new StringBundler(3);
678 }
679
680 query.append(_SQL_SELECT_MBBAN_WHERE);
681
682 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
683
684 if (orderByComparator != null) {
685 String[] orderByFields = orderByComparator.getOrderByFields();
686
687 if (orderByFields.length > 0) {
688 query.append(WHERE_AND);
689 }
690
691 for (int i = 0; i < orderByFields.length; i++) {
692 query.append(_ORDER_BY_ENTITY_ALIAS);
693 query.append(orderByFields[i]);
694
695 if ((i + 1) < orderByFields.length) {
696 if (orderByComparator.isAscending() ^ previous) {
697 query.append(WHERE_GREATER_THAN_HAS_NEXT);
698 }
699 else {
700 query.append(WHERE_LESSER_THAN_HAS_NEXT);
701 }
702 }
703 else {
704 if (orderByComparator.isAscending() ^ previous) {
705 query.append(WHERE_GREATER_THAN);
706 }
707 else {
708 query.append(WHERE_LESSER_THAN);
709 }
710 }
711 }
712
713 query.append(ORDER_BY_CLAUSE);
714
715 for (int i = 0; i < orderByFields.length; i++) {
716 query.append(_ORDER_BY_ENTITY_ALIAS);
717 query.append(orderByFields[i]);
718
719 if ((i + 1) < orderByFields.length) {
720 if (orderByComparator.isAscending() ^ previous) {
721 query.append(ORDER_BY_ASC_HAS_NEXT);
722 }
723 else {
724 query.append(ORDER_BY_DESC_HAS_NEXT);
725 }
726 }
727 else {
728 if (orderByComparator.isAscending() ^ previous) {
729 query.append(ORDER_BY_ASC);
730 }
731 else {
732 query.append(ORDER_BY_DESC);
733 }
734 }
735 }
736 }
737
738 String sql = query.toString();
739
740 Query q = session.createQuery(sql);
741
742 q.setFirstResult(0);
743 q.setMaxResults(2);
744
745 QueryPos qPos = QueryPos.getInstance(q);
746
747 qPos.add(groupId);
748
749 if (orderByComparator != null) {
750 Object[] values = orderByComparator.getOrderByValues(mbBan);
751
752 for (Object value : values) {
753 qPos.add(value);
754 }
755 }
756
757 List<MBBan> list = q.list();
758
759 if (list.size() == 2) {
760 return list.get(1);
761 }
762 else {
763 return null;
764 }
765 }
766
767
774 public List<MBBan> findByUserId(long userId) throws SystemException {
775 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
776 }
777
778
791 public List<MBBan> findByUserId(long userId, int start, int end)
792 throws SystemException {
793 return findByUserId(userId, start, end, null);
794 }
795
796
810 public List<MBBan> findByUserId(long userId, int start, int end,
811 OrderByComparator orderByComparator) throws SystemException {
812 Object[] finderArgs = new Object[] {
813 userId,
814
815 String.valueOf(start), String.valueOf(end),
816 String.valueOf(orderByComparator)
817 };
818
819 List<MBBan> list = (List<MBBan>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
820 finderArgs, this);
821
822 if (list == null) {
823 Session session = null;
824
825 try {
826 session = openSession();
827
828 StringBundler query = null;
829
830 if (orderByComparator != null) {
831 query = new StringBundler(3 +
832 (orderByComparator.getOrderByFields().length * 3));
833 }
834 else {
835 query = new StringBundler(2);
836 }
837
838 query.append(_SQL_SELECT_MBBAN_WHERE);
839
840 query.append(_FINDER_COLUMN_USERID_USERID_2);
841
842 if (orderByComparator != null) {
843 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
844 orderByComparator);
845 }
846
847 String sql = query.toString();
848
849 Query q = session.createQuery(sql);
850
851 QueryPos qPos = QueryPos.getInstance(q);
852
853 qPos.add(userId);
854
855 list = (List<MBBan>)QueryUtil.list(q, getDialect(), start, end);
856 }
857 catch (Exception e) {
858 throw processException(e);
859 }
860 finally {
861 if (list == null) {
862 list = new ArrayList<MBBan>();
863 }
864
865 cacheResult(list);
866
867 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
868 finderArgs, list);
869
870 closeSession(session);
871 }
872 }
873
874 return list;
875 }
876
877
890 public MBBan findByUserId_First(long userId,
891 OrderByComparator orderByComparator)
892 throws NoSuchBanException, SystemException {
893 List<MBBan> list = findByUserId(userId, 0, 1, orderByComparator);
894
895 if (list.isEmpty()) {
896 StringBundler msg = new StringBundler(4);
897
898 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
899
900 msg.append("userId=");
901 msg.append(userId);
902
903 msg.append(StringPool.CLOSE_CURLY_BRACE);
904
905 throw new NoSuchBanException(msg.toString());
906 }
907 else {
908 return list.get(0);
909 }
910 }
911
912
925 public MBBan findByUserId_Last(long userId,
926 OrderByComparator orderByComparator)
927 throws NoSuchBanException, SystemException {
928 int count = countByUserId(userId);
929
930 List<MBBan> list = findByUserId(userId, count - 1, count,
931 orderByComparator);
932
933 if (list.isEmpty()) {
934 StringBundler msg = new StringBundler(4);
935
936 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
937
938 msg.append("userId=");
939 msg.append(userId);
940
941 msg.append(StringPool.CLOSE_CURLY_BRACE);
942
943 throw new NoSuchBanException(msg.toString());
944 }
945 else {
946 return list.get(0);
947 }
948 }
949
950
964 public MBBan[] findByUserId_PrevAndNext(long banId, long userId,
965 OrderByComparator orderByComparator)
966 throws NoSuchBanException, SystemException {
967 MBBan mbBan = findByPrimaryKey(banId);
968
969 Session session = null;
970
971 try {
972 session = openSession();
973
974 MBBan[] array = new MBBanImpl[3];
975
976 array[0] = getByUserId_PrevAndNext(session, mbBan, userId,
977 orderByComparator, true);
978
979 array[1] = mbBan;
980
981 array[2] = getByUserId_PrevAndNext(session, mbBan, userId,
982 orderByComparator, false);
983
984 return array;
985 }
986 catch (Exception e) {
987 throw processException(e);
988 }
989 finally {
990 closeSession(session);
991 }
992 }
993
994 protected MBBan getByUserId_PrevAndNext(Session session, MBBan mbBan,
995 long userId, OrderByComparator orderByComparator, boolean previous) {
996 StringBundler query = null;
997
998 if (orderByComparator != null) {
999 query = new StringBundler(6 +
1000 (orderByComparator.getOrderByFields().length * 6));
1001 }
1002 else {
1003 query = new StringBundler(3);
1004 }
1005
1006 query.append(_SQL_SELECT_MBBAN_WHERE);
1007
1008 query.append(_FINDER_COLUMN_USERID_USERID_2);
1009
1010 if (orderByComparator != null) {
1011 String[] orderByFields = orderByComparator.getOrderByFields();
1012
1013 if (orderByFields.length > 0) {
1014 query.append(WHERE_AND);
1015 }
1016
1017 for (int i = 0; i < orderByFields.length; i++) {
1018 query.append(_ORDER_BY_ENTITY_ALIAS);
1019 query.append(orderByFields[i]);
1020
1021 if ((i + 1) < orderByFields.length) {
1022 if (orderByComparator.isAscending() ^ previous) {
1023 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1024 }
1025 else {
1026 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1027 }
1028 }
1029 else {
1030 if (orderByComparator.isAscending() ^ previous) {
1031 query.append(WHERE_GREATER_THAN);
1032 }
1033 else {
1034 query.append(WHERE_LESSER_THAN);
1035 }
1036 }
1037 }
1038
1039 query.append(ORDER_BY_CLAUSE);
1040
1041 for (int i = 0; i < orderByFields.length; i++) {
1042 query.append(_ORDER_BY_ENTITY_ALIAS);
1043 query.append(orderByFields[i]);
1044
1045 if ((i + 1) < orderByFields.length) {
1046 if (orderByComparator.isAscending() ^ previous) {
1047 query.append(ORDER_BY_ASC_HAS_NEXT);
1048 }
1049 else {
1050 query.append(ORDER_BY_DESC_HAS_NEXT);
1051 }
1052 }
1053 else {
1054 if (orderByComparator.isAscending() ^ previous) {
1055 query.append(ORDER_BY_ASC);
1056 }
1057 else {
1058 query.append(ORDER_BY_DESC);
1059 }
1060 }
1061 }
1062 }
1063
1064 String sql = query.toString();
1065
1066 Query q = session.createQuery(sql);
1067
1068 q.setFirstResult(0);
1069 q.setMaxResults(2);
1070
1071 QueryPos qPos = QueryPos.getInstance(q);
1072
1073 qPos.add(userId);
1074
1075 if (orderByComparator != null) {
1076 Object[] values = orderByComparator.getOrderByValues(mbBan);
1077
1078 for (Object value : values) {
1079 qPos.add(value);
1080 }
1081 }
1082
1083 List<MBBan> list = q.list();
1084
1085 if (list.size() == 2) {
1086 return list.get(1);
1087 }
1088 else {
1089 return null;
1090 }
1091 }
1092
1093
1100 public List<MBBan> findByBanUserId(long banUserId)
1101 throws SystemException {
1102 return findByBanUserId(banUserId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1103 null);
1104 }
1105
1106
1119 public List<MBBan> findByBanUserId(long banUserId, int start, int end)
1120 throws SystemException {
1121 return findByBanUserId(banUserId, start, end, null);
1122 }
1123
1124
1138 public List<MBBan> findByBanUserId(long banUserId, int start, int end,
1139 OrderByComparator orderByComparator) throws SystemException {
1140 Object[] finderArgs = new Object[] {
1141 banUserId,
1142
1143 String.valueOf(start), String.valueOf(end),
1144 String.valueOf(orderByComparator)
1145 };
1146
1147 List<MBBan> list = (List<MBBan>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_BANUSERID,
1148 finderArgs, this);
1149
1150 if (list == null) {
1151 Session session = null;
1152
1153 try {
1154 session = openSession();
1155
1156 StringBundler query = null;
1157
1158 if (orderByComparator != null) {
1159 query = new StringBundler(3 +
1160 (orderByComparator.getOrderByFields().length * 3));
1161 }
1162 else {
1163 query = new StringBundler(2);
1164 }
1165
1166 query.append(_SQL_SELECT_MBBAN_WHERE);
1167
1168 query.append(_FINDER_COLUMN_BANUSERID_BANUSERID_2);
1169
1170 if (orderByComparator != null) {
1171 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1172 orderByComparator);
1173 }
1174
1175 String sql = query.toString();
1176
1177 Query q = session.createQuery(sql);
1178
1179 QueryPos qPos = QueryPos.getInstance(q);
1180
1181 qPos.add(banUserId);
1182
1183 list = (List<MBBan>)QueryUtil.list(q, getDialect(), start, end);
1184 }
1185 catch (Exception e) {
1186 throw processException(e);
1187 }
1188 finally {
1189 if (list == null) {
1190 list = new ArrayList<MBBan>();
1191 }
1192
1193 cacheResult(list);
1194
1195 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_BANUSERID,
1196 finderArgs, list);
1197
1198 closeSession(session);
1199 }
1200 }
1201
1202 return list;
1203 }
1204
1205
1218 public MBBan findByBanUserId_First(long banUserId,
1219 OrderByComparator orderByComparator)
1220 throws NoSuchBanException, SystemException {
1221 List<MBBan> list = findByBanUserId(banUserId, 0, 1, orderByComparator);
1222
1223 if (list.isEmpty()) {
1224 StringBundler msg = new StringBundler(4);
1225
1226 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1227
1228 msg.append("banUserId=");
1229 msg.append(banUserId);
1230
1231 msg.append(StringPool.CLOSE_CURLY_BRACE);
1232
1233 throw new NoSuchBanException(msg.toString());
1234 }
1235 else {
1236 return list.get(0);
1237 }
1238 }
1239
1240
1253 public MBBan findByBanUserId_Last(long banUserId,
1254 OrderByComparator orderByComparator)
1255 throws NoSuchBanException, SystemException {
1256 int count = countByBanUserId(banUserId);
1257
1258 List<MBBan> list = findByBanUserId(banUserId, count - 1, count,
1259 orderByComparator);
1260
1261 if (list.isEmpty()) {
1262 StringBundler msg = new StringBundler(4);
1263
1264 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1265
1266 msg.append("banUserId=");
1267 msg.append(banUserId);
1268
1269 msg.append(StringPool.CLOSE_CURLY_BRACE);
1270
1271 throw new NoSuchBanException(msg.toString());
1272 }
1273 else {
1274 return list.get(0);
1275 }
1276 }
1277
1278
1292 public MBBan[] findByBanUserId_PrevAndNext(long banId, long banUserId,
1293 OrderByComparator orderByComparator)
1294 throws NoSuchBanException, SystemException {
1295 MBBan mbBan = findByPrimaryKey(banId);
1296
1297 Session session = null;
1298
1299 try {
1300 session = openSession();
1301
1302 MBBan[] array = new MBBanImpl[3];
1303
1304 array[0] = getByBanUserId_PrevAndNext(session, mbBan, banUserId,
1305 orderByComparator, true);
1306
1307 array[1] = mbBan;
1308
1309 array[2] = getByBanUserId_PrevAndNext(session, mbBan, banUserId,
1310 orderByComparator, false);
1311
1312 return array;
1313 }
1314 catch (Exception e) {
1315 throw processException(e);
1316 }
1317 finally {
1318 closeSession(session);
1319 }
1320 }
1321
1322 protected MBBan getByBanUserId_PrevAndNext(Session session, MBBan mbBan,
1323 long banUserId, OrderByComparator orderByComparator, boolean previous) {
1324 StringBundler query = null;
1325
1326 if (orderByComparator != null) {
1327 query = new StringBundler(6 +
1328 (orderByComparator.getOrderByFields().length * 6));
1329 }
1330 else {
1331 query = new StringBundler(3);
1332 }
1333
1334 query.append(_SQL_SELECT_MBBAN_WHERE);
1335
1336 query.append(_FINDER_COLUMN_BANUSERID_BANUSERID_2);
1337
1338 if (orderByComparator != null) {
1339 String[] orderByFields = orderByComparator.getOrderByFields();
1340
1341 if (orderByFields.length > 0) {
1342 query.append(WHERE_AND);
1343 }
1344
1345 for (int i = 0; i < orderByFields.length; i++) {
1346 query.append(_ORDER_BY_ENTITY_ALIAS);
1347 query.append(orderByFields[i]);
1348
1349 if ((i + 1) < orderByFields.length) {
1350 if (orderByComparator.isAscending() ^ previous) {
1351 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1352 }
1353 else {
1354 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1355 }
1356 }
1357 else {
1358 if (orderByComparator.isAscending() ^ previous) {
1359 query.append(WHERE_GREATER_THAN);
1360 }
1361 else {
1362 query.append(WHERE_LESSER_THAN);
1363 }
1364 }
1365 }
1366
1367 query.append(ORDER_BY_CLAUSE);
1368
1369 for (int i = 0; i < orderByFields.length; i++) {
1370 query.append(_ORDER_BY_ENTITY_ALIAS);
1371 query.append(orderByFields[i]);
1372
1373 if ((i + 1) < orderByFields.length) {
1374 if (orderByComparator.isAscending() ^ previous) {
1375 query.append(ORDER_BY_ASC_HAS_NEXT);
1376 }
1377 else {
1378 query.append(ORDER_BY_DESC_HAS_NEXT);
1379 }
1380 }
1381 else {
1382 if (orderByComparator.isAscending() ^ previous) {
1383 query.append(ORDER_BY_ASC);
1384 }
1385 else {
1386 query.append(ORDER_BY_DESC);
1387 }
1388 }
1389 }
1390 }
1391
1392 String sql = query.toString();
1393
1394 Query q = session.createQuery(sql);
1395
1396 q.setFirstResult(0);
1397 q.setMaxResults(2);
1398
1399 QueryPos qPos = QueryPos.getInstance(q);
1400
1401 qPos.add(banUserId);
1402
1403 if (orderByComparator != null) {
1404 Object[] values = orderByComparator.getOrderByValues(mbBan);
1405
1406 for (Object value : values) {
1407 qPos.add(value);
1408 }
1409 }
1410
1411 List<MBBan> list = q.list();
1412
1413 if (list.size() == 2) {
1414 return list.get(1);
1415 }
1416 else {
1417 return null;
1418 }
1419 }
1420
1421
1430 public MBBan findByG_B(long groupId, long banUserId)
1431 throws NoSuchBanException, SystemException {
1432 MBBan mbBan = fetchByG_B(groupId, banUserId);
1433
1434 if (mbBan == null) {
1435 StringBundler msg = new StringBundler(6);
1436
1437 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1438
1439 msg.append("groupId=");
1440 msg.append(groupId);
1441
1442 msg.append(", banUserId=");
1443 msg.append(banUserId);
1444
1445 msg.append(StringPool.CLOSE_CURLY_BRACE);
1446
1447 if (_log.isWarnEnabled()) {
1448 _log.warn(msg.toString());
1449 }
1450
1451 throw new NoSuchBanException(msg.toString());
1452 }
1453
1454 return mbBan;
1455 }
1456
1457
1465 public MBBan fetchByG_B(long groupId, long banUserId)
1466 throws SystemException {
1467 return fetchByG_B(groupId, banUserId, true);
1468 }
1469
1470
1478 public MBBan fetchByG_B(long groupId, long banUserId,
1479 boolean retrieveFromCache) throws SystemException {
1480 Object[] finderArgs = new Object[] { groupId, banUserId };
1481
1482 Object result = null;
1483
1484 if (retrieveFromCache) {
1485 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_B,
1486 finderArgs, this);
1487 }
1488
1489 if (result == null) {
1490 Session session = null;
1491
1492 try {
1493 session = openSession();
1494
1495 StringBundler query = new StringBundler(3);
1496
1497 query.append(_SQL_SELECT_MBBAN_WHERE);
1498
1499 query.append(_FINDER_COLUMN_G_B_GROUPID_2);
1500
1501 query.append(_FINDER_COLUMN_G_B_BANUSERID_2);
1502
1503 String sql = query.toString();
1504
1505 Query q = session.createQuery(sql);
1506
1507 QueryPos qPos = QueryPos.getInstance(q);
1508
1509 qPos.add(groupId);
1510
1511 qPos.add(banUserId);
1512
1513 List<MBBan> list = q.list();
1514
1515 result = list;
1516
1517 MBBan mbBan = null;
1518
1519 if (list.isEmpty()) {
1520 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_B,
1521 finderArgs, list);
1522 }
1523 else {
1524 mbBan = list.get(0);
1525
1526 cacheResult(mbBan);
1527
1528 if ((mbBan.getGroupId() != groupId) ||
1529 (mbBan.getBanUserId() != banUserId)) {
1530 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_B,
1531 finderArgs, mbBan);
1532 }
1533 }
1534
1535 return mbBan;
1536 }
1537 catch (Exception e) {
1538 throw processException(e);
1539 }
1540 finally {
1541 if (result == null) {
1542 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_B,
1543 finderArgs, new ArrayList<MBBan>());
1544 }
1545
1546 closeSession(session);
1547 }
1548 }
1549 else {
1550 if (result instanceof List<?>) {
1551 return null;
1552 }
1553 else {
1554 return (MBBan)result;
1555 }
1556 }
1557 }
1558
1559
1565 public List<MBBan> findAll() throws SystemException {
1566 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1567 }
1568
1569
1581 public List<MBBan> findAll(int start, int end) throws SystemException {
1582 return findAll(start, end, null);
1583 }
1584
1585
1598 public List<MBBan> findAll(int start, int end,
1599 OrderByComparator orderByComparator) throws SystemException {
1600 Object[] finderArgs = new Object[] {
1601 String.valueOf(start), String.valueOf(end),
1602 String.valueOf(orderByComparator)
1603 };
1604
1605 List<MBBan> list = (List<MBBan>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1606 finderArgs, this);
1607
1608 if (list == null) {
1609 Session session = null;
1610
1611 try {
1612 session = openSession();
1613
1614 StringBundler query = null;
1615 String sql = null;
1616
1617 if (orderByComparator != null) {
1618 query = new StringBundler(2 +
1619 (orderByComparator.getOrderByFields().length * 3));
1620
1621 query.append(_SQL_SELECT_MBBAN);
1622
1623 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1624 orderByComparator);
1625
1626 sql = query.toString();
1627 }
1628 else {
1629 sql = _SQL_SELECT_MBBAN;
1630 }
1631
1632 Query q = session.createQuery(sql);
1633
1634 if (orderByComparator == null) {
1635 list = (List<MBBan>)QueryUtil.list(q, getDialect(), start,
1636 end, false);
1637
1638 Collections.sort(list);
1639 }
1640 else {
1641 list = (List<MBBan>)QueryUtil.list(q, getDialect(), start,
1642 end);
1643 }
1644 }
1645 catch (Exception e) {
1646 throw processException(e);
1647 }
1648 finally {
1649 if (list == null) {
1650 list = new ArrayList<MBBan>();
1651 }
1652
1653 cacheResult(list);
1654
1655 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1656
1657 closeSession(session);
1658 }
1659 }
1660
1661 return list;
1662 }
1663
1664
1670 public void removeByGroupId(long groupId) throws SystemException {
1671 for (MBBan mbBan : findByGroupId(groupId)) {
1672 remove(mbBan);
1673 }
1674 }
1675
1676
1682 public void removeByUserId(long userId) throws SystemException {
1683 for (MBBan mbBan : findByUserId(userId)) {
1684 remove(mbBan);
1685 }
1686 }
1687
1688
1694 public void removeByBanUserId(long banUserId) throws SystemException {
1695 for (MBBan mbBan : findByBanUserId(banUserId)) {
1696 remove(mbBan);
1697 }
1698 }
1699
1700
1707 public void removeByG_B(long groupId, long banUserId)
1708 throws NoSuchBanException, SystemException {
1709 MBBan mbBan = findByG_B(groupId, banUserId);
1710
1711 remove(mbBan);
1712 }
1713
1714
1719 public void removeAll() throws SystemException {
1720 for (MBBan mbBan : findAll()) {
1721 remove(mbBan);
1722 }
1723 }
1724
1725
1732 public int countByGroupId(long groupId) throws SystemException {
1733 Object[] finderArgs = new Object[] { groupId };
1734
1735 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1736 finderArgs, this);
1737
1738 if (count == null) {
1739 Session session = null;
1740
1741 try {
1742 session = openSession();
1743
1744 StringBundler query = new StringBundler(2);
1745
1746 query.append(_SQL_COUNT_MBBAN_WHERE);
1747
1748 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1749
1750 String sql = query.toString();
1751
1752 Query q = session.createQuery(sql);
1753
1754 QueryPos qPos = QueryPos.getInstance(q);
1755
1756 qPos.add(groupId);
1757
1758 count = (Long)q.uniqueResult();
1759 }
1760 catch (Exception e) {
1761 throw processException(e);
1762 }
1763 finally {
1764 if (count == null) {
1765 count = Long.valueOf(0);
1766 }
1767
1768 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1769 finderArgs, count);
1770
1771 closeSession(session);
1772 }
1773 }
1774
1775 return count.intValue();
1776 }
1777
1778
1785 public int countByUserId(long userId) throws SystemException {
1786 Object[] finderArgs = new Object[] { userId };
1787
1788 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1789 finderArgs, this);
1790
1791 if (count == null) {
1792 Session session = null;
1793
1794 try {
1795 session = openSession();
1796
1797 StringBundler query = new StringBundler(2);
1798
1799 query.append(_SQL_COUNT_MBBAN_WHERE);
1800
1801 query.append(_FINDER_COLUMN_USERID_USERID_2);
1802
1803 String sql = query.toString();
1804
1805 Query q = session.createQuery(sql);
1806
1807 QueryPos qPos = QueryPos.getInstance(q);
1808
1809 qPos.add(userId);
1810
1811 count = (Long)q.uniqueResult();
1812 }
1813 catch (Exception e) {
1814 throw processException(e);
1815 }
1816 finally {
1817 if (count == null) {
1818 count = Long.valueOf(0);
1819 }
1820
1821 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1822 finderArgs, count);
1823
1824 closeSession(session);
1825 }
1826 }
1827
1828 return count.intValue();
1829 }
1830
1831
1838 public int countByBanUserId(long banUserId) throws SystemException {
1839 Object[] finderArgs = new Object[] { banUserId };
1840
1841 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_BANUSERID,
1842 finderArgs, this);
1843
1844 if (count == null) {
1845 Session session = null;
1846
1847 try {
1848 session = openSession();
1849
1850 StringBundler query = new StringBundler(2);
1851
1852 query.append(_SQL_COUNT_MBBAN_WHERE);
1853
1854 query.append(_FINDER_COLUMN_BANUSERID_BANUSERID_2);
1855
1856 String sql = query.toString();
1857
1858 Query q = session.createQuery(sql);
1859
1860 QueryPos qPos = QueryPos.getInstance(q);
1861
1862 qPos.add(banUserId);
1863
1864 count = (Long)q.uniqueResult();
1865 }
1866 catch (Exception e) {
1867 throw processException(e);
1868 }
1869 finally {
1870 if (count == null) {
1871 count = Long.valueOf(0);
1872 }
1873
1874 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_BANUSERID,
1875 finderArgs, count);
1876
1877 closeSession(session);
1878 }
1879 }
1880
1881 return count.intValue();
1882 }
1883
1884
1892 public int countByG_B(long groupId, long banUserId)
1893 throws SystemException {
1894 Object[] finderArgs = new Object[] { groupId, banUserId };
1895
1896 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_B,
1897 finderArgs, this);
1898
1899 if (count == null) {
1900 Session session = null;
1901
1902 try {
1903 session = openSession();
1904
1905 StringBundler query = new StringBundler(3);
1906
1907 query.append(_SQL_COUNT_MBBAN_WHERE);
1908
1909 query.append(_FINDER_COLUMN_G_B_GROUPID_2);
1910
1911 query.append(_FINDER_COLUMN_G_B_BANUSERID_2);
1912
1913 String sql = query.toString();
1914
1915 Query q = session.createQuery(sql);
1916
1917 QueryPos qPos = QueryPos.getInstance(q);
1918
1919 qPos.add(groupId);
1920
1921 qPos.add(banUserId);
1922
1923 count = (Long)q.uniqueResult();
1924 }
1925 catch (Exception e) {
1926 throw processException(e);
1927 }
1928 finally {
1929 if (count == null) {
1930 count = Long.valueOf(0);
1931 }
1932
1933 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_B, finderArgs,
1934 count);
1935
1936 closeSession(session);
1937 }
1938 }
1939
1940 return count.intValue();
1941 }
1942
1943
1949 public int countAll() throws SystemException {
1950 Object[] finderArgs = new Object[0];
1951
1952 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1953 finderArgs, this);
1954
1955 if (count == null) {
1956 Session session = null;
1957
1958 try {
1959 session = openSession();
1960
1961 Query q = session.createQuery(_SQL_COUNT_MBBAN);
1962
1963 count = (Long)q.uniqueResult();
1964 }
1965 catch (Exception e) {
1966 throw processException(e);
1967 }
1968 finally {
1969 if (count == null) {
1970 count = Long.valueOf(0);
1971 }
1972
1973 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1974 count);
1975
1976 closeSession(session);
1977 }
1978 }
1979
1980 return count.intValue();
1981 }
1982
1983
1986 public void afterPropertiesSet() {
1987 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1988 com.liferay.portal.util.PropsUtil.get(
1989 "value.object.listener.com.liferay.portlet.messageboards.model.MBBan")));
1990
1991 if (listenerClassNames.length > 0) {
1992 try {
1993 List<ModelListener<MBBan>> listenersList = new ArrayList<ModelListener<MBBan>>();
1994
1995 for (String listenerClassName : listenerClassNames) {
1996 listenersList.add((ModelListener<MBBan>)InstanceFactory.newInstance(
1997 listenerClassName));
1998 }
1999
2000 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2001 }
2002 catch (Exception e) {
2003 _log.error(e);
2004 }
2005 }
2006 }
2007
2008 public void destroy() {
2009 EntityCacheUtil.removeCache(MBBanImpl.class.getName());
2010 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2011 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
2012 }
2013
2014 @BeanReference(type = MBBanPersistence.class)
2015 protected MBBanPersistence mbBanPersistence;
2016 @BeanReference(type = MBCategoryPersistence.class)
2017 protected MBCategoryPersistence mbCategoryPersistence;
2018 @BeanReference(type = MBDiscussionPersistence.class)
2019 protected MBDiscussionPersistence mbDiscussionPersistence;
2020 @BeanReference(type = MBMailingListPersistence.class)
2021 protected MBMailingListPersistence mbMailingListPersistence;
2022 @BeanReference(type = MBMessagePersistence.class)
2023 protected MBMessagePersistence mbMessagePersistence;
2024 @BeanReference(type = MBMessageFlagPersistence.class)
2025 protected MBMessageFlagPersistence mbMessageFlagPersistence;
2026 @BeanReference(type = MBStatsUserPersistence.class)
2027 protected MBStatsUserPersistence mbStatsUserPersistence;
2028 @BeanReference(type = MBThreadPersistence.class)
2029 protected MBThreadPersistence mbThreadPersistence;
2030 @BeanReference(type = ResourcePersistence.class)
2031 protected ResourcePersistence resourcePersistence;
2032 @BeanReference(type = UserPersistence.class)
2033 protected UserPersistence userPersistence;
2034 private static final String _SQL_SELECT_MBBAN = "SELECT mbBan FROM MBBan mbBan";
2035 private static final String _SQL_SELECT_MBBAN_WHERE = "SELECT mbBan FROM MBBan mbBan WHERE ";
2036 private static final String _SQL_COUNT_MBBAN = "SELECT COUNT(mbBan) FROM MBBan mbBan";
2037 private static final String _SQL_COUNT_MBBAN_WHERE = "SELECT COUNT(mbBan) FROM MBBan mbBan WHERE ";
2038 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mbBan.groupId = ?";
2039 private static final String _FINDER_COLUMN_USERID_USERID_2 = "mbBan.userId = ?";
2040 private static final String _FINDER_COLUMN_BANUSERID_BANUSERID_2 = "mbBan.banUserId = ?";
2041 private static final String _FINDER_COLUMN_G_B_GROUPID_2 = "mbBan.groupId = ? AND ";
2042 private static final String _FINDER_COLUMN_G_B_BANUSERID_2 = "mbBan.banUserId = ?";
2043 private static final String _ORDER_BY_ENTITY_ALIAS = "mbBan.";
2044 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBBan exists with the primary key ";
2045 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBBan exists with the key {";
2046 private static Log _log = LogFactoryUtil.getLog(MBBanPersistenceImpl.class);
2047 }