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