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_WITH_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_WITHOUT_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
459 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
460
461 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
462 new Object[] {
463 mbMailingList.getUuid(),
464 Long.valueOf(mbMailingList.getGroupId())
465 }, mbMailingList);
466 }
467
468 if ((mbMailingListModelImpl.getColumnBitmask() &
469 FINDER_PATH_FETCH_BY_G_C.getColumnBitmask()) != 0) {
470 Object[] args = new Object[] {
471 Long.valueOf(mbMailingListModelImpl.getOriginalGroupId()),
472 Long.valueOf(mbMailingListModelImpl.getOriginalCategoryId())
473 };
474
475 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
476
477 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C, args);
478
479 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
480 new Object[] {
481 Long.valueOf(mbMailingList.getGroupId()),
482 Long.valueOf(mbMailingList.getCategoryId())
483 }, mbMailingList);
484 }
485 }
486
487 return mbMailingList;
488 }
489
490 protected MBMailingList toUnwrappedModel(MBMailingList mbMailingList) {
491 if (mbMailingList instanceof MBMailingListImpl) {
492 return mbMailingList;
493 }
494
495 MBMailingListImpl mbMailingListImpl = new MBMailingListImpl();
496
497 mbMailingListImpl.setNew(mbMailingList.isNew());
498 mbMailingListImpl.setPrimaryKey(mbMailingList.getPrimaryKey());
499
500 mbMailingListImpl.setUuid(mbMailingList.getUuid());
501 mbMailingListImpl.setMailingListId(mbMailingList.getMailingListId());
502 mbMailingListImpl.setGroupId(mbMailingList.getGroupId());
503 mbMailingListImpl.setCompanyId(mbMailingList.getCompanyId());
504 mbMailingListImpl.setUserId(mbMailingList.getUserId());
505 mbMailingListImpl.setUserName(mbMailingList.getUserName());
506 mbMailingListImpl.setCreateDate(mbMailingList.getCreateDate());
507 mbMailingListImpl.setModifiedDate(mbMailingList.getModifiedDate());
508 mbMailingListImpl.setCategoryId(mbMailingList.getCategoryId());
509 mbMailingListImpl.setEmailAddress(mbMailingList.getEmailAddress());
510 mbMailingListImpl.setInProtocol(mbMailingList.getInProtocol());
511 mbMailingListImpl.setInServerName(mbMailingList.getInServerName());
512 mbMailingListImpl.setInServerPort(mbMailingList.getInServerPort());
513 mbMailingListImpl.setInUseSSL(mbMailingList.isInUseSSL());
514 mbMailingListImpl.setInUserName(mbMailingList.getInUserName());
515 mbMailingListImpl.setInPassword(mbMailingList.getInPassword());
516 mbMailingListImpl.setInReadInterval(mbMailingList.getInReadInterval());
517 mbMailingListImpl.setOutEmailAddress(mbMailingList.getOutEmailAddress());
518 mbMailingListImpl.setOutCustom(mbMailingList.isOutCustom());
519 mbMailingListImpl.setOutServerName(mbMailingList.getOutServerName());
520 mbMailingListImpl.setOutServerPort(mbMailingList.getOutServerPort());
521 mbMailingListImpl.setOutUseSSL(mbMailingList.isOutUseSSL());
522 mbMailingListImpl.setOutUserName(mbMailingList.getOutUserName());
523 mbMailingListImpl.setOutPassword(mbMailingList.getOutPassword());
524 mbMailingListImpl.setAllowAnonymous(mbMailingList.isAllowAnonymous());
525 mbMailingListImpl.setActive(mbMailingList.isActive());
526
527 return mbMailingListImpl;
528 }
529
530
538 @Override
539 public MBMailingList findByPrimaryKey(Serializable primaryKey)
540 throws NoSuchModelException, SystemException {
541 return findByPrimaryKey(((Long)primaryKey).longValue());
542 }
543
544
552 public MBMailingList findByPrimaryKey(long mailingListId)
553 throws NoSuchMailingListException, SystemException {
554 MBMailingList mbMailingList = fetchByPrimaryKey(mailingListId);
555
556 if (mbMailingList == null) {
557 if (_log.isWarnEnabled()) {
558 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + mailingListId);
559 }
560
561 throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
562 mailingListId);
563 }
564
565 return mbMailingList;
566 }
567
568
575 @Override
576 public MBMailingList fetchByPrimaryKey(Serializable primaryKey)
577 throws SystemException {
578 return fetchByPrimaryKey(((Long)primaryKey).longValue());
579 }
580
581
588 public MBMailingList fetchByPrimaryKey(long mailingListId)
589 throws SystemException {
590 MBMailingList mbMailingList = (MBMailingList)EntityCacheUtil.getResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
591 MBMailingListImpl.class, mailingListId);
592
593 if (mbMailingList == _nullMBMailingList) {
594 return null;
595 }
596
597 if (mbMailingList == null) {
598 Session session = null;
599
600 boolean hasException = false;
601
602 try {
603 session = openSession();
604
605 mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
606 Long.valueOf(mailingListId));
607 }
608 catch (Exception e) {
609 hasException = true;
610
611 throw processException(e);
612 }
613 finally {
614 if (mbMailingList != null) {
615 cacheResult(mbMailingList);
616 }
617 else if (!hasException) {
618 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
619 MBMailingListImpl.class, mailingListId,
620 _nullMBMailingList);
621 }
622
623 closeSession(session);
624 }
625 }
626
627 return mbMailingList;
628 }
629
630
637 public List<MBMailingList> findByUuid(String uuid)
638 throws SystemException {
639 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
640 }
641
642
655 public List<MBMailingList> findByUuid(String uuid, int start, int end)
656 throws SystemException {
657 return findByUuid(uuid, start, end, null);
658 }
659
660
674 public List<MBMailingList> findByUuid(String uuid, int start, int end,
675 OrderByComparator orderByComparator) throws SystemException {
676 FinderPath finderPath = null;
677 Object[] finderArgs = null;
678
679 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
680 (orderByComparator == null)) {
681 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
682 finderArgs = new Object[] { uuid };
683 }
684 else {
685 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
686 finderArgs = new Object[] { uuid, start, end, orderByComparator };
687 }
688
689 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
690 finderArgs, this);
691
692 if ((list != null) && !list.isEmpty()) {
693 for (MBMailingList mbMailingList : list) {
694 if (!Validator.equals(uuid, mbMailingList.getUuid())) {
695 list = null;
696
697 break;
698 }
699 }
700 }
701
702 if (list == null) {
703 StringBundler query = null;
704
705 if (orderByComparator != null) {
706 query = new StringBundler(3 +
707 (orderByComparator.getOrderByFields().length * 3));
708 }
709 else {
710 query = new StringBundler(2);
711 }
712
713 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
714
715 if (uuid == null) {
716 query.append(_FINDER_COLUMN_UUID_UUID_1);
717 }
718 else {
719 if (uuid.equals(StringPool.BLANK)) {
720 query.append(_FINDER_COLUMN_UUID_UUID_3);
721 }
722 else {
723 query.append(_FINDER_COLUMN_UUID_UUID_2);
724 }
725 }
726
727 if (orderByComparator != null) {
728 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
729 orderByComparator);
730 }
731
732 String sql = query.toString();
733
734 Session session = null;
735
736 try {
737 session = openSession();
738
739 Query q = session.createQuery(sql);
740
741 QueryPos qPos = QueryPos.getInstance(q);
742
743 if (uuid != null) {
744 qPos.add(uuid);
745 }
746
747 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
748 start, end);
749 }
750 catch (Exception e) {
751 throw processException(e);
752 }
753 finally {
754 if (list == null) {
755 FinderCacheUtil.removeResult(finderPath, finderArgs);
756 }
757 else {
758 cacheResult(list);
759
760 FinderCacheUtil.putResult(finderPath, finderArgs, list);
761 }
762
763 closeSession(session);
764 }
765 }
766
767 return list;
768 }
769
770
779 public MBMailingList findByUuid_First(String uuid,
780 OrderByComparator orderByComparator)
781 throws NoSuchMailingListException, SystemException {
782 MBMailingList mbMailingList = fetchByUuid_First(uuid, orderByComparator);
783
784 if (mbMailingList != null) {
785 return mbMailingList;
786 }
787
788 StringBundler msg = new StringBundler(4);
789
790 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
791
792 msg.append("uuid=");
793 msg.append(uuid);
794
795 msg.append(StringPool.CLOSE_CURLY_BRACE);
796
797 throw new NoSuchMailingListException(msg.toString());
798 }
799
800
808 public MBMailingList fetchByUuid_First(String uuid,
809 OrderByComparator orderByComparator) throws SystemException {
810 List<MBMailingList> list = findByUuid(uuid, 0, 1, orderByComparator);
811
812 if (!list.isEmpty()) {
813 return list.get(0);
814 }
815
816 return null;
817 }
818
819
828 public MBMailingList findByUuid_Last(String uuid,
829 OrderByComparator orderByComparator)
830 throws NoSuchMailingListException, SystemException {
831 MBMailingList mbMailingList = fetchByUuid_Last(uuid, orderByComparator);
832
833 if (mbMailingList != null) {
834 return mbMailingList;
835 }
836
837 StringBundler msg = new StringBundler(4);
838
839 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
840
841 msg.append("uuid=");
842 msg.append(uuid);
843
844 msg.append(StringPool.CLOSE_CURLY_BRACE);
845
846 throw new NoSuchMailingListException(msg.toString());
847 }
848
849
857 public MBMailingList fetchByUuid_Last(String uuid,
858 OrderByComparator orderByComparator) throws SystemException {
859 int count = countByUuid(uuid);
860
861 List<MBMailingList> list = findByUuid(uuid, count - 1, count,
862 orderByComparator);
863
864 if (!list.isEmpty()) {
865 return list.get(0);
866 }
867
868 return null;
869 }
870
871
881 public MBMailingList[] findByUuid_PrevAndNext(long mailingListId,
882 String uuid, OrderByComparator orderByComparator)
883 throws NoSuchMailingListException, SystemException {
884 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
885
886 Session session = null;
887
888 try {
889 session = openSession();
890
891 MBMailingList[] array = new MBMailingListImpl[3];
892
893 array[0] = getByUuid_PrevAndNext(session, mbMailingList, uuid,
894 orderByComparator, true);
895
896 array[1] = mbMailingList;
897
898 array[2] = getByUuid_PrevAndNext(session, mbMailingList, uuid,
899 orderByComparator, false);
900
901 return array;
902 }
903 catch (Exception e) {
904 throw processException(e);
905 }
906 finally {
907 closeSession(session);
908 }
909 }
910
911 protected MBMailingList getByUuid_PrevAndNext(Session session,
912 MBMailingList mbMailingList, String uuid,
913 OrderByComparator orderByComparator, boolean previous) {
914 StringBundler query = null;
915
916 if (orderByComparator != null) {
917 query = new StringBundler(6 +
918 (orderByComparator.getOrderByFields().length * 6));
919 }
920 else {
921 query = new StringBundler(3);
922 }
923
924 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
925
926 if (uuid == null) {
927 query.append(_FINDER_COLUMN_UUID_UUID_1);
928 }
929 else {
930 if (uuid.equals(StringPool.BLANK)) {
931 query.append(_FINDER_COLUMN_UUID_UUID_3);
932 }
933 else {
934 query.append(_FINDER_COLUMN_UUID_UUID_2);
935 }
936 }
937
938 if (orderByComparator != null) {
939 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
940
941 if (orderByConditionFields.length > 0) {
942 query.append(WHERE_AND);
943 }
944
945 for (int i = 0; i < orderByConditionFields.length; i++) {
946 query.append(_ORDER_BY_ENTITY_ALIAS);
947 query.append(orderByConditionFields[i]);
948
949 if ((i + 1) < orderByConditionFields.length) {
950 if (orderByComparator.isAscending() ^ previous) {
951 query.append(WHERE_GREATER_THAN_HAS_NEXT);
952 }
953 else {
954 query.append(WHERE_LESSER_THAN_HAS_NEXT);
955 }
956 }
957 else {
958 if (orderByComparator.isAscending() ^ previous) {
959 query.append(WHERE_GREATER_THAN);
960 }
961 else {
962 query.append(WHERE_LESSER_THAN);
963 }
964 }
965 }
966
967 query.append(ORDER_BY_CLAUSE);
968
969 String[] orderByFields = orderByComparator.getOrderByFields();
970
971 for (int i = 0; i < orderByFields.length; i++) {
972 query.append(_ORDER_BY_ENTITY_ALIAS);
973 query.append(orderByFields[i]);
974
975 if ((i + 1) < orderByFields.length) {
976 if (orderByComparator.isAscending() ^ previous) {
977 query.append(ORDER_BY_ASC_HAS_NEXT);
978 }
979 else {
980 query.append(ORDER_BY_DESC_HAS_NEXT);
981 }
982 }
983 else {
984 if (orderByComparator.isAscending() ^ previous) {
985 query.append(ORDER_BY_ASC);
986 }
987 else {
988 query.append(ORDER_BY_DESC);
989 }
990 }
991 }
992 }
993
994 String sql = query.toString();
995
996 Query q = session.createQuery(sql);
997
998 q.setFirstResult(0);
999 q.setMaxResults(2);
1000
1001 QueryPos qPos = QueryPos.getInstance(q);
1002
1003 if (uuid != null) {
1004 qPos.add(uuid);
1005 }
1006
1007 if (orderByComparator != null) {
1008 Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
1009
1010 for (Object value : values) {
1011 qPos.add(value);
1012 }
1013 }
1014
1015 List<MBMailingList> list = q.list();
1016
1017 if (list.size() == 2) {
1018 return list.get(1);
1019 }
1020 else {
1021 return null;
1022 }
1023 }
1024
1025
1034 public MBMailingList findByUUID_G(String uuid, long groupId)
1035 throws NoSuchMailingListException, SystemException {
1036 MBMailingList mbMailingList = fetchByUUID_G(uuid, groupId);
1037
1038 if (mbMailingList == null) {
1039 StringBundler msg = new StringBundler(6);
1040
1041 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1042
1043 msg.append("uuid=");
1044 msg.append(uuid);
1045
1046 msg.append(", groupId=");
1047 msg.append(groupId);
1048
1049 msg.append(StringPool.CLOSE_CURLY_BRACE);
1050
1051 if (_log.isWarnEnabled()) {
1052 _log.warn(msg.toString());
1053 }
1054
1055 throw new NoSuchMailingListException(msg.toString());
1056 }
1057
1058 return mbMailingList;
1059 }
1060
1061
1069 public MBMailingList fetchByUUID_G(String uuid, long groupId)
1070 throws SystemException {
1071 return fetchByUUID_G(uuid, groupId, true);
1072 }
1073
1074
1083 public MBMailingList fetchByUUID_G(String uuid, long groupId,
1084 boolean retrieveFromCache) throws SystemException {
1085 Object[] finderArgs = new Object[] { uuid, groupId };
1086
1087 Object result = null;
1088
1089 if (retrieveFromCache) {
1090 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1091 finderArgs, this);
1092 }
1093
1094 if (result instanceof MBMailingList) {
1095 MBMailingList mbMailingList = (MBMailingList)result;
1096
1097 if (!Validator.equals(uuid, mbMailingList.getUuid()) ||
1098 (groupId != mbMailingList.getGroupId())) {
1099 result = null;
1100 }
1101 }
1102
1103 if (result == null) {
1104 StringBundler query = new StringBundler(3);
1105
1106 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1107
1108 if (uuid == null) {
1109 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1110 }
1111 else {
1112 if (uuid.equals(StringPool.BLANK)) {
1113 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1114 }
1115 else {
1116 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1117 }
1118 }
1119
1120 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1121
1122 String sql = query.toString();
1123
1124 Session session = null;
1125
1126 try {
1127 session = openSession();
1128
1129 Query q = session.createQuery(sql);
1130
1131 QueryPos qPos = QueryPos.getInstance(q);
1132
1133 if (uuid != null) {
1134 qPos.add(uuid);
1135 }
1136
1137 qPos.add(groupId);
1138
1139 List<MBMailingList> list = q.list();
1140
1141 result = list;
1142
1143 MBMailingList mbMailingList = null;
1144
1145 if (list.isEmpty()) {
1146 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1147 finderArgs, list);
1148 }
1149 else {
1150 mbMailingList = list.get(0);
1151
1152 cacheResult(mbMailingList);
1153
1154 if ((mbMailingList.getUuid() == null) ||
1155 !mbMailingList.getUuid().equals(uuid) ||
1156 (mbMailingList.getGroupId() != groupId)) {
1157 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1158 finderArgs, mbMailingList);
1159 }
1160 }
1161
1162 return mbMailingList;
1163 }
1164 catch (Exception e) {
1165 throw processException(e);
1166 }
1167 finally {
1168 if (result == null) {
1169 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1170 finderArgs);
1171 }
1172
1173 closeSession(session);
1174 }
1175 }
1176 else {
1177 if (result instanceof List<?>) {
1178 return null;
1179 }
1180 else {
1181 return (MBMailingList)result;
1182 }
1183 }
1184 }
1185
1186
1193 public List<MBMailingList> findByActive(boolean active)
1194 throws SystemException {
1195 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1196 }
1197
1198
1211 public List<MBMailingList> findByActive(boolean active, int start, int end)
1212 throws SystemException {
1213 return findByActive(active, start, end, null);
1214 }
1215
1216
1230 public List<MBMailingList> findByActive(boolean active, int start, int end,
1231 OrderByComparator orderByComparator) throws SystemException {
1232 FinderPath finderPath = null;
1233 Object[] finderArgs = null;
1234
1235 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1236 (orderByComparator == null)) {
1237 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
1238 finderArgs = new Object[] { active };
1239 }
1240 else {
1241 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
1242 finderArgs = new Object[] { active, start, end, orderByComparator };
1243 }
1244
1245 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
1246 finderArgs, this);
1247
1248 if ((list != null) && !list.isEmpty()) {
1249 for (MBMailingList mbMailingList : list) {
1250 if ((active != mbMailingList.getActive())) {
1251 list = null;
1252
1253 break;
1254 }
1255 }
1256 }
1257
1258 if (list == null) {
1259 StringBundler query = null;
1260
1261 if (orderByComparator != null) {
1262 query = new StringBundler(3 +
1263 (orderByComparator.getOrderByFields().length * 3));
1264 }
1265 else {
1266 query = new StringBundler(2);
1267 }
1268
1269 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1270
1271 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1272
1273 if (orderByComparator != null) {
1274 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1275 orderByComparator);
1276 }
1277
1278 String sql = query.toString();
1279
1280 Session session = null;
1281
1282 try {
1283 session = openSession();
1284
1285 Query q = session.createQuery(sql);
1286
1287 QueryPos qPos = QueryPos.getInstance(q);
1288
1289 qPos.add(active);
1290
1291 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1292 start, end);
1293 }
1294 catch (Exception e) {
1295 throw processException(e);
1296 }
1297 finally {
1298 if (list == null) {
1299 FinderCacheUtil.removeResult(finderPath, finderArgs);
1300 }
1301 else {
1302 cacheResult(list);
1303
1304 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1305 }
1306
1307 closeSession(session);
1308 }
1309 }
1310
1311 return list;
1312 }
1313
1314
1323 public MBMailingList findByActive_First(boolean active,
1324 OrderByComparator orderByComparator)
1325 throws NoSuchMailingListException, SystemException {
1326 MBMailingList mbMailingList = fetchByActive_First(active,
1327 orderByComparator);
1328
1329 if (mbMailingList != null) {
1330 return mbMailingList;
1331 }
1332
1333 StringBundler msg = new StringBundler(4);
1334
1335 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1336
1337 msg.append("active=");
1338 msg.append(active);
1339
1340 msg.append(StringPool.CLOSE_CURLY_BRACE);
1341
1342 throw new NoSuchMailingListException(msg.toString());
1343 }
1344
1345
1353 public MBMailingList fetchByActive_First(boolean active,
1354 OrderByComparator orderByComparator) throws SystemException {
1355 List<MBMailingList> list = findByActive(active, 0, 1, orderByComparator);
1356
1357 if (!list.isEmpty()) {
1358 return list.get(0);
1359 }
1360
1361 return null;
1362 }
1363
1364
1373 public MBMailingList findByActive_Last(boolean active,
1374 OrderByComparator orderByComparator)
1375 throws NoSuchMailingListException, SystemException {
1376 MBMailingList mbMailingList = fetchByActive_Last(active,
1377 orderByComparator);
1378
1379 if (mbMailingList != null) {
1380 return mbMailingList;
1381 }
1382
1383 StringBundler msg = new StringBundler(4);
1384
1385 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1386
1387 msg.append("active=");
1388 msg.append(active);
1389
1390 msg.append(StringPool.CLOSE_CURLY_BRACE);
1391
1392 throw new NoSuchMailingListException(msg.toString());
1393 }
1394
1395
1403 public MBMailingList fetchByActive_Last(boolean active,
1404 OrderByComparator orderByComparator) throws SystemException {
1405 int count = countByActive(active);
1406
1407 List<MBMailingList> list = findByActive(active, count - 1, count,
1408 orderByComparator);
1409
1410 if (!list.isEmpty()) {
1411 return list.get(0);
1412 }
1413
1414 return null;
1415 }
1416
1417
1427 public MBMailingList[] findByActive_PrevAndNext(long mailingListId,
1428 boolean active, OrderByComparator orderByComparator)
1429 throws NoSuchMailingListException, SystemException {
1430 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
1431
1432 Session session = null;
1433
1434 try {
1435 session = openSession();
1436
1437 MBMailingList[] array = new MBMailingListImpl[3];
1438
1439 array[0] = getByActive_PrevAndNext(session, mbMailingList, active,
1440 orderByComparator, true);
1441
1442 array[1] = mbMailingList;
1443
1444 array[2] = getByActive_PrevAndNext(session, mbMailingList, active,
1445 orderByComparator, false);
1446
1447 return array;
1448 }
1449 catch (Exception e) {
1450 throw processException(e);
1451 }
1452 finally {
1453 closeSession(session);
1454 }
1455 }
1456
1457 protected MBMailingList getByActive_PrevAndNext(Session session,
1458 MBMailingList mbMailingList, boolean active,
1459 OrderByComparator orderByComparator, boolean previous) {
1460 StringBundler query = null;
1461
1462 if (orderByComparator != null) {
1463 query = new StringBundler(6 +
1464 (orderByComparator.getOrderByFields().length * 6));
1465 }
1466 else {
1467 query = new StringBundler(3);
1468 }
1469
1470 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1471
1472 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1473
1474 if (orderByComparator != null) {
1475 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1476
1477 if (orderByConditionFields.length > 0) {
1478 query.append(WHERE_AND);
1479 }
1480
1481 for (int i = 0; i < orderByConditionFields.length; i++) {
1482 query.append(_ORDER_BY_ENTITY_ALIAS);
1483 query.append(orderByConditionFields[i]);
1484
1485 if ((i + 1) < orderByConditionFields.length) {
1486 if (orderByComparator.isAscending() ^ previous) {
1487 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1488 }
1489 else {
1490 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1491 }
1492 }
1493 else {
1494 if (orderByComparator.isAscending() ^ previous) {
1495 query.append(WHERE_GREATER_THAN);
1496 }
1497 else {
1498 query.append(WHERE_LESSER_THAN);
1499 }
1500 }
1501 }
1502
1503 query.append(ORDER_BY_CLAUSE);
1504
1505 String[] orderByFields = orderByComparator.getOrderByFields();
1506
1507 for (int i = 0; i < orderByFields.length; i++) {
1508 query.append(_ORDER_BY_ENTITY_ALIAS);
1509 query.append(orderByFields[i]);
1510
1511 if ((i + 1) < orderByFields.length) {
1512 if (orderByComparator.isAscending() ^ previous) {
1513 query.append(ORDER_BY_ASC_HAS_NEXT);
1514 }
1515 else {
1516 query.append(ORDER_BY_DESC_HAS_NEXT);
1517 }
1518 }
1519 else {
1520 if (orderByComparator.isAscending() ^ previous) {
1521 query.append(ORDER_BY_ASC);
1522 }
1523 else {
1524 query.append(ORDER_BY_DESC);
1525 }
1526 }
1527 }
1528 }
1529
1530 String sql = query.toString();
1531
1532 Query q = session.createQuery(sql);
1533
1534 q.setFirstResult(0);
1535 q.setMaxResults(2);
1536
1537 QueryPos qPos = QueryPos.getInstance(q);
1538
1539 qPos.add(active);
1540
1541 if (orderByComparator != null) {
1542 Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
1543
1544 for (Object value : values) {
1545 qPos.add(value);
1546 }
1547 }
1548
1549 List<MBMailingList> list = q.list();
1550
1551 if (list.size() == 2) {
1552 return list.get(1);
1553 }
1554 else {
1555 return null;
1556 }
1557 }
1558
1559
1568 public MBMailingList findByG_C(long groupId, long categoryId)
1569 throws NoSuchMailingListException, SystemException {
1570 MBMailingList mbMailingList = fetchByG_C(groupId, categoryId);
1571
1572 if (mbMailingList == null) {
1573 StringBundler msg = new StringBundler(6);
1574
1575 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1576
1577 msg.append("groupId=");
1578 msg.append(groupId);
1579
1580 msg.append(", categoryId=");
1581 msg.append(categoryId);
1582
1583 msg.append(StringPool.CLOSE_CURLY_BRACE);
1584
1585 if (_log.isWarnEnabled()) {
1586 _log.warn(msg.toString());
1587 }
1588
1589 throw new NoSuchMailingListException(msg.toString());
1590 }
1591
1592 return mbMailingList;
1593 }
1594
1595
1603 public MBMailingList fetchByG_C(long groupId, long categoryId)
1604 throws SystemException {
1605 return fetchByG_C(groupId, categoryId, true);
1606 }
1607
1608
1617 public MBMailingList fetchByG_C(long groupId, long categoryId,
1618 boolean retrieveFromCache) throws SystemException {
1619 Object[] finderArgs = new Object[] { groupId, categoryId };
1620
1621 Object result = null;
1622
1623 if (retrieveFromCache) {
1624 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C,
1625 finderArgs, this);
1626 }
1627
1628 if (result instanceof MBMailingList) {
1629 MBMailingList mbMailingList = (MBMailingList)result;
1630
1631 if ((groupId != mbMailingList.getGroupId()) ||
1632 (categoryId != mbMailingList.getCategoryId())) {
1633 result = null;
1634 }
1635 }
1636
1637 if (result == null) {
1638 StringBundler query = new StringBundler(3);
1639
1640 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1641
1642 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1643
1644 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
1645
1646 String sql = query.toString();
1647
1648 Session session = null;
1649
1650 try {
1651 session = openSession();
1652
1653 Query q = session.createQuery(sql);
1654
1655 QueryPos qPos = QueryPos.getInstance(q);
1656
1657 qPos.add(groupId);
1658
1659 qPos.add(categoryId);
1660
1661 List<MBMailingList> list = q.list();
1662
1663 result = list;
1664
1665 MBMailingList mbMailingList = null;
1666
1667 if (list.isEmpty()) {
1668 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
1669 finderArgs, list);
1670 }
1671 else {
1672 mbMailingList = list.get(0);
1673
1674 cacheResult(mbMailingList);
1675
1676 if ((mbMailingList.getGroupId() != groupId) ||
1677 (mbMailingList.getCategoryId() != categoryId)) {
1678 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
1679 finderArgs, mbMailingList);
1680 }
1681 }
1682
1683 return mbMailingList;
1684 }
1685 catch (Exception e) {
1686 throw processException(e);
1687 }
1688 finally {
1689 if (result == null) {
1690 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C,
1691 finderArgs);
1692 }
1693
1694 closeSession(session);
1695 }
1696 }
1697 else {
1698 if (result instanceof List<?>) {
1699 return null;
1700 }
1701 else {
1702 return (MBMailingList)result;
1703 }
1704 }
1705 }
1706
1707
1713 public List<MBMailingList> findAll() throws SystemException {
1714 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1715 }
1716
1717
1729 public List<MBMailingList> findAll(int start, int end)
1730 throws SystemException {
1731 return findAll(start, end, null);
1732 }
1733
1734
1747 public List<MBMailingList> findAll(int start, int end,
1748 OrderByComparator orderByComparator) throws SystemException {
1749 FinderPath finderPath = null;
1750 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1751
1752 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1753 (orderByComparator == null)) {
1754 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1755 finderArgs = FINDER_ARGS_EMPTY;
1756 }
1757 else {
1758 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1759 finderArgs = new Object[] { start, end, orderByComparator };
1760 }
1761
1762 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
1763 finderArgs, this);
1764
1765 if (list == null) {
1766 StringBundler query = null;
1767 String sql = null;
1768
1769 if (orderByComparator != null) {
1770 query = new StringBundler(2 +
1771 (orderByComparator.getOrderByFields().length * 3));
1772
1773 query.append(_SQL_SELECT_MBMAILINGLIST);
1774
1775 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1776 orderByComparator);
1777
1778 sql = query.toString();
1779 }
1780 else {
1781 sql = _SQL_SELECT_MBMAILINGLIST;
1782 }
1783
1784 Session session = null;
1785
1786 try {
1787 session = openSession();
1788
1789 Query q = session.createQuery(sql);
1790
1791 if (orderByComparator == null) {
1792 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1793 start, end, false);
1794
1795 Collections.sort(list);
1796 }
1797 else {
1798 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1799 start, end);
1800 }
1801 }
1802 catch (Exception e) {
1803 throw processException(e);
1804 }
1805 finally {
1806 if (list == null) {
1807 FinderCacheUtil.removeResult(finderPath, finderArgs);
1808 }
1809 else {
1810 cacheResult(list);
1811
1812 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1813 }
1814
1815 closeSession(session);
1816 }
1817 }
1818
1819 return list;
1820 }
1821
1822
1828 public void removeByUuid(String uuid) throws SystemException {
1829 for (MBMailingList mbMailingList : findByUuid(uuid)) {
1830 remove(mbMailingList);
1831 }
1832 }
1833
1834
1842 public MBMailingList removeByUUID_G(String uuid, long groupId)
1843 throws NoSuchMailingListException, SystemException {
1844 MBMailingList mbMailingList = findByUUID_G(uuid, groupId);
1845
1846 return remove(mbMailingList);
1847 }
1848
1849
1855 public void removeByActive(boolean active) throws SystemException {
1856 for (MBMailingList mbMailingList : findByActive(active)) {
1857 remove(mbMailingList);
1858 }
1859 }
1860
1861
1869 public MBMailingList removeByG_C(long groupId, long categoryId)
1870 throws NoSuchMailingListException, SystemException {
1871 MBMailingList mbMailingList = findByG_C(groupId, categoryId);
1872
1873 return remove(mbMailingList);
1874 }
1875
1876
1881 public void removeAll() throws SystemException {
1882 for (MBMailingList mbMailingList : findAll()) {
1883 remove(mbMailingList);
1884 }
1885 }
1886
1887
1894 public int countByUuid(String uuid) throws SystemException {
1895 Object[] finderArgs = new Object[] { uuid };
1896
1897 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1898 finderArgs, this);
1899
1900 if (count == null) {
1901 StringBundler query = new StringBundler(2);
1902
1903 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1904
1905 if (uuid == null) {
1906 query.append(_FINDER_COLUMN_UUID_UUID_1);
1907 }
1908 else {
1909 if (uuid.equals(StringPool.BLANK)) {
1910 query.append(_FINDER_COLUMN_UUID_UUID_3);
1911 }
1912 else {
1913 query.append(_FINDER_COLUMN_UUID_UUID_2);
1914 }
1915 }
1916
1917 String sql = query.toString();
1918
1919 Session session = null;
1920
1921 try {
1922 session = openSession();
1923
1924 Query q = session.createQuery(sql);
1925
1926 QueryPos qPos = QueryPos.getInstance(q);
1927
1928 if (uuid != null) {
1929 qPos.add(uuid);
1930 }
1931
1932 count = (Long)q.uniqueResult();
1933 }
1934 catch (Exception e) {
1935 throw processException(e);
1936 }
1937 finally {
1938 if (count == null) {
1939 count = Long.valueOf(0);
1940 }
1941
1942 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1943 finderArgs, count);
1944
1945 closeSession(session);
1946 }
1947 }
1948
1949 return count.intValue();
1950 }
1951
1952
1960 public int countByUUID_G(String uuid, long groupId)
1961 throws SystemException {
1962 Object[] finderArgs = new Object[] { uuid, groupId };
1963
1964 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1965 finderArgs, this);
1966
1967 if (count == null) {
1968 StringBundler query = new StringBundler(3);
1969
1970 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1971
1972 if (uuid == null) {
1973 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1974 }
1975 else {
1976 if (uuid.equals(StringPool.BLANK)) {
1977 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1978 }
1979 else {
1980 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1981 }
1982 }
1983
1984 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1985
1986 String sql = query.toString();
1987
1988 Session session = null;
1989
1990 try {
1991 session = openSession();
1992
1993 Query q = session.createQuery(sql);
1994
1995 QueryPos qPos = QueryPos.getInstance(q);
1996
1997 if (uuid != null) {
1998 qPos.add(uuid);
1999 }
2000
2001 qPos.add(groupId);
2002
2003 count = (Long)q.uniqueResult();
2004 }
2005 catch (Exception e) {
2006 throw processException(e);
2007 }
2008 finally {
2009 if (count == null) {
2010 count = Long.valueOf(0);
2011 }
2012
2013 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2014 finderArgs, count);
2015
2016 closeSession(session);
2017 }
2018 }
2019
2020 return count.intValue();
2021 }
2022
2023
2030 public int countByActive(boolean active) throws SystemException {
2031 Object[] finderArgs = new Object[] { active };
2032
2033 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
2034 finderArgs, this);
2035
2036 if (count == null) {
2037 StringBundler query = new StringBundler(2);
2038
2039 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
2040
2041 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
2042
2043 String sql = query.toString();
2044
2045 Session session = null;
2046
2047 try {
2048 session = openSession();
2049
2050 Query q = session.createQuery(sql);
2051
2052 QueryPos qPos = QueryPos.getInstance(q);
2053
2054 qPos.add(active);
2055
2056 count = (Long)q.uniqueResult();
2057 }
2058 catch (Exception e) {
2059 throw processException(e);
2060 }
2061 finally {
2062 if (count == null) {
2063 count = Long.valueOf(0);
2064 }
2065
2066 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
2067 finderArgs, count);
2068
2069 closeSession(session);
2070 }
2071 }
2072
2073 return count.intValue();
2074 }
2075
2076
2084 public int countByG_C(long groupId, long categoryId)
2085 throws SystemException {
2086 Object[] finderArgs = new Object[] { groupId, categoryId };
2087
2088 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
2089 finderArgs, this);
2090
2091 if (count == null) {
2092 StringBundler query = new StringBundler(3);
2093
2094 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
2095
2096 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2097
2098 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2099
2100 String sql = query.toString();
2101
2102 Session session = null;
2103
2104 try {
2105 session = openSession();
2106
2107 Query q = session.createQuery(sql);
2108
2109 QueryPos qPos = QueryPos.getInstance(q);
2110
2111 qPos.add(groupId);
2112
2113 qPos.add(categoryId);
2114
2115 count = (Long)q.uniqueResult();
2116 }
2117 catch (Exception e) {
2118 throw processException(e);
2119 }
2120 finally {
2121 if (count == null) {
2122 count = Long.valueOf(0);
2123 }
2124
2125 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
2126 count);
2127
2128 closeSession(session);
2129 }
2130 }
2131
2132 return count.intValue();
2133 }
2134
2135
2141 public int countAll() throws SystemException {
2142 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2143 FINDER_ARGS_EMPTY, this);
2144
2145 if (count == null) {
2146 Session session = null;
2147
2148 try {
2149 session = openSession();
2150
2151 Query q = session.createQuery(_SQL_COUNT_MBMAILINGLIST);
2152
2153 count = (Long)q.uniqueResult();
2154 }
2155 catch (Exception e) {
2156 throw processException(e);
2157 }
2158 finally {
2159 if (count == null) {
2160 count = Long.valueOf(0);
2161 }
2162
2163 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2164 FINDER_ARGS_EMPTY, count);
2165
2166 closeSession(session);
2167 }
2168 }
2169
2170 return count.intValue();
2171 }
2172
2173
2176 public void afterPropertiesSet() {
2177 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2178 com.liferay.portal.util.PropsUtil.get(
2179 "value.object.listener.com.liferay.portlet.messageboards.model.MBMailingList")));
2180
2181 if (listenerClassNames.length > 0) {
2182 try {
2183 List<ModelListener<MBMailingList>> listenersList = new ArrayList<ModelListener<MBMailingList>>();
2184
2185 for (String listenerClassName : listenerClassNames) {
2186 listenersList.add((ModelListener<MBMailingList>)InstanceFactory.newInstance(
2187 listenerClassName));
2188 }
2189
2190 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2191 }
2192 catch (Exception e) {
2193 _log.error(e);
2194 }
2195 }
2196 }
2197
2198 public void destroy() {
2199 EntityCacheUtil.removeCache(MBMailingListImpl.class.getName());
2200 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2201 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2202 }
2203
2204 @BeanReference(type = MBBanPersistence.class)
2205 protected MBBanPersistence mbBanPersistence;
2206 @BeanReference(type = MBCategoryPersistence.class)
2207 protected MBCategoryPersistence mbCategoryPersistence;
2208 @BeanReference(type = MBDiscussionPersistence.class)
2209 protected MBDiscussionPersistence mbDiscussionPersistence;
2210 @BeanReference(type = MBMailingListPersistence.class)
2211 protected MBMailingListPersistence mbMailingListPersistence;
2212 @BeanReference(type = MBMessagePersistence.class)
2213 protected MBMessagePersistence mbMessagePersistence;
2214 @BeanReference(type = MBStatsUserPersistence.class)
2215 protected MBStatsUserPersistence mbStatsUserPersistence;
2216 @BeanReference(type = MBThreadPersistence.class)
2217 protected MBThreadPersistence mbThreadPersistence;
2218 @BeanReference(type = MBThreadFlagPersistence.class)
2219 protected MBThreadFlagPersistence mbThreadFlagPersistence;
2220 @BeanReference(type = ResourcePersistence.class)
2221 protected ResourcePersistence resourcePersistence;
2222 @BeanReference(type = UserPersistence.class)
2223 protected UserPersistence userPersistence;
2224 private static final String _SQL_SELECT_MBMAILINGLIST = "SELECT mbMailingList FROM MBMailingList mbMailingList";
2225 private static final String _SQL_SELECT_MBMAILINGLIST_WHERE = "SELECT mbMailingList FROM MBMailingList mbMailingList WHERE ";
2226 private static final String _SQL_COUNT_MBMAILINGLIST = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList";
2227 private static final String _SQL_COUNT_MBMAILINGLIST_WHERE = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList WHERE ";
2228 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbMailingList.uuid IS NULL";
2229 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbMailingList.uuid = ?";
2230 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = ?)";
2231 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbMailingList.uuid IS NULL AND ";
2232 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbMailingList.uuid = ? AND ";
2233 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = ?) AND ";
2234 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbMailingList.groupId = ?";
2235 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "mbMailingList.active = ?";
2236 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbMailingList.groupId = ? AND ";
2237 private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbMailingList.categoryId = ?";
2238 private static final String _ORDER_BY_ENTITY_ALIAS = "mbMailingList.";
2239 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBMailingList exists with the primary key ";
2240 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBMailingList exists with the key {";
2241 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2242 private static Log _log = LogFactoryUtil.getLog(MBMailingListPersistenceImpl.class);
2243 private static MBMailingList _nullMBMailingList = new MBMailingListImpl() {
2244 @Override
2245 public Object clone() {
2246 return this;
2247 }
2248
2249 @Override
2250 public CacheModel<MBMailingList> toCacheModel() {
2251 return _nullMBMailingListCacheModel;
2252 }
2253 };
2254
2255 private static CacheModel<MBMailingList> _nullMBMailingListCacheModel = new CacheModel<MBMailingList>() {
2256 public MBMailingList toEntityModel() {
2257 return _nullMBMailingList;
2258 }
2259 };
2260 }