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