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.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.service.persistence.BatchSessionUtil;
040 import com.liferay.portal.service.persistence.ResourcePersistence;
041 import com.liferay.portal.service.persistence.UserPersistence;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import com.liferay.portlet.messageboards.NoSuchMailingListException;
045 import com.liferay.portlet.messageboards.model.MBMailingList;
046 import com.liferay.portlet.messageboards.model.impl.MBMailingListImpl;
047 import com.liferay.portlet.messageboards.model.impl.MBMailingListModelImpl;
048
049 import java.io.Serializable;
050
051 import java.util.ArrayList;
052 import java.util.Collections;
053 import java.util.List;
054
055
071 public class MBMailingListPersistenceImpl extends BasePersistenceImpl<MBMailingList>
072 implements MBMailingListPersistence {
073 public static final String FINDER_CLASS_NAME_ENTITY = MBMailingListImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
075 ".List";
076 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
077 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
078 FINDER_CLASS_NAME_LIST, "findByUuid",
079 new String[] {
080 String.class.getName(),
081
082 "java.lang.Integer", "java.lang.Integer",
083 "com.liferay.portal.kernel.util.OrderByComparator"
084 });
085 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
086 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
087 FINDER_CLASS_NAME_LIST, "countByUuid",
088 new String[] { String.class.getName() });
089 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
090 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
091 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
092 new String[] { String.class.getName(), Long.class.getName() });
093 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
094 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
095 FINDER_CLASS_NAME_LIST, "countByUUID_G",
096 new String[] { String.class.getName(), Long.class.getName() });
097 public static final FinderPath FINDER_PATH_FIND_BY_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
098 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
099 FINDER_CLASS_NAME_LIST, "findByActive",
100 new String[] {
101 Boolean.class.getName(),
102
103 "java.lang.Integer", "java.lang.Integer",
104 "com.liferay.portal.kernel.util.OrderByComparator"
105 });
106 public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
107 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
108 FINDER_CLASS_NAME_LIST, "countByActive",
109 new String[] { Boolean.class.getName() });
110 public static final FinderPath FINDER_PATH_FETCH_BY_G_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
111 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
112 FINDER_CLASS_NAME_ENTITY, "fetchByG_C",
113 new String[] { Long.class.getName(), Long.class.getName() });
114 public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
115 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
116 FINDER_CLASS_NAME_LIST, "countByG_C",
117 new String[] { Long.class.getName(), Long.class.getName() });
118 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
119 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
120 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
121 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
122 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
123 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
124
125
130 public void cacheResult(MBMailingList mbMailingList) {
131 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
132 MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
133 mbMailingList);
134
135 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
136 new Object[] {
137 mbMailingList.getUuid(), new Long(mbMailingList.getGroupId())
138 }, mbMailingList);
139
140 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
141 new Object[] {
142 new Long(mbMailingList.getGroupId()),
143 new Long(mbMailingList.getCategoryId())
144 }, mbMailingList);
145 }
146
147
152 public void cacheResult(List<MBMailingList> mbMailingLists) {
153 for (MBMailingList mbMailingList : mbMailingLists) {
154 if (EntityCacheUtil.getResult(
155 MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
156 MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
157 this) == null) {
158 cacheResult(mbMailingList);
159 }
160 }
161 }
162
163
170 public void clearCache() {
171 CacheRegistryUtil.clear(MBMailingListImpl.class.getName());
172 EntityCacheUtil.clearCache(MBMailingListImpl.class.getName());
173 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
174 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
175 }
176
177
184 public void clearCache(MBMailingList mbMailingList) {
185 EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
186 MBMailingListImpl.class, mbMailingList.getPrimaryKey());
187
188 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
189 new Object[] {
190 mbMailingList.getUuid(), new Long(mbMailingList.getGroupId())
191 });
192
193 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C,
194 new Object[] {
195 new Long(mbMailingList.getGroupId()),
196 new Long(mbMailingList.getCategoryId())
197 });
198 }
199
200
206 public MBMailingList create(long mailingListId) {
207 MBMailingList mbMailingList = new MBMailingListImpl();
208
209 mbMailingList.setNew(true);
210 mbMailingList.setPrimaryKey(mailingListId);
211
212 String uuid = PortalUUIDUtil.generate();
213
214 mbMailingList.setUuid(uuid);
215
216 return mbMailingList;
217 }
218
219
227 public MBMailingList remove(Serializable primaryKey)
228 throws NoSuchModelException, SystemException {
229 return remove(((Long)primaryKey).longValue());
230 }
231
232
240 public MBMailingList remove(long mailingListId)
241 throws NoSuchMailingListException, SystemException {
242 Session session = null;
243
244 try {
245 session = openSession();
246
247 MBMailingList mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
248 new Long(mailingListId));
249
250 if (mbMailingList == null) {
251 if (_log.isWarnEnabled()) {
252 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + mailingListId);
253 }
254
255 throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
256 mailingListId);
257 }
258
259 return remove(mbMailingList);
260 }
261 catch (NoSuchMailingListException nsee) {
262 throw nsee;
263 }
264 catch (Exception e) {
265 throw processException(e);
266 }
267 finally {
268 closeSession(session);
269 }
270 }
271
272 protected MBMailingList removeImpl(MBMailingList mbMailingList)
273 throws SystemException {
274 mbMailingList = toUnwrappedModel(mbMailingList);
275
276 Session session = null;
277
278 try {
279 session = openSession();
280
281 if (mbMailingList.isCachedModel() || BatchSessionUtil.isEnabled()) {
282 Object staleObject = session.get(MBMailingListImpl.class,
283 mbMailingList.getPrimaryKeyObj());
284
285 if (staleObject != null) {
286 session.evict(staleObject);
287 }
288 }
289
290 session.delete(mbMailingList);
291
292 session.flush();
293 }
294 catch (Exception e) {
295 throw processException(e);
296 }
297 finally {
298 closeSession(session);
299 }
300
301 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
302
303 MBMailingListModelImpl mbMailingListModelImpl = (MBMailingListModelImpl)mbMailingList;
304
305 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
306 new Object[] {
307 mbMailingListModelImpl.getOriginalUuid(),
308 new Long(mbMailingListModelImpl.getOriginalGroupId())
309 });
310
311 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C,
312 new Object[] {
313 new Long(mbMailingListModelImpl.getOriginalGroupId()),
314 new Long(mbMailingListModelImpl.getOriginalCategoryId())
315 });
316
317 EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
318 MBMailingListImpl.class, mbMailingList.getPrimaryKey());
319
320 return mbMailingList;
321 }
322
323 public MBMailingList updateImpl(
324 com.liferay.portlet.messageboards.model.MBMailingList mbMailingList,
325 boolean merge) throws SystemException {
326 mbMailingList = toUnwrappedModel(mbMailingList);
327
328 boolean isNew = mbMailingList.isNew();
329
330 MBMailingListModelImpl mbMailingListModelImpl = (MBMailingListModelImpl)mbMailingList;
331
332 if (Validator.isNull(mbMailingList.getUuid())) {
333 String uuid = PortalUUIDUtil.generate();
334
335 mbMailingList.setUuid(uuid);
336 }
337
338 Session session = null;
339
340 try {
341 session = openSession();
342
343 BatchSessionUtil.update(session, mbMailingList, merge);
344
345 mbMailingList.setNew(false);
346 }
347 catch (Exception e) {
348 throw processException(e);
349 }
350 finally {
351 closeSession(session);
352 }
353
354 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
355
356 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
357 MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
358 mbMailingList);
359
360 if (!isNew &&
361 (!Validator.equals(mbMailingList.getUuid(),
362 mbMailingListModelImpl.getOriginalUuid()) ||
363 (mbMailingList.getGroupId() != mbMailingListModelImpl.getOriginalGroupId()))) {
364 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
365 new Object[] {
366 mbMailingListModelImpl.getOriginalUuid(),
367 new Long(mbMailingListModelImpl.getOriginalGroupId())
368 });
369 }
370
371 if (isNew ||
372 (!Validator.equals(mbMailingList.getUuid(),
373 mbMailingListModelImpl.getOriginalUuid()) ||
374 (mbMailingList.getGroupId() != mbMailingListModelImpl.getOriginalGroupId()))) {
375 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
376 new Object[] {
377 mbMailingList.getUuid(),
378 new Long(mbMailingList.getGroupId())
379 }, mbMailingList);
380 }
381
382 if (!isNew &&
383 ((mbMailingList.getGroupId() != mbMailingListModelImpl.getOriginalGroupId()) ||
384 (mbMailingList.getCategoryId() != mbMailingListModelImpl.getOriginalCategoryId()))) {
385 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C,
386 new Object[] {
387 new Long(mbMailingListModelImpl.getOriginalGroupId()),
388 new Long(mbMailingListModelImpl.getOriginalCategoryId())
389 });
390 }
391
392 if (isNew ||
393 ((mbMailingList.getGroupId() != mbMailingListModelImpl.getOriginalGroupId()) ||
394 (mbMailingList.getCategoryId() != mbMailingListModelImpl.getOriginalCategoryId()))) {
395 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
396 new Object[] {
397 new Long(mbMailingList.getGroupId()),
398 new Long(mbMailingList.getCategoryId())
399 }, mbMailingList);
400 }
401
402 return mbMailingList;
403 }
404
405 protected MBMailingList toUnwrappedModel(MBMailingList mbMailingList) {
406 if (mbMailingList instanceof MBMailingListImpl) {
407 return mbMailingList;
408 }
409
410 MBMailingListImpl mbMailingListImpl = new MBMailingListImpl();
411
412 mbMailingListImpl.setNew(mbMailingList.isNew());
413 mbMailingListImpl.setPrimaryKey(mbMailingList.getPrimaryKey());
414
415 mbMailingListImpl.setUuid(mbMailingList.getUuid());
416 mbMailingListImpl.setMailingListId(mbMailingList.getMailingListId());
417 mbMailingListImpl.setGroupId(mbMailingList.getGroupId());
418 mbMailingListImpl.setCompanyId(mbMailingList.getCompanyId());
419 mbMailingListImpl.setUserId(mbMailingList.getUserId());
420 mbMailingListImpl.setUserName(mbMailingList.getUserName());
421 mbMailingListImpl.setCreateDate(mbMailingList.getCreateDate());
422 mbMailingListImpl.setModifiedDate(mbMailingList.getModifiedDate());
423 mbMailingListImpl.setCategoryId(mbMailingList.getCategoryId());
424 mbMailingListImpl.setEmailAddress(mbMailingList.getEmailAddress());
425 mbMailingListImpl.setInProtocol(mbMailingList.getInProtocol());
426 mbMailingListImpl.setInServerName(mbMailingList.getInServerName());
427 mbMailingListImpl.setInServerPort(mbMailingList.getInServerPort());
428 mbMailingListImpl.setInUseSSL(mbMailingList.isInUseSSL());
429 mbMailingListImpl.setInUserName(mbMailingList.getInUserName());
430 mbMailingListImpl.setInPassword(mbMailingList.getInPassword());
431 mbMailingListImpl.setInReadInterval(mbMailingList.getInReadInterval());
432 mbMailingListImpl.setOutEmailAddress(mbMailingList.getOutEmailAddress());
433 mbMailingListImpl.setOutCustom(mbMailingList.isOutCustom());
434 mbMailingListImpl.setOutServerName(mbMailingList.getOutServerName());
435 mbMailingListImpl.setOutServerPort(mbMailingList.getOutServerPort());
436 mbMailingListImpl.setOutUseSSL(mbMailingList.isOutUseSSL());
437 mbMailingListImpl.setOutUserName(mbMailingList.getOutUserName());
438 mbMailingListImpl.setOutPassword(mbMailingList.getOutPassword());
439 mbMailingListImpl.setActive(mbMailingList.isActive());
440
441 return mbMailingListImpl;
442 }
443
444
452 public MBMailingList findByPrimaryKey(Serializable primaryKey)
453 throws NoSuchModelException, SystemException {
454 return findByPrimaryKey(((Long)primaryKey).longValue());
455 }
456
457
465 public MBMailingList findByPrimaryKey(long mailingListId)
466 throws NoSuchMailingListException, SystemException {
467 MBMailingList mbMailingList = fetchByPrimaryKey(mailingListId);
468
469 if (mbMailingList == null) {
470 if (_log.isWarnEnabled()) {
471 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + mailingListId);
472 }
473
474 throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
475 mailingListId);
476 }
477
478 return mbMailingList;
479 }
480
481
488 public MBMailingList fetchByPrimaryKey(Serializable primaryKey)
489 throws SystemException {
490 return fetchByPrimaryKey(((Long)primaryKey).longValue());
491 }
492
493
500 public MBMailingList fetchByPrimaryKey(long mailingListId)
501 throws SystemException {
502 MBMailingList mbMailingList = (MBMailingList)EntityCacheUtil.getResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
503 MBMailingListImpl.class, mailingListId, this);
504
505 if (mbMailingList == null) {
506 Session session = null;
507
508 try {
509 session = openSession();
510
511 mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
512 new Long(mailingListId));
513 }
514 catch (Exception e) {
515 throw processException(e);
516 }
517 finally {
518 if (mbMailingList != null) {
519 cacheResult(mbMailingList);
520 }
521
522 closeSession(session);
523 }
524 }
525
526 return mbMailingList;
527 }
528
529
536 public List<MBMailingList> findByUuid(String uuid)
537 throws SystemException {
538 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
539 }
540
541
554 public List<MBMailingList> findByUuid(String uuid, int start, int end)
555 throws SystemException {
556 return findByUuid(uuid, start, end, null);
557 }
558
559
573 public List<MBMailingList> findByUuid(String uuid, int start, int end,
574 OrderByComparator orderByComparator) throws SystemException {
575 Object[] finderArgs = new Object[] {
576 uuid,
577
578 String.valueOf(start), String.valueOf(end),
579 String.valueOf(orderByComparator)
580 };
581
582 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
583 finderArgs, this);
584
585 if (list == null) {
586 Session session = null;
587
588 try {
589 session = openSession();
590
591 StringBundler query = null;
592
593 if (orderByComparator != null) {
594 query = new StringBundler(3 +
595 (orderByComparator.getOrderByFields().length * 3));
596 }
597 else {
598 query = new StringBundler(2);
599 }
600
601 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
602
603 if (uuid == null) {
604 query.append(_FINDER_COLUMN_UUID_UUID_1);
605 }
606 else {
607 if (uuid.equals(StringPool.BLANK)) {
608 query.append(_FINDER_COLUMN_UUID_UUID_3);
609 }
610 else {
611 query.append(_FINDER_COLUMN_UUID_UUID_2);
612 }
613 }
614
615 if (orderByComparator != null) {
616 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
617 orderByComparator);
618 }
619
620 String sql = query.toString();
621
622 Query q = session.createQuery(sql);
623
624 QueryPos qPos = QueryPos.getInstance(q);
625
626 if (uuid != null) {
627 qPos.add(uuid);
628 }
629
630 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
631 start, end);
632 }
633 catch (Exception e) {
634 throw processException(e);
635 }
636 finally {
637 if (list == null) {
638 list = new ArrayList<MBMailingList>();
639 }
640
641 cacheResult(list);
642
643 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
644 list);
645
646 closeSession(session);
647 }
648 }
649
650 return list;
651 }
652
653
666 public MBMailingList findByUuid_First(String uuid,
667 OrderByComparator orderByComparator)
668 throws NoSuchMailingListException, SystemException {
669 List<MBMailingList> list = findByUuid(uuid, 0, 1, orderByComparator);
670
671 if (list.isEmpty()) {
672 StringBundler msg = new StringBundler(4);
673
674 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
675
676 msg.append("uuid=");
677 msg.append(uuid);
678
679 msg.append(StringPool.CLOSE_CURLY_BRACE);
680
681 throw new NoSuchMailingListException(msg.toString());
682 }
683 else {
684 return list.get(0);
685 }
686 }
687
688
701 public MBMailingList findByUuid_Last(String uuid,
702 OrderByComparator orderByComparator)
703 throws NoSuchMailingListException, SystemException {
704 int count = countByUuid(uuid);
705
706 List<MBMailingList> list = findByUuid(uuid, count - 1, count,
707 orderByComparator);
708
709 if (list.isEmpty()) {
710 StringBundler msg = new StringBundler(4);
711
712 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
713
714 msg.append("uuid=");
715 msg.append(uuid);
716
717 msg.append(StringPool.CLOSE_CURLY_BRACE);
718
719 throw new NoSuchMailingListException(msg.toString());
720 }
721 else {
722 return list.get(0);
723 }
724 }
725
726
740 public MBMailingList[] findByUuid_PrevAndNext(long mailingListId,
741 String uuid, OrderByComparator orderByComparator)
742 throws NoSuchMailingListException, SystemException {
743 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
744
745 Session session = null;
746
747 try {
748 session = openSession();
749
750 MBMailingList[] array = new MBMailingListImpl[3];
751
752 array[0] = getByUuid_PrevAndNext(session, mbMailingList, uuid,
753 orderByComparator, true);
754
755 array[1] = mbMailingList;
756
757 array[2] = getByUuid_PrevAndNext(session, mbMailingList, uuid,
758 orderByComparator, false);
759
760 return array;
761 }
762 catch (Exception e) {
763 throw processException(e);
764 }
765 finally {
766 closeSession(session);
767 }
768 }
769
770 protected MBMailingList getByUuid_PrevAndNext(Session session,
771 MBMailingList mbMailingList, String uuid,
772 OrderByComparator orderByComparator, boolean previous) {
773 StringBundler query = null;
774
775 if (orderByComparator != null) {
776 query = new StringBundler(6 +
777 (orderByComparator.getOrderByFields().length * 6));
778 }
779 else {
780 query = new StringBundler(3);
781 }
782
783 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
784
785 if (uuid == null) {
786 query.append(_FINDER_COLUMN_UUID_UUID_1);
787 }
788 else {
789 if (uuid.equals(StringPool.BLANK)) {
790 query.append(_FINDER_COLUMN_UUID_UUID_3);
791 }
792 else {
793 query.append(_FINDER_COLUMN_UUID_UUID_2);
794 }
795 }
796
797 if (orderByComparator != null) {
798 String[] orderByFields = orderByComparator.getOrderByFields();
799
800 if (orderByFields.length > 0) {
801 query.append(WHERE_AND);
802 }
803
804 for (int i = 0; i < orderByFields.length; i++) {
805 query.append(_ORDER_BY_ENTITY_ALIAS);
806 query.append(orderByFields[i]);
807
808 if ((i + 1) < orderByFields.length) {
809 if (orderByComparator.isAscending() ^ previous) {
810 query.append(WHERE_GREATER_THAN_HAS_NEXT);
811 }
812 else {
813 query.append(WHERE_LESSER_THAN_HAS_NEXT);
814 }
815 }
816 else {
817 if (orderByComparator.isAscending() ^ previous) {
818 query.append(WHERE_GREATER_THAN);
819 }
820 else {
821 query.append(WHERE_LESSER_THAN);
822 }
823 }
824 }
825
826 query.append(ORDER_BY_CLAUSE);
827
828 for (int i = 0; i < orderByFields.length; i++) {
829 query.append(_ORDER_BY_ENTITY_ALIAS);
830 query.append(orderByFields[i]);
831
832 if ((i + 1) < orderByFields.length) {
833 if (orderByComparator.isAscending() ^ previous) {
834 query.append(ORDER_BY_ASC_HAS_NEXT);
835 }
836 else {
837 query.append(ORDER_BY_DESC_HAS_NEXT);
838 }
839 }
840 else {
841 if (orderByComparator.isAscending() ^ previous) {
842 query.append(ORDER_BY_ASC);
843 }
844 else {
845 query.append(ORDER_BY_DESC);
846 }
847 }
848 }
849 }
850
851 String sql = query.toString();
852
853 Query q = session.createQuery(sql);
854
855 q.setFirstResult(0);
856 q.setMaxResults(2);
857
858 QueryPos qPos = QueryPos.getInstance(q);
859
860 if (uuid != null) {
861 qPos.add(uuid);
862 }
863
864 if (orderByComparator != null) {
865 Object[] values = orderByComparator.getOrderByValues(mbMailingList);
866
867 for (Object value : values) {
868 qPos.add(value);
869 }
870 }
871
872 List<MBMailingList> list = q.list();
873
874 if (list.size() == 2) {
875 return list.get(1);
876 }
877 else {
878 return null;
879 }
880 }
881
882
891 public MBMailingList findByUUID_G(String uuid, long groupId)
892 throws NoSuchMailingListException, SystemException {
893 MBMailingList mbMailingList = fetchByUUID_G(uuid, groupId);
894
895 if (mbMailingList == null) {
896 StringBundler msg = new StringBundler(6);
897
898 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
899
900 msg.append("uuid=");
901 msg.append(uuid);
902
903 msg.append(", groupId=");
904 msg.append(groupId);
905
906 msg.append(StringPool.CLOSE_CURLY_BRACE);
907
908 if (_log.isWarnEnabled()) {
909 _log.warn(msg.toString());
910 }
911
912 throw new NoSuchMailingListException(msg.toString());
913 }
914
915 return mbMailingList;
916 }
917
918
926 public MBMailingList fetchByUUID_G(String uuid, long groupId)
927 throws SystemException {
928 return fetchByUUID_G(uuid, groupId, true);
929 }
930
931
939 public MBMailingList fetchByUUID_G(String uuid, long groupId,
940 boolean retrieveFromCache) throws SystemException {
941 Object[] finderArgs = new Object[] { uuid, groupId };
942
943 Object result = null;
944
945 if (retrieveFromCache) {
946 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
947 finderArgs, this);
948 }
949
950 if (result == null) {
951 Session session = null;
952
953 try {
954 session = openSession();
955
956 StringBundler query = new StringBundler(3);
957
958 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
959
960 if (uuid == null) {
961 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
962 }
963 else {
964 if (uuid.equals(StringPool.BLANK)) {
965 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
966 }
967 else {
968 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
969 }
970 }
971
972 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
973
974 String sql = query.toString();
975
976 Query q = session.createQuery(sql);
977
978 QueryPos qPos = QueryPos.getInstance(q);
979
980 if (uuid != null) {
981 qPos.add(uuid);
982 }
983
984 qPos.add(groupId);
985
986 List<MBMailingList> list = q.list();
987
988 result = list;
989
990 MBMailingList mbMailingList = null;
991
992 if (list.isEmpty()) {
993 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
994 finderArgs, list);
995 }
996 else {
997 mbMailingList = list.get(0);
998
999 cacheResult(mbMailingList);
1000
1001 if ((mbMailingList.getUuid() == null) ||
1002 !mbMailingList.getUuid().equals(uuid) ||
1003 (mbMailingList.getGroupId() != groupId)) {
1004 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1005 finderArgs, mbMailingList);
1006 }
1007 }
1008
1009 return mbMailingList;
1010 }
1011 catch (Exception e) {
1012 throw processException(e);
1013 }
1014 finally {
1015 if (result == null) {
1016 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1017 finderArgs, new ArrayList<MBMailingList>());
1018 }
1019
1020 closeSession(session);
1021 }
1022 }
1023 else {
1024 if (result instanceof List<?>) {
1025 return null;
1026 }
1027 else {
1028 return (MBMailingList)result;
1029 }
1030 }
1031 }
1032
1033
1040 public List<MBMailingList> findByActive(boolean active)
1041 throws SystemException {
1042 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1043 }
1044
1045
1058 public List<MBMailingList> findByActive(boolean active, int start, int end)
1059 throws SystemException {
1060 return findByActive(active, start, end, null);
1061 }
1062
1063
1077 public List<MBMailingList> findByActive(boolean active, int start, int end,
1078 OrderByComparator orderByComparator) throws SystemException {
1079 Object[] finderArgs = new Object[] {
1080 active,
1081
1082 String.valueOf(start), String.valueOf(end),
1083 String.valueOf(orderByComparator)
1084 };
1085
1086 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ACTIVE,
1087 finderArgs, this);
1088
1089 if (list == null) {
1090 Session session = null;
1091
1092 try {
1093 session = openSession();
1094
1095 StringBundler query = null;
1096
1097 if (orderByComparator != null) {
1098 query = new StringBundler(3 +
1099 (orderByComparator.getOrderByFields().length * 3));
1100 }
1101 else {
1102 query = new StringBundler(2);
1103 }
1104
1105 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1106
1107 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1108
1109 if (orderByComparator != null) {
1110 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1111 orderByComparator);
1112 }
1113
1114 String sql = query.toString();
1115
1116 Query q = session.createQuery(sql);
1117
1118 QueryPos qPos = QueryPos.getInstance(q);
1119
1120 qPos.add(active);
1121
1122 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1123 start, end);
1124 }
1125 catch (Exception e) {
1126 throw processException(e);
1127 }
1128 finally {
1129 if (list == null) {
1130 list = new ArrayList<MBMailingList>();
1131 }
1132
1133 cacheResult(list);
1134
1135 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ACTIVE,
1136 finderArgs, list);
1137
1138 closeSession(session);
1139 }
1140 }
1141
1142 return list;
1143 }
1144
1145
1158 public MBMailingList findByActive_First(boolean active,
1159 OrderByComparator orderByComparator)
1160 throws NoSuchMailingListException, SystemException {
1161 List<MBMailingList> list = findByActive(active, 0, 1, orderByComparator);
1162
1163 if (list.isEmpty()) {
1164 StringBundler msg = new StringBundler(4);
1165
1166 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1167
1168 msg.append("active=");
1169 msg.append(active);
1170
1171 msg.append(StringPool.CLOSE_CURLY_BRACE);
1172
1173 throw new NoSuchMailingListException(msg.toString());
1174 }
1175 else {
1176 return list.get(0);
1177 }
1178 }
1179
1180
1193 public MBMailingList findByActive_Last(boolean active,
1194 OrderByComparator orderByComparator)
1195 throws NoSuchMailingListException, SystemException {
1196 int count = countByActive(active);
1197
1198 List<MBMailingList> list = findByActive(active, count - 1, count,
1199 orderByComparator);
1200
1201 if (list.isEmpty()) {
1202 StringBundler msg = new StringBundler(4);
1203
1204 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1205
1206 msg.append("active=");
1207 msg.append(active);
1208
1209 msg.append(StringPool.CLOSE_CURLY_BRACE);
1210
1211 throw new NoSuchMailingListException(msg.toString());
1212 }
1213 else {
1214 return list.get(0);
1215 }
1216 }
1217
1218
1232 public MBMailingList[] findByActive_PrevAndNext(long mailingListId,
1233 boolean active, OrderByComparator orderByComparator)
1234 throws NoSuchMailingListException, SystemException {
1235 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
1236
1237 Session session = null;
1238
1239 try {
1240 session = openSession();
1241
1242 MBMailingList[] array = new MBMailingListImpl[3];
1243
1244 array[0] = getByActive_PrevAndNext(session, mbMailingList, active,
1245 orderByComparator, true);
1246
1247 array[1] = mbMailingList;
1248
1249 array[2] = getByActive_PrevAndNext(session, mbMailingList, active,
1250 orderByComparator, false);
1251
1252 return array;
1253 }
1254 catch (Exception e) {
1255 throw processException(e);
1256 }
1257 finally {
1258 closeSession(session);
1259 }
1260 }
1261
1262 protected MBMailingList getByActive_PrevAndNext(Session session,
1263 MBMailingList mbMailingList, boolean active,
1264 OrderByComparator orderByComparator, boolean previous) {
1265 StringBundler query = null;
1266
1267 if (orderByComparator != null) {
1268 query = new StringBundler(6 +
1269 (orderByComparator.getOrderByFields().length * 6));
1270 }
1271 else {
1272 query = new StringBundler(3);
1273 }
1274
1275 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1276
1277 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1278
1279 if (orderByComparator != null) {
1280 String[] orderByFields = orderByComparator.getOrderByFields();
1281
1282 if (orderByFields.length > 0) {
1283 query.append(WHERE_AND);
1284 }
1285
1286 for (int i = 0; i < orderByFields.length; i++) {
1287 query.append(_ORDER_BY_ENTITY_ALIAS);
1288 query.append(orderByFields[i]);
1289
1290 if ((i + 1) < orderByFields.length) {
1291 if (orderByComparator.isAscending() ^ previous) {
1292 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1293 }
1294 else {
1295 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1296 }
1297 }
1298 else {
1299 if (orderByComparator.isAscending() ^ previous) {
1300 query.append(WHERE_GREATER_THAN);
1301 }
1302 else {
1303 query.append(WHERE_LESSER_THAN);
1304 }
1305 }
1306 }
1307
1308 query.append(ORDER_BY_CLAUSE);
1309
1310 for (int i = 0; i < orderByFields.length; i++) {
1311 query.append(_ORDER_BY_ENTITY_ALIAS);
1312 query.append(orderByFields[i]);
1313
1314 if ((i + 1) < orderByFields.length) {
1315 if (orderByComparator.isAscending() ^ previous) {
1316 query.append(ORDER_BY_ASC_HAS_NEXT);
1317 }
1318 else {
1319 query.append(ORDER_BY_DESC_HAS_NEXT);
1320 }
1321 }
1322 else {
1323 if (orderByComparator.isAscending() ^ previous) {
1324 query.append(ORDER_BY_ASC);
1325 }
1326 else {
1327 query.append(ORDER_BY_DESC);
1328 }
1329 }
1330 }
1331 }
1332
1333 String sql = query.toString();
1334
1335 Query q = session.createQuery(sql);
1336
1337 q.setFirstResult(0);
1338 q.setMaxResults(2);
1339
1340 QueryPos qPos = QueryPos.getInstance(q);
1341
1342 qPos.add(active);
1343
1344 if (orderByComparator != null) {
1345 Object[] values = orderByComparator.getOrderByValues(mbMailingList);
1346
1347 for (Object value : values) {
1348 qPos.add(value);
1349 }
1350 }
1351
1352 List<MBMailingList> list = q.list();
1353
1354 if (list.size() == 2) {
1355 return list.get(1);
1356 }
1357 else {
1358 return null;
1359 }
1360 }
1361
1362
1371 public MBMailingList findByG_C(long groupId, long categoryId)
1372 throws NoSuchMailingListException, SystemException {
1373 MBMailingList mbMailingList = fetchByG_C(groupId, categoryId);
1374
1375 if (mbMailingList == null) {
1376 StringBundler msg = new StringBundler(6);
1377
1378 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1379
1380 msg.append("groupId=");
1381 msg.append(groupId);
1382
1383 msg.append(", categoryId=");
1384 msg.append(categoryId);
1385
1386 msg.append(StringPool.CLOSE_CURLY_BRACE);
1387
1388 if (_log.isWarnEnabled()) {
1389 _log.warn(msg.toString());
1390 }
1391
1392 throw new NoSuchMailingListException(msg.toString());
1393 }
1394
1395 return mbMailingList;
1396 }
1397
1398
1406 public MBMailingList fetchByG_C(long groupId, long categoryId)
1407 throws SystemException {
1408 return fetchByG_C(groupId, categoryId, true);
1409 }
1410
1411
1419 public MBMailingList fetchByG_C(long groupId, long categoryId,
1420 boolean retrieveFromCache) throws SystemException {
1421 Object[] finderArgs = new Object[] { groupId, categoryId };
1422
1423 Object result = null;
1424
1425 if (retrieveFromCache) {
1426 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C,
1427 finderArgs, this);
1428 }
1429
1430 if (result == null) {
1431 Session session = null;
1432
1433 try {
1434 session = openSession();
1435
1436 StringBundler query = new StringBundler(3);
1437
1438 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1439
1440 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1441
1442 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1443
1444 String sql = query.toString();
1445
1446 Query q = session.createQuery(sql);
1447
1448 QueryPos qPos = QueryPos.getInstance(q);
1449
1450 qPos.add(groupId);
1451
1452 qPos.add(categoryId);
1453
1454 List<MBMailingList> list = q.list();
1455
1456 result = list;
1457
1458 MBMailingList mbMailingList = null;
1459
1460 if (list.isEmpty()) {
1461 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
1462 finderArgs, list);
1463 }
1464 else {
1465 mbMailingList = list.get(0);
1466
1467 cacheResult(mbMailingList);
1468
1469 if ((mbMailingList.getGroupId() != groupId) ||
1470 (mbMailingList.getCategoryId() != categoryId)) {
1471 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
1472 finderArgs, mbMailingList);
1473 }
1474 }
1475
1476 return mbMailingList;
1477 }
1478 catch (Exception e) {
1479 throw processException(e);
1480 }
1481 finally {
1482 if (result == null) {
1483 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
1484 finderArgs, new ArrayList<MBMailingList>());
1485 }
1486
1487 closeSession(session);
1488 }
1489 }
1490 else {
1491 if (result instanceof List<?>) {
1492 return null;
1493 }
1494 else {
1495 return (MBMailingList)result;
1496 }
1497 }
1498 }
1499
1500
1506 public List<MBMailingList> findAll() throws SystemException {
1507 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1508 }
1509
1510
1522 public List<MBMailingList> findAll(int start, int end)
1523 throws SystemException {
1524 return findAll(start, end, null);
1525 }
1526
1527
1540 public List<MBMailingList> findAll(int start, int end,
1541 OrderByComparator orderByComparator) throws SystemException {
1542 Object[] finderArgs = new Object[] {
1543 String.valueOf(start), String.valueOf(end),
1544 String.valueOf(orderByComparator)
1545 };
1546
1547 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1548 finderArgs, this);
1549
1550 if (list == null) {
1551 Session session = null;
1552
1553 try {
1554 session = openSession();
1555
1556 StringBundler query = null;
1557 String sql = null;
1558
1559 if (orderByComparator != null) {
1560 query = new StringBundler(2 +
1561 (orderByComparator.getOrderByFields().length * 3));
1562
1563 query.append(_SQL_SELECT_MBMAILINGLIST);
1564
1565 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1566 orderByComparator);
1567
1568 sql = query.toString();
1569 }
1570 else {
1571 sql = _SQL_SELECT_MBMAILINGLIST;
1572 }
1573
1574 Query q = session.createQuery(sql);
1575
1576 if (orderByComparator == null) {
1577 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1578 start, end, false);
1579
1580 Collections.sort(list);
1581 }
1582 else {
1583 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1584 start, end);
1585 }
1586 }
1587 catch (Exception e) {
1588 throw processException(e);
1589 }
1590 finally {
1591 if (list == null) {
1592 list = new ArrayList<MBMailingList>();
1593 }
1594
1595 cacheResult(list);
1596
1597 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1598
1599 closeSession(session);
1600 }
1601 }
1602
1603 return list;
1604 }
1605
1606
1612 public void removeByUuid(String uuid) throws SystemException {
1613 for (MBMailingList mbMailingList : findByUuid(uuid)) {
1614 remove(mbMailingList);
1615 }
1616 }
1617
1618
1625 public void removeByUUID_G(String uuid, long groupId)
1626 throws NoSuchMailingListException, SystemException {
1627 MBMailingList mbMailingList = findByUUID_G(uuid, groupId);
1628
1629 remove(mbMailingList);
1630 }
1631
1632
1638 public void removeByActive(boolean active) throws SystemException {
1639 for (MBMailingList mbMailingList : findByActive(active)) {
1640 remove(mbMailingList);
1641 }
1642 }
1643
1644
1651 public void removeByG_C(long groupId, long categoryId)
1652 throws NoSuchMailingListException, SystemException {
1653 MBMailingList mbMailingList = findByG_C(groupId, categoryId);
1654
1655 remove(mbMailingList);
1656 }
1657
1658
1663 public void removeAll() throws SystemException {
1664 for (MBMailingList mbMailingList : findAll()) {
1665 remove(mbMailingList);
1666 }
1667 }
1668
1669
1676 public int countByUuid(String uuid) throws SystemException {
1677 Object[] finderArgs = new Object[] { uuid };
1678
1679 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1680 finderArgs, this);
1681
1682 if (count == null) {
1683 Session session = null;
1684
1685 try {
1686 session = openSession();
1687
1688 StringBundler query = new StringBundler(2);
1689
1690 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1691
1692 if (uuid == null) {
1693 query.append(_FINDER_COLUMN_UUID_UUID_1);
1694 }
1695 else {
1696 if (uuid.equals(StringPool.BLANK)) {
1697 query.append(_FINDER_COLUMN_UUID_UUID_3);
1698 }
1699 else {
1700 query.append(_FINDER_COLUMN_UUID_UUID_2);
1701 }
1702 }
1703
1704 String sql = query.toString();
1705
1706 Query q = session.createQuery(sql);
1707
1708 QueryPos qPos = QueryPos.getInstance(q);
1709
1710 if (uuid != null) {
1711 qPos.add(uuid);
1712 }
1713
1714 count = (Long)q.uniqueResult();
1715 }
1716 catch (Exception e) {
1717 throw processException(e);
1718 }
1719 finally {
1720 if (count == null) {
1721 count = Long.valueOf(0);
1722 }
1723
1724 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1725 finderArgs, count);
1726
1727 closeSession(session);
1728 }
1729 }
1730
1731 return count.intValue();
1732 }
1733
1734
1742 public int countByUUID_G(String uuid, long groupId)
1743 throws SystemException {
1744 Object[] finderArgs = new Object[] { uuid, groupId };
1745
1746 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1747 finderArgs, this);
1748
1749 if (count == null) {
1750 Session session = null;
1751
1752 try {
1753 session = openSession();
1754
1755 StringBundler query = new StringBundler(3);
1756
1757 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1758
1759 if (uuid == null) {
1760 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1761 }
1762 else {
1763 if (uuid.equals(StringPool.BLANK)) {
1764 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1765 }
1766 else {
1767 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1768 }
1769 }
1770
1771 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1772
1773 String sql = query.toString();
1774
1775 Query q = session.createQuery(sql);
1776
1777 QueryPos qPos = QueryPos.getInstance(q);
1778
1779 if (uuid != null) {
1780 qPos.add(uuid);
1781 }
1782
1783 qPos.add(groupId);
1784
1785 count = (Long)q.uniqueResult();
1786 }
1787 catch (Exception e) {
1788 throw processException(e);
1789 }
1790 finally {
1791 if (count == null) {
1792 count = Long.valueOf(0);
1793 }
1794
1795 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1796 finderArgs, count);
1797
1798 closeSession(session);
1799 }
1800 }
1801
1802 return count.intValue();
1803 }
1804
1805
1812 public int countByActive(boolean active) throws SystemException {
1813 Object[] finderArgs = new Object[] { active };
1814
1815 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
1816 finderArgs, this);
1817
1818 if (count == null) {
1819 Session session = null;
1820
1821 try {
1822 session = openSession();
1823
1824 StringBundler query = new StringBundler(2);
1825
1826 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1827
1828 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1829
1830 String sql = query.toString();
1831
1832 Query q = session.createQuery(sql);
1833
1834 QueryPos qPos = QueryPos.getInstance(q);
1835
1836 qPos.add(active);
1837
1838 count = (Long)q.uniqueResult();
1839 }
1840 catch (Exception e) {
1841 throw processException(e);
1842 }
1843 finally {
1844 if (count == null) {
1845 count = Long.valueOf(0);
1846 }
1847
1848 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
1849 finderArgs, count);
1850
1851 closeSession(session);
1852 }
1853 }
1854
1855 return count.intValue();
1856 }
1857
1858
1866 public int countByG_C(long groupId, long categoryId)
1867 throws SystemException {
1868 Object[] finderArgs = new Object[] { groupId, categoryId };
1869
1870 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
1871 finderArgs, this);
1872
1873 if (count == null) {
1874 Session session = null;
1875
1876 try {
1877 session = openSession();
1878
1879 StringBundler query = new StringBundler(3);
1880
1881 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1882
1883 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1884
1885 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1886
1887 String sql = query.toString();
1888
1889 Query q = session.createQuery(sql);
1890
1891 QueryPos qPos = QueryPos.getInstance(q);
1892
1893 qPos.add(groupId);
1894
1895 qPos.add(categoryId);
1896
1897 count = (Long)q.uniqueResult();
1898 }
1899 catch (Exception e) {
1900 throw processException(e);
1901 }
1902 finally {
1903 if (count == null) {
1904 count = Long.valueOf(0);
1905 }
1906
1907 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
1908 count);
1909
1910 closeSession(session);
1911 }
1912 }
1913
1914 return count.intValue();
1915 }
1916
1917
1923 public int countAll() throws SystemException {
1924 Object[] finderArgs = new Object[0];
1925
1926 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1927 finderArgs, this);
1928
1929 if (count == null) {
1930 Session session = null;
1931
1932 try {
1933 session = openSession();
1934
1935 Query q = session.createQuery(_SQL_COUNT_MBMAILINGLIST);
1936
1937 count = (Long)q.uniqueResult();
1938 }
1939 catch (Exception e) {
1940 throw processException(e);
1941 }
1942 finally {
1943 if (count == null) {
1944 count = Long.valueOf(0);
1945 }
1946
1947 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1948 count);
1949
1950 closeSession(session);
1951 }
1952 }
1953
1954 return count.intValue();
1955 }
1956
1957
1960 public void afterPropertiesSet() {
1961 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1962 com.liferay.portal.util.PropsUtil.get(
1963 "value.object.listener.com.liferay.portlet.messageboards.model.MBMailingList")));
1964
1965 if (listenerClassNames.length > 0) {
1966 try {
1967 List<ModelListener<MBMailingList>> listenersList = new ArrayList<ModelListener<MBMailingList>>();
1968
1969 for (String listenerClassName : listenerClassNames) {
1970 listenersList.add((ModelListener<MBMailingList>)InstanceFactory.newInstance(
1971 listenerClassName));
1972 }
1973
1974 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1975 }
1976 catch (Exception e) {
1977 _log.error(e);
1978 }
1979 }
1980 }
1981
1982 @BeanReference(type = MBBanPersistence.class)
1983 protected MBBanPersistence mbBanPersistence;
1984 @BeanReference(type = MBCategoryPersistence.class)
1985 protected MBCategoryPersistence mbCategoryPersistence;
1986 @BeanReference(type = MBDiscussionPersistence.class)
1987 protected MBDiscussionPersistence mbDiscussionPersistence;
1988 @BeanReference(type = MBMailingListPersistence.class)
1989 protected MBMailingListPersistence mbMailingListPersistence;
1990 @BeanReference(type = MBMessagePersistence.class)
1991 protected MBMessagePersistence mbMessagePersistence;
1992 @BeanReference(type = MBMessageFlagPersistence.class)
1993 protected MBMessageFlagPersistence mbMessageFlagPersistence;
1994 @BeanReference(type = MBStatsUserPersistence.class)
1995 protected MBStatsUserPersistence mbStatsUserPersistence;
1996 @BeanReference(type = MBThreadPersistence.class)
1997 protected MBThreadPersistence mbThreadPersistence;
1998 @BeanReference(type = ResourcePersistence.class)
1999 protected ResourcePersistence resourcePersistence;
2000 @BeanReference(type = UserPersistence.class)
2001 protected UserPersistence userPersistence;
2002 private static final String _SQL_SELECT_MBMAILINGLIST = "SELECT mbMailingList FROM MBMailingList mbMailingList";
2003 private static final String _SQL_SELECT_MBMAILINGLIST_WHERE = "SELECT mbMailingList FROM MBMailingList mbMailingList WHERE ";
2004 private static final String _SQL_COUNT_MBMAILINGLIST = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList";
2005 private static final String _SQL_COUNT_MBMAILINGLIST_WHERE = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList WHERE ";
2006 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbMailingList.uuid IS NULL";
2007 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbMailingList.uuid = ?";
2008 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = ?)";
2009 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbMailingList.uuid IS NULL AND ";
2010 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbMailingList.uuid = ? AND ";
2011 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = ?) AND ";
2012 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbMailingList.groupId = ?";
2013 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "mbMailingList.active = ?";
2014 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbMailingList.groupId = ? AND ";
2015 private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbMailingList.categoryId = ?";
2016 private static final String _ORDER_BY_ENTITY_ALIAS = "mbMailingList.";
2017 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBMailingList exists with the primary key ";
2018 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBMailingList exists with the key {";
2019 private static Log _log = LogFactoryUtil.getLog(MBMailingListPersistenceImpl.class);
2020 }