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