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