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