001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchSubscriptionException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.Subscription;
040 import com.liferay.portal.model.impl.SubscriptionImpl;
041 import com.liferay.portal.model.impl.SubscriptionModelImpl;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
045 import com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence;
046 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
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 SubscriptionPersistenceImpl extends BasePersistenceImpl<Subscription>
067 implements SubscriptionPersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = SubscriptionImpl.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_USERID = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
079 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
080 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
081 new String[] {
082 Long.class.getName(),
083
084 "java.lang.Integer", "java.lang.Integer",
085 "com.liferay.portal.kernel.util.OrderByComparator"
086 });
087 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
088 new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
089 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
090 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
091 new String[] { Long.class.getName() },
092 SubscriptionModelImpl.USERID_COLUMN_BITMASK);
093 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
094 SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
096 new String[] { Long.class.getName() });
097 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
098 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
099 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_C",
100 new String[] {
101 Long.class.getName(), Long.class.getName(),
102
103 "java.lang.Integer", "java.lang.Integer",
104 "com.liferay.portal.kernel.util.OrderByComparator"
105 });
106 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
107 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C",
109 new String[] { Long.class.getName(), Long.class.getName() },
110 SubscriptionModelImpl.USERID_COLUMN_BITMASK |
111 SubscriptionModelImpl.CLASSNAMEID_COLUMN_BITMASK);
112 public static final FinderPath FINDER_PATH_COUNT_BY_U_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
113 SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C",
115 new String[] { Long.class.getName(), Long.class.getName() });
116 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
117 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
118 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_C",
119 new String[] {
120 Long.class.getName(), Long.class.getName(), Long.class.getName(),
121
122 "java.lang.Integer", "java.lang.Integer",
123 "com.liferay.portal.kernel.util.OrderByComparator"
124 });
125 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
126 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_C",
128 new String[] {
129 Long.class.getName(), Long.class.getName(), Long.class.getName()
130 },
131 SubscriptionModelImpl.COMPANYID_COLUMN_BITMASK |
132 SubscriptionModelImpl.CLASSNAMEID_COLUMN_BITMASK |
133 SubscriptionModelImpl.CLASSPK_COLUMN_BITMASK);
134 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
135 SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
136 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
137 new String[] {
138 Long.class.getName(), Long.class.getName(), Long.class.getName()
139 });
140 public static final FinderPath FINDER_PATH_FETCH_BY_C_U_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
141 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
142 FINDER_CLASS_NAME_ENTITY, "fetchByC_U_C_C",
143 new String[] {
144 Long.class.getName(), Long.class.getName(), Long.class.getName(),
145 Long.class.getName()
146 },
147 SubscriptionModelImpl.COMPANYID_COLUMN_BITMASK |
148 SubscriptionModelImpl.USERID_COLUMN_BITMASK |
149 SubscriptionModelImpl.CLASSNAMEID_COLUMN_BITMASK |
150 SubscriptionModelImpl.CLASSPK_COLUMN_BITMASK);
151 public static final FinderPath FINDER_PATH_COUNT_BY_C_U_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
152 SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
153 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_C_C",
154 new String[] {
155 Long.class.getName(), Long.class.getName(), Long.class.getName(),
156 Long.class.getName()
157 });
158 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
159 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
160 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
161 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
162 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
163 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
164 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
165 SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
166 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
167
168
173 public void cacheResult(Subscription subscription) {
174 EntityCacheUtil.putResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
175 SubscriptionImpl.class, subscription.getPrimaryKey(), subscription);
176
177 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C,
178 new Object[] {
179 Long.valueOf(subscription.getCompanyId()),
180 Long.valueOf(subscription.getUserId()),
181 Long.valueOf(subscription.getClassNameId()),
182 Long.valueOf(subscription.getClassPK())
183 }, subscription);
184
185 subscription.resetOriginalValues();
186 }
187
188
193 public void cacheResult(List<Subscription> subscriptions) {
194 for (Subscription subscription : subscriptions) {
195 if (EntityCacheUtil.getResult(
196 SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
197 SubscriptionImpl.class, subscription.getPrimaryKey()) == null) {
198 cacheResult(subscription);
199 }
200 else {
201 subscription.resetOriginalValues();
202 }
203 }
204 }
205
206
213 @Override
214 public void clearCache() {
215 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
216 CacheRegistryUtil.clear(SubscriptionImpl.class.getName());
217 }
218
219 EntityCacheUtil.clearCache(SubscriptionImpl.class.getName());
220
221 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
222 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
223 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
224 }
225
226
233 @Override
234 public void clearCache(Subscription subscription) {
235 EntityCacheUtil.removeResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
236 SubscriptionImpl.class, subscription.getPrimaryKey());
237
238 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
239 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
240
241 clearUniqueFindersCache(subscription);
242 }
243
244 @Override
245 public void clearCache(List<Subscription> subscriptions) {
246 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
247 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
248
249 for (Subscription subscription : subscriptions) {
250 EntityCacheUtil.removeResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
251 SubscriptionImpl.class, subscription.getPrimaryKey());
252
253 clearUniqueFindersCache(subscription);
254 }
255 }
256
257 protected void cacheUniqueFindersCache(Subscription subscription) {
258 if (subscription.isNew()) {
259 Object[] args = new Object[] {
260 Long.valueOf(subscription.getCompanyId()),
261 Long.valueOf(subscription.getUserId()),
262 Long.valueOf(subscription.getClassNameId()),
263 Long.valueOf(subscription.getClassPK())
264 };
265
266 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U_C_C, args,
267 Long.valueOf(1));
268 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C, args,
269 subscription);
270 }
271 else {
272 SubscriptionModelImpl subscriptionModelImpl = (SubscriptionModelImpl)subscription;
273
274 if ((subscriptionModelImpl.getColumnBitmask() &
275 FINDER_PATH_FETCH_BY_C_U_C_C.getColumnBitmask()) != 0) {
276 Object[] args = new Object[] {
277 Long.valueOf(subscription.getCompanyId()),
278 Long.valueOf(subscription.getUserId()),
279 Long.valueOf(subscription.getClassNameId()),
280 Long.valueOf(subscription.getClassPK())
281 };
282
283 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U_C_C, args,
284 Long.valueOf(1));
285 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C, args,
286 subscription);
287 }
288 }
289 }
290
291 protected void clearUniqueFindersCache(Subscription subscription) {
292 SubscriptionModelImpl subscriptionModelImpl = (SubscriptionModelImpl)subscription;
293
294 Object[] args = new Object[] {
295 Long.valueOf(subscription.getCompanyId()),
296 Long.valueOf(subscription.getUserId()),
297 Long.valueOf(subscription.getClassNameId()),
298 Long.valueOf(subscription.getClassPK())
299 };
300
301 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_C_C, args);
302 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_C_C, args);
303
304 if ((subscriptionModelImpl.getColumnBitmask() &
305 FINDER_PATH_FETCH_BY_C_U_C_C.getColumnBitmask()) != 0) {
306 args = new Object[] {
307 Long.valueOf(subscriptionModelImpl.getOriginalCompanyId()),
308 Long.valueOf(subscriptionModelImpl.getOriginalUserId()),
309 Long.valueOf(subscriptionModelImpl.getOriginalClassNameId()),
310 Long.valueOf(subscriptionModelImpl.getOriginalClassPK())
311 };
312
313 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_C_C, args);
314 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_C_C, args);
315 }
316 }
317
318
324 public Subscription create(long subscriptionId) {
325 Subscription subscription = new SubscriptionImpl();
326
327 subscription.setNew(true);
328 subscription.setPrimaryKey(subscriptionId);
329
330 return subscription;
331 }
332
333
341 public Subscription remove(long subscriptionId)
342 throws NoSuchSubscriptionException, SystemException {
343 return remove(Long.valueOf(subscriptionId));
344 }
345
346
354 @Override
355 public Subscription remove(Serializable primaryKey)
356 throws NoSuchSubscriptionException, SystemException {
357 Session session = null;
358
359 try {
360 session = openSession();
361
362 Subscription subscription = (Subscription)session.get(SubscriptionImpl.class,
363 primaryKey);
364
365 if (subscription == null) {
366 if (_log.isWarnEnabled()) {
367 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
368 }
369
370 throw new NoSuchSubscriptionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
371 primaryKey);
372 }
373
374 return remove(subscription);
375 }
376 catch (NoSuchSubscriptionException nsee) {
377 throw nsee;
378 }
379 catch (Exception e) {
380 throw processException(e);
381 }
382 finally {
383 closeSession(session);
384 }
385 }
386
387 @Override
388 protected Subscription removeImpl(Subscription subscription)
389 throws SystemException {
390 subscription = toUnwrappedModel(subscription);
391
392 Session session = null;
393
394 try {
395 session = openSession();
396
397 BatchSessionUtil.delete(session, subscription);
398 }
399 catch (Exception e) {
400 throw processException(e);
401 }
402 finally {
403 closeSession(session);
404 }
405
406 clearCache(subscription);
407
408 return subscription;
409 }
410
411 @Override
412 public Subscription updateImpl(
413 com.liferay.portal.model.Subscription subscription, boolean merge)
414 throws SystemException {
415 subscription = toUnwrappedModel(subscription);
416
417 boolean isNew = subscription.isNew();
418
419 SubscriptionModelImpl subscriptionModelImpl = (SubscriptionModelImpl)subscription;
420
421 Session session = null;
422
423 try {
424 session = openSession();
425
426 BatchSessionUtil.update(session, subscription, merge);
427
428 subscription.setNew(false);
429 }
430 catch (Exception e) {
431 throw processException(e);
432 }
433 finally {
434 closeSession(session);
435 }
436
437 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
438
439 if (isNew || !SubscriptionModelImpl.COLUMN_BITMASK_ENABLED) {
440 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
441 }
442
443 else {
444 if ((subscriptionModelImpl.getColumnBitmask() &
445 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
446 Object[] args = new Object[] {
447 Long.valueOf(subscriptionModelImpl.getOriginalUserId())
448 };
449
450 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
451 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
452 args);
453
454 args = new Object[] {
455 Long.valueOf(subscriptionModelImpl.getUserId())
456 };
457
458 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
459 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
460 args);
461 }
462
463 if ((subscriptionModelImpl.getColumnBitmask() &
464 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C.getColumnBitmask()) != 0) {
465 Object[] args = new Object[] {
466 Long.valueOf(subscriptionModelImpl.getOriginalUserId()),
467 Long.valueOf(subscriptionModelImpl.getOriginalClassNameId())
468 };
469
470 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C, args);
471 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C,
472 args);
473
474 args = new Object[] {
475 Long.valueOf(subscriptionModelImpl.getUserId()),
476 Long.valueOf(subscriptionModelImpl.getClassNameId())
477 };
478
479 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C, args);
480 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C,
481 args);
482 }
483
484 if ((subscriptionModelImpl.getColumnBitmask() &
485 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C.getColumnBitmask()) != 0) {
486 Object[] args = new Object[] {
487 Long.valueOf(subscriptionModelImpl.getOriginalCompanyId()),
488 Long.valueOf(subscriptionModelImpl.getOriginalClassNameId()),
489 Long.valueOf(subscriptionModelImpl.getOriginalClassPK())
490 };
491
492 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
493 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
494 args);
495
496 args = new Object[] {
497 Long.valueOf(subscriptionModelImpl.getCompanyId()),
498 Long.valueOf(subscriptionModelImpl.getClassNameId()),
499 Long.valueOf(subscriptionModelImpl.getClassPK())
500 };
501
502 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
503 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
504 args);
505 }
506 }
507
508 EntityCacheUtil.putResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
509 SubscriptionImpl.class, subscription.getPrimaryKey(), subscription);
510
511 clearUniqueFindersCache(subscription);
512 cacheUniqueFindersCache(subscription);
513
514 return subscription;
515 }
516
517 protected Subscription toUnwrappedModel(Subscription subscription) {
518 if (subscription instanceof SubscriptionImpl) {
519 return subscription;
520 }
521
522 SubscriptionImpl subscriptionImpl = new SubscriptionImpl();
523
524 subscriptionImpl.setNew(subscription.isNew());
525 subscriptionImpl.setPrimaryKey(subscription.getPrimaryKey());
526
527 subscriptionImpl.setSubscriptionId(subscription.getSubscriptionId());
528 subscriptionImpl.setCompanyId(subscription.getCompanyId());
529 subscriptionImpl.setUserId(subscription.getUserId());
530 subscriptionImpl.setUserName(subscription.getUserName());
531 subscriptionImpl.setCreateDate(subscription.getCreateDate());
532 subscriptionImpl.setModifiedDate(subscription.getModifiedDate());
533 subscriptionImpl.setClassNameId(subscription.getClassNameId());
534 subscriptionImpl.setClassPK(subscription.getClassPK());
535 subscriptionImpl.setFrequency(subscription.getFrequency());
536
537 return subscriptionImpl;
538 }
539
540
548 @Override
549 public Subscription findByPrimaryKey(Serializable primaryKey)
550 throws NoSuchModelException, SystemException {
551 return findByPrimaryKey(((Long)primaryKey).longValue());
552 }
553
554
562 public Subscription findByPrimaryKey(long subscriptionId)
563 throws NoSuchSubscriptionException, SystemException {
564 Subscription subscription = fetchByPrimaryKey(subscriptionId);
565
566 if (subscription == null) {
567 if (_log.isWarnEnabled()) {
568 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + subscriptionId);
569 }
570
571 throw new NoSuchSubscriptionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
572 subscriptionId);
573 }
574
575 return subscription;
576 }
577
578
585 @Override
586 public Subscription fetchByPrimaryKey(Serializable primaryKey)
587 throws SystemException {
588 return fetchByPrimaryKey(((Long)primaryKey).longValue());
589 }
590
591
598 public Subscription fetchByPrimaryKey(long subscriptionId)
599 throws SystemException {
600 Subscription subscription = (Subscription)EntityCacheUtil.getResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
601 SubscriptionImpl.class, subscriptionId);
602
603 if (subscription == _nullSubscription) {
604 return null;
605 }
606
607 if (subscription == null) {
608 Session session = null;
609
610 boolean hasException = false;
611
612 try {
613 session = openSession();
614
615 subscription = (Subscription)session.get(SubscriptionImpl.class,
616 Long.valueOf(subscriptionId));
617 }
618 catch (Exception e) {
619 hasException = true;
620
621 throw processException(e);
622 }
623 finally {
624 if (subscription != null) {
625 cacheResult(subscription);
626 }
627 else if (!hasException) {
628 EntityCacheUtil.putResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
629 SubscriptionImpl.class, subscriptionId,
630 _nullSubscription);
631 }
632
633 closeSession(session);
634 }
635 }
636
637 return subscription;
638 }
639
640
647 public List<Subscription> findByUserId(long userId)
648 throws SystemException {
649 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
650 }
651
652
665 public List<Subscription> findByUserId(long userId, int start, int end)
666 throws SystemException {
667 return findByUserId(userId, start, end, null);
668 }
669
670
684 public List<Subscription> findByUserId(long userId, int start, int end,
685 OrderByComparator orderByComparator) throws SystemException {
686 FinderPath finderPath = null;
687 Object[] finderArgs = null;
688
689 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
690 (orderByComparator == null)) {
691 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
692 finderArgs = new Object[] { userId };
693 }
694 else {
695 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
696 finderArgs = new Object[] { userId, start, end, orderByComparator };
697 }
698
699 List<Subscription> list = (List<Subscription>)FinderCacheUtil.getResult(finderPath,
700 finderArgs, this);
701
702 if ((list != null) && !list.isEmpty()) {
703 for (Subscription subscription : list) {
704 if ((userId != subscription.getUserId())) {
705 list = null;
706
707 break;
708 }
709 }
710 }
711
712 if (list == null) {
713 StringBundler query = null;
714
715 if (orderByComparator != null) {
716 query = new StringBundler(3 +
717 (orderByComparator.getOrderByFields().length * 3));
718 }
719 else {
720 query = new StringBundler(2);
721 }
722
723 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
724
725 query.append(_FINDER_COLUMN_USERID_USERID_2);
726
727 if (orderByComparator != null) {
728 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
729 orderByComparator);
730 }
731
732 String sql = query.toString();
733
734 Session session = null;
735
736 try {
737 session = openSession();
738
739 Query q = session.createQuery(sql);
740
741 QueryPos qPos = QueryPos.getInstance(q);
742
743 qPos.add(userId);
744
745 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
746 start, end);
747 }
748 catch (Exception e) {
749 throw processException(e);
750 }
751 finally {
752 if (list == null) {
753 FinderCacheUtil.removeResult(finderPath, finderArgs);
754 }
755 else {
756 cacheResult(list);
757
758 FinderCacheUtil.putResult(finderPath, finderArgs, list);
759 }
760
761 closeSession(session);
762 }
763 }
764
765 return list;
766 }
767
768
777 public Subscription findByUserId_First(long userId,
778 OrderByComparator orderByComparator)
779 throws NoSuchSubscriptionException, SystemException {
780 Subscription subscription = fetchByUserId_First(userId,
781 orderByComparator);
782
783 if (subscription != null) {
784 return subscription;
785 }
786
787 StringBundler msg = new StringBundler(4);
788
789 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
790
791 msg.append("userId=");
792 msg.append(userId);
793
794 msg.append(StringPool.CLOSE_CURLY_BRACE);
795
796 throw new NoSuchSubscriptionException(msg.toString());
797 }
798
799
807 public Subscription fetchByUserId_First(long userId,
808 OrderByComparator orderByComparator) throws SystemException {
809 List<Subscription> list = findByUserId(userId, 0, 1, orderByComparator);
810
811 if (!list.isEmpty()) {
812 return list.get(0);
813 }
814
815 return null;
816 }
817
818
827 public Subscription findByUserId_Last(long userId,
828 OrderByComparator orderByComparator)
829 throws NoSuchSubscriptionException, SystemException {
830 Subscription subscription = fetchByUserId_Last(userId, orderByComparator);
831
832 if (subscription != null) {
833 return subscription;
834 }
835
836 StringBundler msg = new StringBundler(4);
837
838 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
839
840 msg.append("userId=");
841 msg.append(userId);
842
843 msg.append(StringPool.CLOSE_CURLY_BRACE);
844
845 throw new NoSuchSubscriptionException(msg.toString());
846 }
847
848
856 public Subscription fetchByUserId_Last(long userId,
857 OrderByComparator orderByComparator) throws SystemException {
858 int count = countByUserId(userId);
859
860 List<Subscription> list = findByUserId(userId, count - 1, count,
861 orderByComparator);
862
863 if (!list.isEmpty()) {
864 return list.get(0);
865 }
866
867 return null;
868 }
869
870
880 public Subscription[] findByUserId_PrevAndNext(long subscriptionId,
881 long userId, OrderByComparator orderByComparator)
882 throws NoSuchSubscriptionException, SystemException {
883 Subscription subscription = findByPrimaryKey(subscriptionId);
884
885 Session session = null;
886
887 try {
888 session = openSession();
889
890 Subscription[] array = new SubscriptionImpl[3];
891
892 array[0] = getByUserId_PrevAndNext(session, subscription, userId,
893 orderByComparator, true);
894
895 array[1] = subscription;
896
897 array[2] = getByUserId_PrevAndNext(session, subscription, userId,
898 orderByComparator, false);
899
900 return array;
901 }
902 catch (Exception e) {
903 throw processException(e);
904 }
905 finally {
906 closeSession(session);
907 }
908 }
909
910 protected Subscription getByUserId_PrevAndNext(Session session,
911 Subscription subscription, long userId,
912 OrderByComparator orderByComparator, boolean previous) {
913 StringBundler query = null;
914
915 if (orderByComparator != null) {
916 query = new StringBundler(6 +
917 (orderByComparator.getOrderByFields().length * 6));
918 }
919 else {
920 query = new StringBundler(3);
921 }
922
923 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
924
925 query.append(_FINDER_COLUMN_USERID_USERID_2);
926
927 if (orderByComparator != null) {
928 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
929
930 if (orderByConditionFields.length > 0) {
931 query.append(WHERE_AND);
932 }
933
934 for (int i = 0; i < orderByConditionFields.length; i++) {
935 query.append(_ORDER_BY_ENTITY_ALIAS);
936 query.append(orderByConditionFields[i]);
937
938 if ((i + 1) < orderByConditionFields.length) {
939 if (orderByComparator.isAscending() ^ previous) {
940 query.append(WHERE_GREATER_THAN_HAS_NEXT);
941 }
942 else {
943 query.append(WHERE_LESSER_THAN_HAS_NEXT);
944 }
945 }
946 else {
947 if (orderByComparator.isAscending() ^ previous) {
948 query.append(WHERE_GREATER_THAN);
949 }
950 else {
951 query.append(WHERE_LESSER_THAN);
952 }
953 }
954 }
955
956 query.append(ORDER_BY_CLAUSE);
957
958 String[] orderByFields = orderByComparator.getOrderByFields();
959
960 for (int i = 0; i < orderByFields.length; i++) {
961 query.append(_ORDER_BY_ENTITY_ALIAS);
962 query.append(orderByFields[i]);
963
964 if ((i + 1) < orderByFields.length) {
965 if (orderByComparator.isAscending() ^ previous) {
966 query.append(ORDER_BY_ASC_HAS_NEXT);
967 }
968 else {
969 query.append(ORDER_BY_DESC_HAS_NEXT);
970 }
971 }
972 else {
973 if (orderByComparator.isAscending() ^ previous) {
974 query.append(ORDER_BY_ASC);
975 }
976 else {
977 query.append(ORDER_BY_DESC);
978 }
979 }
980 }
981 }
982
983 String sql = query.toString();
984
985 Query q = session.createQuery(sql);
986
987 q.setFirstResult(0);
988 q.setMaxResults(2);
989
990 QueryPos qPos = QueryPos.getInstance(q);
991
992 qPos.add(userId);
993
994 if (orderByComparator != null) {
995 Object[] values = orderByComparator.getOrderByConditionValues(subscription);
996
997 for (Object value : values) {
998 qPos.add(value);
999 }
1000 }
1001
1002 List<Subscription> list = q.list();
1003
1004 if (list.size() == 2) {
1005 return list.get(1);
1006 }
1007 else {
1008 return null;
1009 }
1010 }
1011
1012
1020 public List<Subscription> findByU_C(long userId, long classNameId)
1021 throws SystemException {
1022 return findByU_C(userId, classNameId, QueryUtil.ALL_POS,
1023 QueryUtil.ALL_POS, null);
1024 }
1025
1026
1040 public List<Subscription> findByU_C(long userId, long classNameId,
1041 int start, int end) throws SystemException {
1042 return findByU_C(userId, classNameId, start, end, null);
1043 }
1044
1045
1060 public List<Subscription> findByU_C(long userId, long classNameId,
1061 int start, int end, OrderByComparator orderByComparator)
1062 throws SystemException {
1063 FinderPath finderPath = null;
1064 Object[] finderArgs = null;
1065
1066 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1067 (orderByComparator == null)) {
1068 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C;
1069 finderArgs = new Object[] { userId, classNameId };
1070 }
1071 else {
1072 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C;
1073 finderArgs = new Object[] {
1074 userId, classNameId,
1075
1076 start, end, orderByComparator
1077 };
1078 }
1079
1080 List<Subscription> list = (List<Subscription>)FinderCacheUtil.getResult(finderPath,
1081 finderArgs, this);
1082
1083 if ((list != null) && !list.isEmpty()) {
1084 for (Subscription subscription : list) {
1085 if ((userId != subscription.getUserId()) ||
1086 (classNameId != subscription.getClassNameId())) {
1087 list = null;
1088
1089 break;
1090 }
1091 }
1092 }
1093
1094 if (list == null) {
1095 StringBundler query = null;
1096
1097 if (orderByComparator != null) {
1098 query = new StringBundler(4 +
1099 (orderByComparator.getOrderByFields().length * 3));
1100 }
1101 else {
1102 query = new StringBundler(3);
1103 }
1104
1105 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1106
1107 query.append(_FINDER_COLUMN_U_C_USERID_2);
1108
1109 query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2);
1110
1111 if (orderByComparator != null) {
1112 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1113 orderByComparator);
1114 }
1115
1116 String sql = query.toString();
1117
1118 Session session = null;
1119
1120 try {
1121 session = openSession();
1122
1123 Query q = session.createQuery(sql);
1124
1125 QueryPos qPos = QueryPos.getInstance(q);
1126
1127 qPos.add(userId);
1128
1129 qPos.add(classNameId);
1130
1131 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
1132 start, end);
1133 }
1134 catch (Exception e) {
1135 throw processException(e);
1136 }
1137 finally {
1138 if (list == null) {
1139 FinderCacheUtil.removeResult(finderPath, finderArgs);
1140 }
1141 else {
1142 cacheResult(list);
1143
1144 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1145 }
1146
1147 closeSession(session);
1148 }
1149 }
1150
1151 return list;
1152 }
1153
1154
1164 public Subscription findByU_C_First(long userId, long classNameId,
1165 OrderByComparator orderByComparator)
1166 throws NoSuchSubscriptionException, SystemException {
1167 Subscription subscription = fetchByU_C_First(userId, classNameId,
1168 orderByComparator);
1169
1170 if (subscription != null) {
1171 return subscription;
1172 }
1173
1174 StringBundler msg = new StringBundler(6);
1175
1176 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1177
1178 msg.append("userId=");
1179 msg.append(userId);
1180
1181 msg.append(", classNameId=");
1182 msg.append(classNameId);
1183
1184 msg.append(StringPool.CLOSE_CURLY_BRACE);
1185
1186 throw new NoSuchSubscriptionException(msg.toString());
1187 }
1188
1189
1198 public Subscription fetchByU_C_First(long userId, long classNameId,
1199 OrderByComparator orderByComparator) throws SystemException {
1200 List<Subscription> list = findByU_C(userId, classNameId, 0, 1,
1201 orderByComparator);
1202
1203 if (!list.isEmpty()) {
1204 return list.get(0);
1205 }
1206
1207 return null;
1208 }
1209
1210
1220 public Subscription findByU_C_Last(long userId, long classNameId,
1221 OrderByComparator orderByComparator)
1222 throws NoSuchSubscriptionException, SystemException {
1223 Subscription subscription = fetchByU_C_Last(userId, classNameId,
1224 orderByComparator);
1225
1226 if (subscription != null) {
1227 return subscription;
1228 }
1229
1230 StringBundler msg = new StringBundler(6);
1231
1232 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1233
1234 msg.append("userId=");
1235 msg.append(userId);
1236
1237 msg.append(", classNameId=");
1238 msg.append(classNameId);
1239
1240 msg.append(StringPool.CLOSE_CURLY_BRACE);
1241
1242 throw new NoSuchSubscriptionException(msg.toString());
1243 }
1244
1245
1254 public Subscription fetchByU_C_Last(long userId, long classNameId,
1255 OrderByComparator orderByComparator) throws SystemException {
1256 int count = countByU_C(userId, classNameId);
1257
1258 List<Subscription> list = findByU_C(userId, classNameId, count - 1,
1259 count, orderByComparator);
1260
1261 if (!list.isEmpty()) {
1262 return list.get(0);
1263 }
1264
1265 return null;
1266 }
1267
1268
1279 public Subscription[] findByU_C_PrevAndNext(long subscriptionId,
1280 long userId, long classNameId, OrderByComparator orderByComparator)
1281 throws NoSuchSubscriptionException, SystemException {
1282 Subscription subscription = findByPrimaryKey(subscriptionId);
1283
1284 Session session = null;
1285
1286 try {
1287 session = openSession();
1288
1289 Subscription[] array = new SubscriptionImpl[3];
1290
1291 array[0] = getByU_C_PrevAndNext(session, subscription, userId,
1292 classNameId, orderByComparator, true);
1293
1294 array[1] = subscription;
1295
1296 array[2] = getByU_C_PrevAndNext(session, subscription, userId,
1297 classNameId, orderByComparator, false);
1298
1299 return array;
1300 }
1301 catch (Exception e) {
1302 throw processException(e);
1303 }
1304 finally {
1305 closeSession(session);
1306 }
1307 }
1308
1309 protected Subscription getByU_C_PrevAndNext(Session session,
1310 Subscription subscription, long userId, long classNameId,
1311 OrderByComparator orderByComparator, boolean previous) {
1312 StringBundler query = null;
1313
1314 if (orderByComparator != null) {
1315 query = new StringBundler(6 +
1316 (orderByComparator.getOrderByFields().length * 6));
1317 }
1318 else {
1319 query = new StringBundler(3);
1320 }
1321
1322 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1323
1324 query.append(_FINDER_COLUMN_U_C_USERID_2);
1325
1326 query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2);
1327
1328 if (orderByComparator != null) {
1329 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1330
1331 if (orderByConditionFields.length > 0) {
1332 query.append(WHERE_AND);
1333 }
1334
1335 for (int i = 0; i < orderByConditionFields.length; i++) {
1336 query.append(_ORDER_BY_ENTITY_ALIAS);
1337 query.append(orderByConditionFields[i]);
1338
1339 if ((i + 1) < orderByConditionFields.length) {
1340 if (orderByComparator.isAscending() ^ previous) {
1341 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1342 }
1343 else {
1344 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1345 }
1346 }
1347 else {
1348 if (orderByComparator.isAscending() ^ previous) {
1349 query.append(WHERE_GREATER_THAN);
1350 }
1351 else {
1352 query.append(WHERE_LESSER_THAN);
1353 }
1354 }
1355 }
1356
1357 query.append(ORDER_BY_CLAUSE);
1358
1359 String[] orderByFields = orderByComparator.getOrderByFields();
1360
1361 for (int i = 0; i < orderByFields.length; i++) {
1362 query.append(_ORDER_BY_ENTITY_ALIAS);
1363 query.append(orderByFields[i]);
1364
1365 if ((i + 1) < orderByFields.length) {
1366 if (orderByComparator.isAscending() ^ previous) {
1367 query.append(ORDER_BY_ASC_HAS_NEXT);
1368 }
1369 else {
1370 query.append(ORDER_BY_DESC_HAS_NEXT);
1371 }
1372 }
1373 else {
1374 if (orderByComparator.isAscending() ^ previous) {
1375 query.append(ORDER_BY_ASC);
1376 }
1377 else {
1378 query.append(ORDER_BY_DESC);
1379 }
1380 }
1381 }
1382 }
1383
1384 String sql = query.toString();
1385
1386 Query q = session.createQuery(sql);
1387
1388 q.setFirstResult(0);
1389 q.setMaxResults(2);
1390
1391 QueryPos qPos = QueryPos.getInstance(q);
1392
1393 qPos.add(userId);
1394
1395 qPos.add(classNameId);
1396
1397 if (orderByComparator != null) {
1398 Object[] values = orderByComparator.getOrderByConditionValues(subscription);
1399
1400 for (Object value : values) {
1401 qPos.add(value);
1402 }
1403 }
1404
1405 List<Subscription> list = q.list();
1406
1407 if (list.size() == 2) {
1408 return list.get(1);
1409 }
1410 else {
1411 return null;
1412 }
1413 }
1414
1415
1424 public List<Subscription> findByC_C_C(long companyId, long classNameId,
1425 long classPK) throws SystemException {
1426 return findByC_C_C(companyId, classNameId, classPK, QueryUtil.ALL_POS,
1427 QueryUtil.ALL_POS, null);
1428 }
1429
1430
1445 public List<Subscription> findByC_C_C(long companyId, long classNameId,
1446 long classPK, int start, int end) throws SystemException {
1447 return findByC_C_C(companyId, classNameId, classPK, start, end, null);
1448 }
1449
1450
1466 public List<Subscription> findByC_C_C(long companyId, long classNameId,
1467 long classPK, int start, int end, OrderByComparator orderByComparator)
1468 throws SystemException {
1469 FinderPath finderPath = null;
1470 Object[] finderArgs = null;
1471
1472 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1473 (orderByComparator == null)) {
1474 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C;
1475 finderArgs = new Object[] { companyId, classNameId, classPK };
1476 }
1477 else {
1478 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C;
1479 finderArgs = new Object[] {
1480 companyId, classNameId, classPK,
1481
1482 start, end, orderByComparator
1483 };
1484 }
1485
1486 List<Subscription> list = (List<Subscription>)FinderCacheUtil.getResult(finderPath,
1487 finderArgs, this);
1488
1489 if ((list != null) && !list.isEmpty()) {
1490 for (Subscription subscription : list) {
1491 if ((companyId != subscription.getCompanyId()) ||
1492 (classNameId != subscription.getClassNameId()) ||
1493 (classPK != subscription.getClassPK())) {
1494 list = null;
1495
1496 break;
1497 }
1498 }
1499 }
1500
1501 if (list == null) {
1502 StringBundler query = null;
1503
1504 if (orderByComparator != null) {
1505 query = new StringBundler(5 +
1506 (orderByComparator.getOrderByFields().length * 3));
1507 }
1508 else {
1509 query = new StringBundler(4);
1510 }
1511
1512 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1513
1514 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1515
1516 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1517
1518 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1519
1520 if (orderByComparator != null) {
1521 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1522 orderByComparator);
1523 }
1524
1525 String sql = query.toString();
1526
1527 Session session = null;
1528
1529 try {
1530 session = openSession();
1531
1532 Query q = session.createQuery(sql);
1533
1534 QueryPos qPos = QueryPos.getInstance(q);
1535
1536 qPos.add(companyId);
1537
1538 qPos.add(classNameId);
1539
1540 qPos.add(classPK);
1541
1542 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
1543 start, end);
1544 }
1545 catch (Exception e) {
1546 throw processException(e);
1547 }
1548 finally {
1549 if (list == null) {
1550 FinderCacheUtil.removeResult(finderPath, finderArgs);
1551 }
1552 else {
1553 cacheResult(list);
1554
1555 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1556 }
1557
1558 closeSession(session);
1559 }
1560 }
1561
1562 return list;
1563 }
1564
1565
1576 public Subscription findByC_C_C_First(long companyId, long classNameId,
1577 long classPK, OrderByComparator orderByComparator)
1578 throws NoSuchSubscriptionException, SystemException {
1579 Subscription subscription = fetchByC_C_C_First(companyId, classNameId,
1580 classPK, orderByComparator);
1581
1582 if (subscription != null) {
1583 return subscription;
1584 }
1585
1586 StringBundler msg = new StringBundler(8);
1587
1588 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1589
1590 msg.append("companyId=");
1591 msg.append(companyId);
1592
1593 msg.append(", classNameId=");
1594 msg.append(classNameId);
1595
1596 msg.append(", classPK=");
1597 msg.append(classPK);
1598
1599 msg.append(StringPool.CLOSE_CURLY_BRACE);
1600
1601 throw new NoSuchSubscriptionException(msg.toString());
1602 }
1603
1604
1614 public Subscription fetchByC_C_C_First(long companyId, long classNameId,
1615 long classPK, OrderByComparator orderByComparator)
1616 throws SystemException {
1617 List<Subscription> list = findByC_C_C(companyId, classNameId, classPK,
1618 0, 1, orderByComparator);
1619
1620 if (!list.isEmpty()) {
1621 return list.get(0);
1622 }
1623
1624 return null;
1625 }
1626
1627
1638 public Subscription findByC_C_C_Last(long companyId, long classNameId,
1639 long classPK, OrderByComparator orderByComparator)
1640 throws NoSuchSubscriptionException, SystemException {
1641 Subscription subscription = fetchByC_C_C_Last(companyId, classNameId,
1642 classPK, orderByComparator);
1643
1644 if (subscription != null) {
1645 return subscription;
1646 }
1647
1648 StringBundler msg = new StringBundler(8);
1649
1650 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1651
1652 msg.append("companyId=");
1653 msg.append(companyId);
1654
1655 msg.append(", classNameId=");
1656 msg.append(classNameId);
1657
1658 msg.append(", classPK=");
1659 msg.append(classPK);
1660
1661 msg.append(StringPool.CLOSE_CURLY_BRACE);
1662
1663 throw new NoSuchSubscriptionException(msg.toString());
1664 }
1665
1666
1676 public Subscription fetchByC_C_C_Last(long companyId, long classNameId,
1677 long classPK, OrderByComparator orderByComparator)
1678 throws SystemException {
1679 int count = countByC_C_C(companyId, classNameId, classPK);
1680
1681 List<Subscription> list = findByC_C_C(companyId, classNameId, classPK,
1682 count - 1, count, orderByComparator);
1683
1684 if (!list.isEmpty()) {
1685 return list.get(0);
1686 }
1687
1688 return null;
1689 }
1690
1691
1703 public Subscription[] findByC_C_C_PrevAndNext(long subscriptionId,
1704 long companyId, long classNameId, long classPK,
1705 OrderByComparator orderByComparator)
1706 throws NoSuchSubscriptionException, SystemException {
1707 Subscription subscription = findByPrimaryKey(subscriptionId);
1708
1709 Session session = null;
1710
1711 try {
1712 session = openSession();
1713
1714 Subscription[] array = new SubscriptionImpl[3];
1715
1716 array[0] = getByC_C_C_PrevAndNext(session, subscription, companyId,
1717 classNameId, classPK, orderByComparator, true);
1718
1719 array[1] = subscription;
1720
1721 array[2] = getByC_C_C_PrevAndNext(session, subscription, companyId,
1722 classNameId, classPK, orderByComparator, false);
1723
1724 return array;
1725 }
1726 catch (Exception e) {
1727 throw processException(e);
1728 }
1729 finally {
1730 closeSession(session);
1731 }
1732 }
1733
1734 protected Subscription getByC_C_C_PrevAndNext(Session session,
1735 Subscription subscription, long companyId, long classNameId,
1736 long classPK, OrderByComparator orderByComparator, boolean previous) {
1737 StringBundler query = null;
1738
1739 if (orderByComparator != null) {
1740 query = new StringBundler(6 +
1741 (orderByComparator.getOrderByFields().length * 6));
1742 }
1743 else {
1744 query = new StringBundler(3);
1745 }
1746
1747 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1748
1749 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1750
1751 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1752
1753 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1754
1755 if (orderByComparator != null) {
1756 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1757
1758 if (orderByConditionFields.length > 0) {
1759 query.append(WHERE_AND);
1760 }
1761
1762 for (int i = 0; i < orderByConditionFields.length; i++) {
1763 query.append(_ORDER_BY_ENTITY_ALIAS);
1764 query.append(orderByConditionFields[i]);
1765
1766 if ((i + 1) < orderByConditionFields.length) {
1767 if (orderByComparator.isAscending() ^ previous) {
1768 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1769 }
1770 else {
1771 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1772 }
1773 }
1774 else {
1775 if (orderByComparator.isAscending() ^ previous) {
1776 query.append(WHERE_GREATER_THAN);
1777 }
1778 else {
1779 query.append(WHERE_LESSER_THAN);
1780 }
1781 }
1782 }
1783
1784 query.append(ORDER_BY_CLAUSE);
1785
1786 String[] orderByFields = orderByComparator.getOrderByFields();
1787
1788 for (int i = 0; i < orderByFields.length; i++) {
1789 query.append(_ORDER_BY_ENTITY_ALIAS);
1790 query.append(orderByFields[i]);
1791
1792 if ((i + 1) < orderByFields.length) {
1793 if (orderByComparator.isAscending() ^ previous) {
1794 query.append(ORDER_BY_ASC_HAS_NEXT);
1795 }
1796 else {
1797 query.append(ORDER_BY_DESC_HAS_NEXT);
1798 }
1799 }
1800 else {
1801 if (orderByComparator.isAscending() ^ previous) {
1802 query.append(ORDER_BY_ASC);
1803 }
1804 else {
1805 query.append(ORDER_BY_DESC);
1806 }
1807 }
1808 }
1809 }
1810
1811 String sql = query.toString();
1812
1813 Query q = session.createQuery(sql);
1814
1815 q.setFirstResult(0);
1816 q.setMaxResults(2);
1817
1818 QueryPos qPos = QueryPos.getInstance(q);
1819
1820 qPos.add(companyId);
1821
1822 qPos.add(classNameId);
1823
1824 qPos.add(classPK);
1825
1826 if (orderByComparator != null) {
1827 Object[] values = orderByComparator.getOrderByConditionValues(subscription);
1828
1829 for (Object value : values) {
1830 qPos.add(value);
1831 }
1832 }
1833
1834 List<Subscription> list = q.list();
1835
1836 if (list.size() == 2) {
1837 return list.get(1);
1838 }
1839 else {
1840 return null;
1841 }
1842 }
1843
1844
1855 public Subscription findByC_U_C_C(long companyId, long userId,
1856 long classNameId, long classPK)
1857 throws NoSuchSubscriptionException, SystemException {
1858 Subscription subscription = fetchByC_U_C_C(companyId, userId,
1859 classNameId, classPK);
1860
1861 if (subscription == null) {
1862 StringBundler msg = new StringBundler(10);
1863
1864 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1865
1866 msg.append("companyId=");
1867 msg.append(companyId);
1868
1869 msg.append(", userId=");
1870 msg.append(userId);
1871
1872 msg.append(", classNameId=");
1873 msg.append(classNameId);
1874
1875 msg.append(", classPK=");
1876 msg.append(classPK);
1877
1878 msg.append(StringPool.CLOSE_CURLY_BRACE);
1879
1880 if (_log.isWarnEnabled()) {
1881 _log.warn(msg.toString());
1882 }
1883
1884 throw new NoSuchSubscriptionException(msg.toString());
1885 }
1886
1887 return subscription;
1888 }
1889
1890
1900 public Subscription fetchByC_U_C_C(long companyId, long userId,
1901 long classNameId, long classPK) throws SystemException {
1902 return fetchByC_U_C_C(companyId, userId, classNameId, classPK, true);
1903 }
1904
1905
1916 public Subscription fetchByC_U_C_C(long companyId, long userId,
1917 long classNameId, long classPK, boolean retrieveFromCache)
1918 throws SystemException {
1919 Object[] finderArgs = new Object[] {
1920 companyId, userId, classNameId, classPK
1921 };
1922
1923 Object result = null;
1924
1925 if (retrieveFromCache) {
1926 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U_C_C,
1927 finderArgs, this);
1928 }
1929
1930 if (result instanceof Subscription) {
1931 Subscription subscription = (Subscription)result;
1932
1933 if ((companyId != subscription.getCompanyId()) ||
1934 (userId != subscription.getUserId()) ||
1935 (classNameId != subscription.getClassNameId()) ||
1936 (classPK != subscription.getClassPK())) {
1937 result = null;
1938 }
1939 }
1940
1941 if (result == null) {
1942 StringBundler query = new StringBundler(5);
1943
1944 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1945
1946 query.append(_FINDER_COLUMN_C_U_C_C_COMPANYID_2);
1947
1948 query.append(_FINDER_COLUMN_C_U_C_C_USERID_2);
1949
1950 query.append(_FINDER_COLUMN_C_U_C_C_CLASSNAMEID_2);
1951
1952 query.append(_FINDER_COLUMN_C_U_C_C_CLASSPK_2);
1953
1954 String sql = query.toString();
1955
1956 Session session = null;
1957
1958 try {
1959 session = openSession();
1960
1961 Query q = session.createQuery(sql);
1962
1963 QueryPos qPos = QueryPos.getInstance(q);
1964
1965 qPos.add(companyId);
1966
1967 qPos.add(userId);
1968
1969 qPos.add(classNameId);
1970
1971 qPos.add(classPK);
1972
1973 List<Subscription> list = q.list();
1974
1975 result = list;
1976
1977 Subscription subscription = null;
1978
1979 if (list.isEmpty()) {
1980 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C,
1981 finderArgs, list);
1982 }
1983 else {
1984 subscription = list.get(0);
1985
1986 cacheResult(subscription);
1987
1988 if ((subscription.getCompanyId() != companyId) ||
1989 (subscription.getUserId() != userId) ||
1990 (subscription.getClassNameId() != classNameId) ||
1991 (subscription.getClassPK() != classPK)) {
1992 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C,
1993 finderArgs, subscription);
1994 }
1995 }
1996
1997 return subscription;
1998 }
1999 catch (Exception e) {
2000 throw processException(e);
2001 }
2002 finally {
2003 if (result == null) {
2004 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_C_C,
2005 finderArgs);
2006 }
2007
2008 closeSession(session);
2009 }
2010 }
2011 else {
2012 if (result instanceof List<?>) {
2013 return null;
2014 }
2015 else {
2016 return (Subscription)result;
2017 }
2018 }
2019 }
2020
2021
2027 public List<Subscription> findAll() throws SystemException {
2028 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2029 }
2030
2031
2043 public List<Subscription> findAll(int start, int end)
2044 throws SystemException {
2045 return findAll(start, end, null);
2046 }
2047
2048
2061 public List<Subscription> findAll(int start, int end,
2062 OrderByComparator orderByComparator) throws SystemException {
2063 FinderPath finderPath = null;
2064 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2065
2066 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2067 (orderByComparator == null)) {
2068 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2069 finderArgs = FINDER_ARGS_EMPTY;
2070 }
2071 else {
2072 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2073 finderArgs = new Object[] { start, end, orderByComparator };
2074 }
2075
2076 List<Subscription> list = (List<Subscription>)FinderCacheUtil.getResult(finderPath,
2077 finderArgs, this);
2078
2079 if (list == null) {
2080 StringBundler query = null;
2081 String sql = null;
2082
2083 if (orderByComparator != null) {
2084 query = new StringBundler(2 +
2085 (orderByComparator.getOrderByFields().length * 3));
2086
2087 query.append(_SQL_SELECT_SUBSCRIPTION);
2088
2089 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2090 orderByComparator);
2091
2092 sql = query.toString();
2093 }
2094 else {
2095 sql = _SQL_SELECT_SUBSCRIPTION;
2096 }
2097
2098 Session session = null;
2099
2100 try {
2101 session = openSession();
2102
2103 Query q = session.createQuery(sql);
2104
2105 if (orderByComparator == null) {
2106 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
2107 start, end, false);
2108
2109 Collections.sort(list);
2110 }
2111 else {
2112 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
2113 start, end);
2114 }
2115 }
2116 catch (Exception e) {
2117 throw processException(e);
2118 }
2119 finally {
2120 if (list == null) {
2121 FinderCacheUtil.removeResult(finderPath, finderArgs);
2122 }
2123 else {
2124 cacheResult(list);
2125
2126 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2127 }
2128
2129 closeSession(session);
2130 }
2131 }
2132
2133 return list;
2134 }
2135
2136
2142 public void removeByUserId(long userId) throws SystemException {
2143 for (Subscription subscription : findByUserId(userId)) {
2144 remove(subscription);
2145 }
2146 }
2147
2148
2155 public void removeByU_C(long userId, long classNameId)
2156 throws SystemException {
2157 for (Subscription subscription : findByU_C(userId, classNameId)) {
2158 remove(subscription);
2159 }
2160 }
2161
2162
2170 public void removeByC_C_C(long companyId, long classNameId, long classPK)
2171 throws SystemException {
2172 for (Subscription subscription : findByC_C_C(companyId, classNameId,
2173 classPK)) {
2174 remove(subscription);
2175 }
2176 }
2177
2178
2188 public Subscription removeByC_U_C_C(long companyId, long userId,
2189 long classNameId, long classPK)
2190 throws NoSuchSubscriptionException, SystemException {
2191 Subscription subscription = findByC_U_C_C(companyId, userId,
2192 classNameId, classPK);
2193
2194 return remove(subscription);
2195 }
2196
2197
2202 public void removeAll() throws SystemException {
2203 for (Subscription subscription : findAll()) {
2204 remove(subscription);
2205 }
2206 }
2207
2208
2215 public int countByUserId(long userId) throws SystemException {
2216 Object[] finderArgs = new Object[] { userId };
2217
2218 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2219 finderArgs, this);
2220
2221 if (count == null) {
2222 StringBundler query = new StringBundler(2);
2223
2224 query.append(_SQL_COUNT_SUBSCRIPTION_WHERE);
2225
2226 query.append(_FINDER_COLUMN_USERID_USERID_2);
2227
2228 String sql = query.toString();
2229
2230 Session session = null;
2231
2232 try {
2233 session = openSession();
2234
2235 Query q = session.createQuery(sql);
2236
2237 QueryPos qPos = QueryPos.getInstance(q);
2238
2239 qPos.add(userId);
2240
2241 count = (Long)q.uniqueResult();
2242 }
2243 catch (Exception e) {
2244 throw processException(e);
2245 }
2246 finally {
2247 if (count == null) {
2248 count = Long.valueOf(0);
2249 }
2250
2251 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2252 finderArgs, count);
2253
2254 closeSession(session);
2255 }
2256 }
2257
2258 return count.intValue();
2259 }
2260
2261
2269 public int countByU_C(long userId, long classNameId)
2270 throws SystemException {
2271 Object[] finderArgs = new Object[] { userId, classNameId };
2272
2273 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C,
2274 finderArgs, this);
2275
2276 if (count == null) {
2277 StringBundler query = new StringBundler(3);
2278
2279 query.append(_SQL_COUNT_SUBSCRIPTION_WHERE);
2280
2281 query.append(_FINDER_COLUMN_U_C_USERID_2);
2282
2283 query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2);
2284
2285 String sql = query.toString();
2286
2287 Session session = null;
2288
2289 try {
2290 session = openSession();
2291
2292 Query q = session.createQuery(sql);
2293
2294 QueryPos qPos = QueryPos.getInstance(q);
2295
2296 qPos.add(userId);
2297
2298 qPos.add(classNameId);
2299
2300 count = (Long)q.uniqueResult();
2301 }
2302 catch (Exception e) {
2303 throw processException(e);
2304 }
2305 finally {
2306 if (count == null) {
2307 count = Long.valueOf(0);
2308 }
2309
2310 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C, finderArgs,
2311 count);
2312
2313 closeSession(session);
2314 }
2315 }
2316
2317 return count.intValue();
2318 }
2319
2320
2329 public int countByC_C_C(long companyId, long classNameId, long classPK)
2330 throws SystemException {
2331 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
2332
2333 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
2334 finderArgs, this);
2335
2336 if (count == null) {
2337 StringBundler query = new StringBundler(4);
2338
2339 query.append(_SQL_COUNT_SUBSCRIPTION_WHERE);
2340
2341 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2342
2343 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2344
2345 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2346
2347 String sql = query.toString();
2348
2349 Session session = null;
2350
2351 try {
2352 session = openSession();
2353
2354 Query q = session.createQuery(sql);
2355
2356 QueryPos qPos = QueryPos.getInstance(q);
2357
2358 qPos.add(companyId);
2359
2360 qPos.add(classNameId);
2361
2362 qPos.add(classPK);
2363
2364 count = (Long)q.uniqueResult();
2365 }
2366 catch (Exception e) {
2367 throw processException(e);
2368 }
2369 finally {
2370 if (count == null) {
2371 count = Long.valueOf(0);
2372 }
2373
2374 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
2375 finderArgs, count);
2376
2377 closeSession(session);
2378 }
2379 }
2380
2381 return count.intValue();
2382 }
2383
2384
2394 public int countByC_U_C_C(long companyId, long userId, long classNameId,
2395 long classPK) throws SystemException {
2396 Object[] finderArgs = new Object[] {
2397 companyId, userId, classNameId, classPK
2398 };
2399
2400 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U_C_C,
2401 finderArgs, this);
2402
2403 if (count == null) {
2404 StringBundler query = new StringBundler(5);
2405
2406 query.append(_SQL_COUNT_SUBSCRIPTION_WHERE);
2407
2408 query.append(_FINDER_COLUMN_C_U_C_C_COMPANYID_2);
2409
2410 query.append(_FINDER_COLUMN_C_U_C_C_USERID_2);
2411
2412 query.append(_FINDER_COLUMN_C_U_C_C_CLASSNAMEID_2);
2413
2414 query.append(_FINDER_COLUMN_C_U_C_C_CLASSPK_2);
2415
2416 String sql = query.toString();
2417
2418 Session session = null;
2419
2420 try {
2421 session = openSession();
2422
2423 Query q = session.createQuery(sql);
2424
2425 QueryPos qPos = QueryPos.getInstance(q);
2426
2427 qPos.add(companyId);
2428
2429 qPos.add(userId);
2430
2431 qPos.add(classNameId);
2432
2433 qPos.add(classPK);
2434
2435 count = (Long)q.uniqueResult();
2436 }
2437 catch (Exception e) {
2438 throw processException(e);
2439 }
2440 finally {
2441 if (count == null) {
2442 count = Long.valueOf(0);
2443 }
2444
2445 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U_C_C,
2446 finderArgs, count);
2447
2448 closeSession(session);
2449 }
2450 }
2451
2452 return count.intValue();
2453 }
2454
2455
2461 public int countAll() throws SystemException {
2462 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2463 FINDER_ARGS_EMPTY, this);
2464
2465 if (count == null) {
2466 Session session = null;
2467
2468 try {
2469 session = openSession();
2470
2471 Query q = session.createQuery(_SQL_COUNT_SUBSCRIPTION);
2472
2473 count = (Long)q.uniqueResult();
2474 }
2475 catch (Exception e) {
2476 throw processException(e);
2477 }
2478 finally {
2479 if (count == null) {
2480 count = Long.valueOf(0);
2481 }
2482
2483 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2484 FINDER_ARGS_EMPTY, count);
2485
2486 closeSession(session);
2487 }
2488 }
2489
2490 return count.intValue();
2491 }
2492
2493
2496 public void afterPropertiesSet() {
2497 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2498 com.liferay.portal.util.PropsUtil.get(
2499 "value.object.listener.com.liferay.portal.model.Subscription")));
2500
2501 if (listenerClassNames.length > 0) {
2502 try {
2503 List<ModelListener<Subscription>> listenersList = new ArrayList<ModelListener<Subscription>>();
2504
2505 for (String listenerClassName : listenerClassNames) {
2506 Class<?> clazz = getClass();
2507
2508 listenersList.add((ModelListener<Subscription>)InstanceFactory.newInstance(
2509 clazz.getClassLoader(), listenerClassName));
2510 }
2511
2512 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2513 }
2514 catch (Exception e) {
2515 _log.error(e);
2516 }
2517 }
2518 }
2519
2520 public void destroy() {
2521 EntityCacheUtil.removeCache(SubscriptionImpl.class.getName());
2522 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2523 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2524 }
2525
2526 @BeanReference(type = AccountPersistence.class)
2527 protected AccountPersistence accountPersistence;
2528 @BeanReference(type = AddressPersistence.class)
2529 protected AddressPersistence addressPersistence;
2530 @BeanReference(type = BrowserTrackerPersistence.class)
2531 protected BrowserTrackerPersistence browserTrackerPersistence;
2532 @BeanReference(type = ClassNamePersistence.class)
2533 protected ClassNamePersistence classNamePersistence;
2534 @BeanReference(type = ClusterGroupPersistence.class)
2535 protected ClusterGroupPersistence clusterGroupPersistence;
2536 @BeanReference(type = CompanyPersistence.class)
2537 protected CompanyPersistence companyPersistence;
2538 @BeanReference(type = ContactPersistence.class)
2539 protected ContactPersistence contactPersistence;
2540 @BeanReference(type = CountryPersistence.class)
2541 protected CountryPersistence countryPersistence;
2542 @BeanReference(type = EmailAddressPersistence.class)
2543 protected EmailAddressPersistence emailAddressPersistence;
2544 @BeanReference(type = GroupPersistence.class)
2545 protected GroupPersistence groupPersistence;
2546 @BeanReference(type = ImagePersistence.class)
2547 protected ImagePersistence imagePersistence;
2548 @BeanReference(type = LayoutPersistence.class)
2549 protected LayoutPersistence layoutPersistence;
2550 @BeanReference(type = LayoutBranchPersistence.class)
2551 protected LayoutBranchPersistence layoutBranchPersistence;
2552 @BeanReference(type = LayoutPrototypePersistence.class)
2553 protected LayoutPrototypePersistence layoutPrototypePersistence;
2554 @BeanReference(type = LayoutRevisionPersistence.class)
2555 protected LayoutRevisionPersistence layoutRevisionPersistence;
2556 @BeanReference(type = LayoutSetPersistence.class)
2557 protected LayoutSetPersistence layoutSetPersistence;
2558 @BeanReference(type = LayoutSetBranchPersistence.class)
2559 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2560 @BeanReference(type = LayoutSetPrototypePersistence.class)
2561 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2562 @BeanReference(type = ListTypePersistence.class)
2563 protected ListTypePersistence listTypePersistence;
2564 @BeanReference(type = LockPersistence.class)
2565 protected LockPersistence lockPersistence;
2566 @BeanReference(type = MembershipRequestPersistence.class)
2567 protected MembershipRequestPersistence membershipRequestPersistence;
2568 @BeanReference(type = OrganizationPersistence.class)
2569 protected OrganizationPersistence organizationPersistence;
2570 @BeanReference(type = OrgGroupPermissionPersistence.class)
2571 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2572 @BeanReference(type = OrgGroupRolePersistence.class)
2573 protected OrgGroupRolePersistence orgGroupRolePersistence;
2574 @BeanReference(type = OrgLaborPersistence.class)
2575 protected OrgLaborPersistence orgLaborPersistence;
2576 @BeanReference(type = PasswordPolicyPersistence.class)
2577 protected PasswordPolicyPersistence passwordPolicyPersistence;
2578 @BeanReference(type = PasswordPolicyRelPersistence.class)
2579 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2580 @BeanReference(type = PasswordTrackerPersistence.class)
2581 protected PasswordTrackerPersistence passwordTrackerPersistence;
2582 @BeanReference(type = PermissionPersistence.class)
2583 protected PermissionPersistence permissionPersistence;
2584 @BeanReference(type = PhonePersistence.class)
2585 protected PhonePersistence phonePersistence;
2586 @BeanReference(type = PluginSettingPersistence.class)
2587 protected PluginSettingPersistence pluginSettingPersistence;
2588 @BeanReference(type = PortalPreferencesPersistence.class)
2589 protected PortalPreferencesPersistence portalPreferencesPersistence;
2590 @BeanReference(type = PortletPersistence.class)
2591 protected PortletPersistence portletPersistence;
2592 @BeanReference(type = PortletItemPersistence.class)
2593 protected PortletItemPersistence portletItemPersistence;
2594 @BeanReference(type = PortletPreferencesPersistence.class)
2595 protected PortletPreferencesPersistence portletPreferencesPersistence;
2596 @BeanReference(type = RegionPersistence.class)
2597 protected RegionPersistence regionPersistence;
2598 @BeanReference(type = ReleasePersistence.class)
2599 protected ReleasePersistence releasePersistence;
2600 @BeanReference(type = RepositoryPersistence.class)
2601 protected RepositoryPersistence repositoryPersistence;
2602 @BeanReference(type = RepositoryEntryPersistence.class)
2603 protected RepositoryEntryPersistence repositoryEntryPersistence;
2604 @BeanReference(type = ResourcePersistence.class)
2605 protected ResourcePersistence resourcePersistence;
2606 @BeanReference(type = ResourceActionPersistence.class)
2607 protected ResourceActionPersistence resourceActionPersistence;
2608 @BeanReference(type = ResourceBlockPersistence.class)
2609 protected ResourceBlockPersistence resourceBlockPersistence;
2610 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2611 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2612 @BeanReference(type = ResourceCodePersistence.class)
2613 protected ResourceCodePersistence resourceCodePersistence;
2614 @BeanReference(type = ResourcePermissionPersistence.class)
2615 protected ResourcePermissionPersistence resourcePermissionPersistence;
2616 @BeanReference(type = ResourceTypePermissionPersistence.class)
2617 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2618 @BeanReference(type = RolePersistence.class)
2619 protected RolePersistence rolePersistence;
2620 @BeanReference(type = ServiceComponentPersistence.class)
2621 protected ServiceComponentPersistence serviceComponentPersistence;
2622 @BeanReference(type = ShardPersistence.class)
2623 protected ShardPersistence shardPersistence;
2624 @BeanReference(type = SubscriptionPersistence.class)
2625 protected SubscriptionPersistence subscriptionPersistence;
2626 @BeanReference(type = TeamPersistence.class)
2627 protected TeamPersistence teamPersistence;
2628 @BeanReference(type = TicketPersistence.class)
2629 protected TicketPersistence ticketPersistence;
2630 @BeanReference(type = UserPersistence.class)
2631 protected UserPersistence userPersistence;
2632 @BeanReference(type = UserGroupPersistence.class)
2633 protected UserGroupPersistence userGroupPersistence;
2634 @BeanReference(type = UserGroupGroupRolePersistence.class)
2635 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2636 @BeanReference(type = UserGroupRolePersistence.class)
2637 protected UserGroupRolePersistence userGroupRolePersistence;
2638 @BeanReference(type = UserIdMapperPersistence.class)
2639 protected UserIdMapperPersistence userIdMapperPersistence;
2640 @BeanReference(type = UserNotificationEventPersistence.class)
2641 protected UserNotificationEventPersistence userNotificationEventPersistence;
2642 @BeanReference(type = UserTrackerPersistence.class)
2643 protected UserTrackerPersistence userTrackerPersistence;
2644 @BeanReference(type = UserTrackerPathPersistence.class)
2645 protected UserTrackerPathPersistence userTrackerPathPersistence;
2646 @BeanReference(type = VirtualHostPersistence.class)
2647 protected VirtualHostPersistence virtualHostPersistence;
2648 @BeanReference(type = WebDAVPropsPersistence.class)
2649 protected WebDAVPropsPersistence webDAVPropsPersistence;
2650 @BeanReference(type = WebsitePersistence.class)
2651 protected WebsitePersistence websitePersistence;
2652 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2653 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2654 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2655 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2656 @BeanReference(type = AssetEntryPersistence.class)
2657 protected AssetEntryPersistence assetEntryPersistence;
2658 @BeanReference(type = MBThreadPersistence.class)
2659 protected MBThreadPersistence mbThreadPersistence;
2660 @BeanReference(type = SocialActivityPersistence.class)
2661 protected SocialActivityPersistence socialActivityPersistence;
2662 private static final String _SQL_SELECT_SUBSCRIPTION = "SELECT subscription FROM Subscription subscription";
2663 private static final String _SQL_SELECT_SUBSCRIPTION_WHERE = "SELECT subscription FROM Subscription subscription WHERE ";
2664 private static final String _SQL_COUNT_SUBSCRIPTION = "SELECT COUNT(subscription) FROM Subscription subscription";
2665 private static final String _SQL_COUNT_SUBSCRIPTION_WHERE = "SELECT COUNT(subscription) FROM Subscription subscription WHERE ";
2666 private static final String _FINDER_COLUMN_USERID_USERID_2 = "subscription.userId = ?";
2667 private static final String _FINDER_COLUMN_U_C_USERID_2 = "subscription.userId = ? AND ";
2668 private static final String _FINDER_COLUMN_U_C_CLASSNAMEID_2 = "subscription.classNameId = ?";
2669 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "subscription.companyId = ? AND ";
2670 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "subscription.classNameId = ? AND ";
2671 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "subscription.classPK = ?";
2672 private static final String _FINDER_COLUMN_C_U_C_C_COMPANYID_2 = "subscription.companyId = ? AND ";
2673 private static final String _FINDER_COLUMN_C_U_C_C_USERID_2 = "subscription.userId = ? AND ";
2674 private static final String _FINDER_COLUMN_C_U_C_C_CLASSNAMEID_2 = "subscription.classNameId = ? AND ";
2675 private static final String _FINDER_COLUMN_C_U_C_C_CLASSPK_2 = "subscription.classPK = ?";
2676 private static final String _ORDER_BY_ENTITY_ALIAS = "subscription.";
2677 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Subscription exists with the primary key ";
2678 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Subscription exists with the key {";
2679 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2680 private static Log _log = LogFactoryUtil.getLog(SubscriptionPersistenceImpl.class);
2681 private static Subscription _nullSubscription = new SubscriptionImpl() {
2682 @Override
2683 public Object clone() {
2684 return this;
2685 }
2686
2687 @Override
2688 public CacheModel<Subscription> toCacheModel() {
2689 return _nullSubscriptionCacheModel;
2690 }
2691 };
2692
2693 private static CacheModel<Subscription> _nullSubscriptionCacheModel = new CacheModel<Subscription>() {
2694 public Subscription toEntityModel() {
2695 return _nullSubscription;
2696 }
2697 };
2698 }