001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchSubscriptionException;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.UnmodifiableList;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.Subscription;
040 import com.liferay.portal.model.impl.SubscriptionImpl;
041 import com.liferay.portal.model.impl.SubscriptionModelImpl;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import java.io.Serializable;
045
046 import java.util.ArrayList;
047 import java.util.Collections;
048 import java.util.List;
049
050
062 public class SubscriptionPersistenceImpl extends BasePersistenceImpl<Subscription>
063 implements SubscriptionPersistence {
064
069 public static final String FINDER_CLASS_NAME_ENTITY = SubscriptionImpl.class.getName();
070 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071 ".List1";
072 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List2";
074 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
075 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
076 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
077 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
078 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
079 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
080 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
081 SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
082 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
083 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
084 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
085 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
086 new String[] {
087 Long.class.getName(),
088
089 Integer.class.getName(), Integer.class.getName(),
090 OrderByComparator.class.getName()
091 });
092 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
093 new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
094 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
096 new String[] { Long.class.getName() },
097 SubscriptionModelImpl.USERID_COLUMN_BITMASK);
098 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
099 SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
101 new String[] { Long.class.getName() });
102
103
110 public List<Subscription> findByUserId(long userId)
111 throws SystemException {
112 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
113 }
114
115
128 public List<Subscription> findByUserId(long userId, int start, int end)
129 throws SystemException {
130 return findByUserId(userId, start, end, null);
131 }
132
133
147 public List<Subscription> findByUserId(long userId, int start, int end,
148 OrderByComparator orderByComparator) throws SystemException {
149 boolean pagination = true;
150 FinderPath finderPath = null;
151 Object[] finderArgs = null;
152
153 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
154 (orderByComparator == null)) {
155 pagination = false;
156 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
157 finderArgs = new Object[] { userId };
158 }
159 else {
160 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
161 finderArgs = new Object[] { userId, start, end, orderByComparator };
162 }
163
164 List<Subscription> list = (List<Subscription>)FinderCacheUtil.getResult(finderPath,
165 finderArgs, this);
166
167 if ((list != null) && !list.isEmpty()) {
168 for (Subscription subscription : list) {
169 if ((userId != subscription.getUserId())) {
170 list = null;
171
172 break;
173 }
174 }
175 }
176
177 if (list == null) {
178 StringBundler query = null;
179
180 if (orderByComparator != null) {
181 query = new StringBundler(3 +
182 (orderByComparator.getOrderByFields().length * 3));
183 }
184 else {
185 query = new StringBundler(3);
186 }
187
188 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
189
190 query.append(_FINDER_COLUMN_USERID_USERID_2);
191
192 if (orderByComparator != null) {
193 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
194 orderByComparator);
195 }
196 else
197 if (pagination) {
198 query.append(SubscriptionModelImpl.ORDER_BY_JPQL);
199 }
200
201 String sql = query.toString();
202
203 Session session = null;
204
205 try {
206 session = openSession();
207
208 Query q = session.createQuery(sql);
209
210 QueryPos qPos = QueryPos.getInstance(q);
211
212 qPos.add(userId);
213
214 if (!pagination) {
215 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
216 start, end, false);
217
218 Collections.sort(list);
219
220 list = new UnmodifiableList<Subscription>(list);
221 }
222 else {
223 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
224 start, end);
225 }
226
227 cacheResult(list);
228
229 FinderCacheUtil.putResult(finderPath, finderArgs, list);
230 }
231 catch (Exception e) {
232 FinderCacheUtil.removeResult(finderPath, finderArgs);
233
234 throw processException(e);
235 }
236 finally {
237 closeSession(session);
238 }
239 }
240
241 return list;
242 }
243
244
253 public Subscription findByUserId_First(long userId,
254 OrderByComparator orderByComparator)
255 throws NoSuchSubscriptionException, SystemException {
256 Subscription subscription = fetchByUserId_First(userId,
257 orderByComparator);
258
259 if (subscription != null) {
260 return subscription;
261 }
262
263 StringBundler msg = new StringBundler(4);
264
265 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
266
267 msg.append("userId=");
268 msg.append(userId);
269
270 msg.append(StringPool.CLOSE_CURLY_BRACE);
271
272 throw new NoSuchSubscriptionException(msg.toString());
273 }
274
275
283 public Subscription fetchByUserId_First(long userId,
284 OrderByComparator orderByComparator) throws SystemException {
285 List<Subscription> list = findByUserId(userId, 0, 1, orderByComparator);
286
287 if (!list.isEmpty()) {
288 return list.get(0);
289 }
290
291 return null;
292 }
293
294
303 public Subscription findByUserId_Last(long userId,
304 OrderByComparator orderByComparator)
305 throws NoSuchSubscriptionException, SystemException {
306 Subscription subscription = fetchByUserId_Last(userId, orderByComparator);
307
308 if (subscription != null) {
309 return subscription;
310 }
311
312 StringBundler msg = new StringBundler(4);
313
314 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
315
316 msg.append("userId=");
317 msg.append(userId);
318
319 msg.append(StringPool.CLOSE_CURLY_BRACE);
320
321 throw new NoSuchSubscriptionException(msg.toString());
322 }
323
324
332 public Subscription fetchByUserId_Last(long userId,
333 OrderByComparator orderByComparator) throws SystemException {
334 int count = countByUserId(userId);
335
336 List<Subscription> list = findByUserId(userId, count - 1, count,
337 orderByComparator);
338
339 if (!list.isEmpty()) {
340 return list.get(0);
341 }
342
343 return null;
344 }
345
346
356 public Subscription[] findByUserId_PrevAndNext(long subscriptionId,
357 long userId, OrderByComparator orderByComparator)
358 throws NoSuchSubscriptionException, SystemException {
359 Subscription subscription = findByPrimaryKey(subscriptionId);
360
361 Session session = null;
362
363 try {
364 session = openSession();
365
366 Subscription[] array = new SubscriptionImpl[3];
367
368 array[0] = getByUserId_PrevAndNext(session, subscription, userId,
369 orderByComparator, true);
370
371 array[1] = subscription;
372
373 array[2] = getByUserId_PrevAndNext(session, subscription, userId,
374 orderByComparator, false);
375
376 return array;
377 }
378 catch (Exception e) {
379 throw processException(e);
380 }
381 finally {
382 closeSession(session);
383 }
384 }
385
386 protected Subscription getByUserId_PrevAndNext(Session session,
387 Subscription subscription, long userId,
388 OrderByComparator orderByComparator, boolean previous) {
389 StringBundler query = null;
390
391 if (orderByComparator != null) {
392 query = new StringBundler(6 +
393 (orderByComparator.getOrderByFields().length * 6));
394 }
395 else {
396 query = new StringBundler(3);
397 }
398
399 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
400
401 query.append(_FINDER_COLUMN_USERID_USERID_2);
402
403 if (orderByComparator != null) {
404 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
405
406 if (orderByConditionFields.length > 0) {
407 query.append(WHERE_AND);
408 }
409
410 for (int i = 0; i < orderByConditionFields.length; i++) {
411 query.append(_ORDER_BY_ENTITY_ALIAS);
412 query.append(orderByConditionFields[i]);
413
414 if ((i + 1) < orderByConditionFields.length) {
415 if (orderByComparator.isAscending() ^ previous) {
416 query.append(WHERE_GREATER_THAN_HAS_NEXT);
417 }
418 else {
419 query.append(WHERE_LESSER_THAN_HAS_NEXT);
420 }
421 }
422 else {
423 if (orderByComparator.isAscending() ^ previous) {
424 query.append(WHERE_GREATER_THAN);
425 }
426 else {
427 query.append(WHERE_LESSER_THAN);
428 }
429 }
430 }
431
432 query.append(ORDER_BY_CLAUSE);
433
434 String[] orderByFields = orderByComparator.getOrderByFields();
435
436 for (int i = 0; i < orderByFields.length; i++) {
437 query.append(_ORDER_BY_ENTITY_ALIAS);
438 query.append(orderByFields[i]);
439
440 if ((i + 1) < orderByFields.length) {
441 if (orderByComparator.isAscending() ^ previous) {
442 query.append(ORDER_BY_ASC_HAS_NEXT);
443 }
444 else {
445 query.append(ORDER_BY_DESC_HAS_NEXT);
446 }
447 }
448 else {
449 if (orderByComparator.isAscending() ^ previous) {
450 query.append(ORDER_BY_ASC);
451 }
452 else {
453 query.append(ORDER_BY_DESC);
454 }
455 }
456 }
457 }
458 else {
459 query.append(SubscriptionModelImpl.ORDER_BY_JPQL);
460 }
461
462 String sql = query.toString();
463
464 Query q = session.createQuery(sql);
465
466 q.setFirstResult(0);
467 q.setMaxResults(2);
468
469 QueryPos qPos = QueryPos.getInstance(q);
470
471 qPos.add(userId);
472
473 if (orderByComparator != null) {
474 Object[] values = orderByComparator.getOrderByConditionValues(subscription);
475
476 for (Object value : values) {
477 qPos.add(value);
478 }
479 }
480
481 List<Subscription> list = q.list();
482
483 if (list.size() == 2) {
484 return list.get(1);
485 }
486 else {
487 return null;
488 }
489 }
490
491
497 public void removeByUserId(long userId) throws SystemException {
498 for (Subscription subscription : findByUserId(userId,
499 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
500 remove(subscription);
501 }
502 }
503
504
511 public int countByUserId(long userId) throws SystemException {
512 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
513
514 Object[] finderArgs = new Object[] { userId };
515
516 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
517 this);
518
519 if (count == null) {
520 StringBundler query = new StringBundler(2);
521
522 query.append(_SQL_COUNT_SUBSCRIPTION_WHERE);
523
524 query.append(_FINDER_COLUMN_USERID_USERID_2);
525
526 String sql = query.toString();
527
528 Session session = null;
529
530 try {
531 session = openSession();
532
533 Query q = session.createQuery(sql);
534
535 QueryPos qPos = QueryPos.getInstance(q);
536
537 qPos.add(userId);
538
539 count = (Long)q.uniqueResult();
540
541 FinderCacheUtil.putResult(finderPath, finderArgs, count);
542 }
543 catch (Exception e) {
544 FinderCacheUtil.removeResult(finderPath, finderArgs);
545
546 throw processException(e);
547 }
548 finally {
549 closeSession(session);
550 }
551 }
552
553 return count.intValue();
554 }
555
556 private static final String _FINDER_COLUMN_USERID_USERID_2 = "subscription.userId = ?";
557 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
558 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
559 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_C",
560 new String[] {
561 Long.class.getName(), Long.class.getName(),
562
563 Integer.class.getName(), Integer.class.getName(),
564 OrderByComparator.class.getName()
565 });
566 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
567 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
568 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C",
569 new String[] { Long.class.getName(), Long.class.getName() },
570 SubscriptionModelImpl.USERID_COLUMN_BITMASK |
571 SubscriptionModelImpl.CLASSNAMEID_COLUMN_BITMASK);
572 public static final FinderPath FINDER_PATH_COUNT_BY_U_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
573 SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
574 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C",
575 new String[] { Long.class.getName(), Long.class.getName() });
576
577
585 public List<Subscription> findByU_C(long userId, long classNameId)
586 throws SystemException {
587 return findByU_C(userId, classNameId, QueryUtil.ALL_POS,
588 QueryUtil.ALL_POS, null);
589 }
590
591
605 public List<Subscription> findByU_C(long userId, long classNameId,
606 int start, int end) throws SystemException {
607 return findByU_C(userId, classNameId, start, end, null);
608 }
609
610
625 public List<Subscription> findByU_C(long userId, long classNameId,
626 int start, int end, OrderByComparator orderByComparator)
627 throws SystemException {
628 boolean pagination = true;
629 FinderPath finderPath = null;
630 Object[] finderArgs = null;
631
632 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
633 (orderByComparator == null)) {
634 pagination = false;
635 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C;
636 finderArgs = new Object[] { userId, classNameId };
637 }
638 else {
639 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C;
640 finderArgs = new Object[] {
641 userId, classNameId,
642
643 start, end, orderByComparator
644 };
645 }
646
647 List<Subscription> list = (List<Subscription>)FinderCacheUtil.getResult(finderPath,
648 finderArgs, this);
649
650 if ((list != null) && !list.isEmpty()) {
651 for (Subscription subscription : list) {
652 if ((userId != subscription.getUserId()) ||
653 (classNameId != subscription.getClassNameId())) {
654 list = null;
655
656 break;
657 }
658 }
659 }
660
661 if (list == null) {
662 StringBundler query = null;
663
664 if (orderByComparator != null) {
665 query = new StringBundler(4 +
666 (orderByComparator.getOrderByFields().length * 3));
667 }
668 else {
669 query = new StringBundler(4);
670 }
671
672 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
673
674 query.append(_FINDER_COLUMN_U_C_USERID_2);
675
676 query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2);
677
678 if (orderByComparator != null) {
679 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
680 orderByComparator);
681 }
682 else
683 if (pagination) {
684 query.append(SubscriptionModelImpl.ORDER_BY_JPQL);
685 }
686
687 String sql = query.toString();
688
689 Session session = null;
690
691 try {
692 session = openSession();
693
694 Query q = session.createQuery(sql);
695
696 QueryPos qPos = QueryPos.getInstance(q);
697
698 qPos.add(userId);
699
700 qPos.add(classNameId);
701
702 if (!pagination) {
703 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
704 start, end, false);
705
706 Collections.sort(list);
707
708 list = new UnmodifiableList<Subscription>(list);
709 }
710 else {
711 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
712 start, end);
713 }
714
715 cacheResult(list);
716
717 FinderCacheUtil.putResult(finderPath, finderArgs, list);
718 }
719 catch (Exception e) {
720 FinderCacheUtil.removeResult(finderPath, finderArgs);
721
722 throw processException(e);
723 }
724 finally {
725 closeSession(session);
726 }
727 }
728
729 return list;
730 }
731
732
742 public Subscription findByU_C_First(long userId, long classNameId,
743 OrderByComparator orderByComparator)
744 throws NoSuchSubscriptionException, SystemException {
745 Subscription subscription = fetchByU_C_First(userId, classNameId,
746 orderByComparator);
747
748 if (subscription != null) {
749 return subscription;
750 }
751
752 StringBundler msg = new StringBundler(6);
753
754 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
755
756 msg.append("userId=");
757 msg.append(userId);
758
759 msg.append(", classNameId=");
760 msg.append(classNameId);
761
762 msg.append(StringPool.CLOSE_CURLY_BRACE);
763
764 throw new NoSuchSubscriptionException(msg.toString());
765 }
766
767
776 public Subscription fetchByU_C_First(long userId, long classNameId,
777 OrderByComparator orderByComparator) throws SystemException {
778 List<Subscription> list = findByU_C(userId, classNameId, 0, 1,
779 orderByComparator);
780
781 if (!list.isEmpty()) {
782 return list.get(0);
783 }
784
785 return null;
786 }
787
788
798 public Subscription findByU_C_Last(long userId, long classNameId,
799 OrderByComparator orderByComparator)
800 throws NoSuchSubscriptionException, SystemException {
801 Subscription subscription = fetchByU_C_Last(userId, classNameId,
802 orderByComparator);
803
804 if (subscription != null) {
805 return subscription;
806 }
807
808 StringBundler msg = new StringBundler(6);
809
810 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
811
812 msg.append("userId=");
813 msg.append(userId);
814
815 msg.append(", classNameId=");
816 msg.append(classNameId);
817
818 msg.append(StringPool.CLOSE_CURLY_BRACE);
819
820 throw new NoSuchSubscriptionException(msg.toString());
821 }
822
823
832 public Subscription fetchByU_C_Last(long userId, long classNameId,
833 OrderByComparator orderByComparator) throws SystemException {
834 int count = countByU_C(userId, classNameId);
835
836 List<Subscription> list = findByU_C(userId, classNameId, count - 1,
837 count, orderByComparator);
838
839 if (!list.isEmpty()) {
840 return list.get(0);
841 }
842
843 return null;
844 }
845
846
857 public Subscription[] findByU_C_PrevAndNext(long subscriptionId,
858 long userId, long classNameId, OrderByComparator orderByComparator)
859 throws NoSuchSubscriptionException, SystemException {
860 Subscription subscription = findByPrimaryKey(subscriptionId);
861
862 Session session = null;
863
864 try {
865 session = openSession();
866
867 Subscription[] array = new SubscriptionImpl[3];
868
869 array[0] = getByU_C_PrevAndNext(session, subscription, userId,
870 classNameId, orderByComparator, true);
871
872 array[1] = subscription;
873
874 array[2] = getByU_C_PrevAndNext(session, subscription, userId,
875 classNameId, orderByComparator, false);
876
877 return array;
878 }
879 catch (Exception e) {
880 throw processException(e);
881 }
882 finally {
883 closeSession(session);
884 }
885 }
886
887 protected Subscription getByU_C_PrevAndNext(Session session,
888 Subscription subscription, long userId, long classNameId,
889 OrderByComparator orderByComparator, boolean previous) {
890 StringBundler query = null;
891
892 if (orderByComparator != null) {
893 query = new StringBundler(6 +
894 (orderByComparator.getOrderByFields().length * 6));
895 }
896 else {
897 query = new StringBundler(3);
898 }
899
900 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
901
902 query.append(_FINDER_COLUMN_U_C_USERID_2);
903
904 query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2);
905
906 if (orderByComparator != null) {
907 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
908
909 if (orderByConditionFields.length > 0) {
910 query.append(WHERE_AND);
911 }
912
913 for (int i = 0; i < orderByConditionFields.length; i++) {
914 query.append(_ORDER_BY_ENTITY_ALIAS);
915 query.append(orderByConditionFields[i]);
916
917 if ((i + 1) < orderByConditionFields.length) {
918 if (orderByComparator.isAscending() ^ previous) {
919 query.append(WHERE_GREATER_THAN_HAS_NEXT);
920 }
921 else {
922 query.append(WHERE_LESSER_THAN_HAS_NEXT);
923 }
924 }
925 else {
926 if (orderByComparator.isAscending() ^ previous) {
927 query.append(WHERE_GREATER_THAN);
928 }
929 else {
930 query.append(WHERE_LESSER_THAN);
931 }
932 }
933 }
934
935 query.append(ORDER_BY_CLAUSE);
936
937 String[] orderByFields = orderByComparator.getOrderByFields();
938
939 for (int i = 0; i < orderByFields.length; i++) {
940 query.append(_ORDER_BY_ENTITY_ALIAS);
941 query.append(orderByFields[i]);
942
943 if ((i + 1) < orderByFields.length) {
944 if (orderByComparator.isAscending() ^ previous) {
945 query.append(ORDER_BY_ASC_HAS_NEXT);
946 }
947 else {
948 query.append(ORDER_BY_DESC_HAS_NEXT);
949 }
950 }
951 else {
952 if (orderByComparator.isAscending() ^ previous) {
953 query.append(ORDER_BY_ASC);
954 }
955 else {
956 query.append(ORDER_BY_DESC);
957 }
958 }
959 }
960 }
961 else {
962 query.append(SubscriptionModelImpl.ORDER_BY_JPQL);
963 }
964
965 String sql = query.toString();
966
967 Query q = session.createQuery(sql);
968
969 q.setFirstResult(0);
970 q.setMaxResults(2);
971
972 QueryPos qPos = QueryPos.getInstance(q);
973
974 qPos.add(userId);
975
976 qPos.add(classNameId);
977
978 if (orderByComparator != null) {
979 Object[] values = orderByComparator.getOrderByConditionValues(subscription);
980
981 for (Object value : values) {
982 qPos.add(value);
983 }
984 }
985
986 List<Subscription> list = q.list();
987
988 if (list.size() == 2) {
989 return list.get(1);
990 }
991 else {
992 return null;
993 }
994 }
995
996
1003 public void removeByU_C(long userId, long classNameId)
1004 throws SystemException {
1005 for (Subscription subscription : findByU_C(userId, classNameId,
1006 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1007 remove(subscription);
1008 }
1009 }
1010
1011
1019 public int countByU_C(long userId, long classNameId)
1020 throws SystemException {
1021 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_C;
1022
1023 Object[] finderArgs = new Object[] { userId, classNameId };
1024
1025 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1026 this);
1027
1028 if (count == null) {
1029 StringBundler query = new StringBundler(3);
1030
1031 query.append(_SQL_COUNT_SUBSCRIPTION_WHERE);
1032
1033 query.append(_FINDER_COLUMN_U_C_USERID_2);
1034
1035 query.append(_FINDER_COLUMN_U_C_CLASSNAMEID_2);
1036
1037 String sql = query.toString();
1038
1039 Session session = null;
1040
1041 try {
1042 session = openSession();
1043
1044 Query q = session.createQuery(sql);
1045
1046 QueryPos qPos = QueryPos.getInstance(q);
1047
1048 qPos.add(userId);
1049
1050 qPos.add(classNameId);
1051
1052 count = (Long)q.uniqueResult();
1053
1054 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1055 }
1056 catch (Exception e) {
1057 FinderCacheUtil.removeResult(finderPath, finderArgs);
1058
1059 throw processException(e);
1060 }
1061 finally {
1062 closeSession(session);
1063 }
1064 }
1065
1066 return count.intValue();
1067 }
1068
1069 private static final String _FINDER_COLUMN_U_C_USERID_2 = "subscription.userId = ? AND ";
1070 private static final String _FINDER_COLUMN_U_C_CLASSNAMEID_2 = "subscription.classNameId = ?";
1071 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
1072 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
1073 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_C",
1074 new String[] {
1075 Long.class.getName(), Long.class.getName(), Long.class.getName(),
1076
1077 Integer.class.getName(), Integer.class.getName(),
1078 OrderByComparator.class.getName()
1079 });
1080 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
1081 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
1082 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_C",
1083 new String[] {
1084 Long.class.getName(), Long.class.getName(), Long.class.getName()
1085 },
1086 SubscriptionModelImpl.COMPANYID_COLUMN_BITMASK |
1087 SubscriptionModelImpl.CLASSNAMEID_COLUMN_BITMASK |
1088 SubscriptionModelImpl.CLASSPK_COLUMN_BITMASK);
1089 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
1090 SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1091 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
1092 new String[] {
1093 Long.class.getName(), Long.class.getName(), Long.class.getName()
1094 });
1095
1096
1105 public List<Subscription> findByC_C_C(long companyId, long classNameId,
1106 long classPK) throws SystemException {
1107 return findByC_C_C(companyId, classNameId, classPK, QueryUtil.ALL_POS,
1108 QueryUtil.ALL_POS, null);
1109 }
1110
1111
1126 public List<Subscription> findByC_C_C(long companyId, long classNameId,
1127 long classPK, int start, int end) throws SystemException {
1128 return findByC_C_C(companyId, classNameId, classPK, start, end, null);
1129 }
1130
1131
1147 public List<Subscription> findByC_C_C(long companyId, long classNameId,
1148 long classPK, int start, int end, OrderByComparator orderByComparator)
1149 throws SystemException {
1150 boolean pagination = true;
1151 FinderPath finderPath = null;
1152 Object[] finderArgs = null;
1153
1154 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1155 (orderByComparator == null)) {
1156 pagination = false;
1157 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C;
1158 finderArgs = new Object[] { companyId, classNameId, classPK };
1159 }
1160 else {
1161 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_C;
1162 finderArgs = new Object[] {
1163 companyId, classNameId, classPK,
1164
1165 start, end, orderByComparator
1166 };
1167 }
1168
1169 List<Subscription> list = (List<Subscription>)FinderCacheUtil.getResult(finderPath,
1170 finderArgs, this);
1171
1172 if ((list != null) && !list.isEmpty()) {
1173 for (Subscription subscription : list) {
1174 if ((companyId != subscription.getCompanyId()) ||
1175 (classNameId != subscription.getClassNameId()) ||
1176 (classPK != subscription.getClassPK())) {
1177 list = null;
1178
1179 break;
1180 }
1181 }
1182 }
1183
1184 if (list == null) {
1185 StringBundler query = null;
1186
1187 if (orderByComparator != null) {
1188 query = new StringBundler(5 +
1189 (orderByComparator.getOrderByFields().length * 3));
1190 }
1191 else {
1192 query = new StringBundler(5);
1193 }
1194
1195 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1196
1197 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1198
1199 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1200
1201 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1202
1203 if (orderByComparator != null) {
1204 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1205 orderByComparator);
1206 }
1207 else
1208 if (pagination) {
1209 query.append(SubscriptionModelImpl.ORDER_BY_JPQL);
1210 }
1211
1212 String sql = query.toString();
1213
1214 Session session = null;
1215
1216 try {
1217 session = openSession();
1218
1219 Query q = session.createQuery(sql);
1220
1221 QueryPos qPos = QueryPos.getInstance(q);
1222
1223 qPos.add(companyId);
1224
1225 qPos.add(classNameId);
1226
1227 qPos.add(classPK);
1228
1229 if (!pagination) {
1230 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
1231 start, end, false);
1232
1233 Collections.sort(list);
1234
1235 list = new UnmodifiableList<Subscription>(list);
1236 }
1237 else {
1238 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
1239 start, end);
1240 }
1241
1242 cacheResult(list);
1243
1244 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1245 }
1246 catch (Exception e) {
1247 FinderCacheUtil.removeResult(finderPath, finderArgs);
1248
1249 throw processException(e);
1250 }
1251 finally {
1252 closeSession(session);
1253 }
1254 }
1255
1256 return list;
1257 }
1258
1259
1270 public Subscription findByC_C_C_First(long companyId, long classNameId,
1271 long classPK, OrderByComparator orderByComparator)
1272 throws NoSuchSubscriptionException, SystemException {
1273 Subscription subscription = fetchByC_C_C_First(companyId, classNameId,
1274 classPK, orderByComparator);
1275
1276 if (subscription != null) {
1277 return subscription;
1278 }
1279
1280 StringBundler msg = new StringBundler(8);
1281
1282 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1283
1284 msg.append("companyId=");
1285 msg.append(companyId);
1286
1287 msg.append(", classNameId=");
1288 msg.append(classNameId);
1289
1290 msg.append(", classPK=");
1291 msg.append(classPK);
1292
1293 msg.append(StringPool.CLOSE_CURLY_BRACE);
1294
1295 throw new NoSuchSubscriptionException(msg.toString());
1296 }
1297
1298
1308 public Subscription fetchByC_C_C_First(long companyId, long classNameId,
1309 long classPK, OrderByComparator orderByComparator)
1310 throws SystemException {
1311 List<Subscription> list = findByC_C_C(companyId, classNameId, classPK,
1312 0, 1, orderByComparator);
1313
1314 if (!list.isEmpty()) {
1315 return list.get(0);
1316 }
1317
1318 return null;
1319 }
1320
1321
1332 public Subscription findByC_C_C_Last(long companyId, long classNameId,
1333 long classPK, OrderByComparator orderByComparator)
1334 throws NoSuchSubscriptionException, SystemException {
1335 Subscription subscription = fetchByC_C_C_Last(companyId, classNameId,
1336 classPK, orderByComparator);
1337
1338 if (subscription != null) {
1339 return subscription;
1340 }
1341
1342 StringBundler msg = new StringBundler(8);
1343
1344 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1345
1346 msg.append("companyId=");
1347 msg.append(companyId);
1348
1349 msg.append(", classNameId=");
1350 msg.append(classNameId);
1351
1352 msg.append(", classPK=");
1353 msg.append(classPK);
1354
1355 msg.append(StringPool.CLOSE_CURLY_BRACE);
1356
1357 throw new NoSuchSubscriptionException(msg.toString());
1358 }
1359
1360
1370 public Subscription fetchByC_C_C_Last(long companyId, long classNameId,
1371 long classPK, OrderByComparator orderByComparator)
1372 throws SystemException {
1373 int count = countByC_C_C(companyId, classNameId, classPK);
1374
1375 List<Subscription> list = findByC_C_C(companyId, classNameId, classPK,
1376 count - 1, count, orderByComparator);
1377
1378 if (!list.isEmpty()) {
1379 return list.get(0);
1380 }
1381
1382 return null;
1383 }
1384
1385
1397 public Subscription[] findByC_C_C_PrevAndNext(long subscriptionId,
1398 long companyId, long classNameId, long classPK,
1399 OrderByComparator orderByComparator)
1400 throws NoSuchSubscriptionException, SystemException {
1401 Subscription subscription = findByPrimaryKey(subscriptionId);
1402
1403 Session session = null;
1404
1405 try {
1406 session = openSession();
1407
1408 Subscription[] array = new SubscriptionImpl[3];
1409
1410 array[0] = getByC_C_C_PrevAndNext(session, subscription, companyId,
1411 classNameId, classPK, orderByComparator, true);
1412
1413 array[1] = subscription;
1414
1415 array[2] = getByC_C_C_PrevAndNext(session, subscription, companyId,
1416 classNameId, classPK, orderByComparator, false);
1417
1418 return array;
1419 }
1420 catch (Exception e) {
1421 throw processException(e);
1422 }
1423 finally {
1424 closeSession(session);
1425 }
1426 }
1427
1428 protected Subscription getByC_C_C_PrevAndNext(Session session,
1429 Subscription subscription, long companyId, long classNameId,
1430 long classPK, OrderByComparator orderByComparator, boolean previous) {
1431 StringBundler query = null;
1432
1433 if (orderByComparator != null) {
1434 query = new StringBundler(6 +
1435 (orderByComparator.getOrderByFields().length * 6));
1436 }
1437 else {
1438 query = new StringBundler(3);
1439 }
1440
1441 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1442
1443 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1444
1445 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1446
1447 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1448
1449 if (orderByComparator != null) {
1450 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1451
1452 if (orderByConditionFields.length > 0) {
1453 query.append(WHERE_AND);
1454 }
1455
1456 for (int i = 0; i < orderByConditionFields.length; i++) {
1457 query.append(_ORDER_BY_ENTITY_ALIAS);
1458 query.append(orderByConditionFields[i]);
1459
1460 if ((i + 1) < orderByConditionFields.length) {
1461 if (orderByComparator.isAscending() ^ previous) {
1462 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1463 }
1464 else {
1465 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1466 }
1467 }
1468 else {
1469 if (orderByComparator.isAscending() ^ previous) {
1470 query.append(WHERE_GREATER_THAN);
1471 }
1472 else {
1473 query.append(WHERE_LESSER_THAN);
1474 }
1475 }
1476 }
1477
1478 query.append(ORDER_BY_CLAUSE);
1479
1480 String[] orderByFields = orderByComparator.getOrderByFields();
1481
1482 for (int i = 0; i < orderByFields.length; i++) {
1483 query.append(_ORDER_BY_ENTITY_ALIAS);
1484 query.append(orderByFields[i]);
1485
1486 if ((i + 1) < orderByFields.length) {
1487 if (orderByComparator.isAscending() ^ previous) {
1488 query.append(ORDER_BY_ASC_HAS_NEXT);
1489 }
1490 else {
1491 query.append(ORDER_BY_DESC_HAS_NEXT);
1492 }
1493 }
1494 else {
1495 if (orderByComparator.isAscending() ^ previous) {
1496 query.append(ORDER_BY_ASC);
1497 }
1498 else {
1499 query.append(ORDER_BY_DESC);
1500 }
1501 }
1502 }
1503 }
1504 else {
1505 query.append(SubscriptionModelImpl.ORDER_BY_JPQL);
1506 }
1507
1508 String sql = query.toString();
1509
1510 Query q = session.createQuery(sql);
1511
1512 q.setFirstResult(0);
1513 q.setMaxResults(2);
1514
1515 QueryPos qPos = QueryPos.getInstance(q);
1516
1517 qPos.add(companyId);
1518
1519 qPos.add(classNameId);
1520
1521 qPos.add(classPK);
1522
1523 if (orderByComparator != null) {
1524 Object[] values = orderByComparator.getOrderByConditionValues(subscription);
1525
1526 for (Object value : values) {
1527 qPos.add(value);
1528 }
1529 }
1530
1531 List<Subscription> list = q.list();
1532
1533 if (list.size() == 2) {
1534 return list.get(1);
1535 }
1536 else {
1537 return null;
1538 }
1539 }
1540
1541
1549 public void removeByC_C_C(long companyId, long classNameId, long classPK)
1550 throws SystemException {
1551 for (Subscription subscription : findByC_C_C(companyId, classNameId,
1552 classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1553 remove(subscription);
1554 }
1555 }
1556
1557
1566 public int countByC_C_C(long companyId, long classNameId, long classPK)
1567 throws SystemException {
1568 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_C;
1569
1570 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
1571
1572 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1573 this);
1574
1575 if (count == null) {
1576 StringBundler query = new StringBundler(4);
1577
1578 query.append(_SQL_COUNT_SUBSCRIPTION_WHERE);
1579
1580 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1581
1582 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1583
1584 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1585
1586 String sql = query.toString();
1587
1588 Session session = null;
1589
1590 try {
1591 session = openSession();
1592
1593 Query q = session.createQuery(sql);
1594
1595 QueryPos qPos = QueryPos.getInstance(q);
1596
1597 qPos.add(companyId);
1598
1599 qPos.add(classNameId);
1600
1601 qPos.add(classPK);
1602
1603 count = (Long)q.uniqueResult();
1604
1605 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1606 }
1607 catch (Exception e) {
1608 FinderCacheUtil.removeResult(finderPath, finderArgs);
1609
1610 throw processException(e);
1611 }
1612 finally {
1613 closeSession(session);
1614 }
1615 }
1616
1617 return count.intValue();
1618 }
1619
1620 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "subscription.companyId = ? AND ";
1621 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "subscription.classNameId = ? AND ";
1622 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "subscription.classPK = ?";
1623 public static final FinderPath FINDER_PATH_FETCH_BY_C_U_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
1624 SubscriptionModelImpl.FINDER_CACHE_ENABLED, SubscriptionImpl.class,
1625 FINDER_CLASS_NAME_ENTITY, "fetchByC_U_C_C",
1626 new String[] {
1627 Long.class.getName(), Long.class.getName(), Long.class.getName(),
1628 Long.class.getName()
1629 },
1630 SubscriptionModelImpl.COMPANYID_COLUMN_BITMASK |
1631 SubscriptionModelImpl.USERID_COLUMN_BITMASK |
1632 SubscriptionModelImpl.CLASSNAMEID_COLUMN_BITMASK |
1633 SubscriptionModelImpl.CLASSPK_COLUMN_BITMASK);
1634 public static final FinderPath FINDER_PATH_COUNT_BY_C_U_C_C = new FinderPath(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
1635 SubscriptionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1636 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_C_C",
1637 new String[] {
1638 Long.class.getName(), Long.class.getName(), Long.class.getName(),
1639 Long.class.getName()
1640 });
1641
1642
1653 public Subscription findByC_U_C_C(long companyId, long userId,
1654 long classNameId, long classPK)
1655 throws NoSuchSubscriptionException, SystemException {
1656 Subscription subscription = fetchByC_U_C_C(companyId, userId,
1657 classNameId, classPK);
1658
1659 if (subscription == null) {
1660 StringBundler msg = new StringBundler(10);
1661
1662 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1663
1664 msg.append("companyId=");
1665 msg.append(companyId);
1666
1667 msg.append(", userId=");
1668 msg.append(userId);
1669
1670 msg.append(", classNameId=");
1671 msg.append(classNameId);
1672
1673 msg.append(", classPK=");
1674 msg.append(classPK);
1675
1676 msg.append(StringPool.CLOSE_CURLY_BRACE);
1677
1678 if (_log.isWarnEnabled()) {
1679 _log.warn(msg.toString());
1680 }
1681
1682 throw new NoSuchSubscriptionException(msg.toString());
1683 }
1684
1685 return subscription;
1686 }
1687
1688
1698 public Subscription fetchByC_U_C_C(long companyId, long userId,
1699 long classNameId, long classPK) throws SystemException {
1700 return fetchByC_U_C_C(companyId, userId, classNameId, classPK, true);
1701 }
1702
1703
1714 public Subscription fetchByC_U_C_C(long companyId, long userId,
1715 long classNameId, long classPK, boolean retrieveFromCache)
1716 throws SystemException {
1717 Object[] finderArgs = new Object[] {
1718 companyId, userId, classNameId, classPK
1719 };
1720
1721 Object result = null;
1722
1723 if (retrieveFromCache) {
1724 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U_C_C,
1725 finderArgs, this);
1726 }
1727
1728 if (result instanceof Subscription) {
1729 Subscription subscription = (Subscription)result;
1730
1731 if ((companyId != subscription.getCompanyId()) ||
1732 (userId != subscription.getUserId()) ||
1733 (classNameId != subscription.getClassNameId()) ||
1734 (classPK != subscription.getClassPK())) {
1735 result = null;
1736 }
1737 }
1738
1739 if (result == null) {
1740 StringBundler query = new StringBundler(6);
1741
1742 query.append(_SQL_SELECT_SUBSCRIPTION_WHERE);
1743
1744 query.append(_FINDER_COLUMN_C_U_C_C_COMPANYID_2);
1745
1746 query.append(_FINDER_COLUMN_C_U_C_C_USERID_2);
1747
1748 query.append(_FINDER_COLUMN_C_U_C_C_CLASSNAMEID_2);
1749
1750 query.append(_FINDER_COLUMN_C_U_C_C_CLASSPK_2);
1751
1752 String sql = query.toString();
1753
1754 Session session = null;
1755
1756 try {
1757 session = openSession();
1758
1759 Query q = session.createQuery(sql);
1760
1761 QueryPos qPos = QueryPos.getInstance(q);
1762
1763 qPos.add(companyId);
1764
1765 qPos.add(userId);
1766
1767 qPos.add(classNameId);
1768
1769 qPos.add(classPK);
1770
1771 List<Subscription> list = q.list();
1772
1773 if (list.isEmpty()) {
1774 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C,
1775 finderArgs, list);
1776 }
1777 else {
1778 Subscription subscription = list.get(0);
1779
1780 result = subscription;
1781
1782 cacheResult(subscription);
1783
1784 if ((subscription.getCompanyId() != companyId) ||
1785 (subscription.getUserId() != userId) ||
1786 (subscription.getClassNameId() != classNameId) ||
1787 (subscription.getClassPK() != classPK)) {
1788 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C,
1789 finderArgs, subscription);
1790 }
1791 }
1792 }
1793 catch (Exception e) {
1794 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_C_C,
1795 finderArgs);
1796
1797 throw processException(e);
1798 }
1799 finally {
1800 closeSession(session);
1801 }
1802 }
1803
1804 if (result instanceof List<?>) {
1805 return null;
1806 }
1807 else {
1808 return (Subscription)result;
1809 }
1810 }
1811
1812
1822 public Subscription removeByC_U_C_C(long companyId, long userId,
1823 long classNameId, long classPK)
1824 throws NoSuchSubscriptionException, SystemException {
1825 Subscription subscription = findByC_U_C_C(companyId, userId,
1826 classNameId, classPK);
1827
1828 return remove(subscription);
1829 }
1830
1831
1841 public int countByC_U_C_C(long companyId, long userId, long classNameId,
1842 long classPK) throws SystemException {
1843 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_C_C;
1844
1845 Object[] finderArgs = new Object[] {
1846 companyId, userId, classNameId, classPK
1847 };
1848
1849 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1850 this);
1851
1852 if (count == null) {
1853 StringBundler query = new StringBundler(5);
1854
1855 query.append(_SQL_COUNT_SUBSCRIPTION_WHERE);
1856
1857 query.append(_FINDER_COLUMN_C_U_C_C_COMPANYID_2);
1858
1859 query.append(_FINDER_COLUMN_C_U_C_C_USERID_2);
1860
1861 query.append(_FINDER_COLUMN_C_U_C_C_CLASSNAMEID_2);
1862
1863 query.append(_FINDER_COLUMN_C_U_C_C_CLASSPK_2);
1864
1865 String sql = query.toString();
1866
1867 Session session = null;
1868
1869 try {
1870 session = openSession();
1871
1872 Query q = session.createQuery(sql);
1873
1874 QueryPos qPos = QueryPos.getInstance(q);
1875
1876 qPos.add(companyId);
1877
1878 qPos.add(userId);
1879
1880 qPos.add(classNameId);
1881
1882 qPos.add(classPK);
1883
1884 count = (Long)q.uniqueResult();
1885
1886 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1887 }
1888 catch (Exception e) {
1889 FinderCacheUtil.removeResult(finderPath, finderArgs);
1890
1891 throw processException(e);
1892 }
1893 finally {
1894 closeSession(session);
1895 }
1896 }
1897
1898 return count.intValue();
1899 }
1900
1901 private static final String _FINDER_COLUMN_C_U_C_C_COMPANYID_2 = "subscription.companyId = ? AND ";
1902 private static final String _FINDER_COLUMN_C_U_C_C_USERID_2 = "subscription.userId = ? AND ";
1903 private static final String _FINDER_COLUMN_C_U_C_C_CLASSNAMEID_2 = "subscription.classNameId = ? AND ";
1904 private static final String _FINDER_COLUMN_C_U_C_C_CLASSPK_2 = "subscription.classPK = ?";
1905
1906
1911 public void cacheResult(Subscription subscription) {
1912 EntityCacheUtil.putResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
1913 SubscriptionImpl.class, subscription.getPrimaryKey(), subscription);
1914
1915 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C,
1916 new Object[] {
1917 Long.valueOf(subscription.getCompanyId()),
1918 Long.valueOf(subscription.getUserId()),
1919 Long.valueOf(subscription.getClassNameId()),
1920 Long.valueOf(subscription.getClassPK())
1921 }, subscription);
1922
1923 subscription.resetOriginalValues();
1924 }
1925
1926
1931 public void cacheResult(List<Subscription> subscriptions) {
1932 for (Subscription subscription : subscriptions) {
1933 if (EntityCacheUtil.getResult(
1934 SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
1935 SubscriptionImpl.class, subscription.getPrimaryKey()) == null) {
1936 cacheResult(subscription);
1937 }
1938 else {
1939 subscription.resetOriginalValues();
1940 }
1941 }
1942 }
1943
1944
1951 @Override
1952 public void clearCache() {
1953 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
1954 CacheRegistryUtil.clear(SubscriptionImpl.class.getName());
1955 }
1956
1957 EntityCacheUtil.clearCache(SubscriptionImpl.class.getName());
1958
1959 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1960 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1961 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1962 }
1963
1964
1971 @Override
1972 public void clearCache(Subscription subscription) {
1973 EntityCacheUtil.removeResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
1974 SubscriptionImpl.class, subscription.getPrimaryKey());
1975
1976 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1977 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1978
1979 clearUniqueFindersCache(subscription);
1980 }
1981
1982 @Override
1983 public void clearCache(List<Subscription> subscriptions) {
1984 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1985 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1986
1987 for (Subscription subscription : subscriptions) {
1988 EntityCacheUtil.removeResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
1989 SubscriptionImpl.class, subscription.getPrimaryKey());
1990
1991 clearUniqueFindersCache(subscription);
1992 }
1993 }
1994
1995 protected void cacheUniqueFindersCache(Subscription subscription) {
1996 if (subscription.isNew()) {
1997 Object[] args = new Object[] {
1998 Long.valueOf(subscription.getCompanyId()),
1999 Long.valueOf(subscription.getUserId()),
2000 Long.valueOf(subscription.getClassNameId()),
2001 Long.valueOf(subscription.getClassPK())
2002 };
2003
2004 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U_C_C, args,
2005 Long.valueOf(1));
2006 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C, args,
2007 subscription);
2008 }
2009 else {
2010 SubscriptionModelImpl subscriptionModelImpl = (SubscriptionModelImpl)subscription;
2011
2012 if ((subscriptionModelImpl.getColumnBitmask() &
2013 FINDER_PATH_FETCH_BY_C_U_C_C.getColumnBitmask()) != 0) {
2014 Object[] args = new Object[] {
2015 Long.valueOf(subscription.getCompanyId()),
2016 Long.valueOf(subscription.getUserId()),
2017 Long.valueOf(subscription.getClassNameId()),
2018 Long.valueOf(subscription.getClassPK())
2019 };
2020
2021 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U_C_C, args,
2022 Long.valueOf(1));
2023 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_C_C, args,
2024 subscription);
2025 }
2026 }
2027 }
2028
2029 protected void clearUniqueFindersCache(Subscription subscription) {
2030 SubscriptionModelImpl subscriptionModelImpl = (SubscriptionModelImpl)subscription;
2031
2032 Object[] args = new Object[] {
2033 Long.valueOf(subscription.getCompanyId()),
2034 Long.valueOf(subscription.getUserId()),
2035 Long.valueOf(subscription.getClassNameId()),
2036 Long.valueOf(subscription.getClassPK())
2037 };
2038
2039 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_C_C, args);
2040 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_C_C, args);
2041
2042 if ((subscriptionModelImpl.getColumnBitmask() &
2043 FINDER_PATH_FETCH_BY_C_U_C_C.getColumnBitmask()) != 0) {
2044 args = new Object[] {
2045 Long.valueOf(subscriptionModelImpl.getOriginalCompanyId()),
2046 Long.valueOf(subscriptionModelImpl.getOriginalUserId()),
2047 Long.valueOf(subscriptionModelImpl.getOriginalClassNameId()),
2048 Long.valueOf(subscriptionModelImpl.getOriginalClassPK())
2049 };
2050
2051 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_C_C, args);
2052 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_C_C, args);
2053 }
2054 }
2055
2056
2062 public Subscription create(long subscriptionId) {
2063 Subscription subscription = new SubscriptionImpl();
2064
2065 subscription.setNew(true);
2066 subscription.setPrimaryKey(subscriptionId);
2067
2068 return subscription;
2069 }
2070
2071
2079 public Subscription remove(long subscriptionId)
2080 throws NoSuchSubscriptionException, SystemException {
2081 return remove(Long.valueOf(subscriptionId));
2082 }
2083
2084
2092 @Override
2093 public Subscription remove(Serializable primaryKey)
2094 throws NoSuchSubscriptionException, SystemException {
2095 Session session = null;
2096
2097 try {
2098 session = openSession();
2099
2100 Subscription subscription = (Subscription)session.get(SubscriptionImpl.class,
2101 primaryKey);
2102
2103 if (subscription == null) {
2104 if (_log.isWarnEnabled()) {
2105 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2106 }
2107
2108 throw new NoSuchSubscriptionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2109 primaryKey);
2110 }
2111
2112 return remove(subscription);
2113 }
2114 catch (NoSuchSubscriptionException nsee) {
2115 throw nsee;
2116 }
2117 catch (Exception e) {
2118 throw processException(e);
2119 }
2120 finally {
2121 closeSession(session);
2122 }
2123 }
2124
2125 @Override
2126 protected Subscription removeImpl(Subscription subscription)
2127 throws SystemException {
2128 subscription = toUnwrappedModel(subscription);
2129
2130 Session session = null;
2131
2132 try {
2133 session = openSession();
2134
2135 if (!session.contains(subscription)) {
2136 subscription = (Subscription)session.get(SubscriptionImpl.class,
2137 subscription.getPrimaryKeyObj());
2138 }
2139
2140 if (subscription != null) {
2141 session.delete(subscription);
2142 }
2143 }
2144 catch (Exception e) {
2145 throw processException(e);
2146 }
2147 finally {
2148 closeSession(session);
2149 }
2150
2151 if (subscription != null) {
2152 clearCache(subscription);
2153 }
2154
2155 return subscription;
2156 }
2157
2158 @Override
2159 public Subscription updateImpl(
2160 com.liferay.portal.model.Subscription subscription)
2161 throws SystemException {
2162 subscription = toUnwrappedModel(subscription);
2163
2164 boolean isNew = subscription.isNew();
2165
2166 SubscriptionModelImpl subscriptionModelImpl = (SubscriptionModelImpl)subscription;
2167
2168 Session session = null;
2169
2170 try {
2171 session = openSession();
2172
2173 if (subscription.isNew()) {
2174 session.save(subscription);
2175
2176 subscription.setNew(false);
2177 }
2178 else {
2179 session.merge(subscription);
2180 }
2181 }
2182 catch (Exception e) {
2183 throw processException(e);
2184 }
2185 finally {
2186 closeSession(session);
2187 }
2188
2189 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2190
2191 if (isNew || !SubscriptionModelImpl.COLUMN_BITMASK_ENABLED) {
2192 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2193 }
2194
2195 else {
2196 if ((subscriptionModelImpl.getColumnBitmask() &
2197 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
2198 Object[] args = new Object[] {
2199 Long.valueOf(subscriptionModelImpl.getOriginalUserId())
2200 };
2201
2202 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
2203 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
2204 args);
2205
2206 args = new Object[] {
2207 Long.valueOf(subscriptionModelImpl.getUserId())
2208 };
2209
2210 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
2211 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
2212 args);
2213 }
2214
2215 if ((subscriptionModelImpl.getColumnBitmask() &
2216 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C.getColumnBitmask()) != 0) {
2217 Object[] args = new Object[] {
2218 Long.valueOf(subscriptionModelImpl.getOriginalUserId()),
2219 Long.valueOf(subscriptionModelImpl.getOriginalClassNameId())
2220 };
2221
2222 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C, args);
2223 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C,
2224 args);
2225
2226 args = new Object[] {
2227 Long.valueOf(subscriptionModelImpl.getUserId()),
2228 Long.valueOf(subscriptionModelImpl.getClassNameId())
2229 };
2230
2231 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C, args);
2232 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C,
2233 args);
2234 }
2235
2236 if ((subscriptionModelImpl.getColumnBitmask() &
2237 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C.getColumnBitmask()) != 0) {
2238 Object[] args = new Object[] {
2239 Long.valueOf(subscriptionModelImpl.getOriginalCompanyId()),
2240 Long.valueOf(subscriptionModelImpl.getOriginalClassNameId()),
2241 Long.valueOf(subscriptionModelImpl.getOriginalClassPK())
2242 };
2243
2244 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
2245 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
2246 args);
2247
2248 args = new Object[] {
2249 Long.valueOf(subscriptionModelImpl.getCompanyId()),
2250 Long.valueOf(subscriptionModelImpl.getClassNameId()),
2251 Long.valueOf(subscriptionModelImpl.getClassPK())
2252 };
2253
2254 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
2255 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_C,
2256 args);
2257 }
2258 }
2259
2260 EntityCacheUtil.putResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
2261 SubscriptionImpl.class, subscription.getPrimaryKey(), subscription);
2262
2263 clearUniqueFindersCache(subscription);
2264 cacheUniqueFindersCache(subscription);
2265
2266 return subscription;
2267 }
2268
2269 protected Subscription toUnwrappedModel(Subscription subscription) {
2270 if (subscription instanceof SubscriptionImpl) {
2271 return subscription;
2272 }
2273
2274 SubscriptionImpl subscriptionImpl = new SubscriptionImpl();
2275
2276 subscriptionImpl.setNew(subscription.isNew());
2277 subscriptionImpl.setPrimaryKey(subscription.getPrimaryKey());
2278
2279 subscriptionImpl.setSubscriptionId(subscription.getSubscriptionId());
2280 subscriptionImpl.setCompanyId(subscription.getCompanyId());
2281 subscriptionImpl.setUserId(subscription.getUserId());
2282 subscriptionImpl.setUserName(subscription.getUserName());
2283 subscriptionImpl.setCreateDate(subscription.getCreateDate());
2284 subscriptionImpl.setModifiedDate(subscription.getModifiedDate());
2285 subscriptionImpl.setClassNameId(subscription.getClassNameId());
2286 subscriptionImpl.setClassPK(subscription.getClassPK());
2287 subscriptionImpl.setFrequency(subscription.getFrequency());
2288
2289 return subscriptionImpl;
2290 }
2291
2292
2300 @Override
2301 public Subscription findByPrimaryKey(Serializable primaryKey)
2302 throws NoSuchModelException, SystemException {
2303 return findByPrimaryKey(((Long)primaryKey).longValue());
2304 }
2305
2306
2314 public Subscription findByPrimaryKey(long subscriptionId)
2315 throws NoSuchSubscriptionException, SystemException {
2316 Subscription subscription = fetchByPrimaryKey(subscriptionId);
2317
2318 if (subscription == null) {
2319 if (_log.isWarnEnabled()) {
2320 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + subscriptionId);
2321 }
2322
2323 throw new NoSuchSubscriptionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2324 subscriptionId);
2325 }
2326
2327 return subscription;
2328 }
2329
2330
2337 @Override
2338 public Subscription fetchByPrimaryKey(Serializable primaryKey)
2339 throws SystemException {
2340 return fetchByPrimaryKey(((Long)primaryKey).longValue());
2341 }
2342
2343
2350 public Subscription fetchByPrimaryKey(long subscriptionId)
2351 throws SystemException {
2352 Subscription subscription = (Subscription)EntityCacheUtil.getResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
2353 SubscriptionImpl.class, subscriptionId);
2354
2355 if (subscription == _nullSubscription) {
2356 return null;
2357 }
2358
2359 if (subscription == null) {
2360 Session session = null;
2361
2362 try {
2363 session = openSession();
2364
2365 subscription = (Subscription)session.get(SubscriptionImpl.class,
2366 Long.valueOf(subscriptionId));
2367
2368 if (subscription != null) {
2369 cacheResult(subscription);
2370 }
2371 else {
2372 EntityCacheUtil.putResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
2373 SubscriptionImpl.class, subscriptionId,
2374 _nullSubscription);
2375 }
2376 }
2377 catch (Exception e) {
2378 EntityCacheUtil.removeResult(SubscriptionModelImpl.ENTITY_CACHE_ENABLED,
2379 SubscriptionImpl.class, subscriptionId);
2380
2381 throw processException(e);
2382 }
2383 finally {
2384 closeSession(session);
2385 }
2386 }
2387
2388 return subscription;
2389 }
2390
2391
2397 public List<Subscription> findAll() throws SystemException {
2398 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2399 }
2400
2401
2413 public List<Subscription> findAll(int start, int end)
2414 throws SystemException {
2415 return findAll(start, end, null);
2416 }
2417
2418
2431 public List<Subscription> findAll(int start, int end,
2432 OrderByComparator orderByComparator) throws SystemException {
2433 boolean pagination = true;
2434 FinderPath finderPath = null;
2435 Object[] finderArgs = null;
2436
2437 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2438 (orderByComparator == null)) {
2439 pagination = false;
2440 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2441 finderArgs = FINDER_ARGS_EMPTY;
2442 }
2443 else {
2444 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2445 finderArgs = new Object[] { start, end, orderByComparator };
2446 }
2447
2448 List<Subscription> list = (List<Subscription>)FinderCacheUtil.getResult(finderPath,
2449 finderArgs, this);
2450
2451 if (list == null) {
2452 StringBundler query = null;
2453 String sql = null;
2454
2455 if (orderByComparator != null) {
2456 query = new StringBundler(2 +
2457 (orderByComparator.getOrderByFields().length * 3));
2458
2459 query.append(_SQL_SELECT_SUBSCRIPTION);
2460
2461 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2462 orderByComparator);
2463
2464 sql = query.toString();
2465 }
2466 else {
2467 sql = _SQL_SELECT_SUBSCRIPTION;
2468
2469 if (pagination) {
2470 sql = sql.concat(SubscriptionModelImpl.ORDER_BY_JPQL);
2471 }
2472 }
2473
2474 Session session = null;
2475
2476 try {
2477 session = openSession();
2478
2479 Query q = session.createQuery(sql);
2480
2481 if (!pagination) {
2482 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
2483 start, end, false);
2484
2485 Collections.sort(list);
2486
2487 list = new UnmodifiableList<Subscription>(list);
2488 }
2489 else {
2490 list = (List<Subscription>)QueryUtil.list(q, getDialect(),
2491 start, end);
2492 }
2493
2494 cacheResult(list);
2495
2496 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2497 }
2498 catch (Exception e) {
2499 FinderCacheUtil.removeResult(finderPath, finderArgs);
2500
2501 throw processException(e);
2502 }
2503 finally {
2504 closeSession(session);
2505 }
2506 }
2507
2508 return list;
2509 }
2510
2511
2516 public void removeAll() throws SystemException {
2517 for (Subscription subscription : findAll()) {
2518 remove(subscription);
2519 }
2520 }
2521
2522
2528 public int countAll() throws SystemException {
2529 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2530 FINDER_ARGS_EMPTY, this);
2531
2532 if (count == null) {
2533 Session session = null;
2534
2535 try {
2536 session = openSession();
2537
2538 Query q = session.createQuery(_SQL_COUNT_SUBSCRIPTION);
2539
2540 count = (Long)q.uniqueResult();
2541
2542 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2543 FINDER_ARGS_EMPTY, count);
2544 }
2545 catch (Exception e) {
2546 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2547 FINDER_ARGS_EMPTY);
2548
2549 throw processException(e);
2550 }
2551 finally {
2552 closeSession(session);
2553 }
2554 }
2555
2556 return count.intValue();
2557 }
2558
2559
2562 public void afterPropertiesSet() {
2563 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2564 com.liferay.portal.util.PropsUtil.get(
2565 "value.object.listener.com.liferay.portal.model.Subscription")));
2566
2567 if (listenerClassNames.length > 0) {
2568 try {
2569 List<ModelListener<Subscription>> listenersList = new ArrayList<ModelListener<Subscription>>();
2570
2571 for (String listenerClassName : listenerClassNames) {
2572 listenersList.add((ModelListener<Subscription>)InstanceFactory.newInstance(
2573 listenerClassName));
2574 }
2575
2576 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2577 }
2578 catch (Exception e) {
2579 _log.error(e);
2580 }
2581 }
2582 }
2583
2584 public void destroy() {
2585 EntityCacheUtil.removeCache(SubscriptionImpl.class.getName());
2586 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2587 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2588 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2589 }
2590
2591 private static final String _SQL_SELECT_SUBSCRIPTION = "SELECT subscription FROM Subscription subscription";
2592 private static final String _SQL_SELECT_SUBSCRIPTION_WHERE = "SELECT subscription FROM Subscription subscription WHERE ";
2593 private static final String _SQL_COUNT_SUBSCRIPTION = "SELECT COUNT(subscription) FROM Subscription subscription";
2594 private static final String _SQL_COUNT_SUBSCRIPTION_WHERE = "SELECT COUNT(subscription) FROM Subscription subscription WHERE ";
2595 private static final String _ORDER_BY_ENTITY_ALIAS = "subscription.";
2596 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Subscription exists with the primary key ";
2597 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Subscription exists with the key {";
2598 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2599 private static Log _log = LogFactoryUtil.getLog(SubscriptionPersistenceImpl.class);
2600 private static Subscription _nullSubscription = new SubscriptionImpl() {
2601 @Override
2602 public Object clone() {
2603 return this;
2604 }
2605
2606 @Override
2607 public CacheModel<Subscription> toCacheModel() {
2608 return _nullSubscriptionCacheModel;
2609 }
2610 };
2611
2612 private static CacheModel<Subscription> _nullSubscriptionCacheModel = new CacheModel<Subscription>() {
2613 public Subscription toEntityModel() {
2614 return _nullSubscription;
2615 }
2616 };
2617 }