1
22
23 package com.liferay.portlet.messageboards.service.persistence;
24
25 import com.liferay.portal.NoSuchModelException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.annotation.BeanReference;
28 import com.liferay.portal.kernel.cache.CacheRegistry;
29 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
30 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32 import com.liferay.portal.kernel.dao.orm.FinderPath;
33 import com.liferay.portal.kernel.dao.orm.Query;
34 import com.liferay.portal.kernel.dao.orm.QueryPos;
35 import com.liferay.portal.kernel.dao.orm.QueryUtil;
36 import com.liferay.portal.kernel.dao.orm.Session;
37 import com.liferay.portal.kernel.log.Log;
38 import com.liferay.portal.kernel.log.LogFactoryUtil;
39 import com.liferay.portal.kernel.util.GetterUtil;
40 import com.liferay.portal.kernel.util.OrderByComparator;
41 import com.liferay.portal.kernel.util.StringBundler;
42 import com.liferay.portal.kernel.util.StringPool;
43 import com.liferay.portal.kernel.util.StringUtil;
44 import com.liferay.portal.kernel.util.Validator;
45 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
46 import com.liferay.portal.model.ModelListener;
47 import com.liferay.portal.service.persistence.BatchSessionUtil;
48 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
49
50 import com.liferay.portlet.messageboards.NoSuchMailingListException;
51 import com.liferay.portlet.messageboards.model.MBMailingList;
52 import com.liferay.portlet.messageboards.model.impl.MBMailingListImpl;
53 import com.liferay.portlet.messageboards.model.impl.MBMailingListModelImpl;
54
55 import java.io.Serializable;
56
57 import java.util.ArrayList;
58 import java.util.Collections;
59 import java.util.List;
60
61
74 public class MBMailingListPersistenceImpl extends BasePersistenceImpl<MBMailingList>
75 implements MBMailingListPersistence {
76 public static final String FINDER_CLASS_NAME_ENTITY = MBMailingListImpl.class.getName();
77 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
78 ".List";
79 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
80 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
81 FINDER_CLASS_NAME_LIST, "findByUuid",
82 new String[] { String.class.getName() });
83 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
84 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
85 FINDER_CLASS_NAME_LIST, "findByUuid",
86 new String[] {
87 String.class.getName(),
88
89 "java.lang.Integer", "java.lang.Integer",
90 "com.liferay.portal.kernel.util.OrderByComparator"
91 });
92 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
93 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
94 FINDER_CLASS_NAME_LIST, "countByUuid",
95 new String[] { String.class.getName() });
96 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
97 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
98 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
99 new String[] { String.class.getName(), Long.class.getName() });
100 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
101 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
102 FINDER_CLASS_NAME_LIST, "countByUUID_G",
103 new String[] { String.class.getName(), Long.class.getName() });
104 public static final FinderPath FINDER_PATH_FETCH_BY_CATEGORYID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
105 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
106 FINDER_CLASS_NAME_ENTITY, "fetchByCategoryId",
107 new String[] { Long.class.getName() });
108 public static final FinderPath FINDER_PATH_COUNT_BY_CATEGORYID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
109 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
110 FINDER_CLASS_NAME_LIST, "countByCategoryId",
111 new String[] { Long.class.getName() });
112 public static final FinderPath FINDER_PATH_FIND_BY_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
113 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
114 FINDER_CLASS_NAME_LIST, "findByActive",
115 new String[] { Boolean.class.getName() });
116 public static final FinderPath FINDER_PATH_FIND_BY_OBC_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
117 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
118 FINDER_CLASS_NAME_LIST, "findByActive",
119 new String[] {
120 Boolean.class.getName(),
121
122 "java.lang.Integer", "java.lang.Integer",
123 "com.liferay.portal.kernel.util.OrderByComparator"
124 });
125 public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
126 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
127 FINDER_CLASS_NAME_LIST, "countByActive",
128 new String[] { Boolean.class.getName() });
129 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
130 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
131 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
132 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
133 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
134 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
135
136 public void cacheResult(MBMailingList mbMailingList) {
137 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
138 MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
139 mbMailingList);
140
141 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
142 new Object[] {
143 mbMailingList.getUuid(), new Long(mbMailingList.getGroupId())
144 }, mbMailingList);
145
146 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CATEGORYID,
147 new Object[] { new Long(mbMailingList.getCategoryId()) },
148 mbMailingList);
149 }
150
151 public void cacheResult(List<MBMailingList> mbMailingLists) {
152 for (MBMailingList mbMailingList : mbMailingLists) {
153 if (EntityCacheUtil.getResult(
154 MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
155 MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
156 this) == null) {
157 cacheResult(mbMailingList);
158 }
159 }
160 }
161
162 public void clearCache() {
163 CacheRegistry.clear(MBMailingListImpl.class.getName());
164 EntityCacheUtil.clearCache(MBMailingListImpl.class.getName());
165 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
166 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
167 }
168
169 public MBMailingList create(long mailingListId) {
170 MBMailingList mbMailingList = new MBMailingListImpl();
171
172 mbMailingList.setNew(true);
173 mbMailingList.setPrimaryKey(mailingListId);
174
175 String uuid = PortalUUIDUtil.generate();
176
177 mbMailingList.setUuid(uuid);
178
179 return mbMailingList;
180 }
181
182 public MBMailingList remove(Serializable primaryKey)
183 throws NoSuchModelException, SystemException {
184 return remove(((Long)primaryKey).longValue());
185 }
186
187 public MBMailingList remove(long mailingListId)
188 throws NoSuchMailingListException, SystemException {
189 Session session = null;
190
191 try {
192 session = openSession();
193
194 MBMailingList mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
195 new Long(mailingListId));
196
197 if (mbMailingList == null) {
198 if (_log.isWarnEnabled()) {
199 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + mailingListId);
200 }
201
202 throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
203 mailingListId);
204 }
205
206 return remove(mbMailingList);
207 }
208 catch (NoSuchMailingListException nsee) {
209 throw nsee;
210 }
211 catch (Exception e) {
212 throw processException(e);
213 }
214 finally {
215 closeSession(session);
216 }
217 }
218
219 public MBMailingList remove(MBMailingList mbMailingList)
220 throws SystemException {
221 for (ModelListener<MBMailingList> listener : listeners) {
222 listener.onBeforeRemove(mbMailingList);
223 }
224
225 mbMailingList = removeImpl(mbMailingList);
226
227 for (ModelListener<MBMailingList> listener : listeners) {
228 listener.onAfterRemove(mbMailingList);
229 }
230
231 return mbMailingList;
232 }
233
234 protected MBMailingList removeImpl(MBMailingList mbMailingList)
235 throws SystemException {
236 mbMailingList = toUnwrappedModel(mbMailingList);
237
238 Session session = null;
239
240 try {
241 session = openSession();
242
243 if (mbMailingList.isCachedModel() || BatchSessionUtil.isEnabled()) {
244 Object staleObject = session.get(MBMailingListImpl.class,
245 mbMailingList.getPrimaryKeyObj());
246
247 if (staleObject != null) {
248 session.evict(staleObject);
249 }
250 }
251
252 session.delete(mbMailingList);
253
254 session.flush();
255 }
256 catch (Exception e) {
257 throw processException(e);
258 }
259 finally {
260 closeSession(session);
261 }
262
263 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
264
265 MBMailingListModelImpl mbMailingListModelImpl = (MBMailingListModelImpl)mbMailingList;
266
267 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
268 new Object[] {
269 mbMailingListModelImpl.getOriginalUuid(),
270 new Long(mbMailingListModelImpl.getOriginalGroupId())
271 });
272
273 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CATEGORYID,
274 new Object[] {
275 new Long(mbMailingListModelImpl.getOriginalCategoryId())
276 });
277
278 EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
279 MBMailingListImpl.class, mbMailingList.getPrimaryKey());
280
281 return mbMailingList;
282 }
283
284
287 public MBMailingList update(MBMailingList mbMailingList)
288 throws SystemException {
289 if (_log.isWarnEnabled()) {
290 _log.warn(
291 "Using the deprecated update(MBMailingList mbMailingList) method. Use update(MBMailingList mbMailingList, boolean merge) instead.");
292 }
293
294 return update(mbMailingList, false);
295 }
296
297 public MBMailingList updateImpl(
298 com.liferay.portlet.messageboards.model.MBMailingList mbMailingList,
299 boolean merge) throws SystemException {
300 mbMailingList = toUnwrappedModel(mbMailingList);
301
302 boolean isNew = mbMailingList.isNew();
303
304 MBMailingListModelImpl mbMailingListModelImpl = (MBMailingListModelImpl)mbMailingList;
305
306 if (Validator.isNull(mbMailingList.getUuid())) {
307 String uuid = PortalUUIDUtil.generate();
308
309 mbMailingList.setUuid(uuid);
310 }
311
312 Session session = null;
313
314 try {
315 session = openSession();
316
317 BatchSessionUtil.update(session, mbMailingList, merge);
318
319 mbMailingList.setNew(false);
320 }
321 catch (Exception e) {
322 throw processException(e);
323 }
324 finally {
325 closeSession(session);
326 }
327
328 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
329
330 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
331 MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
332 mbMailingList);
333
334 if (!isNew &&
335 (!Validator.equals(mbMailingList.getUuid(),
336 mbMailingListModelImpl.getOriginalUuid()) ||
337 (mbMailingList.getGroupId() != mbMailingListModelImpl.getOriginalGroupId()))) {
338 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
339 new Object[] {
340 mbMailingListModelImpl.getOriginalUuid(),
341 new Long(mbMailingListModelImpl.getOriginalGroupId())
342 });
343 }
344
345 if (isNew ||
346 (!Validator.equals(mbMailingList.getUuid(),
347 mbMailingListModelImpl.getOriginalUuid()) ||
348 (mbMailingList.getGroupId() != mbMailingListModelImpl.getOriginalGroupId()))) {
349 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
350 new Object[] {
351 mbMailingList.getUuid(),
352 new Long(mbMailingList.getGroupId())
353 }, mbMailingList);
354 }
355
356 if (!isNew &&
357 (mbMailingList.getCategoryId() != mbMailingListModelImpl.getOriginalCategoryId())) {
358 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CATEGORYID,
359 new Object[] {
360 new Long(mbMailingListModelImpl.getOriginalCategoryId())
361 });
362 }
363
364 if (isNew ||
365 (mbMailingList.getCategoryId() != mbMailingListModelImpl.getOriginalCategoryId())) {
366 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CATEGORYID,
367 new Object[] { new Long(mbMailingList.getCategoryId()) },
368 mbMailingList);
369 }
370
371 return mbMailingList;
372 }
373
374 protected MBMailingList toUnwrappedModel(MBMailingList mbMailingList) {
375 if (mbMailingList instanceof MBMailingListImpl) {
376 return mbMailingList;
377 }
378
379 MBMailingListImpl mbMailingListImpl = new MBMailingListImpl();
380
381 mbMailingListImpl.setNew(mbMailingList.isNew());
382 mbMailingListImpl.setPrimaryKey(mbMailingList.getPrimaryKey());
383
384 mbMailingListImpl.setUuid(mbMailingList.getUuid());
385 mbMailingListImpl.setMailingListId(mbMailingList.getMailingListId());
386 mbMailingListImpl.setGroupId(mbMailingList.getGroupId());
387 mbMailingListImpl.setCompanyId(mbMailingList.getCompanyId());
388 mbMailingListImpl.setUserId(mbMailingList.getUserId());
389 mbMailingListImpl.setUserName(mbMailingList.getUserName());
390 mbMailingListImpl.setCreateDate(mbMailingList.getCreateDate());
391 mbMailingListImpl.setModifiedDate(mbMailingList.getModifiedDate());
392 mbMailingListImpl.setCategoryId(mbMailingList.getCategoryId());
393 mbMailingListImpl.setEmailAddress(mbMailingList.getEmailAddress());
394 mbMailingListImpl.setInProtocol(mbMailingList.getInProtocol());
395 mbMailingListImpl.setInServerName(mbMailingList.getInServerName());
396 mbMailingListImpl.setInServerPort(mbMailingList.getInServerPort());
397 mbMailingListImpl.setInUseSSL(mbMailingList.isInUseSSL());
398 mbMailingListImpl.setInUserName(mbMailingList.getInUserName());
399 mbMailingListImpl.setInPassword(mbMailingList.getInPassword());
400 mbMailingListImpl.setInReadInterval(mbMailingList.getInReadInterval());
401 mbMailingListImpl.setOutEmailAddress(mbMailingList.getOutEmailAddress());
402 mbMailingListImpl.setOutCustom(mbMailingList.isOutCustom());
403 mbMailingListImpl.setOutServerName(mbMailingList.getOutServerName());
404 mbMailingListImpl.setOutServerPort(mbMailingList.getOutServerPort());
405 mbMailingListImpl.setOutUseSSL(mbMailingList.isOutUseSSL());
406 mbMailingListImpl.setOutUserName(mbMailingList.getOutUserName());
407 mbMailingListImpl.setOutPassword(mbMailingList.getOutPassword());
408 mbMailingListImpl.setActive(mbMailingList.isActive());
409
410 return mbMailingListImpl;
411 }
412
413 public MBMailingList findByPrimaryKey(Serializable primaryKey)
414 throws NoSuchModelException, SystemException {
415 return findByPrimaryKey(((Long)primaryKey).longValue());
416 }
417
418 public MBMailingList findByPrimaryKey(long mailingListId)
419 throws NoSuchMailingListException, SystemException {
420 MBMailingList mbMailingList = fetchByPrimaryKey(mailingListId);
421
422 if (mbMailingList == null) {
423 if (_log.isWarnEnabled()) {
424 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + mailingListId);
425 }
426
427 throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
428 mailingListId);
429 }
430
431 return mbMailingList;
432 }
433
434 public MBMailingList fetchByPrimaryKey(Serializable primaryKey)
435 throws SystemException {
436 return fetchByPrimaryKey(((Long)primaryKey).longValue());
437 }
438
439 public MBMailingList fetchByPrimaryKey(long mailingListId)
440 throws SystemException {
441 MBMailingList mbMailingList = (MBMailingList)EntityCacheUtil.getResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
442 MBMailingListImpl.class, mailingListId, this);
443
444 if (mbMailingList == null) {
445 Session session = null;
446
447 try {
448 session = openSession();
449
450 mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
451 new Long(mailingListId));
452 }
453 catch (Exception e) {
454 throw processException(e);
455 }
456 finally {
457 if (mbMailingList != null) {
458 cacheResult(mbMailingList);
459 }
460
461 closeSession(session);
462 }
463 }
464
465 return mbMailingList;
466 }
467
468 public List<MBMailingList> findByUuid(String uuid)
469 throws SystemException {
470 Object[] finderArgs = new Object[] { uuid };
471
472 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
473 finderArgs, this);
474
475 if (list == null) {
476 Session session = null;
477
478 try {
479 session = openSession();
480
481 StringBundler query = new StringBundler(2);
482
483 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
484
485 if (uuid == null) {
486 query.append(_FINDER_COLUMN_UUID_UUID_1);
487 }
488 else {
489 if (uuid.equals(StringPool.BLANK)) {
490 query.append(_FINDER_COLUMN_UUID_UUID_3);
491 }
492 else {
493 query.append(_FINDER_COLUMN_UUID_UUID_2);
494 }
495 }
496
497 String sql = query.toString();
498
499 Query q = session.createQuery(sql);
500
501 QueryPos qPos = QueryPos.getInstance(q);
502
503 if (uuid != null) {
504 qPos.add(uuid);
505 }
506
507 list = q.list();
508 }
509 catch (Exception e) {
510 throw processException(e);
511 }
512 finally {
513 if (list == null) {
514 list = new ArrayList<MBMailingList>();
515 }
516
517 cacheResult(list);
518
519 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
520 list);
521
522 closeSession(session);
523 }
524 }
525
526 return list;
527 }
528
529 public List<MBMailingList> findByUuid(String uuid, int start, int end)
530 throws SystemException {
531 return findByUuid(uuid, start, end, null);
532 }
533
534 public List<MBMailingList> findByUuid(String uuid, int start, int end,
535 OrderByComparator obc) throws SystemException {
536 Object[] finderArgs = new Object[] {
537 uuid,
538
539 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
540 };
541
542 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
543 finderArgs, this);
544
545 if (list == null) {
546 Session session = null;
547
548 try {
549 session = openSession();
550
551 StringBundler query = null;
552
553 if (obc != null) {
554 query = new StringBundler(3 +
555 (obc.getOrderByFields().length * 3));
556 }
557 else {
558 query = new StringBundler(2);
559 }
560
561 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
562
563 if (uuid == null) {
564 query.append(_FINDER_COLUMN_UUID_UUID_1);
565 }
566 else {
567 if (uuid.equals(StringPool.BLANK)) {
568 query.append(_FINDER_COLUMN_UUID_UUID_3);
569 }
570 else {
571 query.append(_FINDER_COLUMN_UUID_UUID_2);
572 }
573 }
574
575 if (obc != null) {
576 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
577 }
578
579 String sql = query.toString();
580
581 Query q = session.createQuery(sql);
582
583 QueryPos qPos = QueryPos.getInstance(q);
584
585 if (uuid != null) {
586 qPos.add(uuid);
587 }
588
589 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
590 start, end);
591 }
592 catch (Exception e) {
593 throw processException(e);
594 }
595 finally {
596 if (list == null) {
597 list = new ArrayList<MBMailingList>();
598 }
599
600 cacheResult(list);
601
602 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
603 finderArgs, list);
604
605 closeSession(session);
606 }
607 }
608
609 return list;
610 }
611
612 public MBMailingList findByUuid_First(String uuid, OrderByComparator obc)
613 throws NoSuchMailingListException, SystemException {
614 List<MBMailingList> list = findByUuid(uuid, 0, 1, obc);
615
616 if (list.isEmpty()) {
617 StringBundler msg = new StringBundler(4);
618
619 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
620
621 msg.append("uuid=");
622 msg.append(uuid);
623
624 msg.append(StringPool.CLOSE_CURLY_BRACE);
625
626 throw new NoSuchMailingListException(msg.toString());
627 }
628 else {
629 return list.get(0);
630 }
631 }
632
633 public MBMailingList findByUuid_Last(String uuid, OrderByComparator obc)
634 throws NoSuchMailingListException, SystemException {
635 int count = countByUuid(uuid);
636
637 List<MBMailingList> list = findByUuid(uuid, count - 1, count, obc);
638
639 if (list.isEmpty()) {
640 StringBundler msg = new StringBundler(4);
641
642 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
643
644 msg.append("uuid=");
645 msg.append(uuid);
646
647 msg.append(StringPool.CLOSE_CURLY_BRACE);
648
649 throw new NoSuchMailingListException(msg.toString());
650 }
651 else {
652 return list.get(0);
653 }
654 }
655
656 public MBMailingList[] findByUuid_PrevAndNext(long mailingListId,
657 String uuid, OrderByComparator obc)
658 throws NoSuchMailingListException, SystemException {
659 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
660
661 int count = countByUuid(uuid);
662
663 Session session = null;
664
665 try {
666 session = openSession();
667
668 StringBundler query = null;
669
670 if (obc != null) {
671 query = new StringBundler(3 +
672 (obc.getOrderByFields().length * 3));
673 }
674 else {
675 query = new StringBundler(2);
676 }
677
678 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
679
680 if (uuid == null) {
681 query.append(_FINDER_COLUMN_UUID_UUID_1);
682 }
683 else {
684 if (uuid.equals(StringPool.BLANK)) {
685 query.append(_FINDER_COLUMN_UUID_UUID_3);
686 }
687 else {
688 query.append(_FINDER_COLUMN_UUID_UUID_2);
689 }
690 }
691
692 if (obc != null) {
693 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
694 }
695
696 String sql = query.toString();
697
698 Query q = session.createQuery(sql);
699
700 QueryPos qPos = QueryPos.getInstance(q);
701
702 if (uuid != null) {
703 qPos.add(uuid);
704 }
705
706 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
707 mbMailingList);
708
709 MBMailingList[] array = new MBMailingListImpl[3];
710
711 array[0] = (MBMailingList)objArray[0];
712 array[1] = (MBMailingList)objArray[1];
713 array[2] = (MBMailingList)objArray[2];
714
715 return array;
716 }
717 catch (Exception e) {
718 throw processException(e);
719 }
720 finally {
721 closeSession(session);
722 }
723 }
724
725 public MBMailingList findByUUID_G(String uuid, long groupId)
726 throws NoSuchMailingListException, SystemException {
727 MBMailingList mbMailingList = fetchByUUID_G(uuid, groupId);
728
729 if (mbMailingList == null) {
730 StringBundler msg = new StringBundler(6);
731
732 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
733
734 msg.append("uuid=");
735 msg.append(uuid);
736
737 msg.append(", groupId=");
738 msg.append(groupId);
739
740 msg.append(StringPool.CLOSE_CURLY_BRACE);
741
742 if (_log.isWarnEnabled()) {
743 _log.warn(msg.toString());
744 }
745
746 throw new NoSuchMailingListException(msg.toString());
747 }
748
749 return mbMailingList;
750 }
751
752 public MBMailingList fetchByUUID_G(String uuid, long groupId)
753 throws SystemException {
754 return fetchByUUID_G(uuid, groupId, true);
755 }
756
757 public MBMailingList fetchByUUID_G(String uuid, long groupId,
758 boolean retrieveFromCache) throws SystemException {
759 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
760
761 Object result = null;
762
763 if (retrieveFromCache) {
764 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
765 finderArgs, this);
766 }
767
768 if (result == null) {
769 Session session = null;
770
771 try {
772 session = openSession();
773
774 StringBundler query = new StringBundler(3);
775
776 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
777
778 if (uuid == null) {
779 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
780 }
781 else {
782 if (uuid.equals(StringPool.BLANK)) {
783 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
784 }
785 else {
786 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
787 }
788 }
789
790 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
791
792 String sql = query.toString();
793
794 Query q = session.createQuery(sql);
795
796 QueryPos qPos = QueryPos.getInstance(q);
797
798 if (uuid != null) {
799 qPos.add(uuid);
800 }
801
802 qPos.add(groupId);
803
804 List<MBMailingList> list = q.list();
805
806 result = list;
807
808 MBMailingList mbMailingList = null;
809
810 if (list.isEmpty()) {
811 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
812 finderArgs, list);
813 }
814 else {
815 mbMailingList = list.get(0);
816
817 cacheResult(mbMailingList);
818
819 if ((mbMailingList.getUuid() == null) ||
820 !mbMailingList.getUuid().equals(uuid) ||
821 (mbMailingList.getGroupId() != groupId)) {
822 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
823 finderArgs, mbMailingList);
824 }
825 }
826
827 return mbMailingList;
828 }
829 catch (Exception e) {
830 throw processException(e);
831 }
832 finally {
833 if (result == null) {
834 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
835 finderArgs, new ArrayList<MBMailingList>());
836 }
837
838 closeSession(session);
839 }
840 }
841 else {
842 if (result instanceof List<?>) {
843 return null;
844 }
845 else {
846 return (MBMailingList)result;
847 }
848 }
849 }
850
851 public MBMailingList findByCategoryId(long categoryId)
852 throws NoSuchMailingListException, SystemException {
853 MBMailingList mbMailingList = fetchByCategoryId(categoryId);
854
855 if (mbMailingList == null) {
856 StringBundler msg = new StringBundler(4);
857
858 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
859
860 msg.append("categoryId=");
861 msg.append(categoryId);
862
863 msg.append(StringPool.CLOSE_CURLY_BRACE);
864
865 if (_log.isWarnEnabled()) {
866 _log.warn(msg.toString());
867 }
868
869 throw new NoSuchMailingListException(msg.toString());
870 }
871
872 return mbMailingList;
873 }
874
875 public MBMailingList fetchByCategoryId(long categoryId)
876 throws SystemException {
877 return fetchByCategoryId(categoryId, true);
878 }
879
880 public MBMailingList fetchByCategoryId(long categoryId,
881 boolean retrieveFromCache) throws SystemException {
882 Object[] finderArgs = new Object[] { new Long(categoryId) };
883
884 Object result = null;
885
886 if (retrieveFromCache) {
887 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CATEGORYID,
888 finderArgs, this);
889 }
890
891 if (result == null) {
892 Session session = null;
893
894 try {
895 session = openSession();
896
897 StringBundler query = new StringBundler(2);
898
899 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
900
901 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
902
903 String sql = query.toString();
904
905 Query q = session.createQuery(sql);
906
907 QueryPos qPos = QueryPos.getInstance(q);
908
909 qPos.add(categoryId);
910
911 List<MBMailingList> list = q.list();
912
913 result = list;
914
915 MBMailingList mbMailingList = null;
916
917 if (list.isEmpty()) {
918 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CATEGORYID,
919 finderArgs, list);
920 }
921 else {
922 mbMailingList = list.get(0);
923
924 cacheResult(mbMailingList);
925
926 if ((mbMailingList.getCategoryId() != categoryId)) {
927 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CATEGORYID,
928 finderArgs, mbMailingList);
929 }
930 }
931
932 return mbMailingList;
933 }
934 catch (Exception e) {
935 throw processException(e);
936 }
937 finally {
938 if (result == null) {
939 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CATEGORYID,
940 finderArgs, new ArrayList<MBMailingList>());
941 }
942
943 closeSession(session);
944 }
945 }
946 else {
947 if (result instanceof List<?>) {
948 return null;
949 }
950 else {
951 return (MBMailingList)result;
952 }
953 }
954 }
955
956 public List<MBMailingList> findByActive(boolean active)
957 throws SystemException {
958 Object[] finderArgs = new Object[] { Boolean.valueOf(active) };
959
960 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ACTIVE,
961 finderArgs, this);
962
963 if (list == null) {
964 Session session = null;
965
966 try {
967 session = openSession();
968
969 StringBundler query = new StringBundler(2);
970
971 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
972
973 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
974
975 String sql = query.toString();
976
977 Query q = session.createQuery(sql);
978
979 QueryPos qPos = QueryPos.getInstance(q);
980
981 qPos.add(active);
982
983 list = q.list();
984 }
985 catch (Exception e) {
986 throw processException(e);
987 }
988 finally {
989 if (list == null) {
990 list = new ArrayList<MBMailingList>();
991 }
992
993 cacheResult(list);
994
995 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ACTIVE,
996 finderArgs, list);
997
998 closeSession(session);
999 }
1000 }
1001
1002 return list;
1003 }
1004
1005 public List<MBMailingList> findByActive(boolean active, int start, int end)
1006 throws SystemException {
1007 return findByActive(active, start, end, null);
1008 }
1009
1010 public List<MBMailingList> findByActive(boolean active, int start, int end,
1011 OrderByComparator obc) throws SystemException {
1012 Object[] finderArgs = new Object[] {
1013 Boolean.valueOf(active),
1014
1015 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1016 };
1017
1018 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ACTIVE,
1019 finderArgs, this);
1020
1021 if (list == null) {
1022 Session session = null;
1023
1024 try {
1025 session = openSession();
1026
1027 StringBundler query = null;
1028
1029 if (obc != null) {
1030 query = new StringBundler(3 +
1031 (obc.getOrderByFields().length * 3));
1032 }
1033 else {
1034 query = new StringBundler(2);
1035 }
1036
1037 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1038
1039 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1040
1041 if (obc != null) {
1042 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1043 }
1044
1045 String sql = query.toString();
1046
1047 Query q = session.createQuery(sql);
1048
1049 QueryPos qPos = QueryPos.getInstance(q);
1050
1051 qPos.add(active);
1052
1053 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1054 start, end);
1055 }
1056 catch (Exception e) {
1057 throw processException(e);
1058 }
1059 finally {
1060 if (list == null) {
1061 list = new ArrayList<MBMailingList>();
1062 }
1063
1064 cacheResult(list);
1065
1066 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ACTIVE,
1067 finderArgs, list);
1068
1069 closeSession(session);
1070 }
1071 }
1072
1073 return list;
1074 }
1075
1076 public MBMailingList findByActive_First(boolean active,
1077 OrderByComparator obc)
1078 throws NoSuchMailingListException, SystemException {
1079 List<MBMailingList> list = findByActive(active, 0, 1, obc);
1080
1081 if (list.isEmpty()) {
1082 StringBundler msg = new StringBundler(4);
1083
1084 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1085
1086 msg.append("active=");
1087 msg.append(active);
1088
1089 msg.append(StringPool.CLOSE_CURLY_BRACE);
1090
1091 throw new NoSuchMailingListException(msg.toString());
1092 }
1093 else {
1094 return list.get(0);
1095 }
1096 }
1097
1098 public MBMailingList findByActive_Last(boolean active, OrderByComparator obc)
1099 throws NoSuchMailingListException, SystemException {
1100 int count = countByActive(active);
1101
1102 List<MBMailingList> list = findByActive(active, count - 1, count, obc);
1103
1104 if (list.isEmpty()) {
1105 StringBundler msg = new StringBundler(4);
1106
1107 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1108
1109 msg.append("active=");
1110 msg.append(active);
1111
1112 msg.append(StringPool.CLOSE_CURLY_BRACE);
1113
1114 throw new NoSuchMailingListException(msg.toString());
1115 }
1116 else {
1117 return list.get(0);
1118 }
1119 }
1120
1121 public MBMailingList[] findByActive_PrevAndNext(long mailingListId,
1122 boolean active, OrderByComparator obc)
1123 throws NoSuchMailingListException, SystemException {
1124 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
1125
1126 int count = countByActive(active);
1127
1128 Session session = null;
1129
1130 try {
1131 session = openSession();
1132
1133 StringBundler query = null;
1134
1135 if (obc != null) {
1136 query = new StringBundler(3 +
1137 (obc.getOrderByFields().length * 3));
1138 }
1139 else {
1140 query = new StringBundler(2);
1141 }
1142
1143 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1144
1145 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1146
1147 if (obc != null) {
1148 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1149 }
1150
1151 String sql = query.toString();
1152
1153 Query q = session.createQuery(sql);
1154
1155 QueryPos qPos = QueryPos.getInstance(q);
1156
1157 qPos.add(active);
1158
1159 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1160 mbMailingList);
1161
1162 MBMailingList[] array = new MBMailingListImpl[3];
1163
1164 array[0] = (MBMailingList)objArray[0];
1165 array[1] = (MBMailingList)objArray[1];
1166 array[2] = (MBMailingList)objArray[2];
1167
1168 return array;
1169 }
1170 catch (Exception e) {
1171 throw processException(e);
1172 }
1173 finally {
1174 closeSession(session);
1175 }
1176 }
1177
1178 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1179 throws SystemException {
1180 Session session = null;
1181
1182 try {
1183 session = openSession();
1184
1185 dynamicQuery.compile(session);
1186
1187 return dynamicQuery.list();
1188 }
1189 catch (Exception e) {
1190 throw processException(e);
1191 }
1192 finally {
1193 closeSession(session);
1194 }
1195 }
1196
1197 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1198 int start, int end) throws SystemException {
1199 Session session = null;
1200
1201 try {
1202 session = openSession();
1203
1204 dynamicQuery.setLimit(start, end);
1205
1206 dynamicQuery.compile(session);
1207
1208 return dynamicQuery.list();
1209 }
1210 catch (Exception e) {
1211 throw processException(e);
1212 }
1213 finally {
1214 closeSession(session);
1215 }
1216 }
1217
1218 public List<MBMailingList> findAll() throws SystemException {
1219 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1220 }
1221
1222 public List<MBMailingList> findAll(int start, int end)
1223 throws SystemException {
1224 return findAll(start, end, null);
1225 }
1226
1227 public List<MBMailingList> findAll(int start, int end, OrderByComparator obc)
1228 throws SystemException {
1229 Object[] finderArgs = new Object[] {
1230 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1231 };
1232
1233 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1234 finderArgs, this);
1235
1236 if (list == null) {
1237 Session session = null;
1238
1239 try {
1240 session = openSession();
1241
1242 StringBundler query = null;
1243 String sql = null;
1244
1245 if (obc != null) {
1246 query = new StringBundler(2 +
1247 (obc.getOrderByFields().length * 3));
1248
1249 query.append(_SQL_SELECT_MBMAILINGLIST);
1250
1251 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1252
1253 sql = query.toString();
1254 }
1255
1256 sql = _SQL_SELECT_MBMAILINGLIST;
1257
1258 Query q = session.createQuery(sql);
1259
1260 if (obc == null) {
1261 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1262 start, end, false);
1263
1264 Collections.sort(list);
1265 }
1266 else {
1267 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1268 start, end);
1269 }
1270 }
1271 catch (Exception e) {
1272 throw processException(e);
1273 }
1274 finally {
1275 if (list == null) {
1276 list = new ArrayList<MBMailingList>();
1277 }
1278
1279 cacheResult(list);
1280
1281 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1282
1283 closeSession(session);
1284 }
1285 }
1286
1287 return list;
1288 }
1289
1290 public void removeByUuid(String uuid) throws SystemException {
1291 for (MBMailingList mbMailingList : findByUuid(uuid)) {
1292 remove(mbMailingList);
1293 }
1294 }
1295
1296 public void removeByUUID_G(String uuid, long groupId)
1297 throws NoSuchMailingListException, SystemException {
1298 MBMailingList mbMailingList = findByUUID_G(uuid, groupId);
1299
1300 remove(mbMailingList);
1301 }
1302
1303 public void removeByCategoryId(long categoryId)
1304 throws NoSuchMailingListException, SystemException {
1305 MBMailingList mbMailingList = findByCategoryId(categoryId);
1306
1307 remove(mbMailingList);
1308 }
1309
1310 public void removeByActive(boolean active) throws SystemException {
1311 for (MBMailingList mbMailingList : findByActive(active)) {
1312 remove(mbMailingList);
1313 }
1314 }
1315
1316 public void removeAll() throws SystemException {
1317 for (MBMailingList mbMailingList : findAll()) {
1318 remove(mbMailingList);
1319 }
1320 }
1321
1322 public int countByUuid(String uuid) throws SystemException {
1323 Object[] finderArgs = new Object[] { uuid };
1324
1325 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1326 finderArgs, this);
1327
1328 if (count == null) {
1329 Session session = null;
1330
1331 try {
1332 session = openSession();
1333
1334 StringBundler query = new StringBundler(2);
1335
1336 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1337
1338 if (uuid == null) {
1339 query.append(_FINDER_COLUMN_UUID_UUID_1);
1340 }
1341 else {
1342 if (uuid.equals(StringPool.BLANK)) {
1343 query.append(_FINDER_COLUMN_UUID_UUID_3);
1344 }
1345 else {
1346 query.append(_FINDER_COLUMN_UUID_UUID_2);
1347 }
1348 }
1349
1350 String sql = query.toString();
1351
1352 Query q = session.createQuery(sql);
1353
1354 QueryPos qPos = QueryPos.getInstance(q);
1355
1356 if (uuid != null) {
1357 qPos.add(uuid);
1358 }
1359
1360 count = (Long)q.uniqueResult();
1361 }
1362 catch (Exception e) {
1363 throw processException(e);
1364 }
1365 finally {
1366 if (count == null) {
1367 count = Long.valueOf(0);
1368 }
1369
1370 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1371 finderArgs, count);
1372
1373 closeSession(session);
1374 }
1375 }
1376
1377 return count.intValue();
1378 }
1379
1380 public int countByUUID_G(String uuid, long groupId)
1381 throws SystemException {
1382 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1383
1384 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1385 finderArgs, this);
1386
1387 if (count == null) {
1388 Session session = null;
1389
1390 try {
1391 session = openSession();
1392
1393 StringBundler query = new StringBundler(3);
1394
1395 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1396
1397 if (uuid == null) {
1398 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1399 }
1400 else {
1401 if (uuid.equals(StringPool.BLANK)) {
1402 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1403 }
1404 else {
1405 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1406 }
1407 }
1408
1409 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1410
1411 String sql = query.toString();
1412
1413 Query q = session.createQuery(sql);
1414
1415 QueryPos qPos = QueryPos.getInstance(q);
1416
1417 if (uuid != null) {
1418 qPos.add(uuid);
1419 }
1420
1421 qPos.add(groupId);
1422
1423 count = (Long)q.uniqueResult();
1424 }
1425 catch (Exception e) {
1426 throw processException(e);
1427 }
1428 finally {
1429 if (count == null) {
1430 count = Long.valueOf(0);
1431 }
1432
1433 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1434 finderArgs, count);
1435
1436 closeSession(session);
1437 }
1438 }
1439
1440 return count.intValue();
1441 }
1442
1443 public int countByCategoryId(long categoryId) throws SystemException {
1444 Object[] finderArgs = new Object[] { new Long(categoryId) };
1445
1446 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CATEGORYID,
1447 finderArgs, this);
1448
1449 if (count == null) {
1450 Session session = null;
1451
1452 try {
1453 session = openSession();
1454
1455 StringBundler query = new StringBundler(2);
1456
1457 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1458
1459 query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1460
1461 String sql = query.toString();
1462
1463 Query q = session.createQuery(sql);
1464
1465 QueryPos qPos = QueryPos.getInstance(q);
1466
1467 qPos.add(categoryId);
1468
1469 count = (Long)q.uniqueResult();
1470 }
1471 catch (Exception e) {
1472 throw processException(e);
1473 }
1474 finally {
1475 if (count == null) {
1476 count = Long.valueOf(0);
1477 }
1478
1479 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CATEGORYID,
1480 finderArgs, count);
1481
1482 closeSession(session);
1483 }
1484 }
1485
1486 return count.intValue();
1487 }
1488
1489 public int countByActive(boolean active) throws SystemException {
1490 Object[] finderArgs = new Object[] { Boolean.valueOf(active) };
1491
1492 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
1493 finderArgs, this);
1494
1495 if (count == null) {
1496 Session session = null;
1497
1498 try {
1499 session = openSession();
1500
1501 StringBundler query = new StringBundler(2);
1502
1503 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
1504
1505 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1506
1507 String sql = query.toString();
1508
1509 Query q = session.createQuery(sql);
1510
1511 QueryPos qPos = QueryPos.getInstance(q);
1512
1513 qPos.add(active);
1514
1515 count = (Long)q.uniqueResult();
1516 }
1517 catch (Exception e) {
1518 throw processException(e);
1519 }
1520 finally {
1521 if (count == null) {
1522 count = Long.valueOf(0);
1523 }
1524
1525 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
1526 finderArgs, count);
1527
1528 closeSession(session);
1529 }
1530 }
1531
1532 return count.intValue();
1533 }
1534
1535 public int countAll() throws SystemException {
1536 Object[] finderArgs = new Object[0];
1537
1538 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1539 finderArgs, this);
1540
1541 if (count == null) {
1542 Session session = null;
1543
1544 try {
1545 session = openSession();
1546
1547 Query q = session.createQuery(_SQL_COUNT_MBMAILINGLIST);
1548
1549 count = (Long)q.uniqueResult();
1550 }
1551 catch (Exception e) {
1552 throw processException(e);
1553 }
1554 finally {
1555 if (count == null) {
1556 count = Long.valueOf(0);
1557 }
1558
1559 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1560 count);
1561
1562 closeSession(session);
1563 }
1564 }
1565
1566 return count.intValue();
1567 }
1568
1569 public void afterPropertiesSet() {
1570 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1571 com.liferay.portal.util.PropsUtil.get(
1572 "value.object.listener.com.liferay.portlet.messageboards.model.MBMailingList")));
1573
1574 if (listenerClassNames.length > 0) {
1575 try {
1576 List<ModelListener<MBMailingList>> listenersList = new ArrayList<ModelListener<MBMailingList>>();
1577
1578 for (String listenerClassName : listenerClassNames) {
1579 listenersList.add((ModelListener<MBMailingList>)Class.forName(
1580 listenerClassName).newInstance());
1581 }
1582
1583 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1584 }
1585 catch (Exception e) {
1586 _log.error(e);
1587 }
1588 }
1589 }
1590
1591 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBBanPersistence")
1592 protected com.liferay.portlet.messageboards.service.persistence.MBBanPersistence mbBanPersistence;
1593 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence")
1594 protected com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence mbCategoryPersistence;
1595 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence")
1596 protected com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence mbDiscussionPersistence;
1597 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMailingListPersistence")
1598 protected com.liferay.portlet.messageboards.service.persistence.MBMailingListPersistence mbMailingListPersistence;
1599 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence")
1600 protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
1601 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence")
1602 protected com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence mbMessageFlagPersistence;
1603 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence")
1604 protected com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence mbStatsUserPersistence;
1605 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence")
1606 protected com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence mbThreadPersistence;
1607 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
1608 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1609 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
1610 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1611 private static final String _SQL_SELECT_MBMAILINGLIST = "SELECT mbMailingList FROM MBMailingList mbMailingList";
1612 private static final String _SQL_SELECT_MBMAILINGLIST_WHERE = "SELECT mbMailingList FROM MBMailingList mbMailingList WHERE ";
1613 private static final String _SQL_COUNT_MBMAILINGLIST = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList";
1614 private static final String _SQL_COUNT_MBMAILINGLIST_WHERE = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList WHERE ";
1615 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbMailingList.uuid IS NULL";
1616 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbMailingList.uuid = ?";
1617 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = ?)";
1618 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbMailingList.uuid IS NULL AND ";
1619 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbMailingList.uuid = ? AND ";
1620 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = ?) AND ";
1621 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbMailingList.groupId = ?";
1622 private static final String _FINDER_COLUMN_CATEGORYID_CATEGORYID_2 = "mbMailingList.categoryId = ?";
1623 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "mbMailingList.active = ?";
1624 private static final String _ORDER_BY_ENTITY_ALIAS = "mbMailingList.";
1625 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBMailingList exists with the primary key ";
1626 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBMailingList exists with the key {";
1627 private static Log _log = LogFactoryUtil.getLog(MBMailingListPersistenceImpl.class);
1628}