001
014
015 package com.liferay.portlet.messageboards.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.service.persistence.UserPersistence;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import com.liferay.portlet.messageboards.NoSuchMailingListException;
044 import com.liferay.portlet.messageboards.model.MBMailingList;
045 import com.liferay.portlet.messageboards.model.impl.MBMailingListImpl;
046 import com.liferay.portlet.messageboards.model.impl.MBMailingListModelImpl;
047
048 import java.io.Serializable;
049
050 import java.util.ArrayList;
051 import java.util.Collections;
052 import java.util.List;
053
054
066 public class MBMailingListPersistenceImpl extends BasePersistenceImpl<MBMailingList>
067 implements MBMailingListPersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = MBMailingListImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List1";
076 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List2";
078 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
079 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
080 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
081 "findByUuid",
082 new String[] {
083 String.class.getName(),
084
085 "java.lang.Integer", "java.lang.Integer",
086 "com.liferay.portal.kernel.util.OrderByComparator"
087 });
088 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
089 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
090 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
091 "findByUuid", new String[] { String.class.getName() },
092 MBMailingListModelImpl.UUID_COLUMN_BITMASK);
093 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
094 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
096 new String[] { String.class.getName() });
097 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
098 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
099 MBMailingListImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
100 new String[] { String.class.getName(), Long.class.getName() },
101 MBMailingListModelImpl.UUID_COLUMN_BITMASK |
102 MBMailingListModelImpl.GROUPID_COLUMN_BITMASK);
103 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
104 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
105 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
106 new String[] { String.class.getName(), Long.class.getName() });
107 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
108 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
109 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
110 "findByUuid_C",
111 new String[] {
112 String.class.getName(), Long.class.getName(),
113
114 "java.lang.Integer", "java.lang.Integer",
115 "com.liferay.portal.kernel.util.OrderByComparator"
116 });
117 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
118 new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
119 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
120 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
121 "findByUuid_C",
122 new String[] { String.class.getName(), Long.class.getName() },
123 MBMailingListModelImpl.UUID_COLUMN_BITMASK |
124 MBMailingListModelImpl.COMPANYID_COLUMN_BITMASK);
125 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
126 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
128 new String[] { String.class.getName(), Long.class.getName() });
129 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
130 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
131 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
132 "findByActive",
133 new String[] {
134 Boolean.class.getName(),
135
136 "java.lang.Integer", "java.lang.Integer",
137 "com.liferay.portal.kernel.util.OrderByComparator"
138 });
139 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE =
140 new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
141 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
142 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
143 "findByActive", new String[] { Boolean.class.getName() },
144 MBMailingListModelImpl.ACTIVE_COLUMN_BITMASK);
145 public static final FinderPath FINDER_PATH_COUNT_BY_ACTIVE = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
146 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
147 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByActive",
148 new String[] { Boolean.class.getName() });
149 public static final FinderPath FINDER_PATH_FETCH_BY_G_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
150 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
151 MBMailingListImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_C",
152 new String[] { Long.class.getName(), Long.class.getName() },
153 MBMailingListModelImpl.GROUPID_COLUMN_BITMASK |
154 MBMailingListModelImpl.CATEGORYID_COLUMN_BITMASK);
155 public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
156 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
157 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C",
158 new String[] { Long.class.getName(), Long.class.getName() });
159 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
160 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
161 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
162 "findAll", new String[0]);
163 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
164 MBMailingListModelImpl.FINDER_CACHE_ENABLED,
165 MBMailingListImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
166 "findAll", new String[0]);
167 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
168 MBMailingListModelImpl.FINDER_CACHE_ENABLED, Long.class,
169 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
170
171
176 public void cacheResult(MBMailingList mbMailingList) {
177 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
178 MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
179 mbMailingList);
180
181 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
182 new Object[] {
183 mbMailingList.getUuid(),
184 Long.valueOf(mbMailingList.getGroupId())
185 }, mbMailingList);
186
187 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
188 new Object[] {
189 Long.valueOf(mbMailingList.getGroupId()),
190 Long.valueOf(mbMailingList.getCategoryId())
191 }, mbMailingList);
192
193 mbMailingList.resetOriginalValues();
194 }
195
196
201 public void cacheResult(List<MBMailingList> mbMailingLists) {
202 for (MBMailingList mbMailingList : mbMailingLists) {
203 if (EntityCacheUtil.getResult(
204 MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
205 MBMailingListImpl.class, mbMailingList.getPrimaryKey()) == null) {
206 cacheResult(mbMailingList);
207 }
208 else {
209 mbMailingList.resetOriginalValues();
210 }
211 }
212 }
213
214
221 @Override
222 public void clearCache() {
223 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
224 CacheRegistryUtil.clear(MBMailingListImpl.class.getName());
225 }
226
227 EntityCacheUtil.clearCache(MBMailingListImpl.class.getName());
228
229 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
230 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
231 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
232 }
233
234
241 @Override
242 public void clearCache(MBMailingList mbMailingList) {
243 EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
244 MBMailingListImpl.class, mbMailingList.getPrimaryKey());
245
246 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
247 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
248
249 clearUniqueFindersCache(mbMailingList);
250 }
251
252 @Override
253 public void clearCache(List<MBMailingList> mbMailingLists) {
254 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
255 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
256
257 for (MBMailingList mbMailingList : mbMailingLists) {
258 EntityCacheUtil.removeResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
259 MBMailingListImpl.class, mbMailingList.getPrimaryKey());
260
261 clearUniqueFindersCache(mbMailingList);
262 }
263 }
264
265 protected void clearUniqueFindersCache(MBMailingList mbMailingList) {
266 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
267 new Object[] {
268 mbMailingList.getUuid(),
269 Long.valueOf(mbMailingList.getGroupId())
270 });
271
272 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C,
273 new Object[] {
274 Long.valueOf(mbMailingList.getGroupId()),
275 Long.valueOf(mbMailingList.getCategoryId())
276 });
277 }
278
279
285 public MBMailingList create(long mailingListId) {
286 MBMailingList mbMailingList = new MBMailingListImpl();
287
288 mbMailingList.setNew(true);
289 mbMailingList.setPrimaryKey(mailingListId);
290
291 String uuid = PortalUUIDUtil.generate();
292
293 mbMailingList.setUuid(uuid);
294
295 return mbMailingList;
296 }
297
298
306 public MBMailingList remove(long mailingListId)
307 throws NoSuchMailingListException, SystemException {
308 return remove(Long.valueOf(mailingListId));
309 }
310
311
319 @Override
320 public MBMailingList remove(Serializable primaryKey)
321 throws NoSuchMailingListException, SystemException {
322 Session session = null;
323
324 try {
325 session = openSession();
326
327 MBMailingList mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
328 primaryKey);
329
330 if (mbMailingList == null) {
331 if (_log.isWarnEnabled()) {
332 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
333 }
334
335 throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
336 primaryKey);
337 }
338
339 return remove(mbMailingList);
340 }
341 catch (NoSuchMailingListException nsee) {
342 throw nsee;
343 }
344 catch (Exception e) {
345 throw processException(e);
346 }
347 finally {
348 closeSession(session);
349 }
350 }
351
352 @Override
353 protected MBMailingList removeImpl(MBMailingList mbMailingList)
354 throws SystemException {
355 mbMailingList = toUnwrappedModel(mbMailingList);
356
357 Session session = null;
358
359 try {
360 session = openSession();
361
362 if (mbMailingList.isCachedModel()) {
363 mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
364 mbMailingList.getPrimaryKeyObj());
365 }
366
367 session.delete(mbMailingList);
368 }
369 catch (Exception e) {
370 throw processException(e);
371 }
372 finally {
373 closeSession(session);
374 }
375
376 clearCache(mbMailingList);
377
378 return mbMailingList;
379 }
380
381 @Override
382 public MBMailingList updateImpl(
383 com.liferay.portlet.messageboards.model.MBMailingList mbMailingList)
384 throws SystemException {
385 mbMailingList = toUnwrappedModel(mbMailingList);
386
387 boolean isNew = mbMailingList.isNew();
388
389 MBMailingListModelImpl mbMailingListModelImpl = (MBMailingListModelImpl)mbMailingList;
390
391 if (Validator.isNull(mbMailingList.getUuid())) {
392 String uuid = PortalUUIDUtil.generate();
393
394 mbMailingList.setUuid(uuid);
395 }
396
397 Session session = null;
398
399 try {
400 session = openSession();
401
402 if (mbMailingList.isNew()) {
403 session.save(mbMailingList);
404
405 mbMailingList.setNew(false);
406 }
407 else {
408 session.merge(mbMailingList);
409 }
410 }
411 catch (Exception e) {
412 throw processException(e);
413 }
414 finally {
415 closeSession(session);
416 }
417
418 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
419
420 if (isNew || !MBMailingListModelImpl.COLUMN_BITMASK_ENABLED) {
421 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
422 }
423
424 else {
425 if ((mbMailingListModelImpl.getColumnBitmask() &
426 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
427 Object[] args = new Object[] {
428 mbMailingListModelImpl.getOriginalUuid()
429 };
430
431 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
432 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
433 args);
434
435 args = new Object[] { mbMailingListModelImpl.getUuid() };
436
437 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
438 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
439 args);
440 }
441
442 if ((mbMailingListModelImpl.getColumnBitmask() &
443 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
444 Object[] args = new Object[] {
445 mbMailingListModelImpl.getOriginalUuid(),
446 Long.valueOf(mbMailingListModelImpl.getOriginalCompanyId())
447 };
448
449 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
450 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
451 args);
452
453 args = new Object[] {
454 mbMailingListModelImpl.getUuid(),
455 Long.valueOf(mbMailingListModelImpl.getCompanyId())
456 };
457
458 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
459 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
460 args);
461 }
462
463 if ((mbMailingListModelImpl.getColumnBitmask() &
464 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE.getColumnBitmask()) != 0) {
465 Object[] args = new Object[] {
466 Boolean.valueOf(mbMailingListModelImpl.getOriginalActive())
467 };
468
469 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
470 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
471 args);
472
473 args = new Object[] {
474 Boolean.valueOf(mbMailingListModelImpl.getActive())
475 };
476
477 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ACTIVE, args);
478 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE,
479 args);
480 }
481 }
482
483 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
484 MBMailingListImpl.class, mbMailingList.getPrimaryKey(),
485 mbMailingList);
486
487 if (isNew) {
488 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
489 new Object[] {
490 mbMailingList.getUuid(),
491 Long.valueOf(mbMailingList.getGroupId())
492 }, mbMailingList);
493
494 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
495 new Object[] {
496 Long.valueOf(mbMailingList.getGroupId()),
497 Long.valueOf(mbMailingList.getCategoryId())
498 }, mbMailingList);
499 }
500 else {
501 if ((mbMailingListModelImpl.getColumnBitmask() &
502 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
503 Object[] args = new Object[] {
504 mbMailingListModelImpl.getOriginalUuid(),
505 Long.valueOf(mbMailingListModelImpl.getOriginalGroupId())
506 };
507
508 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
509
510 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
511
512 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
513 new Object[] {
514 mbMailingList.getUuid(),
515 Long.valueOf(mbMailingList.getGroupId())
516 }, mbMailingList);
517 }
518
519 if ((mbMailingListModelImpl.getColumnBitmask() &
520 FINDER_PATH_FETCH_BY_G_C.getColumnBitmask()) != 0) {
521 Object[] args = new Object[] {
522 Long.valueOf(mbMailingListModelImpl.getOriginalGroupId()),
523 Long.valueOf(mbMailingListModelImpl.getOriginalCategoryId())
524 };
525
526 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
527
528 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C, args);
529
530 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
531 new Object[] {
532 Long.valueOf(mbMailingList.getGroupId()),
533 Long.valueOf(mbMailingList.getCategoryId())
534 }, mbMailingList);
535 }
536 }
537
538 return mbMailingList;
539 }
540
541 protected MBMailingList toUnwrappedModel(MBMailingList mbMailingList) {
542 if (mbMailingList instanceof MBMailingListImpl) {
543 return mbMailingList;
544 }
545
546 MBMailingListImpl mbMailingListImpl = new MBMailingListImpl();
547
548 mbMailingListImpl.setNew(mbMailingList.isNew());
549 mbMailingListImpl.setPrimaryKey(mbMailingList.getPrimaryKey());
550
551 mbMailingListImpl.setUuid(mbMailingList.getUuid());
552 mbMailingListImpl.setMailingListId(mbMailingList.getMailingListId());
553 mbMailingListImpl.setGroupId(mbMailingList.getGroupId());
554 mbMailingListImpl.setCompanyId(mbMailingList.getCompanyId());
555 mbMailingListImpl.setUserId(mbMailingList.getUserId());
556 mbMailingListImpl.setUserName(mbMailingList.getUserName());
557 mbMailingListImpl.setCreateDate(mbMailingList.getCreateDate());
558 mbMailingListImpl.setModifiedDate(mbMailingList.getModifiedDate());
559 mbMailingListImpl.setCategoryId(mbMailingList.getCategoryId());
560 mbMailingListImpl.setEmailAddress(mbMailingList.getEmailAddress());
561 mbMailingListImpl.setInProtocol(mbMailingList.getInProtocol());
562 mbMailingListImpl.setInServerName(mbMailingList.getInServerName());
563 mbMailingListImpl.setInServerPort(mbMailingList.getInServerPort());
564 mbMailingListImpl.setInUseSSL(mbMailingList.isInUseSSL());
565 mbMailingListImpl.setInUserName(mbMailingList.getInUserName());
566 mbMailingListImpl.setInPassword(mbMailingList.getInPassword());
567 mbMailingListImpl.setInReadInterval(mbMailingList.getInReadInterval());
568 mbMailingListImpl.setOutEmailAddress(mbMailingList.getOutEmailAddress());
569 mbMailingListImpl.setOutCustom(mbMailingList.isOutCustom());
570 mbMailingListImpl.setOutServerName(mbMailingList.getOutServerName());
571 mbMailingListImpl.setOutServerPort(mbMailingList.getOutServerPort());
572 mbMailingListImpl.setOutUseSSL(mbMailingList.isOutUseSSL());
573 mbMailingListImpl.setOutUserName(mbMailingList.getOutUserName());
574 mbMailingListImpl.setOutPassword(mbMailingList.getOutPassword());
575 mbMailingListImpl.setAllowAnonymous(mbMailingList.isAllowAnonymous());
576 mbMailingListImpl.setActive(mbMailingList.isActive());
577
578 return mbMailingListImpl;
579 }
580
581
589 @Override
590 public MBMailingList findByPrimaryKey(Serializable primaryKey)
591 throws NoSuchModelException, SystemException {
592 return findByPrimaryKey(((Long)primaryKey).longValue());
593 }
594
595
603 public MBMailingList findByPrimaryKey(long mailingListId)
604 throws NoSuchMailingListException, SystemException {
605 MBMailingList mbMailingList = fetchByPrimaryKey(mailingListId);
606
607 if (mbMailingList == null) {
608 if (_log.isWarnEnabled()) {
609 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + mailingListId);
610 }
611
612 throw new NoSuchMailingListException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
613 mailingListId);
614 }
615
616 return mbMailingList;
617 }
618
619
626 @Override
627 public MBMailingList fetchByPrimaryKey(Serializable primaryKey)
628 throws SystemException {
629 return fetchByPrimaryKey(((Long)primaryKey).longValue());
630 }
631
632
639 public MBMailingList fetchByPrimaryKey(long mailingListId)
640 throws SystemException {
641 MBMailingList mbMailingList = (MBMailingList)EntityCacheUtil.getResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
642 MBMailingListImpl.class, mailingListId);
643
644 if (mbMailingList == _nullMBMailingList) {
645 return null;
646 }
647
648 if (mbMailingList == null) {
649 Session session = null;
650
651 boolean hasException = false;
652
653 try {
654 session = openSession();
655
656 mbMailingList = (MBMailingList)session.get(MBMailingListImpl.class,
657 Long.valueOf(mailingListId));
658 }
659 catch (Exception e) {
660 hasException = true;
661
662 throw processException(e);
663 }
664 finally {
665 if (mbMailingList != null) {
666 cacheResult(mbMailingList);
667 }
668 else if (!hasException) {
669 EntityCacheUtil.putResult(MBMailingListModelImpl.ENTITY_CACHE_ENABLED,
670 MBMailingListImpl.class, mailingListId,
671 _nullMBMailingList);
672 }
673
674 closeSession(session);
675 }
676 }
677
678 return mbMailingList;
679 }
680
681
688 public List<MBMailingList> findByUuid(String uuid)
689 throws SystemException {
690 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
691 }
692
693
706 public List<MBMailingList> findByUuid(String uuid, int start, int end)
707 throws SystemException {
708 return findByUuid(uuid, start, end, null);
709 }
710
711
725 public List<MBMailingList> findByUuid(String uuid, int start, int end,
726 OrderByComparator orderByComparator) throws SystemException {
727 FinderPath finderPath = null;
728 Object[] finderArgs = null;
729
730 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
731 (orderByComparator == null)) {
732 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
733 finderArgs = new Object[] { uuid };
734 }
735 else {
736 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
737 finderArgs = new Object[] { uuid, start, end, orderByComparator };
738 }
739
740 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
741 finderArgs, this);
742
743 if ((list != null) && !list.isEmpty()) {
744 for (MBMailingList mbMailingList : list) {
745 if (!Validator.equals(uuid, mbMailingList.getUuid())) {
746 list = null;
747
748 break;
749 }
750 }
751 }
752
753 if (list == null) {
754 StringBundler query = null;
755
756 if (orderByComparator != null) {
757 query = new StringBundler(3 +
758 (orderByComparator.getOrderByFields().length * 3));
759 }
760 else {
761 query = new StringBundler(2);
762 }
763
764 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
765
766 if (uuid == null) {
767 query.append(_FINDER_COLUMN_UUID_UUID_1);
768 }
769 else {
770 if (uuid.equals(StringPool.BLANK)) {
771 query.append(_FINDER_COLUMN_UUID_UUID_3);
772 }
773 else {
774 query.append(_FINDER_COLUMN_UUID_UUID_2);
775 }
776 }
777
778 if (orderByComparator != null) {
779 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
780 orderByComparator);
781 }
782
783 String sql = query.toString();
784
785 Session session = null;
786
787 try {
788 session = openSession();
789
790 Query q = session.createQuery(sql);
791
792 QueryPos qPos = QueryPos.getInstance(q);
793
794 if (uuid != null) {
795 qPos.add(uuid);
796 }
797
798 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
799 start, end);
800 }
801 catch (Exception e) {
802 throw processException(e);
803 }
804 finally {
805 if (list == null) {
806 FinderCacheUtil.removeResult(finderPath, finderArgs);
807 }
808 else {
809 cacheResult(list);
810
811 FinderCacheUtil.putResult(finderPath, finderArgs, list);
812 }
813
814 closeSession(session);
815 }
816 }
817
818 return list;
819 }
820
821
830 public MBMailingList findByUuid_First(String uuid,
831 OrderByComparator orderByComparator)
832 throws NoSuchMailingListException, SystemException {
833 MBMailingList mbMailingList = fetchByUuid_First(uuid, orderByComparator);
834
835 if (mbMailingList != null) {
836 return mbMailingList;
837 }
838
839 StringBundler msg = new StringBundler(4);
840
841 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
842
843 msg.append("uuid=");
844 msg.append(uuid);
845
846 msg.append(StringPool.CLOSE_CURLY_BRACE);
847
848 throw new NoSuchMailingListException(msg.toString());
849 }
850
851
859 public MBMailingList fetchByUuid_First(String uuid,
860 OrderByComparator orderByComparator) throws SystemException {
861 List<MBMailingList> list = findByUuid(uuid, 0, 1, orderByComparator);
862
863 if (!list.isEmpty()) {
864 return list.get(0);
865 }
866
867 return null;
868 }
869
870
879 public MBMailingList findByUuid_Last(String uuid,
880 OrderByComparator orderByComparator)
881 throws NoSuchMailingListException, SystemException {
882 MBMailingList mbMailingList = fetchByUuid_Last(uuid, orderByComparator);
883
884 if (mbMailingList != null) {
885 return mbMailingList;
886 }
887
888 StringBundler msg = new StringBundler(4);
889
890 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
891
892 msg.append("uuid=");
893 msg.append(uuid);
894
895 msg.append(StringPool.CLOSE_CURLY_BRACE);
896
897 throw new NoSuchMailingListException(msg.toString());
898 }
899
900
908 public MBMailingList fetchByUuid_Last(String uuid,
909 OrderByComparator orderByComparator) throws SystemException {
910 int count = countByUuid(uuid);
911
912 List<MBMailingList> list = findByUuid(uuid, count - 1, count,
913 orderByComparator);
914
915 if (!list.isEmpty()) {
916 return list.get(0);
917 }
918
919 return null;
920 }
921
922
932 public MBMailingList[] findByUuid_PrevAndNext(long mailingListId,
933 String uuid, OrderByComparator orderByComparator)
934 throws NoSuchMailingListException, SystemException {
935 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
936
937 Session session = null;
938
939 try {
940 session = openSession();
941
942 MBMailingList[] array = new MBMailingListImpl[3];
943
944 array[0] = getByUuid_PrevAndNext(session, mbMailingList, uuid,
945 orderByComparator, true);
946
947 array[1] = mbMailingList;
948
949 array[2] = getByUuid_PrevAndNext(session, mbMailingList, uuid,
950 orderByComparator, false);
951
952 return array;
953 }
954 catch (Exception e) {
955 throw processException(e);
956 }
957 finally {
958 closeSession(session);
959 }
960 }
961
962 protected MBMailingList getByUuid_PrevAndNext(Session session,
963 MBMailingList mbMailingList, String uuid,
964 OrderByComparator orderByComparator, boolean previous) {
965 StringBundler query = null;
966
967 if (orderByComparator != null) {
968 query = new StringBundler(6 +
969 (orderByComparator.getOrderByFields().length * 6));
970 }
971 else {
972 query = new StringBundler(3);
973 }
974
975 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
976
977 if (uuid == null) {
978 query.append(_FINDER_COLUMN_UUID_UUID_1);
979 }
980 else {
981 if (uuid.equals(StringPool.BLANK)) {
982 query.append(_FINDER_COLUMN_UUID_UUID_3);
983 }
984 else {
985 query.append(_FINDER_COLUMN_UUID_UUID_2);
986 }
987 }
988
989 if (orderByComparator != null) {
990 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
991
992 if (orderByConditionFields.length > 0) {
993 query.append(WHERE_AND);
994 }
995
996 for (int i = 0; i < orderByConditionFields.length; i++) {
997 query.append(_ORDER_BY_ENTITY_ALIAS);
998 query.append(orderByConditionFields[i]);
999
1000 if ((i + 1) < orderByConditionFields.length) {
1001 if (orderByComparator.isAscending() ^ previous) {
1002 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1003 }
1004 else {
1005 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1006 }
1007 }
1008 else {
1009 if (orderByComparator.isAscending() ^ previous) {
1010 query.append(WHERE_GREATER_THAN);
1011 }
1012 else {
1013 query.append(WHERE_LESSER_THAN);
1014 }
1015 }
1016 }
1017
1018 query.append(ORDER_BY_CLAUSE);
1019
1020 String[] orderByFields = orderByComparator.getOrderByFields();
1021
1022 for (int i = 0; i < orderByFields.length; i++) {
1023 query.append(_ORDER_BY_ENTITY_ALIAS);
1024 query.append(orderByFields[i]);
1025
1026 if ((i + 1) < orderByFields.length) {
1027 if (orderByComparator.isAscending() ^ previous) {
1028 query.append(ORDER_BY_ASC_HAS_NEXT);
1029 }
1030 else {
1031 query.append(ORDER_BY_DESC_HAS_NEXT);
1032 }
1033 }
1034 else {
1035 if (orderByComparator.isAscending() ^ previous) {
1036 query.append(ORDER_BY_ASC);
1037 }
1038 else {
1039 query.append(ORDER_BY_DESC);
1040 }
1041 }
1042 }
1043 }
1044
1045 String sql = query.toString();
1046
1047 Query q = session.createQuery(sql);
1048
1049 q.setFirstResult(0);
1050 q.setMaxResults(2);
1051
1052 QueryPos qPos = QueryPos.getInstance(q);
1053
1054 if (uuid != null) {
1055 qPos.add(uuid);
1056 }
1057
1058 if (orderByComparator != null) {
1059 Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
1060
1061 for (Object value : values) {
1062 qPos.add(value);
1063 }
1064 }
1065
1066 List<MBMailingList> list = q.list();
1067
1068 if (list.size() == 2) {
1069 return list.get(1);
1070 }
1071 else {
1072 return null;
1073 }
1074 }
1075
1076
1085 public MBMailingList findByUUID_G(String uuid, long groupId)
1086 throws NoSuchMailingListException, SystemException {
1087 MBMailingList mbMailingList = fetchByUUID_G(uuid, groupId);
1088
1089 if (mbMailingList == null) {
1090 StringBundler msg = new StringBundler(6);
1091
1092 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1093
1094 msg.append("uuid=");
1095 msg.append(uuid);
1096
1097 msg.append(", groupId=");
1098 msg.append(groupId);
1099
1100 msg.append(StringPool.CLOSE_CURLY_BRACE);
1101
1102 if (_log.isWarnEnabled()) {
1103 _log.warn(msg.toString());
1104 }
1105
1106 throw new NoSuchMailingListException(msg.toString());
1107 }
1108
1109 return mbMailingList;
1110 }
1111
1112
1120 public MBMailingList fetchByUUID_G(String uuid, long groupId)
1121 throws SystemException {
1122 return fetchByUUID_G(uuid, groupId, true);
1123 }
1124
1125
1134 public MBMailingList fetchByUUID_G(String uuid, long groupId,
1135 boolean retrieveFromCache) throws SystemException {
1136 Object[] finderArgs = new Object[] { uuid, groupId };
1137
1138 Object result = null;
1139
1140 if (retrieveFromCache) {
1141 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1142 finderArgs, this);
1143 }
1144
1145 if (result instanceof MBMailingList) {
1146 MBMailingList mbMailingList = (MBMailingList)result;
1147
1148 if (!Validator.equals(uuid, mbMailingList.getUuid()) ||
1149 (groupId != mbMailingList.getGroupId())) {
1150 result = null;
1151 }
1152 }
1153
1154 if (result == null) {
1155 StringBundler query = new StringBundler(3);
1156
1157 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1158
1159 if (uuid == null) {
1160 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1161 }
1162 else {
1163 if (uuid.equals(StringPool.BLANK)) {
1164 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1165 }
1166 else {
1167 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1168 }
1169 }
1170
1171 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1172
1173 String sql = query.toString();
1174
1175 Session session = null;
1176
1177 try {
1178 session = openSession();
1179
1180 Query q = session.createQuery(sql);
1181
1182 QueryPos qPos = QueryPos.getInstance(q);
1183
1184 if (uuid != null) {
1185 qPos.add(uuid);
1186 }
1187
1188 qPos.add(groupId);
1189
1190 List<MBMailingList> list = q.list();
1191
1192 result = list;
1193
1194 MBMailingList mbMailingList = null;
1195
1196 if (list.isEmpty()) {
1197 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1198 finderArgs, list);
1199 }
1200 else {
1201 mbMailingList = list.get(0);
1202
1203 cacheResult(mbMailingList);
1204
1205 if ((mbMailingList.getUuid() == null) ||
1206 !mbMailingList.getUuid().equals(uuid) ||
1207 (mbMailingList.getGroupId() != groupId)) {
1208 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1209 finderArgs, mbMailingList);
1210 }
1211 }
1212
1213 return mbMailingList;
1214 }
1215 catch (Exception e) {
1216 throw processException(e);
1217 }
1218 finally {
1219 if (result == null) {
1220 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1221 finderArgs);
1222 }
1223
1224 closeSession(session);
1225 }
1226 }
1227 else {
1228 if (result instanceof List<?>) {
1229 return null;
1230 }
1231 else {
1232 return (MBMailingList)result;
1233 }
1234 }
1235 }
1236
1237
1245 public List<MBMailingList> findByUuid_C(String uuid, long companyId)
1246 throws SystemException {
1247 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1248 QueryUtil.ALL_POS, null);
1249 }
1250
1251
1265 public List<MBMailingList> findByUuid_C(String uuid, long companyId,
1266 int start, int end) throws SystemException {
1267 return findByUuid_C(uuid, companyId, start, end, null);
1268 }
1269
1270
1285 public List<MBMailingList> findByUuid_C(String uuid, long companyId,
1286 int start, int end, OrderByComparator orderByComparator)
1287 throws SystemException {
1288 FinderPath finderPath = null;
1289 Object[] finderArgs = null;
1290
1291 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1292 (orderByComparator == null)) {
1293 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1294 finderArgs = new Object[] { uuid, companyId };
1295 }
1296 else {
1297 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1298 finderArgs = new Object[] {
1299 uuid, companyId,
1300
1301 start, end, orderByComparator
1302 };
1303 }
1304
1305 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
1306 finderArgs, this);
1307
1308 if ((list != null) && !list.isEmpty()) {
1309 for (MBMailingList mbMailingList : list) {
1310 if (!Validator.equals(uuid, mbMailingList.getUuid()) ||
1311 (companyId != mbMailingList.getCompanyId())) {
1312 list = null;
1313
1314 break;
1315 }
1316 }
1317 }
1318
1319 if (list == null) {
1320 StringBundler query = null;
1321
1322 if (orderByComparator != null) {
1323 query = new StringBundler(4 +
1324 (orderByComparator.getOrderByFields().length * 3));
1325 }
1326 else {
1327 query = new StringBundler(3);
1328 }
1329
1330 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1331
1332 if (uuid == null) {
1333 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1334 }
1335 else {
1336 if (uuid.equals(StringPool.BLANK)) {
1337 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1338 }
1339 else {
1340 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1341 }
1342 }
1343
1344 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1345
1346 if (orderByComparator != null) {
1347 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1348 orderByComparator);
1349 }
1350
1351 String sql = query.toString();
1352
1353 Session session = null;
1354
1355 try {
1356 session = openSession();
1357
1358 Query q = session.createQuery(sql);
1359
1360 QueryPos qPos = QueryPos.getInstance(q);
1361
1362 if (uuid != null) {
1363 qPos.add(uuid);
1364 }
1365
1366 qPos.add(companyId);
1367
1368 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1369 start, end);
1370 }
1371 catch (Exception e) {
1372 throw processException(e);
1373 }
1374 finally {
1375 if (list == null) {
1376 FinderCacheUtil.removeResult(finderPath, finderArgs);
1377 }
1378 else {
1379 cacheResult(list);
1380
1381 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1382 }
1383
1384 closeSession(session);
1385 }
1386 }
1387
1388 return list;
1389 }
1390
1391
1401 public MBMailingList findByUuid_C_First(String uuid, long companyId,
1402 OrderByComparator orderByComparator)
1403 throws NoSuchMailingListException, SystemException {
1404 MBMailingList mbMailingList = fetchByUuid_C_First(uuid, companyId,
1405 orderByComparator);
1406
1407 if (mbMailingList != null) {
1408 return mbMailingList;
1409 }
1410
1411 StringBundler msg = new StringBundler(6);
1412
1413 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1414
1415 msg.append("uuid=");
1416 msg.append(uuid);
1417
1418 msg.append(", companyId=");
1419 msg.append(companyId);
1420
1421 msg.append(StringPool.CLOSE_CURLY_BRACE);
1422
1423 throw new NoSuchMailingListException(msg.toString());
1424 }
1425
1426
1435 public MBMailingList fetchByUuid_C_First(String uuid, long companyId,
1436 OrderByComparator orderByComparator) throws SystemException {
1437 List<MBMailingList> list = findByUuid_C(uuid, companyId, 0, 1,
1438 orderByComparator);
1439
1440 if (!list.isEmpty()) {
1441 return list.get(0);
1442 }
1443
1444 return null;
1445 }
1446
1447
1457 public MBMailingList findByUuid_C_Last(String uuid, long companyId,
1458 OrderByComparator orderByComparator)
1459 throws NoSuchMailingListException, SystemException {
1460 MBMailingList mbMailingList = fetchByUuid_C_Last(uuid, companyId,
1461 orderByComparator);
1462
1463 if (mbMailingList != null) {
1464 return mbMailingList;
1465 }
1466
1467 StringBundler msg = new StringBundler(6);
1468
1469 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1470
1471 msg.append("uuid=");
1472 msg.append(uuid);
1473
1474 msg.append(", companyId=");
1475 msg.append(companyId);
1476
1477 msg.append(StringPool.CLOSE_CURLY_BRACE);
1478
1479 throw new NoSuchMailingListException(msg.toString());
1480 }
1481
1482
1491 public MBMailingList fetchByUuid_C_Last(String uuid, long companyId,
1492 OrderByComparator orderByComparator) throws SystemException {
1493 int count = countByUuid_C(uuid, companyId);
1494
1495 List<MBMailingList> list = findByUuid_C(uuid, companyId, count - 1,
1496 count, orderByComparator);
1497
1498 if (!list.isEmpty()) {
1499 return list.get(0);
1500 }
1501
1502 return null;
1503 }
1504
1505
1516 public MBMailingList[] findByUuid_C_PrevAndNext(long mailingListId,
1517 String uuid, long companyId, OrderByComparator orderByComparator)
1518 throws NoSuchMailingListException, SystemException {
1519 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
1520
1521 Session session = null;
1522
1523 try {
1524 session = openSession();
1525
1526 MBMailingList[] array = new MBMailingListImpl[3];
1527
1528 array[0] = getByUuid_C_PrevAndNext(session, mbMailingList, uuid,
1529 companyId, orderByComparator, true);
1530
1531 array[1] = mbMailingList;
1532
1533 array[2] = getByUuid_C_PrevAndNext(session, mbMailingList, uuid,
1534 companyId, orderByComparator, false);
1535
1536 return array;
1537 }
1538 catch (Exception e) {
1539 throw processException(e);
1540 }
1541 finally {
1542 closeSession(session);
1543 }
1544 }
1545
1546 protected MBMailingList getByUuid_C_PrevAndNext(Session session,
1547 MBMailingList mbMailingList, String uuid, long companyId,
1548 OrderByComparator orderByComparator, boolean previous) {
1549 StringBundler query = null;
1550
1551 if (orderByComparator != null) {
1552 query = new StringBundler(6 +
1553 (orderByComparator.getOrderByFields().length * 6));
1554 }
1555 else {
1556 query = new StringBundler(3);
1557 }
1558
1559 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1560
1561 if (uuid == null) {
1562 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1563 }
1564 else {
1565 if (uuid.equals(StringPool.BLANK)) {
1566 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1567 }
1568 else {
1569 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1570 }
1571 }
1572
1573 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1574
1575 if (orderByComparator != null) {
1576 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1577
1578 if (orderByConditionFields.length > 0) {
1579 query.append(WHERE_AND);
1580 }
1581
1582 for (int i = 0; i < orderByConditionFields.length; i++) {
1583 query.append(_ORDER_BY_ENTITY_ALIAS);
1584 query.append(orderByConditionFields[i]);
1585
1586 if ((i + 1) < orderByConditionFields.length) {
1587 if (orderByComparator.isAscending() ^ previous) {
1588 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1589 }
1590 else {
1591 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1592 }
1593 }
1594 else {
1595 if (orderByComparator.isAscending() ^ previous) {
1596 query.append(WHERE_GREATER_THAN);
1597 }
1598 else {
1599 query.append(WHERE_LESSER_THAN);
1600 }
1601 }
1602 }
1603
1604 query.append(ORDER_BY_CLAUSE);
1605
1606 String[] orderByFields = orderByComparator.getOrderByFields();
1607
1608 for (int i = 0; i < orderByFields.length; i++) {
1609 query.append(_ORDER_BY_ENTITY_ALIAS);
1610 query.append(orderByFields[i]);
1611
1612 if ((i + 1) < orderByFields.length) {
1613 if (orderByComparator.isAscending() ^ previous) {
1614 query.append(ORDER_BY_ASC_HAS_NEXT);
1615 }
1616 else {
1617 query.append(ORDER_BY_DESC_HAS_NEXT);
1618 }
1619 }
1620 else {
1621 if (orderByComparator.isAscending() ^ previous) {
1622 query.append(ORDER_BY_ASC);
1623 }
1624 else {
1625 query.append(ORDER_BY_DESC);
1626 }
1627 }
1628 }
1629 }
1630
1631 String sql = query.toString();
1632
1633 Query q = session.createQuery(sql);
1634
1635 q.setFirstResult(0);
1636 q.setMaxResults(2);
1637
1638 QueryPos qPos = QueryPos.getInstance(q);
1639
1640 if (uuid != null) {
1641 qPos.add(uuid);
1642 }
1643
1644 qPos.add(companyId);
1645
1646 if (orderByComparator != null) {
1647 Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
1648
1649 for (Object value : values) {
1650 qPos.add(value);
1651 }
1652 }
1653
1654 List<MBMailingList> list = q.list();
1655
1656 if (list.size() == 2) {
1657 return list.get(1);
1658 }
1659 else {
1660 return null;
1661 }
1662 }
1663
1664
1671 public List<MBMailingList> findByActive(boolean active)
1672 throws SystemException {
1673 return findByActive(active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1674 }
1675
1676
1689 public List<MBMailingList> findByActive(boolean active, int start, int end)
1690 throws SystemException {
1691 return findByActive(active, start, end, null);
1692 }
1693
1694
1708 public List<MBMailingList> findByActive(boolean active, int start, int end,
1709 OrderByComparator orderByComparator) throws SystemException {
1710 FinderPath finderPath = null;
1711 Object[] finderArgs = null;
1712
1713 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1714 (orderByComparator == null)) {
1715 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ACTIVE;
1716 finderArgs = new Object[] { active };
1717 }
1718 else {
1719 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ACTIVE;
1720 finderArgs = new Object[] { active, start, end, orderByComparator };
1721 }
1722
1723 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
1724 finderArgs, this);
1725
1726 if ((list != null) && !list.isEmpty()) {
1727 for (MBMailingList mbMailingList : list) {
1728 if ((active != mbMailingList.getActive())) {
1729 list = null;
1730
1731 break;
1732 }
1733 }
1734 }
1735
1736 if (list == null) {
1737 StringBundler query = null;
1738
1739 if (orderByComparator != null) {
1740 query = new StringBundler(3 +
1741 (orderByComparator.getOrderByFields().length * 3));
1742 }
1743 else {
1744 query = new StringBundler(2);
1745 }
1746
1747 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1748
1749 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1750
1751 if (orderByComparator != null) {
1752 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1753 orderByComparator);
1754 }
1755
1756 String sql = query.toString();
1757
1758 Session session = null;
1759
1760 try {
1761 session = openSession();
1762
1763 Query q = session.createQuery(sql);
1764
1765 QueryPos qPos = QueryPos.getInstance(q);
1766
1767 qPos.add(active);
1768
1769 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
1770 start, end);
1771 }
1772 catch (Exception e) {
1773 throw processException(e);
1774 }
1775 finally {
1776 if (list == null) {
1777 FinderCacheUtil.removeResult(finderPath, finderArgs);
1778 }
1779 else {
1780 cacheResult(list);
1781
1782 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1783 }
1784
1785 closeSession(session);
1786 }
1787 }
1788
1789 return list;
1790 }
1791
1792
1801 public MBMailingList findByActive_First(boolean active,
1802 OrderByComparator orderByComparator)
1803 throws NoSuchMailingListException, SystemException {
1804 MBMailingList mbMailingList = fetchByActive_First(active,
1805 orderByComparator);
1806
1807 if (mbMailingList != null) {
1808 return mbMailingList;
1809 }
1810
1811 StringBundler msg = new StringBundler(4);
1812
1813 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1814
1815 msg.append("active=");
1816 msg.append(active);
1817
1818 msg.append(StringPool.CLOSE_CURLY_BRACE);
1819
1820 throw new NoSuchMailingListException(msg.toString());
1821 }
1822
1823
1831 public MBMailingList fetchByActive_First(boolean active,
1832 OrderByComparator orderByComparator) throws SystemException {
1833 List<MBMailingList> list = findByActive(active, 0, 1, orderByComparator);
1834
1835 if (!list.isEmpty()) {
1836 return list.get(0);
1837 }
1838
1839 return null;
1840 }
1841
1842
1851 public MBMailingList findByActive_Last(boolean active,
1852 OrderByComparator orderByComparator)
1853 throws NoSuchMailingListException, SystemException {
1854 MBMailingList mbMailingList = fetchByActive_Last(active,
1855 orderByComparator);
1856
1857 if (mbMailingList != null) {
1858 return mbMailingList;
1859 }
1860
1861 StringBundler msg = new StringBundler(4);
1862
1863 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1864
1865 msg.append("active=");
1866 msg.append(active);
1867
1868 msg.append(StringPool.CLOSE_CURLY_BRACE);
1869
1870 throw new NoSuchMailingListException(msg.toString());
1871 }
1872
1873
1881 public MBMailingList fetchByActive_Last(boolean active,
1882 OrderByComparator orderByComparator) throws SystemException {
1883 int count = countByActive(active);
1884
1885 List<MBMailingList> list = findByActive(active, count - 1, count,
1886 orderByComparator);
1887
1888 if (!list.isEmpty()) {
1889 return list.get(0);
1890 }
1891
1892 return null;
1893 }
1894
1895
1905 public MBMailingList[] findByActive_PrevAndNext(long mailingListId,
1906 boolean active, OrderByComparator orderByComparator)
1907 throws NoSuchMailingListException, SystemException {
1908 MBMailingList mbMailingList = findByPrimaryKey(mailingListId);
1909
1910 Session session = null;
1911
1912 try {
1913 session = openSession();
1914
1915 MBMailingList[] array = new MBMailingListImpl[3];
1916
1917 array[0] = getByActive_PrevAndNext(session, mbMailingList, active,
1918 orderByComparator, true);
1919
1920 array[1] = mbMailingList;
1921
1922 array[2] = getByActive_PrevAndNext(session, mbMailingList, active,
1923 orderByComparator, false);
1924
1925 return array;
1926 }
1927 catch (Exception e) {
1928 throw processException(e);
1929 }
1930 finally {
1931 closeSession(session);
1932 }
1933 }
1934
1935 protected MBMailingList getByActive_PrevAndNext(Session session,
1936 MBMailingList mbMailingList, boolean active,
1937 OrderByComparator orderByComparator, boolean previous) {
1938 StringBundler query = null;
1939
1940 if (orderByComparator != null) {
1941 query = new StringBundler(6 +
1942 (orderByComparator.getOrderByFields().length * 6));
1943 }
1944 else {
1945 query = new StringBundler(3);
1946 }
1947
1948 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
1949
1950 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
1951
1952 if (orderByComparator != null) {
1953 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1954
1955 if (orderByConditionFields.length > 0) {
1956 query.append(WHERE_AND);
1957 }
1958
1959 for (int i = 0; i < orderByConditionFields.length; i++) {
1960 query.append(_ORDER_BY_ENTITY_ALIAS);
1961 query.append(orderByConditionFields[i]);
1962
1963 if ((i + 1) < orderByConditionFields.length) {
1964 if (orderByComparator.isAscending() ^ previous) {
1965 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1966 }
1967 else {
1968 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1969 }
1970 }
1971 else {
1972 if (orderByComparator.isAscending() ^ previous) {
1973 query.append(WHERE_GREATER_THAN);
1974 }
1975 else {
1976 query.append(WHERE_LESSER_THAN);
1977 }
1978 }
1979 }
1980
1981 query.append(ORDER_BY_CLAUSE);
1982
1983 String[] orderByFields = orderByComparator.getOrderByFields();
1984
1985 for (int i = 0; i < orderByFields.length; i++) {
1986 query.append(_ORDER_BY_ENTITY_ALIAS);
1987 query.append(orderByFields[i]);
1988
1989 if ((i + 1) < orderByFields.length) {
1990 if (orderByComparator.isAscending() ^ previous) {
1991 query.append(ORDER_BY_ASC_HAS_NEXT);
1992 }
1993 else {
1994 query.append(ORDER_BY_DESC_HAS_NEXT);
1995 }
1996 }
1997 else {
1998 if (orderByComparator.isAscending() ^ previous) {
1999 query.append(ORDER_BY_ASC);
2000 }
2001 else {
2002 query.append(ORDER_BY_DESC);
2003 }
2004 }
2005 }
2006 }
2007
2008 String sql = query.toString();
2009
2010 Query q = session.createQuery(sql);
2011
2012 q.setFirstResult(0);
2013 q.setMaxResults(2);
2014
2015 QueryPos qPos = QueryPos.getInstance(q);
2016
2017 qPos.add(active);
2018
2019 if (orderByComparator != null) {
2020 Object[] values = orderByComparator.getOrderByConditionValues(mbMailingList);
2021
2022 for (Object value : values) {
2023 qPos.add(value);
2024 }
2025 }
2026
2027 List<MBMailingList> list = q.list();
2028
2029 if (list.size() == 2) {
2030 return list.get(1);
2031 }
2032 else {
2033 return null;
2034 }
2035 }
2036
2037
2046 public MBMailingList findByG_C(long groupId, long categoryId)
2047 throws NoSuchMailingListException, SystemException {
2048 MBMailingList mbMailingList = fetchByG_C(groupId, categoryId);
2049
2050 if (mbMailingList == null) {
2051 StringBundler msg = new StringBundler(6);
2052
2053 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2054
2055 msg.append("groupId=");
2056 msg.append(groupId);
2057
2058 msg.append(", categoryId=");
2059 msg.append(categoryId);
2060
2061 msg.append(StringPool.CLOSE_CURLY_BRACE);
2062
2063 if (_log.isWarnEnabled()) {
2064 _log.warn(msg.toString());
2065 }
2066
2067 throw new NoSuchMailingListException(msg.toString());
2068 }
2069
2070 return mbMailingList;
2071 }
2072
2073
2081 public MBMailingList fetchByG_C(long groupId, long categoryId)
2082 throws SystemException {
2083 return fetchByG_C(groupId, categoryId, true);
2084 }
2085
2086
2095 public MBMailingList fetchByG_C(long groupId, long categoryId,
2096 boolean retrieveFromCache) throws SystemException {
2097 Object[] finderArgs = new Object[] { groupId, categoryId };
2098
2099 Object result = null;
2100
2101 if (retrieveFromCache) {
2102 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C,
2103 finderArgs, this);
2104 }
2105
2106 if (result instanceof MBMailingList) {
2107 MBMailingList mbMailingList = (MBMailingList)result;
2108
2109 if ((groupId != mbMailingList.getGroupId()) ||
2110 (categoryId != mbMailingList.getCategoryId())) {
2111 result = null;
2112 }
2113 }
2114
2115 if (result == null) {
2116 StringBundler query = new StringBundler(3);
2117
2118 query.append(_SQL_SELECT_MBMAILINGLIST_WHERE);
2119
2120 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2121
2122 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2123
2124 String sql = query.toString();
2125
2126 Session session = null;
2127
2128 try {
2129 session = openSession();
2130
2131 Query q = session.createQuery(sql);
2132
2133 QueryPos qPos = QueryPos.getInstance(q);
2134
2135 qPos.add(groupId);
2136
2137 qPos.add(categoryId);
2138
2139 List<MBMailingList> list = q.list();
2140
2141 result = list;
2142
2143 MBMailingList mbMailingList = null;
2144
2145 if (list.isEmpty()) {
2146 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
2147 finderArgs, list);
2148 }
2149 else {
2150 mbMailingList = list.get(0);
2151
2152 cacheResult(mbMailingList);
2153
2154 if ((mbMailingList.getGroupId() != groupId) ||
2155 (mbMailingList.getCategoryId() != categoryId)) {
2156 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C,
2157 finderArgs, mbMailingList);
2158 }
2159 }
2160
2161 return mbMailingList;
2162 }
2163 catch (Exception e) {
2164 throw processException(e);
2165 }
2166 finally {
2167 if (result == null) {
2168 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C,
2169 finderArgs);
2170 }
2171
2172 closeSession(session);
2173 }
2174 }
2175 else {
2176 if (result instanceof List<?>) {
2177 return null;
2178 }
2179 else {
2180 return (MBMailingList)result;
2181 }
2182 }
2183 }
2184
2185
2191 public List<MBMailingList> findAll() throws SystemException {
2192 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2193 }
2194
2195
2207 public List<MBMailingList> findAll(int start, int end)
2208 throws SystemException {
2209 return findAll(start, end, null);
2210 }
2211
2212
2225 public List<MBMailingList> findAll(int start, int end,
2226 OrderByComparator orderByComparator) throws SystemException {
2227 FinderPath finderPath = null;
2228 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2229
2230 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2231 (orderByComparator == null)) {
2232 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2233 finderArgs = FINDER_ARGS_EMPTY;
2234 }
2235 else {
2236 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2237 finderArgs = new Object[] { start, end, orderByComparator };
2238 }
2239
2240 List<MBMailingList> list = (List<MBMailingList>)FinderCacheUtil.getResult(finderPath,
2241 finderArgs, this);
2242
2243 if (list == null) {
2244 StringBundler query = null;
2245 String sql = null;
2246
2247 if (orderByComparator != null) {
2248 query = new StringBundler(2 +
2249 (orderByComparator.getOrderByFields().length * 3));
2250
2251 query.append(_SQL_SELECT_MBMAILINGLIST);
2252
2253 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2254 orderByComparator);
2255
2256 sql = query.toString();
2257 }
2258 else {
2259 sql = _SQL_SELECT_MBMAILINGLIST;
2260 }
2261
2262 Session session = null;
2263
2264 try {
2265 session = openSession();
2266
2267 Query q = session.createQuery(sql);
2268
2269 if (orderByComparator == null) {
2270 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
2271 start, end, false);
2272
2273 Collections.sort(list);
2274 }
2275 else {
2276 list = (List<MBMailingList>)QueryUtil.list(q, getDialect(),
2277 start, end);
2278 }
2279 }
2280 catch (Exception e) {
2281 throw processException(e);
2282 }
2283 finally {
2284 if (list == null) {
2285 FinderCacheUtil.removeResult(finderPath, finderArgs);
2286 }
2287 else {
2288 cacheResult(list);
2289
2290 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2291 }
2292
2293 closeSession(session);
2294 }
2295 }
2296
2297 return list;
2298 }
2299
2300
2306 public void removeByUuid(String uuid) throws SystemException {
2307 for (MBMailingList mbMailingList : findByUuid(uuid)) {
2308 remove(mbMailingList);
2309 }
2310 }
2311
2312
2320 public MBMailingList removeByUUID_G(String uuid, long groupId)
2321 throws NoSuchMailingListException, SystemException {
2322 MBMailingList mbMailingList = findByUUID_G(uuid, groupId);
2323
2324 return remove(mbMailingList);
2325 }
2326
2327
2334 public void removeByUuid_C(String uuid, long companyId)
2335 throws SystemException {
2336 for (MBMailingList mbMailingList : findByUuid_C(uuid, companyId)) {
2337 remove(mbMailingList);
2338 }
2339 }
2340
2341
2347 public void removeByActive(boolean active) throws SystemException {
2348 for (MBMailingList mbMailingList : findByActive(active)) {
2349 remove(mbMailingList);
2350 }
2351 }
2352
2353
2361 public MBMailingList removeByG_C(long groupId, long categoryId)
2362 throws NoSuchMailingListException, SystemException {
2363 MBMailingList mbMailingList = findByG_C(groupId, categoryId);
2364
2365 return remove(mbMailingList);
2366 }
2367
2368
2373 public void removeAll() throws SystemException {
2374 for (MBMailingList mbMailingList : findAll()) {
2375 remove(mbMailingList);
2376 }
2377 }
2378
2379
2386 public int countByUuid(String uuid) throws SystemException {
2387 Object[] finderArgs = new Object[] { uuid };
2388
2389 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2390 finderArgs, this);
2391
2392 if (count == null) {
2393 StringBundler query = new StringBundler(2);
2394
2395 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
2396
2397 if (uuid == null) {
2398 query.append(_FINDER_COLUMN_UUID_UUID_1);
2399 }
2400 else {
2401 if (uuid.equals(StringPool.BLANK)) {
2402 query.append(_FINDER_COLUMN_UUID_UUID_3);
2403 }
2404 else {
2405 query.append(_FINDER_COLUMN_UUID_UUID_2);
2406 }
2407 }
2408
2409 String sql = query.toString();
2410
2411 Session session = null;
2412
2413 try {
2414 session = openSession();
2415
2416 Query q = session.createQuery(sql);
2417
2418 QueryPos qPos = QueryPos.getInstance(q);
2419
2420 if (uuid != null) {
2421 qPos.add(uuid);
2422 }
2423
2424 count = (Long)q.uniqueResult();
2425 }
2426 catch (Exception e) {
2427 throw processException(e);
2428 }
2429 finally {
2430 if (count == null) {
2431 count = Long.valueOf(0);
2432 }
2433
2434 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2435 finderArgs, count);
2436
2437 closeSession(session);
2438 }
2439 }
2440
2441 return count.intValue();
2442 }
2443
2444
2452 public int countByUUID_G(String uuid, long groupId)
2453 throws SystemException {
2454 Object[] finderArgs = new Object[] { uuid, groupId };
2455
2456 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2457 finderArgs, this);
2458
2459 if (count == null) {
2460 StringBundler query = new StringBundler(3);
2461
2462 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
2463
2464 if (uuid == null) {
2465 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2466 }
2467 else {
2468 if (uuid.equals(StringPool.BLANK)) {
2469 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2470 }
2471 else {
2472 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2473 }
2474 }
2475
2476 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2477
2478 String sql = query.toString();
2479
2480 Session session = null;
2481
2482 try {
2483 session = openSession();
2484
2485 Query q = session.createQuery(sql);
2486
2487 QueryPos qPos = QueryPos.getInstance(q);
2488
2489 if (uuid != null) {
2490 qPos.add(uuid);
2491 }
2492
2493 qPos.add(groupId);
2494
2495 count = (Long)q.uniqueResult();
2496 }
2497 catch (Exception e) {
2498 throw processException(e);
2499 }
2500 finally {
2501 if (count == null) {
2502 count = Long.valueOf(0);
2503 }
2504
2505 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2506 finderArgs, count);
2507
2508 closeSession(session);
2509 }
2510 }
2511
2512 return count.intValue();
2513 }
2514
2515
2523 public int countByUuid_C(String uuid, long companyId)
2524 throws SystemException {
2525 Object[] finderArgs = new Object[] { uuid, companyId };
2526
2527 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
2528 finderArgs, this);
2529
2530 if (count == null) {
2531 StringBundler query = new StringBundler(3);
2532
2533 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
2534
2535 if (uuid == null) {
2536 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
2537 }
2538 else {
2539 if (uuid.equals(StringPool.BLANK)) {
2540 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
2541 }
2542 else {
2543 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
2544 }
2545 }
2546
2547 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
2548
2549 String sql = query.toString();
2550
2551 Session session = null;
2552
2553 try {
2554 session = openSession();
2555
2556 Query q = session.createQuery(sql);
2557
2558 QueryPos qPos = QueryPos.getInstance(q);
2559
2560 if (uuid != null) {
2561 qPos.add(uuid);
2562 }
2563
2564 qPos.add(companyId);
2565
2566 count = (Long)q.uniqueResult();
2567 }
2568 catch (Exception e) {
2569 throw processException(e);
2570 }
2571 finally {
2572 if (count == null) {
2573 count = Long.valueOf(0);
2574 }
2575
2576 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
2577 finderArgs, count);
2578
2579 closeSession(session);
2580 }
2581 }
2582
2583 return count.intValue();
2584 }
2585
2586
2593 public int countByActive(boolean active) throws SystemException {
2594 Object[] finderArgs = new Object[] { active };
2595
2596 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ACTIVE,
2597 finderArgs, this);
2598
2599 if (count == null) {
2600 StringBundler query = new StringBundler(2);
2601
2602 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
2603
2604 query.append(_FINDER_COLUMN_ACTIVE_ACTIVE_2);
2605
2606 String sql = query.toString();
2607
2608 Session session = null;
2609
2610 try {
2611 session = openSession();
2612
2613 Query q = session.createQuery(sql);
2614
2615 QueryPos qPos = QueryPos.getInstance(q);
2616
2617 qPos.add(active);
2618
2619 count = (Long)q.uniqueResult();
2620 }
2621 catch (Exception e) {
2622 throw processException(e);
2623 }
2624 finally {
2625 if (count == null) {
2626 count = Long.valueOf(0);
2627 }
2628
2629 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ACTIVE,
2630 finderArgs, count);
2631
2632 closeSession(session);
2633 }
2634 }
2635
2636 return count.intValue();
2637 }
2638
2639
2647 public int countByG_C(long groupId, long categoryId)
2648 throws SystemException {
2649 Object[] finderArgs = new Object[] { groupId, categoryId };
2650
2651 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
2652 finderArgs, this);
2653
2654 if (count == null) {
2655 StringBundler query = new StringBundler(3);
2656
2657 query.append(_SQL_COUNT_MBMAILINGLIST_WHERE);
2658
2659 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2660
2661 query.append(_FINDER_COLUMN_G_C_CATEGORYID_2);
2662
2663 String sql = query.toString();
2664
2665 Session session = null;
2666
2667 try {
2668 session = openSession();
2669
2670 Query q = session.createQuery(sql);
2671
2672 QueryPos qPos = QueryPos.getInstance(q);
2673
2674 qPos.add(groupId);
2675
2676 qPos.add(categoryId);
2677
2678 count = (Long)q.uniqueResult();
2679 }
2680 catch (Exception e) {
2681 throw processException(e);
2682 }
2683 finally {
2684 if (count == null) {
2685 count = Long.valueOf(0);
2686 }
2687
2688 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
2689 count);
2690
2691 closeSession(session);
2692 }
2693 }
2694
2695 return count.intValue();
2696 }
2697
2698
2704 public int countAll() throws SystemException {
2705 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2706 FINDER_ARGS_EMPTY, this);
2707
2708 if (count == null) {
2709 Session session = null;
2710
2711 try {
2712 session = openSession();
2713
2714 Query q = session.createQuery(_SQL_COUNT_MBMAILINGLIST);
2715
2716 count = (Long)q.uniqueResult();
2717 }
2718 catch (Exception e) {
2719 throw processException(e);
2720 }
2721 finally {
2722 if (count == null) {
2723 count = Long.valueOf(0);
2724 }
2725
2726 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2727 FINDER_ARGS_EMPTY, count);
2728
2729 closeSession(session);
2730 }
2731 }
2732
2733 return count.intValue();
2734 }
2735
2736
2739 public void afterPropertiesSet() {
2740 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2741 com.liferay.portal.util.PropsUtil.get(
2742 "value.object.listener.com.liferay.portlet.messageboards.model.MBMailingList")));
2743
2744 if (listenerClassNames.length > 0) {
2745 try {
2746 List<ModelListener<MBMailingList>> listenersList = new ArrayList<ModelListener<MBMailingList>>();
2747
2748 for (String listenerClassName : listenerClassNames) {
2749 listenersList.add((ModelListener<MBMailingList>)InstanceFactory.newInstance(
2750 listenerClassName));
2751 }
2752
2753 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2754 }
2755 catch (Exception e) {
2756 _log.error(e);
2757 }
2758 }
2759 }
2760
2761 public void destroy() {
2762 EntityCacheUtil.removeCache(MBMailingListImpl.class.getName());
2763 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2764 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2765 }
2766
2767 @BeanReference(type = MBBanPersistence.class)
2768 protected MBBanPersistence mbBanPersistence;
2769 @BeanReference(type = MBCategoryPersistence.class)
2770 protected MBCategoryPersistence mbCategoryPersistence;
2771 @BeanReference(type = MBDiscussionPersistence.class)
2772 protected MBDiscussionPersistence mbDiscussionPersistence;
2773 @BeanReference(type = MBMailingListPersistence.class)
2774 protected MBMailingListPersistence mbMailingListPersistence;
2775 @BeanReference(type = MBMessagePersistence.class)
2776 protected MBMessagePersistence mbMessagePersistence;
2777 @BeanReference(type = MBStatsUserPersistence.class)
2778 protected MBStatsUserPersistence mbStatsUserPersistence;
2779 @BeanReference(type = MBThreadPersistence.class)
2780 protected MBThreadPersistence mbThreadPersistence;
2781 @BeanReference(type = MBThreadFlagPersistence.class)
2782 protected MBThreadFlagPersistence mbThreadFlagPersistence;
2783 @BeanReference(type = UserPersistence.class)
2784 protected UserPersistence userPersistence;
2785 private static final String _SQL_SELECT_MBMAILINGLIST = "SELECT mbMailingList FROM MBMailingList mbMailingList";
2786 private static final String _SQL_SELECT_MBMAILINGLIST_WHERE = "SELECT mbMailingList FROM MBMailingList mbMailingList WHERE ";
2787 private static final String _SQL_COUNT_MBMAILINGLIST = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList";
2788 private static final String _SQL_COUNT_MBMAILINGLIST_WHERE = "SELECT COUNT(mbMailingList) FROM MBMailingList mbMailingList WHERE ";
2789 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mbMailingList.uuid IS NULL";
2790 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mbMailingList.uuid = ?";
2791 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = ?)";
2792 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mbMailingList.uuid IS NULL AND ";
2793 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mbMailingList.uuid = ? AND ";
2794 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = ?) AND ";
2795 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mbMailingList.groupId = ?";
2796 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mbMailingList.uuid IS NULL AND ";
2797 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mbMailingList.uuid = ? AND ";
2798 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mbMailingList.uuid IS NULL OR mbMailingList.uuid = ?) AND ";
2799 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mbMailingList.companyId = ?";
2800 private static final String _FINDER_COLUMN_ACTIVE_ACTIVE_2 = "mbMailingList.active = ?";
2801 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "mbMailingList.groupId = ? AND ";
2802 private static final String _FINDER_COLUMN_G_C_CATEGORYID_2 = "mbMailingList.categoryId = ?";
2803 private static final String _ORDER_BY_ENTITY_ALIAS = "mbMailingList.";
2804 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MBMailingList exists with the primary key ";
2805 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MBMailingList exists with the key {";
2806 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2807 private static Log _log = LogFactoryUtil.getLog(MBMailingListPersistenceImpl.class);
2808 private static MBMailingList _nullMBMailingList = new MBMailingListImpl() {
2809 @Override
2810 public Object clone() {
2811 return this;
2812 }
2813
2814 @Override
2815 public CacheModel<MBMailingList> toCacheModel() {
2816 return _nullMBMailingListCacheModel;
2817 }
2818 };
2819
2820 private static CacheModel<MBMailingList> _nullMBMailingListCacheModel = new CacheModel<MBMailingList>() {
2821 public MBMailingList toEntityModel() {
2822 return _nullMBMailingList;
2823 }
2824 };
2825 }