001
014
015 package com.liferay.portlet.messageboards.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.service.persistence.BatchSessionUtil;
041 import com.liferay.portal.service.persistence.ResourcePersistence;
042 import com.liferay.portal.service.persistence.UserPersistence;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import com.liferay.portlet.messageboards.NoSuchMailingListException;
046 import com.liferay.portlet.messageboards.model.MBMailingList;
047 import com.liferay.portlet.messageboards.model.impl.MBMailingListImpl;
048 import com.liferay.portlet.messageboards.model.impl.MBMailingListModelImpl;
049
050 import java.io.Serializable;
051
052 import java.util.ArrayList;
053 import java.util.Collections;
054 import java.util.List;
055
056
068 public class MBMailingListPersistenceImpl extends BasePersistenceImpl<MBMailingList>
069 implements MBMailingListPersistence {
070
075 public static final String FINDER_CLASS_NAME_ENTITY = MBMailingListImpl.class.getName();
076 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List1";
078 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List2";
080 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
081 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
082 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
083 "findByUuid",
084 new String[] {
085 String.class.getName(),
086
087 "java.lang.Integer", "java.lang.Integer",
088 "com.liferay.portal.kernel.util.OrderByComparator"
089 });
090 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
091 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
092 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
093 "findByUuid", new String[] { String.class.getName() },
094 MBMailingListModelImpl.UUID_COLUMN_BITMASK);
095 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
096 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
097 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
098 new String[] { String.class.getName() });
099 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
100 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
101 MBMailingListImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
102 new String[] { String.class.getName(), Long.class.getName() },
103 MBMailingListModelImpl.UUID_COLUMN_BITMASK |
104 MBMailingListModelImpl.GROUPID_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
106 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
108 new String[] { String.class.getName(), Long.class.getName() });
109 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
110 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
111 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
112 "findByActive",
113 new String[] {
114 Boolean.class.getName(),
115
116 "java.lang.Integer", "java.lang.Integer",
117 "com.liferay.portal.kernel.util.OrderByComparator"
118 });
119 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE =
120 new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
121 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
122 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
123 "findByActive", new String[] { Boolean.class.getName() },
124 MBMailingListModelImpl.ACTIVE_COLUMN_BITMASK);
125 public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
126 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByActive",
128 new String[] { Boolean.class.getName() });
129 public static final FinderPath FINDER_PATH_FETCH_BY_G_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
130 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
131 MBMailingListImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C",
132 new String[] { Long.class.getName(), Long.class.getName() },
133 MBMailingListModelImpl.GROUPID_COLUMN_BITMASK |
134 MBMailingListModelImpl.CATEGORYID_COLUMN_BITMASK);
135 public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
136 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
137 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C",
138 new String[] { Long.class.getName(), Long.class.getName() });
139 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
140 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
141 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
142 "findAll", new String[0]);
143 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
144 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
145 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
146 "findAll", new String[0]);
147 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
148 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
149 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
150
151
156 public void cacheResult(MBMailingList mbMailingList) {
157 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
158 MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
159 mbMailingList);
160
161 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
162 new Object[] {
163 mbMailingList.getUuid(),
164 Long.valueOf(mbMailingList.getGroupId())
165 }, mbMailingList);
166
167 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
168 new Object[] {
169 Long.valueOf(mbMailingList.getGroupId()),
170 Long.valueOf(mbMailingList.getCategoryId())
171 }, mbMailingList);
172
173 mbMailingList.resetOriginalValues();
174 }
175
176
181 public void cacheResult(List<MBMailingList> mbMailingLists) {
182 for (MBMailingList mbMailingList : mbMailingLists) {
183 if (EntityCacheUtil.getResult(
184 MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
185 MBMailingListImpl.class, mbMailingList.getPrimaryKey()) == null) {
186 cacheResult(mbMailingList);
187 }
188 else {
189 mbMailingList.resetOriginalValues();
190 }
191 }
192 }
193
194
201 @Override
202 public void clearCache() {
203 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
204 CacheRegistryUtil.clear(MBMailingListImpl.class.getName());
205 }
206
207 EntityCacheUtil.clearCache(MBMailingListImpl.class.getName());
208
209 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
210 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
211 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
212 }
213
214
221 @Override
222 public void clearCache(MBMailingList mbMailingList) {
223 EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
224 MBMailingListImpl.class, mbMailingList.getPrimaryKey());
225
226 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
227 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
228
229 clearUniqueFindersCache(mbMailingList);
230 }
231
232 @Override
233 public void clearCache(List<MBMailingList> mbMailingLists) {
234 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
235 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
236
237 for (MBMailingList mbMailingList : mbMailingLists) {
238 EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
239 MBMailingListImpl.class, mbMailingList.getPrimaryKey());
240
241 clearUniqueFindersCache(mbMailingList);
242 }
243 }
244
245 protected void clearUniqueFindersCache(MBMailingList mbMailingList) {
246 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
247 new Object[] {
248 mbMailingList.getUuid(),
249 Long.valueOf(mbMailingList.getGroupId())
250 });
251
252 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C,
253 new Object[] {
254 Long.valueOf(mbMailingList.getGroupId()),
255 Long.valueOf(mbMailingList.getCategoryId())
256 });
257 }
258
259
265 public MBMailingList create(long mailingListId) {
266 MBMailingList mbMailingList = new MBMailingListImpl();
267
268 mbMailingList.setNew(true);
269 mbMailingList.setPrimaryKey(mailingListId);
270
271 String uuid = PortalUUIDUtil.generate();
272
273 mbMailingList.setUuid(uuid);
274
275 return mbMailingList;
276 }
277
278
286 public MBMailingList remove(long mailingListId)
287 throws NoSuchMailingListException, SystemException {
288 return remove(Long.valueOf(mailingListId));
289 }
290
291
299 @Override
300 public MBMailingList remove(Serializable primaryKey)
301 throws NoSuchMailingListException, SystemException {
302 Session session = null;
303
304 try {
305 session = openSession();
306
307 MBMailingList mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
308 primaryKey);
309
310 if (mbMailingList == null) {
311 if (_log.isWarnEnabled()) {
312 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
313 }
314
315 throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
316 primaryKey);
317 }
318
319 return remove(mbMailingList);
320 }
321 catch (NoSuchMailingListException nsee) {
322 throw nsee;
323 }
324 catch (Exception e) {
325 throw processException(e);
326 }
327 finally {
328 closeSession(session);
329 }
330 }
331
332 @Override
333 protected MBMailingList removeImpl(MBMailingList mbMailingList)
334 throws SystemException {
335 mbMailingList = toUnwrappedModel(mbMailingList);
336
337 Session session = null;
338
339 try {
340 session = openSession();
341
342 BatchSessionUtil.delete(session, mbMailingList);
343 }
344 catch (Exception e) {
345 throw processException(e);
346 }
347 finally {
348 closeSession(session);
349 }
350
351 clearCache(mbMailingList);
352
353 return mbMailingList;
354 }
355
356 @Override
357 public MBMailingList updateImpl(
358 com.liferay.portlet.messageboards.model.MBMailingList mbMailingList,
359 boolean merge) throws SystemException {
360 mbMailingList = toUnwrappedModel(mbMailingList);
361
362 boolean isNew = mbMailingList.isNew();
363
364 MBMailingListModelImpl mbMailingListModelImpl = (MBMailingListModelImpl)mbMailingList;
365
366 if (Validator.isNull(mbMailingList.getUuid())) {
367 String uuid = PortalUUIDUtil.generate();
368
369 mbMailingList.setUuid(uuid);
370 }
371
372 Session session = null;
373
374 try {
375 session = openSession();
376
377 BatchSessionUtil.update(session, mbMailingList, merge);
378
379 mbMailingList.setNew(false);
380 }
381 catch (Exception e) {
382 throw processException(e);
383 }
384 finally {
385 closeSession(session);
386 }
387
388 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
389
390 if (isNew || !MBMailingListModelImpl.COLUMN_BITMASK_ENABLED) {
391 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
392 }
393
394 else {
395 if ((mbMailingListModelImpl.getColumnBitmask() &
396 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
397 Object[] args = new Object[] {
398 mbMailingListModelImpl.getOriginalUuid()
399 };
400
401 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
402 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
403 args);
404
405 args = new Object[] { mbMailingListModelImpl.getUuid() };
406
407 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
408 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
409 args);
410 }
411
412 if ((mbMailingListModelImpl.getColumnBitmask() &
413 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE.getColumnBitmask()) != 0) {
414 Object[] args = new Object[] {
415 Boolean.valueOf(mbMailingListModelImpl.getOriginalActive())
416 };
417
418 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
419 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
420 args);
421
422 args = new Object[] {
423 Boolean.valueOf(mbMailingListModelImpl.getActive())
424 };
425
426 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
427 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
428 args);
429 }
430 }
431
432 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
433 MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
434 mbMailingList);
435
436 if (isNew) {
437 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
438 new Object[] {
439 mbMailingList.getUuid(),
440 Long.valueOf(mbMailingList.getGroupId())
441 }, mbMailingList);
442
443 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
444 new Object[] {
445 Long.valueOf(mbMailingList.getGroupId()),
446 Long.valueOf(mbMailingList.getCategoryId())
447 }, mbMailingList);
448 }
449 else {
450 if ((mbMailingListModelImpl.getColumnBitmask() &
451 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
452 Object[] args = new Object[] {
453 mbMailingListModelImpl.getOriginalUuid(),
454 Long.valueOf(mbMailingListModelImpl.getOriginalGroupId())
455 };
456
457 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
458 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
459
460 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
461 new Object[] {
462 mbMailingList.getUuid(),
463 Long.valueOf(mbMailingList.getGroupId())
464 }, mbMailingList);
465 }
466
467 if ((mbMailingListModelImpl.getColumnBitmask() &
468 FINDER_PATH_FETCH_BY_G_C.getColumnBitmask()) != 0) {
469 Object[] args = new Object[] {
470 Long.valueOf(mbMailingListModelImpl.getOriginalGroupId()),
471 Long.valueOf(mbMailingListModelImpl.getOriginalCategoryId())
472 };
473
474 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
475 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C, args);
476
477 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
478 new Object[] {
479 Long.valueOf(mbMailingList.getGroupId()),
480 Long.valueOf(mbMailingList.getCategoryId())
481 }, mbMailingList);
482 }
483 }
484
485 return mbMailingList;
486 }
487
488 protected MBMailingList toUnwrappedModel(MBMailingList mbMailingList) {
489 if (mbMailingList instanceof MBMailingListImpl) {
490 return mbMailingList;
491 }
492
493 MBMailingListImpl mbMailingListImpl = new MBMailingListImpl();
494
495 mbMailingListImpl.setNew(mbMailingList.isNew());
496 mbMailingListImpl.setPrimaryKey(mbMailingList.getPrimaryKey());
497
498 mbMailingListImpl.setUuid(mbMailingList.getUuid());
499 mbMailingListImpl.setMailingListId(mbMailingList.getMailingListId());
500 mbMailingListImpl.setGroupId(mbMailingList.getGroupId());
501 mbMailingListImpl.setCompanyId(mbMailingList.getCompanyId());
502 mbMailingListImpl.setUserId(mbMailingList.getUserId());
503 mbMailingListImpl.setUserName(mbMailingList.getUserName());
504 mbMailingListImpl.setCreateDate(mbMailingList.getCreateDate());
505 mbMailingListImpl.setModifiedDate(mbMailingList.getModifiedDate());
506 mbMailingListImpl.setCategoryId(mbMailingList.getCategoryId());
507 mbMailingListImpl.setEmailAddress(mbMailingList.getEmailAddress());
508 mbMailingListImpl.setInProtocol(mbMailingList.getInProtocol());
509 mbMailingListImpl.setInServerName(mbMailingList.getInServerName());
510 mbMailingListImpl.setInServerPort(mbMailingList.getInServerPort());
511 mbMailingListImpl.setInUseSSL(mbMailingList.isInUseSSL());
512 mbMailingListImpl.setInUserName(mbMailingList.getInUserName());
513 mbMailingListImpl.setInPassword(mbMailingList.getInPassword());
514 mbMailingListImpl.setInReadInterval(mbMailingList.getInReadInterval());
515 mbMailingListImpl.setOutEmailAddress(mbMailingList.getOutEmailAddress());
516 mbMailingListImpl.setOutCustom(mbMailingList.isOutCustom());
517 mbMailingListImpl.setOutServerName(mbMailingList.getOutServerName());
518 mbMailingListImpl.setOutServerPort(mbMailingList.getOutServerPort());
519 mbMailingListImpl.setOutUseSSL(mbMailingList.isOutUseSSL());
520 mbMailingListImpl.setOutUserName(mbMailingList.getOutUserName());
521 mbMailingListImpl.setOutPassword(mbMailingList.getOutPassword());
522 mbMailingListImpl.setAllowAnonymous(mbMailingList.isAllowAnonymous());
523 mbMailingListImpl.setActive(mbMailingList.isActive());
524
525 return mbMailingListImpl;
526 }
527
528
536 @Override
537 public MBMailingList findByPrimaryKey(Serializable primaryKey)
538 throws NoSuchModelException, SystemException {
539 return findByPrimaryKey(((Long)primaryKey).longValue());
540 }
541
542
550 public MBMailingList findByPrimaryKey(long mailingListId)
551 throws NoSuchMailingListException, SystemException {
552 MBMailingList mbMailingList = fetchByPrimaryKey(mailingListId);
553
554 if (mbMailingList == null) {
555 if (_log.isWarnEnabled()) {
556 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + mailingListId);
557 }
558
559 throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
560 mailingListId);
561 }
562
563 return mbMailingList;
564 }
565
566
573 @Override
574 public MBMailingList fetchByPrimaryKey(Serializable primaryKey)
575 throws SystemException {
576 return fetchByPrimaryKey(((Long)primaryKey).longValue());
577 }
578
579
586 public MBMailingList fetchByPrimaryKey(long mailingListId)
587 throws SystemException {
588 MBMailingList mbMailingList = (MBMailingList)EntityCacheUtil.getResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
589 MBMailingListImpl.class, mailingListId);
590
591 if (mbMailingList == _nullMBMailingList) {
592 return null;
593 }
594
595 if (mbMailingList == null) {
596 Session session = null;
597
598 boolean hasException = false;
599
600 try {
601 session = openSession();
602
603 mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
604 Long.valueOf(mailingListId));
605 }
606 catch (Exception e) {
607 hasException = true;
608
609 throw processException(e);
610 }
611 finally {
612 if (mbMailingList != null) {
613 cacheResult(mbMailingList);
614 }
615 else if (!hasException) {
616 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
617 MBMailingListImpl.class, mailingListId,
618 _nullMBMailingList);
619 }
620
621 closeSession(session);
622 }
623 }
624
625 return mbMailingList;
626 }
627
628
635 public List<MBMailingList> findByUuid(String uuid)
636 throws SystemException {
637 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
638 }
639
640
653 public List<MBMailingList> findByUuid(String uuid, int start, int end)
654 throws SystemException {
655 return findByUuid(uuid, start, end, null);
656 }
657
658
672 public List<MBMailingList> findByUuid(String uuid, int start, int end,
673 OrderByComparator orderByComparator) throws SystemException {
674 FinderPath finderPath = null;
675 Object[] finderArgs = null;
676
677 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
678 (orderByComparator == null)) {
679 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
680 finderArgs = new Object[] { uuid };
681 }
682 else {
683 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
684 finderArgs = new Object[] { uuid, start, end, orderByComparator };
685 }
686
687 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
688 finderArgs, this);
689
690 if (list == null) {
691 StringBundler query = null;
692
693 if (orderByComparator != null) {
694 query = new StringBundler(3 +
695 (orderByComparator.getOrderByFields().length * 3));
696 }
697 else {
698 query = new StringBundler(2);
699 }
700
701 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
702
703 if (uuid == null) {
704 query.append(_FINDER_COLUMN_UUID_UUID_1);
705 }
706 else {
707 if (uuid.equals(StringPool.BLANK)) {
708 query.append(_FINDER_COLUMN_UUID_UUID_3);
709 }
710 else {
711 query.append(_FINDER_COLUMN_UUID_UUID_2);
712 }
713 }
714
715 if (orderByComparator != null) {
716 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
717 orderByComparator);
718 }
719
720 String sql = query.toString();
721
722 Session session = null;
723
724 try {
725 session = openSession();
726
727 Query q = session.createQuery(sql);
728
729 QueryPos qPos = QueryPos.getInstance(q);
730
731 if (uuid != null) {
732 qPos.add(uuid);
733 }
734
735 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
736 start, end);
737 }
738 catch (Exception e) {
739 throw processException(e);
740 }
741 finally {
742 if (list == null) {
743 FinderCacheUtil.removeResult(finderPath, finderArgs);
744 }
745 else {
746 cacheResult(list);
747
748 FinderCacheUtil.putResult(finderPath, finderArgs, list);
749 }
750
751 closeSession(session);
752 }
753 }
754
755 return list;
756 }
757
758
771 public MBMailingList findByUuid_First(String uuid,
772 OrderByComparator orderByComparator)
773 throws NoSuchMailingListException, SystemException {
774 List<MBMailingList> list = findByUuid(uuid, 0, 1, orderByComparator);
775
776 if (list.isEmpty()) {
777 StringBundler msg = new StringBundler(4);
778
779 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
780
781 msg.append("uuid=");
782 msg.append(uuid);
783
784 msg.append(StringPool.CLOSE_CURLY_BRACE);
785
786 throw new NoSuchMailingListException(msg.toString());
787 }
788 else {
789 return list.get(0);
790 }
791 }
792
793
806 public MBMailingList findByUuid_Last(String uuid,
807 OrderByComparator orderByComparator)
808 throws NoSuchMailingListException, SystemException {
809 int count = countByUuid(uuid);
810
811 List<MBMailingList> list = findByUuid(uuid, count - 1, count,
812 orderByComparator);
813
814 if (list.isEmpty()) {
815 StringBundler msg = new StringBundler(4);
816
817 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
818
819 msg.append("uuid=");
820 msg.append(uuid);
821
822 msg.append(StringPool.CLOSE_CURLY_BRACE);
823
824 throw new NoSuchMailingListException(msg.toString());
825 }
826 else {
827 return list.get(0);
828 }
829 }
830
831
845 public MBMailingList[] findByUuid_PrevAndNext(long mailingListId,
846 String uuid, OrderByComparator orderByComparator)
847 throws NoSuchMailingListException, SystemException {
848 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
849
850 Session session = null;
851
852 try {
853 session = openSession();
854
855 MBMailingList[] array = new MBMailingListImpl[3];
856
857 array[0] = getByUuid_PrevAndNext(session, mbMailingList, uuid,
858 orderByComparator, true);
859
860 array[1] = mbMailingList;
861
862 array[2] = getByUuid_PrevAndNext(session, mbMailingList, uuid,
863 orderByComparator, false);
864
865 return array;
866 }
867 catch (Exception e) {
868 throw processException(e);
869 }
870 finally {
871 closeSession(session);
872 }
873 }
874
875 protected MBMailingList getByUuid_PrevAndNext(Session session,
876 MBMailingList mbMailingList, String uuid,
877 OrderByComparator orderByComparator, boolean previous) {
878 StringBundler query = null;
879
880 if (orderByComparator != null) {
881 query = new StringBundler(6 +
882 (orderByComparator.getOrderByFields().length * 6));
883 }
884 else {
885 query = new StringBundler(3);
886 }
887
888 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
889
890 if (uuid == null) {
891 query.append(_FINDER_COLUMN_UUID_UUID_1);
892 }
893 else {
894 if (uuid.equals(StringPool.BLANK)) {
895 query.append(_FINDER_COLUMN_UUID_UUID_3);
896 }
897 else {
898 query.append(_FINDER_COLUMN_UUID_UUID_2);
899 }
900 }
901
902 if (orderByComparator != null) {
903 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
904
905 if (orderByConditionFields.length > 0) {
906 query.append(WHERE_AND);
907 }
908
909 for (int i = 0; i < orderByConditionFields.length; i++) {
910 query.append(_ORDER_BY_ENTITY_ALIAS);
911 query.append(orderByConditionFields[i]);
912
913 if ((i + 1) < orderByConditionFields.length) {
914 if (orderByComparator.isAscending() ^ previous) {
915 query.append(WHERE_GREATER_THAN_HAS_NEXT);
916 }
917 else {
918 query.append(WHERE_LESSER_THAN_HAS_NEXT);
919 }
920 }
921 else {
922 if (orderByComparator.isAscending() ^ previous) {
923 query.append(WHERE_GREATER_THAN);
924 }
925 else {
926 query.append(WHERE_LESSER_THAN);
927 }
928 }
929 }
930
931 query.append(ORDER_BY_CLAUSE);
932
933 String[] orderByFields = orderByComparator.getOrderByFields();
934
935 for (int i = 0; i < orderByFields.length; i++) {
936 query.append(_ORDER_BY_ENTITY_ALIAS);
937 query.append(orderByFields[i]);
938
939 if ((i + 1) < orderByFields.length) {
940 if (orderByComparator.isAscending() ^ previous) {
941 query.append(ORDER_BY_ASC_HAS_NEXT);
942 }
943 else {
944 query.append(ORDER_BY_DESC_HAS_NEXT);
945 }
946 }
947 else {
948 if (orderByComparator.isAscending() ^ previous) {
949 query.append(ORDER_BY_ASC);
950 }
951 else {
952 query.append(ORDER_BY_DESC);
953 }
954 }
955 }
956 }
957
958 String sql = query.toString();
959
960 Query q = session.createQuery(sql);
961
962 q.setFirstResult(0);
963 q.setMaxResults(2);
964
965 QueryPos qPos = QueryPos.getInstance(q);
966
967 if (uuid != null) {
968 qPos.add(uuid);
969 }
970
971 if (orderByComparator != null) {
972 Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
973
974 for (Object value : values) {
975 qPos.add(value);
976 }
977 }
978
979 List<MBMailingList> list = q.list();
980
981 if (list.size() == 2) {
982 return list.get(1);
983 }
984 else {
985 return null;
986 }
987 }
988
989
998 public MBMailingList findByUUID_G(String uuid, long groupId)
999 throws NoSuchMailingListException, SystemException {
1000 MBMailingList mbMailingList = fetchByUUID_G(uuid, groupId);
1001
1002 if (mbMailingList == null) {
1003 StringBundler msg = new StringBundler(6);
1004
1005 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1006
1007 msg.append("uuid=");
1008 msg.append(uuid);
1009
1010 msg.append(", groupId=");
1011 msg.append(groupId);
1012
1013 msg.append(StringPool.CLOSE_CURLY_BRACE);
1014
1015 if (_log.isWarnEnabled()) {
1016 _log.warn(msg.toString());
1017 }
1018
1019 throw new NoSuchMailingListException(msg.toString());
1020 }
1021
1022 return mbMailingList;
1023 }
1024
1025
1033 public MBMailingList fetchByUUID_G(String uuid, long groupId)
1034 throws SystemException {
1035 return fetchByUUID_G(uuid, groupId, true);
1036 }
1037
1038
1047 public MBMailingList fetchByUUID_G(String uuid, long groupId,
1048 boolean retrieveFromCache) throws SystemException {
1049 Object[] finderArgs = new Object[] { uuid, groupId };
1050
1051 Object result = null;
1052
1053 if (retrieveFromCache) {
1054 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1055 finderArgs, this);
1056 }
1057
1058 if (result == null) {
1059 StringBundler query = new StringBundler(3);
1060
1061 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1062
1063 if (uuid == null) {
1064 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1065 }
1066 else {
1067 if (uuid.equals(StringPool.BLANK)) {
1068 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1069 }
1070 else {
1071 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1072 }
1073 }
1074
1075 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1076
1077 String sql = query.toString();
1078
1079 Session session = null;
1080
1081 try {
1082 session = openSession();
1083
1084 Query q = session.createQuery(sql);
1085
1086 QueryPos qPos = QueryPos.getInstance(q);
1087
1088 if (uuid != null) {
1089 qPos.add(uuid);
1090 }
1091
1092 qPos.add(groupId);
1093
1094 List<MBMailingList> list = q.list();
1095
1096 result = list;
1097
1098 MBMailingList mbMailingList = null;
1099
1100 if (list.isEmpty()) {
1101 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1102 finderArgs, list);
1103 }
1104 else {
1105 mbMailingList = list.get(0);
1106
1107 cacheResult(mbMailingList);
1108
1109 if ((mbMailingList.getUuid() == null) ||
1110 !mbMailingList.getUuid().equals(uuid) ||
1111 (mbMailingList.getGroupId() != groupId)) {
1112 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1113 finderArgs, mbMailingList);
1114 }
1115 }
1116
1117 return mbMailingList;
1118 }
1119 catch (Exception e) {
1120 throw processException(e);
1121 }
1122 finally {
1123 if (result == null) {
1124 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1125 finderArgs);
1126 }
1127
1128 closeSession(session);
1129 }
1130 }
1131 else {
1132 if (result instanceof List<?>) {
1133 return null;
1134 }
1135 else {
1136 return (MBMailingList)result;
1137 }
1138 }
1139 }
1140
1141
1148 public List<MBMailingList> findByActive(boolean active)
1149 throws SystemException {
1150 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1151 }
1152
1153
1166 public List<MBMailingList> findByActive(boolean active, int start, int end)
1167 throws SystemException {
1168 return findByActive(active, start, end, null);
1169 }
1170
1171
1185 public List<MBMailingList> findByActive(boolean active, int start, int end,
1186 OrderByComparator orderByComparator) throws SystemException {
1187 FinderPath finderPath = null;
1188 Object[] finderArgs = null;
1189
1190 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1191 (orderByComparator == null)) {
1192 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
1193 finderArgs = new Object[] { active };
1194 }
1195 else {
1196 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
1197 finderArgs = new Object[] { active, start, end, orderByComparator };
1198 }
1199
1200 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
1201 finderArgs, this);
1202
1203 if (list == null) {
1204 StringBundler query = null;
1205
1206 if (orderByComparator != null) {
1207 query = new StringBundler(3 +
1208 (orderByComparator.getOrderByFields().length * 3));
1209 }
1210 else {
1211 query = new StringBundler(2);
1212 }
1213
1214 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1215
1216 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1217
1218 if (orderByComparator != null) {
1219 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1220 orderByComparator);
1221 }
1222
1223 String sql = query.toString();
1224
1225 Session session = null;
1226
1227 try {
1228 session = openSession();
1229
1230 Query q = session.createQuery(sql);
1231
1232 QueryPos qPos = QueryPos.getInstance(q);
1233
1234 qPos.add(active);
1235
1236 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1237 start, end);
1238 }
1239 catch (Exception e) {
1240 throw processException(e);
1241 }
1242 finally {
1243 if (list == null) {
1244 FinderCacheUtil.removeResult(finderPath, finderArgs);
1245 }
1246 else {
1247 cacheResult(list);
1248
1249 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1250 }
1251
1252 closeSession(session);
1253 }
1254 }
1255
1256 return list;
1257 }
1258
1259
1272 public MBMailingList findByActive_First(boolean active,
1273 OrderByComparator orderByComparator)
1274 throws NoSuchMailingListException, SystemException {
1275 List<MBMailingList> list = findByActive(active, 0, 1, orderByComparator);
1276
1277 if (list.isEmpty()) {
1278 StringBundler msg = new StringBundler(4);
1279
1280 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1281
1282 msg.append("active=");
1283 msg.append(active);
1284
1285 msg.append(StringPool.CLOSE_CURLY_BRACE);
1286
1287 throw new NoSuchMailingListException(msg.toString());
1288 }
1289 else {
1290 return list.get(0);
1291 }
1292 }
1293
1294
1307 public MBMailingList findByActive_Last(boolean active,
1308 OrderByComparator orderByComparator)
1309 throws NoSuchMailingListException, SystemException {
1310 int count = countByActive(active);
1311
1312 List<MBMailingList> list = findByActive(active, count - 1, count,
1313 orderByComparator);
1314
1315 if (list.isEmpty()) {
1316 StringBundler msg = new StringBundler(4);
1317
1318 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1319
1320 msg.append("active=");
1321 msg.append(active);
1322
1323 msg.append(StringPool.CLOSE_CURLY_BRACE);
1324
1325 throw new NoSuchMailingListException(msg.toString());
1326 }
1327 else {
1328 return list.get(0);
1329 }
1330 }
1331
1332
1346 public MBMailingList[] findByActive_PrevAndNext(long mailingListId,
1347 boolean active, OrderByComparator orderByComparator)
1348 throws NoSuchMailingListException, SystemException {
1349 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
1350
1351 Session session = null;
1352
1353 try {
1354 session = openSession();
1355
1356 MBMailingList[] array = new MBMailingListImpl[3];
1357
1358 array[0] = getByActive_PrevAndNext(session, mbMailingList, active,
1359 orderByComparator, true);
1360
1361 array[1] = mbMailingList;
1362
1363 array[2] = getByActive_PrevAndNext(session, mbMailingList, active,
1364 orderByComparator, false);
1365
1366 return array;
1367 }
1368 catch (Exception e) {
1369 throw processException(e);
1370 }
1371 finally {
1372 closeSession(session);
1373 }
1374 }
1375
1376 protected MBMailingList getByActive_PrevAndNext(Session session,
1377 MBMailingList mbMailingList, boolean active,
1378 OrderByComparator orderByComparator, boolean previous) {
1379 StringBundler query = null;
1380
1381 if (orderByComparator != null) {
1382 query = new StringBundler(6 +
1383 (orderByComparator.getOrderByFields().length * 6));
1384 }
1385 else {
1386 query = new StringBundler(3);
1387 }
1388
1389 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1390
1391 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1392
1393 if (orderByComparator != null) {
1394 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1395
1396 if (orderByConditionFields.length > 0) {
1397 query.append(WHERE_AND);
1398 }
1399
1400 for (int i = 0; i < orderByConditionFields.length; i++) {
1401 query.append(_ORDER_BY_ENTITY_ALIAS);
1402 query.append(orderByConditionFields[i]);
1403
1404 if ((i + 1) < orderByConditionFields.length) {
1405 if (orderByComparator.isAscending() ^ previous) {
1406 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1407 }
1408 else {
1409 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1410 }
1411 }
1412 else {
1413 if (orderByComparator.isAscending() ^ previous) {
1414 query.append(WHERE_GREATER_THAN);
1415 }
1416 else {
1417 query.append(WHERE_LESSER_THAN);
1418 }
1419 }
1420 }
1421
1422 query.append(ORDER_BY_CLAUSE);
1423
1424 String[] orderByFields = orderByComparator.getOrderByFields();
1425
1426 for (int i = 0; i < orderByFields.length; i++) {
1427 query.append(_ORDER_BY_ENTITY_ALIAS);
1428 query.append(orderByFields[i]);
1429
1430 if ((i + 1) < orderByFields.length) {
1431 if (orderByComparator.isAscending() ^ previous) {
1432 query.append(ORDER_BY_ASC_HAS_NEXT);
1433 }
1434 else {
1435 query.append(ORDER_BY_DESC_HAS_NEXT);
1436 }
1437 }
1438 else {
1439 if (orderByComparator.isAscending() ^ previous) {
1440 query.append(ORDER_BY_ASC);
1441 }
1442 else {
1443 query.append(ORDER_BY_DESC);
1444 }
1445 }
1446 }
1447 }
1448
1449 String sql = query.toString();
1450
1451 Query q = session.createQuery(sql);
1452
1453 q.setFirstResult(0);
1454 q.setMaxResults(2);
1455
1456 QueryPos qPos = QueryPos.getInstance(q);
1457
1458 qPos.add(active);
1459
1460 if (orderByComparator != null) {
1461 Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
1462
1463 for (Object value : values) {
1464 qPos.add(value);
1465 }
1466 }
1467
1468 List<MBMailingList> list = q.list();
1469
1470 if (list.size() == 2) {
1471 return list.get(1);
1472 }
1473 else {
1474 return null;
1475 }
1476 }
1477
1478
1487 public MBMailingList findByG_C(long groupId, long categoryId)
1488 throws NoSuchMailingListException, SystemException {
1489 MBMailingList mbMailingList = fetchByG_C(groupId, categoryId);
1490
1491 if (mbMailingList == null) {
1492 StringBundler msg = new StringBundler(6);
1493
1494 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1495
1496 msg.append("groupId=");
1497 msg.append(groupId);
1498
1499 msg.append(", categoryId=");
1500 msg.append(categoryId);
1501
1502 msg.append(StringPool.CLOSE_CURLY_BRACE);
1503
1504 if (_log.isWarnEnabled()) {
1505 _log.warn(msg.toString());
1506 }
1507
1508 throw new NoSuchMailingListException(msg.toString());
1509 }
1510
1511 return mbMailingList;
1512 }
1513
1514
1522 public MBMailingList fetchByG_C(long groupId, long categoryId)
1523 throws SystemException {
1524 return fetchByG_C(groupId, categoryId, true);
1525 }
1526
1527
1536 public MBMailingList fetchByG_C(long groupId, long categoryId,
1537 boolean retrieveFromCache) throws SystemException {
1538 Object[] finderArgs = new Object[] { groupId, categoryId };
1539
1540 Object result = null;
1541
1542 if (retrieveFromCache) {
1543 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C,
1544 finderArgs, this);
1545 }
1546
1547 if (result == null) {
1548 StringBundler query = new StringBundler(3);
1549
1550 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1551
1552 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1553
1554 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1555
1556 String sql = query.toString();
1557
1558 Session session = null;
1559
1560 try {
1561 session = openSession();
1562
1563 Query q = session.createQuery(sql);
1564
1565 QueryPos qPos = QueryPos.getInstance(q);
1566
1567 qPos.add(groupId);
1568
1569 qPos.add(categoryId);
1570
1571 List<MBMailingList> list = q.list();
1572
1573 result = list;
1574
1575 MBMailingList mbMailingList = null;
1576
1577 if (list.isEmpty()) {
1578 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
1579 finderArgs, list);
1580 }
1581 else {
1582 mbMailingList = list.get(0);
1583
1584 cacheResult(mbMailingList);
1585
1586 if ((mbMailingList.getGroupId() != groupId) ||
1587 (mbMailingList.getCategoryId() != categoryId)) {
1588 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
1589 finderArgs, mbMailingList);
1590 }
1591 }
1592
1593 return mbMailingList;
1594 }
1595 catch (Exception e) {
1596 throw processException(e);
1597 }
1598 finally {
1599 if (result == null) {
1600 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C,
1601 finderArgs);
1602 }
1603
1604 closeSession(session);
1605 }
1606 }
1607 else {
1608 if (result instanceof List<?>) {
1609 return null;
1610 }
1611 else {
1612 return (MBMailingList)result;
1613 }
1614 }
1615 }
1616
1617
1623 public List<MBMailingList> findAll() throws SystemException {
1624 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1625 }
1626
1627
1639 public List<MBMailingList> findAll(int start, int end)
1640 throws SystemException {
1641 return findAll(start, end, null);
1642 }
1643
1644
1657 public List<MBMailingList> findAll(int start, int end,
1658 OrderByComparator orderByComparator) throws SystemException {
1659 FinderPath finderPath = null;
1660 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1661
1662 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1663 (orderByComparator == null)) {
1664 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1665 finderArgs = FINDER_ARGS_EMPTY;
1666 }
1667 else {
1668 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1669 finderArgs = new Object[] { start, end, orderByComparator };
1670 }
1671
1672 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
1673 finderArgs, this);
1674
1675 if (list == null) {
1676 StringBundler query = null;
1677 String sql = null;
1678
1679 if (orderByComparator != null) {
1680 query = new StringBundler(2 +
1681 (orderByComparator.getOrderByFields().length * 3));
1682
1683 query.append(_SQL_SELECT_MBMAILINGLIST);
1684
1685 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1686 orderByComparator);
1687
1688 sql = query.toString();
1689 }
1690 else {
1691 sql = _SQL_SELECT_MBMAILINGLIST;
1692 }
1693
1694 Session session = null;
1695
1696 try {
1697 session = openSession();
1698
1699 Query q = session.createQuery(sql);
1700
1701 if (orderByComparator == null) {
1702 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1703 start, end, false);
1704
1705 Collections.sort(list);
1706 }
1707 else {
1708 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1709 start, end);
1710 }
1711 }
1712 catch (Exception e) {
1713 throw processException(e);
1714 }
1715 finally {
1716 if (list == null) {
1717 FinderCacheUtil.removeResult(finderPath, finderArgs);
1718 }
1719 else {
1720 cacheResult(list);
1721
1722 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1723 }
1724
1725 closeSession(session);
1726 }
1727 }
1728
1729 return list;
1730 }
1731
1732
1738 public void removeByUuid(String uuid) throws SystemException {
1739 for (MBMailingList mbMailingList : findByUuid(uuid)) {
1740 remove(mbMailingList);
1741 }
1742 }
1743
1744
1751 public void removeByUUID_G(String uuid, long groupId)
1752 throws NoSuchMailingListException, SystemException {
1753 MBMailingList mbMailingList = findByUUID_G(uuid, groupId);
1754
1755 remove(mbMailingList);
1756 }
1757
1758
1764 public void removeByActive(boolean active) throws SystemException {
1765 for (MBMailingList mbMailingList : findByActive(active)) {
1766 remove(mbMailingList);
1767 }
1768 }
1769
1770
1777 public void removeByG_C(long groupId, long categoryId)
1778 throws NoSuchMailingListException, SystemException {
1779 MBMailingList mbMailingList = findByG_C(groupId, categoryId);
1780
1781 remove(mbMailingList);
1782 }
1783
1784
1789 public void removeAll() throws SystemException {
1790 for (MBMailingList mbMailingList : findAll()) {
1791 remove(mbMailingList);
1792 }
1793 }
1794
1795
1802 public int countByUuid(String uuid) throws SystemException {
1803 Object[] finderArgs = new Object[] { uuid };
1804
1805 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1806 finderArgs, this);
1807
1808 if (count == null) {
1809 StringBundler query = new StringBundler(2);
1810
1811 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1812
1813 if (uuid == null) {
1814 query.append(_FINDER_COLUMN_UUID_UUID_1);
1815 }
1816 else {
1817 if (uuid.equals(StringPool.BLANK)) {
1818 query.append(_FINDER_COLUMN_UUID_UUID_3);
1819 }
1820 else {
1821 query.append(_FINDER_COLUMN_UUID_UUID_2);
1822 }
1823 }
1824
1825 String sql = query.toString();
1826
1827 Session session = null;
1828
1829 try {
1830 session = openSession();
1831
1832 Query q = session.createQuery(sql);
1833
1834 QueryPos qPos = QueryPos.getInstance(q);
1835
1836 if (uuid != null) {
1837 qPos.add(uuid);
1838 }
1839
1840 count = (Long)q.uniqueResult();
1841 }
1842 catch (Exception e) {
1843 throw processException(e);
1844 }
1845 finally {
1846 if (count == null) {
1847 count = Long.valueOf(0);
1848 }
1849
1850 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1851 finderArgs, count);
1852
1853 closeSession(session);
1854 }
1855 }
1856
1857 return count.intValue();
1858 }
1859
1860
1868 public int countByUUID_G(String uuid, long groupId)
1869 throws SystemException {
1870 Object[] finderArgs = new Object[] { uuid, groupId };
1871
1872 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1873 finderArgs, this);
1874
1875 if (count == null) {
1876 StringBundler query = new StringBundler(3);
1877
1878 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1879
1880 if (uuid == null) {
1881 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1882 }
1883 else {
1884 if (uuid.equals(StringPool.BLANK)) {
1885 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1886 }
1887 else {
1888 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1889 }
1890 }
1891
1892 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1893
1894 String sql = query.toString();
1895
1896 Session session = null;
1897
1898 try {
1899 session = openSession();
1900
1901 Query q = session.createQuery(sql);
1902
1903 QueryPos qPos = QueryPos.getInstance(q);
1904
1905 if (uuid != null) {
1906 qPos.add(uuid);
1907 }
1908
1909 qPos.add(groupId);
1910
1911 count = (Long)q.uniqueResult();
1912 }
1913 catch (Exception e) {
1914 throw processException(e);
1915 }
1916 finally {
1917 if (count == null) {
1918 count = Long.valueOf(0);
1919 }
1920
1921 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1922 finderArgs, count);
1923
1924 closeSession(session);
1925 }
1926 }
1927
1928 return count.intValue();
1929 }
1930
1931
1938 public int countByActive(boolean active) throws SystemException {
1939 Object[] finderArgs = new Object[] { active };
1940
1941 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
1942 finderArgs, this);
1943
1944 if (count == null) {
1945 StringBundler query = new StringBundler(2);
1946
1947 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1948
1949 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1950
1951 String sql = query.toString();
1952
1953 Session session = null;
1954
1955 try {
1956 session = openSession();
1957
1958 Query q = session.createQuery(sql);
1959
1960 QueryPos qPos = QueryPos.getInstance(q);
1961
1962 qPos.add(active);
1963
1964 count = (Long)q.uniqueResult();
1965 }
1966 catch (Exception e) {
1967 throw processException(e);
1968 }
1969 finally {
1970 if (count == null) {
1971 count = Long.valueOf(0);
1972 }
1973
1974 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
1975 finderArgs, count);
1976
1977 closeSession(session);
1978 }
1979 }
1980
1981 return count.intValue();
1982 }
1983
1984
1992 public int countByG_C(long groupId, long categoryId)
1993 throws SystemException {
1994 Object[] finderArgs = new Object[] { groupId, categoryId };
1995
1996 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
1997 finderArgs, this);
1998
1999 if (count == null) {
2000 StringBundler query = new StringBundler(3);
2001
2002 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
2003
2004 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2005
2006 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2007
2008 String sql = query.toString();
2009
2010 Session session = null;
2011
2012 try {
2013 session = openSession();
2014
2015 Query q = session.createQuery(sql);
2016
2017 QueryPos qPos = QueryPos.getInstance(q);
2018
2019 qPos.add(groupId);
2020
2021 qPos.add(categoryId);
2022
2023 count = (Long)q.uniqueResult();
2024 }
2025 catch (Exception e) {
2026 throw processException(e);
2027 }
2028 finally {
2029 if (count == null) {
2030 count = Long.valueOf(0);
2031 }
2032
2033 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
2034 count);
2035
2036 closeSession(session);
2037 }
2038 }
2039
2040 return count.intValue();
2041 }
2042
2043
2049 public int countAll() throws SystemException {
2050 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2051 FINDER_ARGS_EMPTY, this);
2052
2053 if (count == null) {
2054 Session session = null;
2055
2056 try {
2057 session = openSession();
2058
2059 Query q = session.createQuery(_SQL_COUNT_MBMAILINGLIST);
2060
2061 count = (Long)q.uniqueResult();
2062 }
2063 catch (Exception e) {
2064 throw processException(e);
2065 }
2066 finally {
2067 if (count == null) {
2068 count = Long.valueOf(0);
2069 }
2070
2071 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2072 FINDER_ARGS_EMPTY, count);
2073
2074 closeSession(session);
2075 }
2076 }
2077
2078 return count.intValue();
2079 }
2080
2081
2084 public void afterPropertiesSet() {
2085 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2086 com.liferay.portal.util.PropsUtil.get(
2087 "value.object.listener.com.liferay.portlet.messageboards.model.MBMailingList")));
2088
2089 if (listenerClassNames.length > 0) {
2090 try {
2091 List<ModelListener<MBMailingList>> listenersList = new ArrayList<ModelListener<MBMailingList>>();
2092
2093 for (String listenerClassName : listenerClassNames) {
2094 listenersList.add((ModelListener<MBMailingList>)InstanceFactory.newInstance(
2095 listenerClassName));
2096 }
2097
2098 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2099 }
2100 catch (Exception e) {
2101 _log.error(e);
2102 }
2103 }
2104 }
2105
2106 public void destroy() {
2107 EntityCacheUtil.removeCache(MBMailingListImpl.class.getName());
2108 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2109 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2110 }
2111
2112 @BeanReference(type = MBBanPersistence.class)
2113 protected MBBanPersistence mbBanPersistence;
2114 @BeanReference(type = MBCategoryPersistence.class)
2115 protected MBCategoryPersistence mbCategoryPersistence;
2116 @BeanReference(type = MBDiscussionPersistence.class)
2117 protected MBDiscussionPersistence mbDiscussionPersistence;
2118 @BeanReference(type = MBMailingListPersistence.class)
2119 protected MBMailingListPersistence mbMailingListPersistence;
2120 @BeanReference(type = MBMessagePersistence.class)
2121 protected MBMessagePersistence mbMessagePersistence;
2122 @BeanReference(type = MBStatsUserPersistence.class)
2123 protected MBStatsUserPersistence mbStatsUserPersistence;
2124 @BeanReference(type = MBThreadPersistence.class)
2125 protected MBThreadPersistence mbThreadPersistence;
2126 @BeanReference(type = MBThreadFlagPersistence.class)
2127 protected MBThreadFlagPersistence mbThreadFlagPersistence;
2128 @BeanReference(type = ResourcePersistence.class)
2129 protected ResourcePersistence resourcePersistence;
2130 @BeanReference(type = UserPersistence.class)
2131 protected UserPersistence userPersistence;
2132 private static final String _SQL_SELECT_MBMAILINGLIST = "SELECT mbMailingList FROM MBMailingList mbMailingList";
2133 private static final String _SQL_SELECT_MBMAILINGLIST_WHERE = "SELECT mbMailingList FROM MBMailingList mbMailingList WHERE ";
2134 private static final String _SQL_COUNT_MBMAILINGLIST = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList";
2135 private static final String _SQL_COUNT_MBMAILINGLIST_WHERE = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList WHERE ";
2136 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbMailingList.uuid IS NULL";
2137 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbMailingList.uuid = ?";
2138 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = ?)";
2139 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbMailingList.uuid IS NULL AND ";
2140 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbMailingList.uuid = ? AND ";
2141 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = ?) AND ";
2142 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbMailingList.groupId = ?";
2143 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "mbMailingList.active = ?";
2144 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbMailingList.groupId = ? AND ";
2145 private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbMailingList.categoryId = ?";
2146 private static final String _ORDER_BY_ENTITY_ALIAS = "mbMailingList.";
2147 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBMailingList exists with the primary key ";
2148 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBMailingList exists with the key {";
2149 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2150 private static Log _log = LogFactoryUtil.getLog(MBMailingListPersistenceImpl.class);
2151 private static MBMailingList _nullMBMailingList = new MBMailingListImpl() {
2152 @Override
2153 public Object clone() {
2154 return this;
2155 }
2156
2157 @Override
2158 public CacheModel<MBMailingList> toCacheModel() {
2159 return _nullMBMailingListCacheModel;
2160 }
2161 };
2162
2163 private static CacheModel<MBMailingList> _nullMBMailingListCacheModel = new CacheModel<MBMailingList>() {
2164 public MBMailingList toEntityModel() {
2165 return _nullMBMailingList;
2166 }
2167 };
2168 }