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