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