001
014
015 package com.liferay.portlet.messageboards.service.persistence;
016
017 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderPath;
021 import com.liferay.portal.kernel.dao.orm.Query;
022 import com.liferay.portal.kernel.dao.orm.QueryPos;
023 import com.liferay.portal.kernel.dao.orm.QueryUtil;
024 import com.liferay.portal.kernel.dao.orm.Session;
025 import com.liferay.portal.kernel.exception.SystemException;
026 import com.liferay.portal.kernel.log.Log;
027 import com.liferay.portal.kernel.log.LogFactoryUtil;
028 import com.liferay.portal.kernel.util.GetterUtil;
029 import com.liferay.portal.kernel.util.InstanceFactory;
030 import com.liferay.portal.kernel.util.OrderByComparator;
031 import com.liferay.portal.kernel.util.SetUtil;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.kernel.util.StringUtil;
035 import com.liferay.portal.kernel.util.UnmodifiableList;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041
042 import com.liferay.portlet.messageboards.NoSuchMailingListException;
043 import com.liferay.portlet.messageboards.model.MBMailingList;
044 import com.liferay.portlet.messageboards.model.impl.MBMailingListImpl;
045 import com.liferay.portlet.messageboards.model.impl.MBMailingListModelImpl;
046
047 import java.io.Serializable;
048
049 import java.util.ArrayList;
050 import java.util.Collections;
051 import java.util.List;
052 import java.util.Set;
053
054
066 public class MBMailingListPersistenceImpl extends BasePersistenceImpl<MBMailingList>
067 implements MBMailingListPersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = MBMailingListImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List1";
076 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List2";
078 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
079 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
080 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
081 "findAll", new String[0]);
082 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
083 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
084 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
085 "findAll", new String[0]);
086 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
087 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
089 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
090 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
091 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
092 "findByUuid",
093 new String[] {
094 String.class.getName(),
095
096 Integer.class.getName(), Integer.class.getName(),
097 OrderByComparator.class.getName()
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
100 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
101 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
102 "findByUuid", new String[] { String.class.getName() },
103 MBMailingListModelImpl.UUID_COLUMN_BITMASK);
104 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
105 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
107 new String[] { String.class.getName() });
108
109
116 public List<MBMailingList> findByUuid(String uuid)
117 throws SystemException {
118 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
119 }
120
121
134 public List<MBMailingList> findByUuid(String uuid, int start, int end)
135 throws SystemException {
136 return findByUuid(uuid, start, end, null);
137 }
138
139
153 public List<MBMailingList> findByUuid(String uuid, int start, int end,
154 OrderByComparator orderByComparator) throws SystemException {
155 boolean pagination = true;
156 FinderPath finderPath = null;
157 Object[] finderArgs = null;
158
159 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
160 (orderByComparator == null)) {
161 pagination = false;
162 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
163 finderArgs = new Object[] { uuid };
164 }
165 else {
166 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
167 finderArgs = new Object[] { uuid, start, end, orderByComparator };
168 }
169
170 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
171 finderArgs, this);
172
173 if ((list != null) && !list.isEmpty()) {
174 for (MBMailingList mbMailingList : list) {
175 if (!Validator.equals(uuid, mbMailingList.getUuid())) {
176 list = null;
177
178 break;
179 }
180 }
181 }
182
183 if (list == null) {
184 StringBundler query = null;
185
186 if (orderByComparator != null) {
187 query = new StringBundler(3 +
188 (orderByComparator.getOrderByFields().length * 3));
189 }
190 else {
191 query = new StringBundler(3);
192 }
193
194 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
195
196 boolean bindUuid = false;
197
198 if (uuid == null) {
199 query.append(_FINDER_COLUMN_UUID_UUID_1);
200 }
201 else if (uuid.equals(StringPool.BLANK)) {
202 query.append(_FINDER_COLUMN_UUID_UUID_3);
203 }
204 else {
205 bindUuid = true;
206
207 query.append(_FINDER_COLUMN_UUID_UUID_2);
208 }
209
210 if (orderByComparator != null) {
211 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
212 orderByComparator);
213 }
214 else
215 if (pagination) {
216 query.append(MBMailingListModelImpl.ORDER_BY_JPQL);
217 }
218
219 String sql = query.toString();
220
221 Session session = null;
222
223 try {
224 session = openSession();
225
226 Query q = session.createQuery(sql);
227
228 QueryPos qPos = QueryPos.getInstance(q);
229
230 if (bindUuid) {
231 qPos.add(uuid);
232 }
233
234 if (!pagination) {
235 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
236 start, end, false);
237
238 Collections.sort(list);
239
240 list = new UnmodifiableList<MBMailingList>(list);
241 }
242 else {
243 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
244 start, end);
245 }
246
247 cacheResult(list);
248
249 FinderCacheUtil.putResult(finderPath, finderArgs, list);
250 }
251 catch (Exception e) {
252 FinderCacheUtil.removeResult(finderPath, finderArgs);
253
254 throw processException(e);
255 }
256 finally {
257 closeSession(session);
258 }
259 }
260
261 return list;
262 }
263
264
273 public MBMailingList findByUuid_First(String uuid,
274 OrderByComparator orderByComparator)
275 throws NoSuchMailingListException, SystemException {
276 MBMailingList mbMailingList = fetchByUuid_First(uuid, orderByComparator);
277
278 if (mbMailingList != null) {
279 return mbMailingList;
280 }
281
282 StringBundler msg = new StringBundler(4);
283
284 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
285
286 msg.append("uuid=");
287 msg.append(uuid);
288
289 msg.append(StringPool.CLOSE_CURLY_BRACE);
290
291 throw new NoSuchMailingListException(msg.toString());
292 }
293
294
302 public MBMailingList fetchByUuid_First(String uuid,
303 OrderByComparator orderByComparator) throws SystemException {
304 List<MBMailingList> list = findByUuid(uuid, 0, 1, orderByComparator);
305
306 if (!list.isEmpty()) {
307 return list.get(0);
308 }
309
310 return null;
311 }
312
313
322 public MBMailingList findByUuid_Last(String uuid,
323 OrderByComparator orderByComparator)
324 throws NoSuchMailingListException, SystemException {
325 MBMailingList mbMailingList = fetchByUuid_Last(uuid, orderByComparator);
326
327 if (mbMailingList != null) {
328 return mbMailingList;
329 }
330
331 StringBundler msg = new StringBundler(4);
332
333 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
334
335 msg.append("uuid=");
336 msg.append(uuid);
337
338 msg.append(StringPool.CLOSE_CURLY_BRACE);
339
340 throw new NoSuchMailingListException(msg.toString());
341 }
342
343
351 public MBMailingList fetchByUuid_Last(String uuid,
352 OrderByComparator orderByComparator) throws SystemException {
353 int count = countByUuid(uuid);
354
355 List<MBMailingList> list = findByUuid(uuid, count - 1, count,
356 orderByComparator);
357
358 if (!list.isEmpty()) {
359 return list.get(0);
360 }
361
362 return null;
363 }
364
365
375 public MBMailingList[] findByUuid_PrevAndNext(long mailingListId,
376 String uuid, OrderByComparator orderByComparator)
377 throws NoSuchMailingListException, SystemException {
378 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
379
380 Session session = null;
381
382 try {
383 session = openSession();
384
385 MBMailingList[] array = new MBMailingListImpl[3];
386
387 array[0] = getByUuid_PrevAndNext(session, mbMailingList, uuid,
388 orderByComparator, true);
389
390 array[1] = mbMailingList;
391
392 array[2] = getByUuid_PrevAndNext(session, mbMailingList, uuid,
393 orderByComparator, false);
394
395 return array;
396 }
397 catch (Exception e) {
398 throw processException(e);
399 }
400 finally {
401 closeSession(session);
402 }
403 }
404
405 protected MBMailingList getByUuid_PrevAndNext(Session session,
406 MBMailingList mbMailingList, String uuid,
407 OrderByComparator orderByComparator, boolean previous) {
408 StringBundler query = null;
409
410 if (orderByComparator != null) {
411 query = new StringBundler(6 +
412 (orderByComparator.getOrderByFields().length * 6));
413 }
414 else {
415 query = new StringBundler(3);
416 }
417
418 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
419
420 boolean bindUuid = false;
421
422 if (uuid == null) {
423 query.append(_FINDER_COLUMN_UUID_UUID_1);
424 }
425 else if (uuid.equals(StringPool.BLANK)) {
426 query.append(_FINDER_COLUMN_UUID_UUID_3);
427 }
428 else {
429 bindUuid = true;
430
431 query.append(_FINDER_COLUMN_UUID_UUID_2);
432 }
433
434 if (orderByComparator != null) {
435 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
436
437 if (orderByConditionFields.length > 0) {
438 query.append(WHERE_AND);
439 }
440
441 for (int i = 0; i < orderByConditionFields.length; i++) {
442 query.append(_ORDER_BY_ENTITY_ALIAS);
443 query.append(orderByConditionFields[i]);
444
445 if ((i + 1) < orderByConditionFields.length) {
446 if (orderByComparator.isAscending() ^ previous) {
447 query.append(WHERE_GREATER_THAN_HAS_NEXT);
448 }
449 else {
450 query.append(WHERE_LESSER_THAN_HAS_NEXT);
451 }
452 }
453 else {
454 if (orderByComparator.isAscending() ^ previous) {
455 query.append(WHERE_GREATER_THAN);
456 }
457 else {
458 query.append(WHERE_LESSER_THAN);
459 }
460 }
461 }
462
463 query.append(ORDER_BY_CLAUSE);
464
465 String[] orderByFields = orderByComparator.getOrderByFields();
466
467 for (int i = 0; i < orderByFields.length; i++) {
468 query.append(_ORDER_BY_ENTITY_ALIAS);
469 query.append(orderByFields[i]);
470
471 if ((i + 1) < orderByFields.length) {
472 if (orderByComparator.isAscending() ^ previous) {
473 query.append(ORDER_BY_ASC_HAS_NEXT);
474 }
475 else {
476 query.append(ORDER_BY_DESC_HAS_NEXT);
477 }
478 }
479 else {
480 if (orderByComparator.isAscending() ^ previous) {
481 query.append(ORDER_BY_ASC);
482 }
483 else {
484 query.append(ORDER_BY_DESC);
485 }
486 }
487 }
488 }
489 else {
490 query.append(MBMailingListModelImpl.ORDER_BY_JPQL);
491 }
492
493 String sql = query.toString();
494
495 Query q = session.createQuery(sql);
496
497 q.setFirstResult(0);
498 q.setMaxResults(2);
499
500 QueryPos qPos = QueryPos.getInstance(q);
501
502 if (bindUuid) {
503 qPos.add(uuid);
504 }
505
506 if (orderByComparator != null) {
507 Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
508
509 for (Object value : values) {
510 qPos.add(value);
511 }
512 }
513
514 List<MBMailingList> list = q.list();
515
516 if (list.size() == 2) {
517 return list.get(1);
518 }
519 else {
520 return null;
521 }
522 }
523
524
530 public void removeByUuid(String uuid) throws SystemException {
531 for (MBMailingList mbMailingList : findByUuid(uuid, QueryUtil.ALL_POS,
532 QueryUtil.ALL_POS, null)) {
533 remove(mbMailingList);
534 }
535 }
536
537
544 public int countByUuid(String uuid) throws SystemException {
545 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
546
547 Object[] finderArgs = new Object[] { uuid };
548
549 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
550 this);
551
552 if (count == null) {
553 StringBundler query = new StringBundler(2);
554
555 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
556
557 boolean bindUuid = false;
558
559 if (uuid == null) {
560 query.append(_FINDER_COLUMN_UUID_UUID_1);
561 }
562 else if (uuid.equals(StringPool.BLANK)) {
563 query.append(_FINDER_COLUMN_UUID_UUID_3);
564 }
565 else {
566 bindUuid = true;
567
568 query.append(_FINDER_COLUMN_UUID_UUID_2);
569 }
570
571 String sql = query.toString();
572
573 Session session = null;
574
575 try {
576 session = openSession();
577
578 Query q = session.createQuery(sql);
579
580 QueryPos qPos = QueryPos.getInstance(q);
581
582 if (bindUuid) {
583 qPos.add(uuid);
584 }
585
586 count = (Long)q.uniqueResult();
587
588 FinderCacheUtil.putResult(finderPath, finderArgs, count);
589 }
590 catch (Exception e) {
591 FinderCacheUtil.removeResult(finderPath, finderArgs);
592
593 throw processException(e);
594 }
595 finally {
596 closeSession(session);
597 }
598 }
599
600 return count.intValue();
601 }
602
603 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbMailingList.uuid IS NULL";
604 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbMailingList.uuid = ?";
605 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = '')";
606 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
607 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
608 MBMailingListImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
609 new String[] { String.class.getName(), Long.class.getName() },
610 MBMailingListModelImpl.UUID_COLUMN_BITMASK |
611 MBMailingListModelImpl.GROUPID_COLUMN_BITMASK);
612 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
613 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
614 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
615 new String[] { String.class.getName(), Long.class.getName() });
616
617
626 public MBMailingList findByUUID_G(String uuid, long groupId)
627 throws NoSuchMailingListException, SystemException {
628 MBMailingList mbMailingList = fetchByUUID_G(uuid, groupId);
629
630 if (mbMailingList == null) {
631 StringBundler msg = new StringBundler(6);
632
633 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
634
635 msg.append("uuid=");
636 msg.append(uuid);
637
638 msg.append(", groupId=");
639 msg.append(groupId);
640
641 msg.append(StringPool.CLOSE_CURLY_BRACE);
642
643 if (_log.isWarnEnabled()) {
644 _log.warn(msg.toString());
645 }
646
647 throw new NoSuchMailingListException(msg.toString());
648 }
649
650 return mbMailingList;
651 }
652
653
661 public MBMailingList fetchByUUID_G(String uuid, long groupId)
662 throws SystemException {
663 return fetchByUUID_G(uuid, groupId, true);
664 }
665
666
675 public MBMailingList fetchByUUID_G(String uuid, long groupId,
676 boolean retrieveFromCache) throws SystemException {
677 Object[] finderArgs = new Object[] { uuid, groupId };
678
679 Object result = null;
680
681 if (retrieveFromCache) {
682 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
683 finderArgs, this);
684 }
685
686 if (result instanceof MBMailingList) {
687 MBMailingList mbMailingList = (MBMailingList)result;
688
689 if (!Validator.equals(uuid, mbMailingList.getUuid()) ||
690 (groupId != mbMailingList.getGroupId())) {
691 result = null;
692 }
693 }
694
695 if (result == null) {
696 StringBundler query = new StringBundler(4);
697
698 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
699
700 boolean bindUuid = false;
701
702 if (uuid == null) {
703 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
704 }
705 else if (uuid.equals(StringPool.BLANK)) {
706 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
707 }
708 else {
709 bindUuid = true;
710
711 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
712 }
713
714 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
715
716 String sql = query.toString();
717
718 Session session = null;
719
720 try {
721 session = openSession();
722
723 Query q = session.createQuery(sql);
724
725 QueryPos qPos = QueryPos.getInstance(q);
726
727 if (bindUuid) {
728 qPos.add(uuid);
729 }
730
731 qPos.add(groupId);
732
733 List<MBMailingList> list = q.list();
734
735 if (list.isEmpty()) {
736 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
737 finderArgs, list);
738 }
739 else {
740 MBMailingList mbMailingList = list.get(0);
741
742 result = mbMailingList;
743
744 cacheResult(mbMailingList);
745
746 if ((mbMailingList.getUuid() == null) ||
747 !mbMailingList.getUuid().equals(uuid) ||
748 (mbMailingList.getGroupId() != groupId)) {
749 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
750 finderArgs, mbMailingList);
751 }
752 }
753 }
754 catch (Exception e) {
755 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
756 finderArgs);
757
758 throw processException(e);
759 }
760 finally {
761 closeSession(session);
762 }
763 }
764
765 if (result instanceof List<?>) {
766 return null;
767 }
768 else {
769 return (MBMailingList)result;
770 }
771 }
772
773
781 public MBMailingList removeByUUID_G(String uuid, long groupId)
782 throws NoSuchMailingListException, SystemException {
783 MBMailingList mbMailingList = findByUUID_G(uuid, groupId);
784
785 return remove(mbMailingList);
786 }
787
788
796 public int countByUUID_G(String uuid, long groupId)
797 throws SystemException {
798 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
799
800 Object[] finderArgs = new Object[] { uuid, groupId };
801
802 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
803 this);
804
805 if (count == null) {
806 StringBundler query = new StringBundler(3);
807
808 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
809
810 boolean bindUuid = false;
811
812 if (uuid == null) {
813 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
814 }
815 else if (uuid.equals(StringPool.BLANK)) {
816 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
817 }
818 else {
819 bindUuid = true;
820
821 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
822 }
823
824 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
825
826 String sql = query.toString();
827
828 Session session = null;
829
830 try {
831 session = openSession();
832
833 Query q = session.createQuery(sql);
834
835 QueryPos qPos = QueryPos.getInstance(q);
836
837 if (bindUuid) {
838 qPos.add(uuid);
839 }
840
841 qPos.add(groupId);
842
843 count = (Long)q.uniqueResult();
844
845 FinderCacheUtil.putResult(finderPath, finderArgs, count);
846 }
847 catch (Exception e) {
848 FinderCacheUtil.removeResult(finderPath, finderArgs);
849
850 throw processException(e);
851 }
852 finally {
853 closeSession(session);
854 }
855 }
856
857 return count.intValue();
858 }
859
860 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbMailingList.uuid IS NULL AND ";
861 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbMailingList.uuid = ? AND ";
862 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = '') AND ";
863 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbMailingList.groupId = ?";
864 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
865 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
866 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
867 "findByUuid_C",
868 new String[] {
869 String.class.getName(), Long.class.getName(),
870
871 Integer.class.getName(), Integer.class.getName(),
872 OrderByComparator.class.getName()
873 });
874 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
875 new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
876 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
877 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
878 "findByUuid_C",
879 new String[] { String.class.getName(), Long.class.getName() },
880 MBMailingListModelImpl.UUID_COLUMN_BITMASK |
881 MBMailingListModelImpl.COMPANYID_COLUMN_BITMASK);
882 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
883 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
884 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
885 new String[] { String.class.getName(), Long.class.getName() });
886
887
895 public List<MBMailingList> findByUuid_C(String uuid, long companyId)
896 throws SystemException {
897 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
898 QueryUtil.ALL_POS, null);
899 }
900
901
915 public List<MBMailingList> findByUuid_C(String uuid, long companyId,
916 int start, int end) throws SystemException {
917 return findByUuid_C(uuid, companyId, start, end, null);
918 }
919
920
935 public List<MBMailingList> findByUuid_C(String uuid, long companyId,
936 int start, int end, OrderByComparator orderByComparator)
937 throws SystemException {
938 boolean pagination = true;
939 FinderPath finderPath = null;
940 Object[] finderArgs = null;
941
942 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
943 (orderByComparator == null)) {
944 pagination = false;
945 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
946 finderArgs = new Object[] { uuid, companyId };
947 }
948 else {
949 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
950 finderArgs = new Object[] {
951 uuid, companyId,
952
953 start, end, orderByComparator
954 };
955 }
956
957 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
958 finderArgs, this);
959
960 if ((list != null) && !list.isEmpty()) {
961 for (MBMailingList mbMailingList : list) {
962 if (!Validator.equals(uuid, mbMailingList.getUuid()) ||
963 (companyId != mbMailingList.getCompanyId())) {
964 list = null;
965
966 break;
967 }
968 }
969 }
970
971 if (list == null) {
972 StringBundler query = null;
973
974 if (orderByComparator != null) {
975 query = new StringBundler(4 +
976 (orderByComparator.getOrderByFields().length * 3));
977 }
978 else {
979 query = new StringBundler(4);
980 }
981
982 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
983
984 boolean bindUuid = false;
985
986 if (uuid == null) {
987 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
988 }
989 else if (uuid.equals(StringPool.BLANK)) {
990 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
991 }
992 else {
993 bindUuid = true;
994
995 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
996 }
997
998 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
999
1000 if (orderByComparator != null) {
1001 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1002 orderByComparator);
1003 }
1004 else
1005 if (pagination) {
1006 query.append(MBMailingListModelImpl.ORDER_BY_JPQL);
1007 }
1008
1009 String sql = query.toString();
1010
1011 Session session = null;
1012
1013 try {
1014 session = openSession();
1015
1016 Query q = session.createQuery(sql);
1017
1018 QueryPos qPos = QueryPos.getInstance(q);
1019
1020 if (bindUuid) {
1021 qPos.add(uuid);
1022 }
1023
1024 qPos.add(companyId);
1025
1026 if (!pagination) {
1027 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1028 start, end, false);
1029
1030 Collections.sort(list);
1031
1032 list = new UnmodifiableList<MBMailingList>(list);
1033 }
1034 else {
1035 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1036 start, end);
1037 }
1038
1039 cacheResult(list);
1040
1041 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1042 }
1043 catch (Exception e) {
1044 FinderCacheUtil.removeResult(finderPath, finderArgs);
1045
1046 throw processException(e);
1047 }
1048 finally {
1049 closeSession(session);
1050 }
1051 }
1052
1053 return list;
1054 }
1055
1056
1066 public MBMailingList findByUuid_C_First(String uuid, long companyId,
1067 OrderByComparator orderByComparator)
1068 throws NoSuchMailingListException, SystemException {
1069 MBMailingList mbMailingList = fetchByUuid_C_First(uuid, companyId,
1070 orderByComparator);
1071
1072 if (mbMailingList != null) {
1073 return mbMailingList;
1074 }
1075
1076 StringBundler msg = new StringBundler(6);
1077
1078 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1079
1080 msg.append("uuid=");
1081 msg.append(uuid);
1082
1083 msg.append(", companyId=");
1084 msg.append(companyId);
1085
1086 msg.append(StringPool.CLOSE_CURLY_BRACE);
1087
1088 throw new NoSuchMailingListException(msg.toString());
1089 }
1090
1091
1100 public MBMailingList fetchByUuid_C_First(String uuid, long companyId,
1101 OrderByComparator orderByComparator) throws SystemException {
1102 List<MBMailingList> list = findByUuid_C(uuid, companyId, 0, 1,
1103 orderByComparator);
1104
1105 if (!list.isEmpty()) {
1106 return list.get(0);
1107 }
1108
1109 return null;
1110 }
1111
1112
1122 public MBMailingList findByUuid_C_Last(String uuid, long companyId,
1123 OrderByComparator orderByComparator)
1124 throws NoSuchMailingListException, SystemException {
1125 MBMailingList mbMailingList = fetchByUuid_C_Last(uuid, companyId,
1126 orderByComparator);
1127
1128 if (mbMailingList != null) {
1129 return mbMailingList;
1130 }
1131
1132 StringBundler msg = new StringBundler(6);
1133
1134 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1135
1136 msg.append("uuid=");
1137 msg.append(uuid);
1138
1139 msg.append(", companyId=");
1140 msg.append(companyId);
1141
1142 msg.append(StringPool.CLOSE_CURLY_BRACE);
1143
1144 throw new NoSuchMailingListException(msg.toString());
1145 }
1146
1147
1156 public MBMailingList fetchByUuid_C_Last(String uuid, long companyId,
1157 OrderByComparator orderByComparator) throws SystemException {
1158 int count = countByUuid_C(uuid, companyId);
1159
1160 List<MBMailingList> list = findByUuid_C(uuid, companyId, count - 1,
1161 count, orderByComparator);
1162
1163 if (!list.isEmpty()) {
1164 return list.get(0);
1165 }
1166
1167 return null;
1168 }
1169
1170
1181 public MBMailingList[] findByUuid_C_PrevAndNext(long mailingListId,
1182 String uuid, long companyId, OrderByComparator orderByComparator)
1183 throws NoSuchMailingListException, SystemException {
1184 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
1185
1186 Session session = null;
1187
1188 try {
1189 session = openSession();
1190
1191 MBMailingList[] array = new MBMailingListImpl[3];
1192
1193 array[0] = getByUuid_C_PrevAndNext(session, mbMailingList, uuid,
1194 companyId, orderByComparator, true);
1195
1196 array[1] = mbMailingList;
1197
1198 array[2] = getByUuid_C_PrevAndNext(session, mbMailingList, uuid,
1199 companyId, orderByComparator, false);
1200
1201 return array;
1202 }
1203 catch (Exception e) {
1204 throw processException(e);
1205 }
1206 finally {
1207 closeSession(session);
1208 }
1209 }
1210
1211 protected MBMailingList getByUuid_C_PrevAndNext(Session session,
1212 MBMailingList mbMailingList, String uuid, long companyId,
1213 OrderByComparator orderByComparator, boolean previous) {
1214 StringBundler query = null;
1215
1216 if (orderByComparator != null) {
1217 query = new StringBundler(6 +
1218 (orderByComparator.getOrderByFields().length * 6));
1219 }
1220 else {
1221 query = new StringBundler(3);
1222 }
1223
1224 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1225
1226 boolean bindUuid = false;
1227
1228 if (uuid == null) {
1229 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1230 }
1231 else if (uuid.equals(StringPool.BLANK)) {
1232 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1233 }
1234 else {
1235 bindUuid = true;
1236
1237 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1238 }
1239
1240 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1241
1242 if (orderByComparator != null) {
1243 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1244
1245 if (orderByConditionFields.length > 0) {
1246 query.append(WHERE_AND);
1247 }
1248
1249 for (int i = 0; i < orderByConditionFields.length; i++) {
1250 query.append(_ORDER_BY_ENTITY_ALIAS);
1251 query.append(orderByConditionFields[i]);
1252
1253 if ((i + 1) < orderByConditionFields.length) {
1254 if (orderByComparator.isAscending() ^ previous) {
1255 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1256 }
1257 else {
1258 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1259 }
1260 }
1261 else {
1262 if (orderByComparator.isAscending() ^ previous) {
1263 query.append(WHERE_GREATER_THAN);
1264 }
1265 else {
1266 query.append(WHERE_LESSER_THAN);
1267 }
1268 }
1269 }
1270
1271 query.append(ORDER_BY_CLAUSE);
1272
1273 String[] orderByFields = orderByComparator.getOrderByFields();
1274
1275 for (int i = 0; i < orderByFields.length; i++) {
1276 query.append(_ORDER_BY_ENTITY_ALIAS);
1277 query.append(orderByFields[i]);
1278
1279 if ((i + 1) < orderByFields.length) {
1280 if (orderByComparator.isAscending() ^ previous) {
1281 query.append(ORDER_BY_ASC_HAS_NEXT);
1282 }
1283 else {
1284 query.append(ORDER_BY_DESC_HAS_NEXT);
1285 }
1286 }
1287 else {
1288 if (orderByComparator.isAscending() ^ previous) {
1289 query.append(ORDER_BY_ASC);
1290 }
1291 else {
1292 query.append(ORDER_BY_DESC);
1293 }
1294 }
1295 }
1296 }
1297 else {
1298 query.append(MBMailingListModelImpl.ORDER_BY_JPQL);
1299 }
1300
1301 String sql = query.toString();
1302
1303 Query q = session.createQuery(sql);
1304
1305 q.setFirstResult(0);
1306 q.setMaxResults(2);
1307
1308 QueryPos qPos = QueryPos.getInstance(q);
1309
1310 if (bindUuid) {
1311 qPos.add(uuid);
1312 }
1313
1314 qPos.add(companyId);
1315
1316 if (orderByComparator != null) {
1317 Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
1318
1319 for (Object value : values) {
1320 qPos.add(value);
1321 }
1322 }
1323
1324 List<MBMailingList> list = q.list();
1325
1326 if (list.size() == 2) {
1327 return list.get(1);
1328 }
1329 else {
1330 return null;
1331 }
1332 }
1333
1334
1341 public void removeByUuid_C(String uuid, long companyId)
1342 throws SystemException {
1343 for (MBMailingList mbMailingList : findByUuid_C(uuid, companyId,
1344 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1345 remove(mbMailingList);
1346 }
1347 }
1348
1349
1357 public int countByUuid_C(String uuid, long companyId)
1358 throws SystemException {
1359 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1360
1361 Object[] finderArgs = new Object[] { uuid, companyId };
1362
1363 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1364 this);
1365
1366 if (count == null) {
1367 StringBundler query = new StringBundler(3);
1368
1369 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1370
1371 boolean bindUuid = false;
1372
1373 if (uuid == null) {
1374 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1375 }
1376 else if (uuid.equals(StringPool.BLANK)) {
1377 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1378 }
1379 else {
1380 bindUuid = true;
1381
1382 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1383 }
1384
1385 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1386
1387 String sql = query.toString();
1388
1389 Session session = null;
1390
1391 try {
1392 session = openSession();
1393
1394 Query q = session.createQuery(sql);
1395
1396 QueryPos qPos = QueryPos.getInstance(q);
1397
1398 if (bindUuid) {
1399 qPos.add(uuid);
1400 }
1401
1402 qPos.add(companyId);
1403
1404 count = (Long)q.uniqueResult();
1405
1406 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1407 }
1408 catch (Exception e) {
1409 FinderCacheUtil.removeResult(finderPath, finderArgs);
1410
1411 throw processException(e);
1412 }
1413 finally {
1414 closeSession(session);
1415 }
1416 }
1417
1418 return count.intValue();
1419 }
1420
1421 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mbMailingList.uuid IS NULL AND ";
1422 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mbMailingList.uuid = ? AND ";
1423 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = '') AND ";
1424 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mbMailingList.companyId = ?";
1425 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
1426 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
1427 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1428 "findByActive",
1429 new String[] {
1430 Boolean.class.getName(),
1431
1432 Integer.class.getName(), Integer.class.getName(),
1433 OrderByComparator.class.getName()
1434 });
1435 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE =
1436 new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
1437 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
1438 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1439 "findByActive", new String[] { Boolean.class.getName() },
1440 MBMailingListModelImpl.ACTIVE_COLUMN_BITMASK);
1441 public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
1442 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
1443 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByActive",
1444 new String[] { Boolean.class.getName() });
1445
1446
1453 public List<MBMailingList> findByActive(boolean active)
1454 throws SystemException {
1455 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1456 }
1457
1458
1471 public List<MBMailingList> findByActive(boolean active, int start, int end)
1472 throws SystemException {
1473 return findByActive(active, start, end, null);
1474 }
1475
1476
1490 public List<MBMailingList> findByActive(boolean active, int start, int end,
1491 OrderByComparator orderByComparator) throws SystemException {
1492 boolean pagination = true;
1493 FinderPath finderPath = null;
1494 Object[] finderArgs = null;
1495
1496 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1497 (orderByComparator == null)) {
1498 pagination = false;
1499 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
1500 finderArgs = new Object[] { active };
1501 }
1502 else {
1503 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
1504 finderArgs = new Object[] { active, start, end, orderByComparator };
1505 }
1506
1507 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
1508 finderArgs, this);
1509
1510 if ((list != null) && !list.isEmpty()) {
1511 for (MBMailingList mbMailingList : list) {
1512 if ((active != mbMailingList.getActive())) {
1513 list = null;
1514
1515 break;
1516 }
1517 }
1518 }
1519
1520 if (list == null) {
1521 StringBundler query = null;
1522
1523 if (orderByComparator != null) {
1524 query = new StringBundler(3 +
1525 (orderByComparator.getOrderByFields().length * 3));
1526 }
1527 else {
1528 query = new StringBundler(3);
1529 }
1530
1531 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1532
1533 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1534
1535 if (orderByComparator != null) {
1536 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1537 orderByComparator);
1538 }
1539 else
1540 if (pagination) {
1541 query.append(MBMailingListModelImpl.ORDER_BY_JPQL);
1542 }
1543
1544 String sql = query.toString();
1545
1546 Session session = null;
1547
1548 try {
1549 session = openSession();
1550
1551 Query q = session.createQuery(sql);
1552
1553 QueryPos qPos = QueryPos.getInstance(q);
1554
1555 qPos.add(active);
1556
1557 if (!pagination) {
1558 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1559 start, end, false);
1560
1561 Collections.sort(list);
1562
1563 list = new UnmodifiableList<MBMailingList>(list);
1564 }
1565 else {
1566 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1567 start, end);
1568 }
1569
1570 cacheResult(list);
1571
1572 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1573 }
1574 catch (Exception e) {
1575 FinderCacheUtil.removeResult(finderPath, finderArgs);
1576
1577 throw processException(e);
1578 }
1579 finally {
1580 closeSession(session);
1581 }
1582 }
1583
1584 return list;
1585 }
1586
1587
1596 public MBMailingList findByActive_First(boolean active,
1597 OrderByComparator orderByComparator)
1598 throws NoSuchMailingListException, SystemException {
1599 MBMailingList mbMailingList = fetchByActive_First(active,
1600 orderByComparator);
1601
1602 if (mbMailingList != null) {
1603 return mbMailingList;
1604 }
1605
1606 StringBundler msg = new StringBundler(4);
1607
1608 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1609
1610 msg.append("active=");
1611 msg.append(active);
1612
1613 msg.append(StringPool.CLOSE_CURLY_BRACE);
1614
1615 throw new NoSuchMailingListException(msg.toString());
1616 }
1617
1618
1626 public MBMailingList fetchByActive_First(boolean active,
1627 OrderByComparator orderByComparator) throws SystemException {
1628 List<MBMailingList> list = findByActive(active, 0, 1, orderByComparator);
1629
1630 if (!list.isEmpty()) {
1631 return list.get(0);
1632 }
1633
1634 return null;
1635 }
1636
1637
1646 public MBMailingList findByActive_Last(boolean active,
1647 OrderByComparator orderByComparator)
1648 throws NoSuchMailingListException, SystemException {
1649 MBMailingList mbMailingList = fetchByActive_Last(active,
1650 orderByComparator);
1651
1652 if (mbMailingList != null) {
1653 return mbMailingList;
1654 }
1655
1656 StringBundler msg = new StringBundler(4);
1657
1658 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1659
1660 msg.append("active=");
1661 msg.append(active);
1662
1663 msg.append(StringPool.CLOSE_CURLY_BRACE);
1664
1665 throw new NoSuchMailingListException(msg.toString());
1666 }
1667
1668
1676 public MBMailingList fetchByActive_Last(boolean active,
1677 OrderByComparator orderByComparator) throws SystemException {
1678 int count = countByActive(active);
1679
1680 List<MBMailingList> list = findByActive(active, count - 1, count,
1681 orderByComparator);
1682
1683 if (!list.isEmpty()) {
1684 return list.get(0);
1685 }
1686
1687 return null;
1688 }
1689
1690
1700 public MBMailingList[] findByActive_PrevAndNext(long mailingListId,
1701 boolean active, OrderByComparator orderByComparator)
1702 throws NoSuchMailingListException, SystemException {
1703 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
1704
1705 Session session = null;
1706
1707 try {
1708 session = openSession();
1709
1710 MBMailingList[] array = new MBMailingListImpl[3];
1711
1712 array[0] = getByActive_PrevAndNext(session, mbMailingList, active,
1713 orderByComparator, true);
1714
1715 array[1] = mbMailingList;
1716
1717 array[2] = getByActive_PrevAndNext(session, mbMailingList, active,
1718 orderByComparator, false);
1719
1720 return array;
1721 }
1722 catch (Exception e) {
1723 throw processException(e);
1724 }
1725 finally {
1726 closeSession(session);
1727 }
1728 }
1729
1730 protected MBMailingList getByActive_PrevAndNext(Session session,
1731 MBMailingList mbMailingList, boolean active,
1732 OrderByComparator orderByComparator, boolean previous) {
1733 StringBundler query = null;
1734
1735 if (orderByComparator != null) {
1736 query = new StringBundler(6 +
1737 (orderByComparator.getOrderByFields().length * 6));
1738 }
1739 else {
1740 query = new StringBundler(3);
1741 }
1742
1743 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1744
1745 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1746
1747 if (orderByComparator != null) {
1748 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1749
1750 if (orderByConditionFields.length > 0) {
1751 query.append(WHERE_AND);
1752 }
1753
1754 for (int i = 0; i < orderByConditionFields.length; i++) {
1755 query.append(_ORDER_BY_ENTITY_ALIAS);
1756 query.append(orderByConditionFields[i]);
1757
1758 if ((i + 1) < orderByConditionFields.length) {
1759 if (orderByComparator.isAscending() ^ previous) {
1760 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1761 }
1762 else {
1763 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1764 }
1765 }
1766 else {
1767 if (orderByComparator.isAscending() ^ previous) {
1768 query.append(WHERE_GREATER_THAN);
1769 }
1770 else {
1771 query.append(WHERE_LESSER_THAN);
1772 }
1773 }
1774 }
1775
1776 query.append(ORDER_BY_CLAUSE);
1777
1778 String[] orderByFields = orderByComparator.getOrderByFields();
1779
1780 for (int i = 0; i < orderByFields.length; i++) {
1781 query.append(_ORDER_BY_ENTITY_ALIAS);
1782 query.append(orderByFields[i]);
1783
1784 if ((i + 1) < orderByFields.length) {
1785 if (orderByComparator.isAscending() ^ previous) {
1786 query.append(ORDER_BY_ASC_HAS_NEXT);
1787 }
1788 else {
1789 query.append(ORDER_BY_DESC_HAS_NEXT);
1790 }
1791 }
1792 else {
1793 if (orderByComparator.isAscending() ^ previous) {
1794 query.append(ORDER_BY_ASC);
1795 }
1796 else {
1797 query.append(ORDER_BY_DESC);
1798 }
1799 }
1800 }
1801 }
1802 else {
1803 query.append(MBMailingListModelImpl.ORDER_BY_JPQL);
1804 }
1805
1806 String sql = query.toString();
1807
1808 Query q = session.createQuery(sql);
1809
1810 q.setFirstResult(0);
1811 q.setMaxResults(2);
1812
1813 QueryPos qPos = QueryPos.getInstance(q);
1814
1815 qPos.add(active);
1816
1817 if (orderByComparator != null) {
1818 Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
1819
1820 for (Object value : values) {
1821 qPos.add(value);
1822 }
1823 }
1824
1825 List<MBMailingList> list = q.list();
1826
1827 if (list.size() == 2) {
1828 return list.get(1);
1829 }
1830 else {
1831 return null;
1832 }
1833 }
1834
1835
1841 public void removeByActive(boolean active) throws SystemException {
1842 for (MBMailingList mbMailingList : findByActive(active,
1843 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1844 remove(mbMailingList);
1845 }
1846 }
1847
1848
1855 public int countByActive(boolean active) throws SystemException {
1856 FinderPath finderPath = FINDER_PATH_COUNT_BY_ACTIVE;
1857
1858 Object[] finderArgs = new Object[] { active };
1859
1860 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1861 this);
1862
1863 if (count == null) {
1864 StringBundler query = new StringBundler(2);
1865
1866 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1867
1868 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1869
1870 String sql = query.toString();
1871
1872 Session session = null;
1873
1874 try {
1875 session = openSession();
1876
1877 Query q = session.createQuery(sql);
1878
1879 QueryPos qPos = QueryPos.getInstance(q);
1880
1881 qPos.add(active);
1882
1883 count = (Long)q.uniqueResult();
1884
1885 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1886 }
1887 catch (Exception e) {
1888 FinderCacheUtil.removeResult(finderPath, finderArgs);
1889
1890 throw processException(e);
1891 }
1892 finally {
1893 closeSession(session);
1894 }
1895 }
1896
1897 return count.intValue();
1898 }
1899
1900 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "mbMailingList.active = ?";
1901 public static final FinderPath FINDER_PATH_FETCH_BY_G_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
1902 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
1903 MBMailingListImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C",
1904 new String[] { Long.class.getName(), Long.class.getName() },
1905 MBMailingListModelImpl.GROUPID_COLUMN_BITMASK |
1906 MBMailingListModelImpl.CATEGORYID_COLUMN_BITMASK);
1907 public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
1908 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
1909 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C",
1910 new String[] { Long.class.getName(), Long.class.getName() });
1911
1912
1921 public MBMailingList findByG_C(long groupId, long categoryId)
1922 throws NoSuchMailingListException, SystemException {
1923 MBMailingList mbMailingList = fetchByG_C(groupId, categoryId);
1924
1925 if (mbMailingList == null) {
1926 StringBundler msg = new StringBundler(6);
1927
1928 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1929
1930 msg.append("groupId=");
1931 msg.append(groupId);
1932
1933 msg.append(", categoryId=");
1934 msg.append(categoryId);
1935
1936 msg.append(StringPool.CLOSE_CURLY_BRACE);
1937
1938 if (_log.isWarnEnabled()) {
1939 _log.warn(msg.toString());
1940 }
1941
1942 throw new NoSuchMailingListException(msg.toString());
1943 }
1944
1945 return mbMailingList;
1946 }
1947
1948
1956 public MBMailingList fetchByG_C(long groupId, long categoryId)
1957 throws SystemException {
1958 return fetchByG_C(groupId, categoryId, true);
1959 }
1960
1961
1970 public MBMailingList fetchByG_C(long groupId, long categoryId,
1971 boolean retrieveFromCache) throws SystemException {
1972 Object[] finderArgs = new Object[] { groupId, categoryId };
1973
1974 Object result = null;
1975
1976 if (retrieveFromCache) {
1977 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C,
1978 finderArgs, this);
1979 }
1980
1981 if (result instanceof MBMailingList) {
1982 MBMailingList mbMailingList = (MBMailingList)result;
1983
1984 if ((groupId != mbMailingList.getGroupId()) ||
1985 (categoryId != mbMailingList.getCategoryId())) {
1986 result = null;
1987 }
1988 }
1989
1990 if (result == null) {
1991 StringBundler query = new StringBundler(4);
1992
1993 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1994
1995 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1996
1997 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1998
1999 String sql = query.toString();
2000
2001 Session session = null;
2002
2003 try {
2004 session = openSession();
2005
2006 Query q = session.createQuery(sql);
2007
2008 QueryPos qPos = QueryPos.getInstance(q);
2009
2010 qPos.add(groupId);
2011
2012 qPos.add(categoryId);
2013
2014 List<MBMailingList> list = q.list();
2015
2016 if (list.isEmpty()) {
2017 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
2018 finderArgs, list);
2019 }
2020 else {
2021 MBMailingList mbMailingList = list.get(0);
2022
2023 result = mbMailingList;
2024
2025 cacheResult(mbMailingList);
2026
2027 if ((mbMailingList.getGroupId() != groupId) ||
2028 (mbMailingList.getCategoryId() != categoryId)) {
2029 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
2030 finderArgs, mbMailingList);
2031 }
2032 }
2033 }
2034 catch (Exception e) {
2035 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C,
2036 finderArgs);
2037
2038 throw processException(e);
2039 }
2040 finally {
2041 closeSession(session);
2042 }
2043 }
2044
2045 if (result instanceof List<?>) {
2046 return null;
2047 }
2048 else {
2049 return (MBMailingList)result;
2050 }
2051 }
2052
2053
2061 public MBMailingList removeByG_C(long groupId, long categoryId)
2062 throws NoSuchMailingListException, SystemException {
2063 MBMailingList mbMailingList = findByG_C(groupId, categoryId);
2064
2065 return remove(mbMailingList);
2066 }
2067
2068
2076 public int countByG_C(long groupId, long categoryId)
2077 throws SystemException {
2078 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C;
2079
2080 Object[] finderArgs = new Object[] { groupId, categoryId };
2081
2082 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2083 this);
2084
2085 if (count == null) {
2086 StringBundler query = new StringBundler(3);
2087
2088 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
2089
2090 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2091
2092 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2093
2094 String sql = query.toString();
2095
2096 Session session = null;
2097
2098 try {
2099 session = openSession();
2100
2101 Query q = session.createQuery(sql);
2102
2103 QueryPos qPos = QueryPos.getInstance(q);
2104
2105 qPos.add(groupId);
2106
2107 qPos.add(categoryId);
2108
2109 count = (Long)q.uniqueResult();
2110
2111 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2112 }
2113 catch (Exception e) {
2114 FinderCacheUtil.removeResult(finderPath, finderArgs);
2115
2116 throw processException(e);
2117 }
2118 finally {
2119 closeSession(session);
2120 }
2121 }
2122
2123 return count.intValue();
2124 }
2125
2126 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbMailingList.groupId = ? AND ";
2127 private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbMailingList.categoryId = ?";
2128
2129
2134 public void cacheResult(MBMailingList mbMailingList) {
2135 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2136 MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
2137 mbMailingList);
2138
2139 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2140 new Object[] { mbMailingList.getUuid(), mbMailingList.getGroupId() },
2141 mbMailingList);
2142
2143 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
2144 new Object[] {
2145 mbMailingList.getGroupId(), mbMailingList.getCategoryId()
2146 }, mbMailingList);
2147
2148 mbMailingList.resetOriginalValues();
2149 }
2150
2151
2156 public void cacheResult(List<MBMailingList> mbMailingLists) {
2157 for (MBMailingList mbMailingList : mbMailingLists) {
2158 if (EntityCacheUtil.getResult(
2159 MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2160 MBMailingListImpl.class, mbMailingList.getPrimaryKey()) == null) {
2161 cacheResult(mbMailingList);
2162 }
2163 else {
2164 mbMailingList.resetOriginalValues();
2165 }
2166 }
2167 }
2168
2169
2176 @Override
2177 public void clearCache() {
2178 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2179 CacheRegistryUtil.clear(MBMailingListImpl.class.getName());
2180 }
2181
2182 EntityCacheUtil.clearCache(MBMailingListImpl.class.getName());
2183
2184 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2185 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2186 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2187 }
2188
2189
2196 @Override
2197 public void clearCache(MBMailingList mbMailingList) {
2198 EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2199 MBMailingListImpl.class, mbMailingList.getPrimaryKey());
2200
2201 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2202 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2203
2204 clearUniqueFindersCache(mbMailingList);
2205 }
2206
2207 @Override
2208 public void clearCache(List<MBMailingList> mbMailingLists) {
2209 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2210 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2211
2212 for (MBMailingList mbMailingList : mbMailingLists) {
2213 EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2214 MBMailingListImpl.class, mbMailingList.getPrimaryKey());
2215
2216 clearUniqueFindersCache(mbMailingList);
2217 }
2218 }
2219
2220 protected void cacheUniqueFindersCache(MBMailingList mbMailingList) {
2221 if (mbMailingList.isNew()) {
2222 Object[] args = new Object[] {
2223 mbMailingList.getUuid(), mbMailingList.getGroupId()
2224 };
2225
2226 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2227 Long.valueOf(1));
2228 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2229 mbMailingList);
2230
2231 args = new Object[] {
2232 mbMailingList.getGroupId(), mbMailingList.getCategoryId()
2233 };
2234
2235 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, args,
2236 Long.valueOf(1));
2237 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C, args,
2238 mbMailingList);
2239 }
2240 else {
2241 MBMailingListModelImpl mbMailingListModelImpl = (MBMailingListModelImpl)mbMailingList;
2242
2243 if ((mbMailingListModelImpl.getColumnBitmask() &
2244 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2245 Object[] args = new Object[] {
2246 mbMailingList.getUuid(), mbMailingList.getGroupId()
2247 };
2248
2249 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2250 Long.valueOf(1));
2251 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2252 mbMailingList);
2253 }
2254
2255 if ((mbMailingListModelImpl.getColumnBitmask() &
2256 FINDER_PATH_FETCH_BY_G_C.getColumnBitmask()) != 0) {
2257 Object[] args = new Object[] {
2258 mbMailingList.getGroupId(),
2259 mbMailingList.getCategoryId()
2260 };
2261
2262 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, args,
2263 Long.valueOf(1));
2264 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C, args,
2265 mbMailingList);
2266 }
2267 }
2268 }
2269
2270 protected void clearUniqueFindersCache(MBMailingList mbMailingList) {
2271 MBMailingListModelImpl mbMailingListModelImpl = (MBMailingListModelImpl)mbMailingList;
2272
2273 Object[] args = new Object[] {
2274 mbMailingList.getUuid(), mbMailingList.getGroupId()
2275 };
2276
2277 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2278 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2279
2280 if ((mbMailingListModelImpl.getColumnBitmask() &
2281 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2282 args = new Object[] {
2283 mbMailingListModelImpl.getOriginalUuid(),
2284 mbMailingListModelImpl.getOriginalGroupId()
2285 };
2286
2287 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2288 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2289 }
2290
2291 args = new Object[] {
2292 mbMailingList.getGroupId(), mbMailingList.getCategoryId()
2293 };
2294
2295 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
2296 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C, args);
2297
2298 if ((mbMailingListModelImpl.getColumnBitmask() &
2299 FINDER_PATH_FETCH_BY_G_C.getColumnBitmask()) != 0) {
2300 args = new Object[] {
2301 mbMailingListModelImpl.getOriginalGroupId(),
2302 mbMailingListModelImpl.getOriginalCategoryId()
2303 };
2304
2305 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
2306 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C, args);
2307 }
2308 }
2309
2310
2316 public MBMailingList create(long mailingListId) {
2317 MBMailingList mbMailingList = new MBMailingListImpl();
2318
2319 mbMailingList.setNew(true);
2320 mbMailingList.setPrimaryKey(mailingListId);
2321
2322 String uuid = PortalUUIDUtil.generate();
2323
2324 mbMailingList.setUuid(uuid);
2325
2326 return mbMailingList;
2327 }
2328
2329
2337 public MBMailingList remove(long mailingListId)
2338 throws NoSuchMailingListException, SystemException {
2339 return remove((Serializable)mailingListId);
2340 }
2341
2342
2350 @Override
2351 public MBMailingList remove(Serializable primaryKey)
2352 throws NoSuchMailingListException, SystemException {
2353 Session session = null;
2354
2355 try {
2356 session = openSession();
2357
2358 MBMailingList mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
2359 primaryKey);
2360
2361 if (mbMailingList == null) {
2362 if (_log.isWarnEnabled()) {
2363 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2364 }
2365
2366 throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2367 primaryKey);
2368 }
2369
2370 return remove(mbMailingList);
2371 }
2372 catch (NoSuchMailingListException nsee) {
2373 throw nsee;
2374 }
2375 catch (Exception e) {
2376 throw processException(e);
2377 }
2378 finally {
2379 closeSession(session);
2380 }
2381 }
2382
2383 @Override
2384 protected MBMailingList removeImpl(MBMailingList mbMailingList)
2385 throws SystemException {
2386 mbMailingList = toUnwrappedModel(mbMailingList);
2387
2388 Session session = null;
2389
2390 try {
2391 session = openSession();
2392
2393 if (!session.contains(mbMailingList)) {
2394 mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
2395 mbMailingList.getPrimaryKeyObj());
2396 }
2397
2398 if (mbMailingList != null) {
2399 session.delete(mbMailingList);
2400 }
2401 }
2402 catch (Exception e) {
2403 throw processException(e);
2404 }
2405 finally {
2406 closeSession(session);
2407 }
2408
2409 if (mbMailingList != null) {
2410 clearCache(mbMailingList);
2411 }
2412
2413 return mbMailingList;
2414 }
2415
2416 @Override
2417 public MBMailingList updateImpl(
2418 com.liferay.portlet.messageboards.model.MBMailingList mbMailingList)
2419 throws SystemException {
2420 mbMailingList = toUnwrappedModel(mbMailingList);
2421
2422 boolean isNew = mbMailingList.isNew();
2423
2424 MBMailingListModelImpl mbMailingListModelImpl = (MBMailingListModelImpl)mbMailingList;
2425
2426 if (Validator.isNull(mbMailingList.getUuid())) {
2427 String uuid = PortalUUIDUtil.generate();
2428
2429 mbMailingList.setUuid(uuid);
2430 }
2431
2432 Session session = null;
2433
2434 try {
2435 session = openSession();
2436
2437 if (mbMailingList.isNew()) {
2438 session.save(mbMailingList);
2439
2440 mbMailingList.setNew(false);
2441 }
2442 else {
2443 session.merge(mbMailingList);
2444 }
2445 }
2446 catch (Exception e) {
2447 throw processException(e);
2448 }
2449 finally {
2450 closeSession(session);
2451 }
2452
2453 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2454
2455 if (isNew || !MBMailingListModelImpl.COLUMN_BITMASK_ENABLED) {
2456 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2457 }
2458
2459 else {
2460 if ((mbMailingListModelImpl.getColumnBitmask() &
2461 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2462 Object[] args = new Object[] {
2463 mbMailingListModelImpl.getOriginalUuid()
2464 };
2465
2466 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2467 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2468 args);
2469
2470 args = new Object[] { mbMailingListModelImpl.getUuid() };
2471
2472 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2473 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2474 args);
2475 }
2476
2477 if ((mbMailingListModelImpl.getColumnBitmask() &
2478 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
2479 Object[] args = new Object[] {
2480 mbMailingListModelImpl.getOriginalUuid(),
2481 mbMailingListModelImpl.getOriginalCompanyId()
2482 };
2483
2484 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2485 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2486 args);
2487
2488 args = new Object[] {
2489 mbMailingListModelImpl.getUuid(),
2490 mbMailingListModelImpl.getCompanyId()
2491 };
2492
2493 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2494 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2495 args);
2496 }
2497
2498 if ((mbMailingListModelImpl.getColumnBitmask() &
2499 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE.getColumnBitmask()) != 0) {
2500 Object[] args = new Object[] {
2501 mbMailingListModelImpl.getOriginalActive()
2502 };
2503
2504 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
2505 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
2506 args);
2507
2508 args = new Object[] { mbMailingListModelImpl.getActive() };
2509
2510 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
2511 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
2512 args);
2513 }
2514 }
2515
2516 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2517 MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
2518 mbMailingList);
2519
2520 clearUniqueFindersCache(mbMailingList);
2521 cacheUniqueFindersCache(mbMailingList);
2522
2523 return mbMailingList;
2524 }
2525
2526 protected MBMailingList toUnwrappedModel(MBMailingList mbMailingList) {
2527 if (mbMailingList instanceof MBMailingListImpl) {
2528 return mbMailingList;
2529 }
2530
2531 MBMailingListImpl mbMailingListImpl = new MBMailingListImpl();
2532
2533 mbMailingListImpl.setNew(mbMailingList.isNew());
2534 mbMailingListImpl.setPrimaryKey(mbMailingList.getPrimaryKey());
2535
2536 mbMailingListImpl.setUuid(mbMailingList.getUuid());
2537 mbMailingListImpl.setMailingListId(mbMailingList.getMailingListId());
2538 mbMailingListImpl.setGroupId(mbMailingList.getGroupId());
2539 mbMailingListImpl.setCompanyId(mbMailingList.getCompanyId());
2540 mbMailingListImpl.setUserId(mbMailingList.getUserId());
2541 mbMailingListImpl.setUserName(mbMailingList.getUserName());
2542 mbMailingListImpl.setCreateDate(mbMailingList.getCreateDate());
2543 mbMailingListImpl.setModifiedDate(mbMailingList.getModifiedDate());
2544 mbMailingListImpl.setCategoryId(mbMailingList.getCategoryId());
2545 mbMailingListImpl.setEmailAddress(mbMailingList.getEmailAddress());
2546 mbMailingListImpl.setInProtocol(mbMailingList.getInProtocol());
2547 mbMailingListImpl.setInServerName(mbMailingList.getInServerName());
2548 mbMailingListImpl.setInServerPort(mbMailingList.getInServerPort());
2549 mbMailingListImpl.setInUseSSL(mbMailingList.isInUseSSL());
2550 mbMailingListImpl.setInUserName(mbMailingList.getInUserName());
2551 mbMailingListImpl.setInPassword(mbMailingList.getInPassword());
2552 mbMailingListImpl.setInReadInterval(mbMailingList.getInReadInterval());
2553 mbMailingListImpl.setOutEmailAddress(mbMailingList.getOutEmailAddress());
2554 mbMailingListImpl.setOutCustom(mbMailingList.isOutCustom());
2555 mbMailingListImpl.setOutServerName(mbMailingList.getOutServerName());
2556 mbMailingListImpl.setOutServerPort(mbMailingList.getOutServerPort());
2557 mbMailingListImpl.setOutUseSSL(mbMailingList.isOutUseSSL());
2558 mbMailingListImpl.setOutUserName(mbMailingList.getOutUserName());
2559 mbMailingListImpl.setOutPassword(mbMailingList.getOutPassword());
2560 mbMailingListImpl.setAllowAnonymous(mbMailingList.isAllowAnonymous());
2561 mbMailingListImpl.setActive(mbMailingList.isActive());
2562
2563 return mbMailingListImpl;
2564 }
2565
2566
2574 @Override
2575 public MBMailingList findByPrimaryKey(Serializable primaryKey)
2576 throws NoSuchMailingListException, SystemException {
2577 MBMailingList mbMailingList = fetchByPrimaryKey(primaryKey);
2578
2579 if (mbMailingList == null) {
2580 if (_log.isWarnEnabled()) {
2581 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2582 }
2583
2584 throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2585 primaryKey);
2586 }
2587
2588 return mbMailingList;
2589 }
2590
2591
2599 public MBMailingList findByPrimaryKey(long mailingListId)
2600 throws NoSuchMailingListException, SystemException {
2601 return findByPrimaryKey((Serializable)mailingListId);
2602 }
2603
2604
2611 @Override
2612 public MBMailingList fetchByPrimaryKey(Serializable primaryKey)
2613 throws SystemException {
2614 MBMailingList mbMailingList = (MBMailingList)EntityCacheUtil.getResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2615 MBMailingListImpl.class, primaryKey);
2616
2617 if (mbMailingList == _nullMBMailingList) {
2618 return null;
2619 }
2620
2621 if (mbMailingList == null) {
2622 Session session = null;
2623
2624 try {
2625 session = openSession();
2626
2627 mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
2628 primaryKey);
2629
2630 if (mbMailingList != null) {
2631 cacheResult(mbMailingList);
2632 }
2633 else {
2634 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2635 MBMailingListImpl.class, primaryKey, _nullMBMailingList);
2636 }
2637 }
2638 catch (Exception e) {
2639 EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
2640 MBMailingListImpl.class, primaryKey);
2641
2642 throw processException(e);
2643 }
2644 finally {
2645 closeSession(session);
2646 }
2647 }
2648
2649 return mbMailingList;
2650 }
2651
2652
2659 public MBMailingList fetchByPrimaryKey(long mailingListId)
2660 throws SystemException {
2661 return fetchByPrimaryKey((Serializable)mailingListId);
2662 }
2663
2664
2670 public List<MBMailingList> findAll() throws SystemException {
2671 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2672 }
2673
2674
2686 public List<MBMailingList> findAll(int start, int end)
2687 throws SystemException {
2688 return findAll(start, end, null);
2689 }
2690
2691
2704 public List<MBMailingList> findAll(int start, int end,
2705 OrderByComparator orderByComparator) throws SystemException {
2706 boolean pagination = true;
2707 FinderPath finderPath = null;
2708 Object[] finderArgs = null;
2709
2710 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2711 (orderByComparator == null)) {
2712 pagination = false;
2713 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2714 finderArgs = FINDER_ARGS_EMPTY;
2715 }
2716 else {
2717 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2718 finderArgs = new Object[] { start, end, orderByComparator };
2719 }
2720
2721 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
2722 finderArgs, this);
2723
2724 if (list == null) {
2725 StringBundler query = null;
2726 String sql = null;
2727
2728 if (orderByComparator != null) {
2729 query = new StringBundler(2 +
2730 (orderByComparator.getOrderByFields().length * 3));
2731
2732 query.append(_SQL_SELECT_MBMAILINGLIST);
2733
2734 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2735 orderByComparator);
2736
2737 sql = query.toString();
2738 }
2739 else {
2740 sql = _SQL_SELECT_MBMAILINGLIST;
2741
2742 if (pagination) {
2743 sql = sql.concat(MBMailingListModelImpl.ORDER_BY_JPQL);
2744 }
2745 }
2746
2747 Session session = null;
2748
2749 try {
2750 session = openSession();
2751
2752 Query q = session.createQuery(sql);
2753
2754 if (!pagination) {
2755 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
2756 start, end, false);
2757
2758 Collections.sort(list);
2759
2760 list = new UnmodifiableList<MBMailingList>(list);
2761 }
2762 else {
2763 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
2764 start, end);
2765 }
2766
2767 cacheResult(list);
2768
2769 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2770 }
2771 catch (Exception e) {
2772 FinderCacheUtil.removeResult(finderPath, finderArgs);
2773
2774 throw processException(e);
2775 }
2776 finally {
2777 closeSession(session);
2778 }
2779 }
2780
2781 return list;
2782 }
2783
2784
2789 public void removeAll() throws SystemException {
2790 for (MBMailingList mbMailingList : findAll()) {
2791 remove(mbMailingList);
2792 }
2793 }
2794
2795
2801 public int countAll() throws SystemException {
2802 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2803 FINDER_ARGS_EMPTY, this);
2804
2805 if (count == null) {
2806 Session session = null;
2807
2808 try {
2809 session = openSession();
2810
2811 Query q = session.createQuery(_SQL_COUNT_MBMAILINGLIST);
2812
2813 count = (Long)q.uniqueResult();
2814
2815 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2816 FINDER_ARGS_EMPTY, count);
2817 }
2818 catch (Exception e) {
2819 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2820 FINDER_ARGS_EMPTY);
2821
2822 throw processException(e);
2823 }
2824 finally {
2825 closeSession(session);
2826 }
2827 }
2828
2829 return count.intValue();
2830 }
2831
2832 @Override
2833 protected Set<String> getBadColumnNames() {
2834 return _badColumnNames;
2835 }
2836
2837
2840 public void afterPropertiesSet() {
2841 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2842 com.liferay.portal.util.PropsUtil.get(
2843 "value.object.listener.com.liferay.portlet.messageboards.model.MBMailingList")));
2844
2845 if (listenerClassNames.length > 0) {
2846 try {
2847 List<ModelListener<MBMailingList>> listenersList = new ArrayList<ModelListener<MBMailingList>>();
2848
2849 for (String listenerClassName : listenerClassNames) {
2850 listenersList.add((ModelListener<MBMailingList>)InstanceFactory.newInstance(
2851 getClassLoader(), listenerClassName));
2852 }
2853
2854 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2855 }
2856 catch (Exception e) {
2857 _log.error(e);
2858 }
2859 }
2860 }
2861
2862 public void destroy() {
2863 EntityCacheUtil.removeCache(MBMailingListImpl.class.getName());
2864 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2865 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2866 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2867 }
2868
2869 private static final String _SQL_SELECT_MBMAILINGLIST = "SELECT mbMailingList FROM MBMailingList mbMailingList";
2870 private static final String _SQL_SELECT_MBMAILINGLIST_WHERE = "SELECT mbMailingList FROM MBMailingList mbMailingList WHERE ";
2871 private static final String _SQL_COUNT_MBMAILINGLIST = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList";
2872 private static final String _SQL_COUNT_MBMAILINGLIST_WHERE = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList WHERE ";
2873 private static final String _ORDER_BY_ENTITY_ALIAS = "mbMailingList.";
2874 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBMailingList exists with the primary key ";
2875 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBMailingList exists with the key {";
2876 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2877 private static Log _log = LogFactoryUtil.getLog(MBMailingListPersistenceImpl.class);
2878 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2879 "uuid", "active"
2880 });
2881 private static MBMailingList _nullMBMailingList = new MBMailingListImpl() {
2882 @Override
2883 public Object clone() {
2884 return this;
2885 }
2886
2887 @Override
2888 public CacheModel<MBMailingList> toCacheModel() {
2889 return _nullMBMailingListCacheModel;
2890 }
2891 };
2892
2893 private static CacheModel<MBMailingList> _nullMBMailingListCacheModel = new CacheModel<MBMailingList>() {
2894 public MBMailingList toEntityModel() {
2895 return _nullMBMailingList;
2896 }
2897 };
2898 }