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