001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchUserNotificationDeliveryException;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.exception.SystemException;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.GetterUtil;
030 import com.liferay.portal.kernel.util.InstanceFactory;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.kernel.util.StringUtil;
035 import com.liferay.portal.kernel.util.UnmodifiableList;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.UserNotificationDelivery;
040 import com.liferay.portal.model.impl.UserNotificationDeliveryImpl;
041 import com.liferay.portal.model.impl.UserNotificationDeliveryModelImpl;
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 UserNotificationDeliveryPersistenceImpl extends BasePersistenceImpl<UserNotificationDelivery>
063 implements UserNotificationDeliveryPersistence {
064
069 public static final String FINDER_CLASS_NAME_ENTITY = UserNotificationDeliveryImpl.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(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
075 UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED,
076 UserNotificationDeliveryImpl.class,
077 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
078 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
079 UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED,
080 UserNotificationDeliveryImpl.class,
081 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
082 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
083 UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED, Long.class,
084 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
085 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
086 UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED,
087 UserNotificationDeliveryImpl.class,
088 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
089 new String[] {
090 Long.class.getName(),
091
092 Integer.class.getName(), Integer.class.getName(),
093 OrderByComparator.class.getName()
094 });
095 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
096 new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
097 UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED,
098 UserNotificationDeliveryImpl.class,
099 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
100 new String[] { Long.class.getName() },
101 UserNotificationDeliveryModelImpl.USERID_COLUMN_BITMASK);
102 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
103 UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED, Long.class,
104 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
105 new String[] { Long.class.getName() });
106
107
114 @Override
115 public List<UserNotificationDelivery> findByUserId(long userId)
116 throws SystemException {
117 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
118 }
119
120
133 @Override
134 public List<UserNotificationDelivery> findByUserId(long userId, int start,
135 int end) throws SystemException {
136 return findByUserId(userId, start, end, null);
137 }
138
139
153 @Override
154 public List<UserNotificationDelivery> findByUserId(long userId, int start,
155 int end, OrderByComparator orderByComparator) throws SystemException {
156 boolean pagination = true;
157 FinderPath finderPath = null;
158 Object[] finderArgs = null;
159
160 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
161 (orderByComparator == null)) {
162 pagination = false;
163 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
164 finderArgs = new Object[] { userId };
165 }
166 else {
167 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
168 finderArgs = new Object[] { userId, start, end, orderByComparator };
169 }
170
171 List<UserNotificationDelivery> list = (List<UserNotificationDelivery>)FinderCacheUtil.getResult(finderPath,
172 finderArgs, this);
173
174 if ((list != null) && !list.isEmpty()) {
175 for (UserNotificationDelivery userNotificationDelivery : list) {
176 if ((userId != userNotificationDelivery.getUserId())) {
177 list = null;
178
179 break;
180 }
181 }
182 }
183
184 if (list == null) {
185 StringBundler query = null;
186
187 if (orderByComparator != null) {
188 query = new StringBundler(3 +
189 (orderByComparator.getOrderByFields().length * 3));
190 }
191 else {
192 query = new StringBundler(3);
193 }
194
195 query.append(_SQL_SELECT_USERNOTIFICATIONDELIVERY_WHERE);
196
197 query.append(_FINDER_COLUMN_USERID_USERID_2);
198
199 if (orderByComparator != null) {
200 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
201 orderByComparator);
202 }
203 else
204 if (pagination) {
205 query.append(UserNotificationDeliveryModelImpl.ORDER_BY_JPQL);
206 }
207
208 String sql = query.toString();
209
210 Session session = null;
211
212 try {
213 session = openSession();
214
215 Query q = session.createQuery(sql);
216
217 QueryPos qPos = QueryPos.getInstance(q);
218
219 qPos.add(userId);
220
221 if (!pagination) {
222 list = (List<UserNotificationDelivery>)QueryUtil.list(q,
223 getDialect(), start, end, false);
224
225 Collections.sort(list);
226
227 list = new UnmodifiableList<UserNotificationDelivery>(list);
228 }
229 else {
230 list = (List<UserNotificationDelivery>)QueryUtil.list(q,
231 getDialect(), start, end);
232 }
233
234 cacheResult(list);
235
236 FinderCacheUtil.putResult(finderPath, finderArgs, list);
237 }
238 catch (Exception e) {
239 FinderCacheUtil.removeResult(finderPath, finderArgs);
240
241 throw processException(e);
242 }
243 finally {
244 closeSession(session);
245 }
246 }
247
248 return list;
249 }
250
251
260 @Override
261 public UserNotificationDelivery findByUserId_First(long userId,
262 OrderByComparator orderByComparator)
263 throws NoSuchUserNotificationDeliveryException, SystemException {
264 UserNotificationDelivery userNotificationDelivery = fetchByUserId_First(userId,
265 orderByComparator);
266
267 if (userNotificationDelivery != null) {
268 return userNotificationDelivery;
269 }
270
271 StringBundler msg = new StringBundler(4);
272
273 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
274
275 msg.append("userId=");
276 msg.append(userId);
277
278 msg.append(StringPool.CLOSE_CURLY_BRACE);
279
280 throw new NoSuchUserNotificationDeliveryException(msg.toString());
281 }
282
283
291 @Override
292 public UserNotificationDelivery fetchByUserId_First(long userId,
293 OrderByComparator orderByComparator) throws SystemException {
294 List<UserNotificationDelivery> list = findByUserId(userId, 0, 1,
295 orderByComparator);
296
297 if (!list.isEmpty()) {
298 return list.get(0);
299 }
300
301 return null;
302 }
303
304
313 @Override
314 public UserNotificationDelivery findByUserId_Last(long userId,
315 OrderByComparator orderByComparator)
316 throws NoSuchUserNotificationDeliveryException, SystemException {
317 UserNotificationDelivery userNotificationDelivery = fetchByUserId_Last(userId,
318 orderByComparator);
319
320 if (userNotificationDelivery != null) {
321 return userNotificationDelivery;
322 }
323
324 StringBundler msg = new StringBundler(4);
325
326 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
327
328 msg.append("userId=");
329 msg.append(userId);
330
331 msg.append(StringPool.CLOSE_CURLY_BRACE);
332
333 throw new NoSuchUserNotificationDeliveryException(msg.toString());
334 }
335
336
344 @Override
345 public UserNotificationDelivery fetchByUserId_Last(long userId,
346 OrderByComparator orderByComparator) throws SystemException {
347 int count = countByUserId(userId);
348
349 if (count == 0) {
350 return null;
351 }
352
353 List<UserNotificationDelivery> list = findByUserId(userId, count - 1,
354 count, orderByComparator);
355
356 if (!list.isEmpty()) {
357 return list.get(0);
358 }
359
360 return null;
361 }
362
363
373 @Override
374 public UserNotificationDelivery[] findByUserId_PrevAndNext(
375 long userNotificationDeliveryId, long userId,
376 OrderByComparator orderByComparator)
377 throws NoSuchUserNotificationDeliveryException, SystemException {
378 UserNotificationDelivery userNotificationDelivery = findByPrimaryKey(userNotificationDeliveryId);
379
380 Session session = null;
381
382 try {
383 session = openSession();
384
385 UserNotificationDelivery[] array = new UserNotificationDeliveryImpl[3];
386
387 array[0] = getByUserId_PrevAndNext(session,
388 userNotificationDelivery, userId, orderByComparator, true);
389
390 array[1] = userNotificationDelivery;
391
392 array[2] = getByUserId_PrevAndNext(session,
393 userNotificationDelivery, userId, orderByComparator, false);
394
395 return array;
396 }
397 catch (Exception e) {
398 throw processException(e);
399 }
400 finally {
401 closeSession(session);
402 }
403 }
404
405 protected UserNotificationDelivery getByUserId_PrevAndNext(
406 Session session, UserNotificationDelivery userNotificationDelivery,
407 long userId, OrderByComparator orderByComparator, boolean previous) {
408 StringBundler query = null;
409
410 if (orderByComparator != null) {
411 query = new StringBundler(6 +
412 (orderByComparator.getOrderByFields().length * 6));
413 }
414 else {
415 query = new StringBundler(3);
416 }
417
418 query.append(_SQL_SELECT_USERNOTIFICATIONDELIVERY_WHERE);
419
420 query.append(_FINDER_COLUMN_USERID_USERID_2);
421
422 if (orderByComparator != null) {
423 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
424
425 if (orderByConditionFields.length > 0) {
426 query.append(WHERE_AND);
427 }
428
429 for (int i = 0; i < orderByConditionFields.length; i++) {
430 query.append(_ORDER_BY_ENTITY_ALIAS);
431 query.append(orderByConditionFields[i]);
432
433 if ((i + 1) < orderByConditionFields.length) {
434 if (orderByComparator.isAscending() ^ previous) {
435 query.append(WHERE_GREATER_THAN_HAS_NEXT);
436 }
437 else {
438 query.append(WHERE_LESSER_THAN_HAS_NEXT);
439 }
440 }
441 else {
442 if (orderByComparator.isAscending() ^ previous) {
443 query.append(WHERE_GREATER_THAN);
444 }
445 else {
446 query.append(WHERE_LESSER_THAN);
447 }
448 }
449 }
450
451 query.append(ORDER_BY_CLAUSE);
452
453 String[] orderByFields = orderByComparator.getOrderByFields();
454
455 for (int i = 0; i < orderByFields.length; i++) {
456 query.append(_ORDER_BY_ENTITY_ALIAS);
457 query.append(orderByFields[i]);
458
459 if ((i + 1) < orderByFields.length) {
460 if (orderByComparator.isAscending() ^ previous) {
461 query.append(ORDER_BY_ASC_HAS_NEXT);
462 }
463 else {
464 query.append(ORDER_BY_DESC_HAS_NEXT);
465 }
466 }
467 else {
468 if (orderByComparator.isAscending() ^ previous) {
469 query.append(ORDER_BY_ASC);
470 }
471 else {
472 query.append(ORDER_BY_DESC);
473 }
474 }
475 }
476 }
477 else {
478 query.append(UserNotificationDeliveryModelImpl.ORDER_BY_JPQL);
479 }
480
481 String sql = query.toString();
482
483 Query q = session.createQuery(sql);
484
485 q.setFirstResult(0);
486 q.setMaxResults(2);
487
488 QueryPos qPos = QueryPos.getInstance(q);
489
490 qPos.add(userId);
491
492 if (orderByComparator != null) {
493 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationDelivery);
494
495 for (Object value : values) {
496 qPos.add(value);
497 }
498 }
499
500 List<UserNotificationDelivery> list = q.list();
501
502 if (list.size() == 2) {
503 return list.get(1);
504 }
505 else {
506 return null;
507 }
508 }
509
510
516 @Override
517 public void removeByUserId(long userId) throws SystemException {
518 for (UserNotificationDelivery userNotificationDelivery : findByUserId(
519 userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
520 remove(userNotificationDelivery);
521 }
522 }
523
524
531 @Override
532 public int countByUserId(long userId) throws SystemException {
533 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
534
535 Object[] finderArgs = new Object[] { userId };
536
537 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
538 this);
539
540 if (count == null) {
541 StringBundler query = new StringBundler(2);
542
543 query.append(_SQL_COUNT_USERNOTIFICATIONDELIVERY_WHERE);
544
545 query.append(_FINDER_COLUMN_USERID_USERID_2);
546
547 String sql = query.toString();
548
549 Session session = null;
550
551 try {
552 session = openSession();
553
554 Query q = session.createQuery(sql);
555
556 QueryPos qPos = QueryPos.getInstance(q);
557
558 qPos.add(userId);
559
560 count = (Long)q.uniqueResult();
561
562 FinderCacheUtil.putResult(finderPath, finderArgs, count);
563 }
564 catch (Exception e) {
565 FinderCacheUtil.removeResult(finderPath, finderArgs);
566
567 throw processException(e);
568 }
569 finally {
570 closeSession(session);
571 }
572 }
573
574 return count.intValue();
575 }
576
577 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userNotificationDelivery.userId = ?";
578 public static final FinderPath FINDER_PATH_FETCH_BY_U_P_C_N_D = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
579 UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED,
580 UserNotificationDeliveryImpl.class, FINDER_CLASS_NAME_ENTITY,
581 "fetchByU_P_C_N_D",
582 new String[] {
583 Long.class.getName(), String.class.getName(),
584 Long.class.getName(), Integer.class.getName(),
585 Integer.class.getName()
586 },
587 UserNotificationDeliveryModelImpl.USERID_COLUMN_BITMASK |
588 UserNotificationDeliveryModelImpl.PORTLETID_COLUMN_BITMASK |
589 UserNotificationDeliveryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
590 UserNotificationDeliveryModelImpl.NOTIFICATIONTYPE_COLUMN_BITMASK |
591 UserNotificationDeliveryModelImpl.DELIVERYTYPE_COLUMN_BITMASK);
592 public static final FinderPath FINDER_PATH_COUNT_BY_U_P_C_N_D = new FinderPath(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
593 UserNotificationDeliveryModelImpl.FINDER_CACHE_ENABLED, Long.class,
594 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_P_C_N_D",
595 new String[] {
596 Long.class.getName(), String.class.getName(),
597 Long.class.getName(), Integer.class.getName(),
598 Integer.class.getName()
599 });
600
601
613 @Override
614 public UserNotificationDelivery findByU_P_C_N_D(long userId,
615 String portletId, long classNameId, int notificationType,
616 int deliveryType)
617 throws NoSuchUserNotificationDeliveryException, SystemException {
618 UserNotificationDelivery userNotificationDelivery = fetchByU_P_C_N_D(userId,
619 portletId, classNameId, notificationType, deliveryType);
620
621 if (userNotificationDelivery == null) {
622 StringBundler msg = new StringBundler(12);
623
624 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
625
626 msg.append("userId=");
627 msg.append(userId);
628
629 msg.append(", portletId=");
630 msg.append(portletId);
631
632 msg.append(", classNameId=");
633 msg.append(classNameId);
634
635 msg.append(", notificationType=");
636 msg.append(notificationType);
637
638 msg.append(", deliveryType=");
639 msg.append(deliveryType);
640
641 msg.append(StringPool.CLOSE_CURLY_BRACE);
642
643 if (_log.isWarnEnabled()) {
644 _log.warn(msg.toString());
645 }
646
647 throw new NoSuchUserNotificationDeliveryException(msg.toString());
648 }
649
650 return userNotificationDelivery;
651 }
652
653
664 @Override
665 public UserNotificationDelivery fetchByU_P_C_N_D(long userId,
666 String portletId, long classNameId, int notificationType,
667 int deliveryType) throws SystemException {
668 return fetchByU_P_C_N_D(userId, portletId, classNameId,
669 notificationType, deliveryType, true);
670 }
671
672
684 @Override
685 public UserNotificationDelivery fetchByU_P_C_N_D(long userId,
686 String portletId, long classNameId, int notificationType,
687 int deliveryType, boolean retrieveFromCache) throws SystemException {
688 Object[] finderArgs = new Object[] {
689 userId, portletId, classNameId, notificationType, deliveryType
690 };
691
692 Object result = null;
693
694 if (retrieveFromCache) {
695 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_P_C_N_D,
696 finderArgs, this);
697 }
698
699 if (result instanceof UserNotificationDelivery) {
700 UserNotificationDelivery userNotificationDelivery = (UserNotificationDelivery)result;
701
702 if ((userId != userNotificationDelivery.getUserId()) ||
703 !Validator.equals(portletId,
704 userNotificationDelivery.getPortletId()) ||
705 (classNameId != userNotificationDelivery.getClassNameId()) ||
706 (notificationType != userNotificationDelivery.getNotificationType()) ||
707 (deliveryType != userNotificationDelivery.getDeliveryType())) {
708 result = null;
709 }
710 }
711
712 if (result == null) {
713 StringBundler query = new StringBundler(7);
714
715 query.append(_SQL_SELECT_USERNOTIFICATIONDELIVERY_WHERE);
716
717 query.append(_FINDER_COLUMN_U_P_C_N_D_USERID_2);
718
719 boolean bindPortletId = false;
720
721 if (portletId == null) {
722 query.append(_FINDER_COLUMN_U_P_C_N_D_PORTLETID_1);
723 }
724 else if (portletId.equals(StringPool.BLANK)) {
725 query.append(_FINDER_COLUMN_U_P_C_N_D_PORTLETID_3);
726 }
727 else {
728 bindPortletId = true;
729
730 query.append(_FINDER_COLUMN_U_P_C_N_D_PORTLETID_2);
731 }
732
733 query.append(_FINDER_COLUMN_U_P_C_N_D_CLASSNAMEID_2);
734
735 query.append(_FINDER_COLUMN_U_P_C_N_D_NOTIFICATIONTYPE_2);
736
737 query.append(_FINDER_COLUMN_U_P_C_N_D_DELIVERYTYPE_2);
738
739 String sql = query.toString();
740
741 Session session = null;
742
743 try {
744 session = openSession();
745
746 Query q = session.createQuery(sql);
747
748 QueryPos qPos = QueryPos.getInstance(q);
749
750 qPos.add(userId);
751
752 if (bindPortletId) {
753 qPos.add(portletId);
754 }
755
756 qPos.add(classNameId);
757
758 qPos.add(notificationType);
759
760 qPos.add(deliveryType);
761
762 List<UserNotificationDelivery> list = q.list();
763
764 if (list.isEmpty()) {
765 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_P_C_N_D,
766 finderArgs, list);
767 }
768 else {
769 UserNotificationDelivery userNotificationDelivery = list.get(0);
770
771 result = userNotificationDelivery;
772
773 cacheResult(userNotificationDelivery);
774
775 if ((userNotificationDelivery.getUserId() != userId) ||
776 (userNotificationDelivery.getPortletId() == null) ||
777 !userNotificationDelivery.getPortletId()
778 .equals(portletId) ||
779 (userNotificationDelivery.getClassNameId() != classNameId) ||
780 (userNotificationDelivery.getNotificationType() != notificationType) ||
781 (userNotificationDelivery.getDeliveryType() != deliveryType)) {
782 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_P_C_N_D,
783 finderArgs, userNotificationDelivery);
784 }
785 }
786 }
787 catch (Exception e) {
788 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_P_C_N_D,
789 finderArgs);
790
791 throw processException(e);
792 }
793 finally {
794 closeSession(session);
795 }
796 }
797
798 if (result instanceof List<?>) {
799 return null;
800 }
801 else {
802 return (UserNotificationDelivery)result;
803 }
804 }
805
806
817 @Override
818 public UserNotificationDelivery removeByU_P_C_N_D(long userId,
819 String portletId, long classNameId, int notificationType,
820 int deliveryType)
821 throws NoSuchUserNotificationDeliveryException, SystemException {
822 UserNotificationDelivery userNotificationDelivery = findByU_P_C_N_D(userId,
823 portletId, classNameId, notificationType, deliveryType);
824
825 return remove(userNotificationDelivery);
826 }
827
828
839 @Override
840 public int countByU_P_C_N_D(long userId, String portletId,
841 long classNameId, int notificationType, int deliveryType)
842 throws SystemException {
843 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_P_C_N_D;
844
845 Object[] finderArgs = new Object[] {
846 userId, portletId, classNameId, notificationType, deliveryType
847 };
848
849 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
850 this);
851
852 if (count == null) {
853 StringBundler query = new StringBundler(6);
854
855 query.append(_SQL_COUNT_USERNOTIFICATIONDELIVERY_WHERE);
856
857 query.append(_FINDER_COLUMN_U_P_C_N_D_USERID_2);
858
859 boolean bindPortletId = false;
860
861 if (portletId == null) {
862 query.append(_FINDER_COLUMN_U_P_C_N_D_PORTLETID_1);
863 }
864 else if (portletId.equals(StringPool.BLANK)) {
865 query.append(_FINDER_COLUMN_U_P_C_N_D_PORTLETID_3);
866 }
867 else {
868 bindPortletId = true;
869
870 query.append(_FINDER_COLUMN_U_P_C_N_D_PORTLETID_2);
871 }
872
873 query.append(_FINDER_COLUMN_U_P_C_N_D_CLASSNAMEID_2);
874
875 query.append(_FINDER_COLUMN_U_P_C_N_D_NOTIFICATIONTYPE_2);
876
877 query.append(_FINDER_COLUMN_U_P_C_N_D_DELIVERYTYPE_2);
878
879 String sql = query.toString();
880
881 Session session = null;
882
883 try {
884 session = openSession();
885
886 Query q = session.createQuery(sql);
887
888 QueryPos qPos = QueryPos.getInstance(q);
889
890 qPos.add(userId);
891
892 if (bindPortletId) {
893 qPos.add(portletId);
894 }
895
896 qPos.add(classNameId);
897
898 qPos.add(notificationType);
899
900 qPos.add(deliveryType);
901
902 count = (Long)q.uniqueResult();
903
904 FinderCacheUtil.putResult(finderPath, finderArgs, count);
905 }
906 catch (Exception e) {
907 FinderCacheUtil.removeResult(finderPath, finderArgs);
908
909 throw processException(e);
910 }
911 finally {
912 closeSession(session);
913 }
914 }
915
916 return count.intValue();
917 }
918
919 private static final String _FINDER_COLUMN_U_P_C_N_D_USERID_2 = "userNotificationDelivery.userId = ? AND ";
920 private static final String _FINDER_COLUMN_U_P_C_N_D_PORTLETID_1 = "userNotificationDelivery.portletId IS NULL AND ";
921 private static final String _FINDER_COLUMN_U_P_C_N_D_PORTLETID_2 = "userNotificationDelivery.portletId = ? AND ";
922 private static final String _FINDER_COLUMN_U_P_C_N_D_PORTLETID_3 = "(userNotificationDelivery.portletId IS NULL OR userNotificationDelivery.portletId = '') AND ";
923 private static final String _FINDER_COLUMN_U_P_C_N_D_CLASSNAMEID_2 = "userNotificationDelivery.classNameId = ? AND ";
924 private static final String _FINDER_COLUMN_U_P_C_N_D_NOTIFICATIONTYPE_2 = "userNotificationDelivery.notificationType = ? AND ";
925 private static final String _FINDER_COLUMN_U_P_C_N_D_DELIVERYTYPE_2 = "userNotificationDelivery.deliveryType = ?";
926
927
932 @Override
933 public void cacheResult(UserNotificationDelivery userNotificationDelivery) {
934 EntityCacheUtil.putResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
935 UserNotificationDeliveryImpl.class,
936 userNotificationDelivery.getPrimaryKey(), userNotificationDelivery);
937
938 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_P_C_N_D,
939 new Object[] {
940 userNotificationDelivery.getUserId(),
941 userNotificationDelivery.getPortletId(),
942 userNotificationDelivery.getClassNameId(),
943 userNotificationDelivery.getNotificationType(),
944 userNotificationDelivery.getDeliveryType()
945 }, userNotificationDelivery);
946
947 userNotificationDelivery.resetOriginalValues();
948 }
949
950
955 @Override
956 public void cacheResult(
957 List<UserNotificationDelivery> userNotificationDeliveries) {
958 for (UserNotificationDelivery userNotificationDelivery : userNotificationDeliveries) {
959 if (EntityCacheUtil.getResult(
960 UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
961 UserNotificationDeliveryImpl.class,
962 userNotificationDelivery.getPrimaryKey()) == null) {
963 cacheResult(userNotificationDelivery);
964 }
965 else {
966 userNotificationDelivery.resetOriginalValues();
967 }
968 }
969 }
970
971
978 @Override
979 public void clearCache() {
980 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
981 CacheRegistryUtil.clear(UserNotificationDeliveryImpl.class.getName());
982 }
983
984 EntityCacheUtil.clearCache(UserNotificationDeliveryImpl.class.getName());
985
986 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
987 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
988 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
989 }
990
991
998 @Override
999 public void clearCache(UserNotificationDelivery userNotificationDelivery) {
1000 EntityCacheUtil.removeResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1001 UserNotificationDeliveryImpl.class,
1002 userNotificationDelivery.getPrimaryKey());
1003
1004 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1005 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1006
1007 clearUniqueFindersCache(userNotificationDelivery);
1008 }
1009
1010 @Override
1011 public void clearCache(
1012 List<UserNotificationDelivery> userNotificationDeliveries) {
1013 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1014 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1015
1016 for (UserNotificationDelivery userNotificationDelivery : userNotificationDeliveries) {
1017 EntityCacheUtil.removeResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1018 UserNotificationDeliveryImpl.class,
1019 userNotificationDelivery.getPrimaryKey());
1020
1021 clearUniqueFindersCache(userNotificationDelivery);
1022 }
1023 }
1024
1025 protected void cacheUniqueFindersCache(
1026 UserNotificationDelivery userNotificationDelivery) {
1027 if (userNotificationDelivery.isNew()) {
1028 Object[] args = new Object[] {
1029 userNotificationDelivery.getUserId(),
1030 userNotificationDelivery.getPortletId(),
1031 userNotificationDelivery.getClassNameId(),
1032 userNotificationDelivery.getNotificationType(),
1033 userNotificationDelivery.getDeliveryType()
1034 };
1035
1036 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_P_C_N_D, args,
1037 Long.valueOf(1));
1038 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_P_C_N_D, args,
1039 userNotificationDelivery);
1040 }
1041 else {
1042 UserNotificationDeliveryModelImpl userNotificationDeliveryModelImpl = (UserNotificationDeliveryModelImpl)userNotificationDelivery;
1043
1044 if ((userNotificationDeliveryModelImpl.getColumnBitmask() &
1045 FINDER_PATH_FETCH_BY_U_P_C_N_D.getColumnBitmask()) != 0) {
1046 Object[] args = new Object[] {
1047 userNotificationDelivery.getUserId(),
1048 userNotificationDelivery.getPortletId(),
1049 userNotificationDelivery.getClassNameId(),
1050 userNotificationDelivery.getNotificationType(),
1051 userNotificationDelivery.getDeliveryType()
1052 };
1053
1054 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_P_C_N_D, args,
1055 Long.valueOf(1));
1056 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_P_C_N_D, args,
1057 userNotificationDelivery);
1058 }
1059 }
1060 }
1061
1062 protected void clearUniqueFindersCache(
1063 UserNotificationDelivery userNotificationDelivery) {
1064 UserNotificationDeliveryModelImpl userNotificationDeliveryModelImpl = (UserNotificationDeliveryModelImpl)userNotificationDelivery;
1065
1066 Object[] args = new Object[] {
1067 userNotificationDelivery.getUserId(),
1068 userNotificationDelivery.getPortletId(),
1069 userNotificationDelivery.getClassNameId(),
1070 userNotificationDelivery.getNotificationType(),
1071 userNotificationDelivery.getDeliveryType()
1072 };
1073
1074 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_P_C_N_D, args);
1075 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_P_C_N_D, args);
1076
1077 if ((userNotificationDeliveryModelImpl.getColumnBitmask() &
1078 FINDER_PATH_FETCH_BY_U_P_C_N_D.getColumnBitmask()) != 0) {
1079 args = new Object[] {
1080 userNotificationDeliveryModelImpl.getOriginalUserId(),
1081 userNotificationDeliveryModelImpl.getOriginalPortletId(),
1082 userNotificationDeliveryModelImpl.getOriginalClassNameId(),
1083 userNotificationDeliveryModelImpl.getOriginalNotificationType(),
1084 userNotificationDeliveryModelImpl.getOriginalDeliveryType()
1085 };
1086
1087 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_P_C_N_D, args);
1088 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_P_C_N_D, args);
1089 }
1090 }
1091
1092
1098 @Override
1099 public UserNotificationDelivery create(long userNotificationDeliveryId) {
1100 UserNotificationDelivery userNotificationDelivery = new UserNotificationDeliveryImpl();
1101
1102 userNotificationDelivery.setNew(true);
1103 userNotificationDelivery.setPrimaryKey(userNotificationDeliveryId);
1104
1105 return userNotificationDelivery;
1106 }
1107
1108
1116 @Override
1117 public UserNotificationDelivery remove(long userNotificationDeliveryId)
1118 throws NoSuchUserNotificationDeliveryException, SystemException {
1119 return remove((Serializable)userNotificationDeliveryId);
1120 }
1121
1122
1130 @Override
1131 public UserNotificationDelivery remove(Serializable primaryKey)
1132 throws NoSuchUserNotificationDeliveryException, SystemException {
1133 Session session = null;
1134
1135 try {
1136 session = openSession();
1137
1138 UserNotificationDelivery userNotificationDelivery = (UserNotificationDelivery)session.get(UserNotificationDeliveryImpl.class,
1139 primaryKey);
1140
1141 if (userNotificationDelivery == null) {
1142 if (_log.isWarnEnabled()) {
1143 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1144 }
1145
1146 throw new NoSuchUserNotificationDeliveryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1147 primaryKey);
1148 }
1149
1150 return remove(userNotificationDelivery);
1151 }
1152 catch (NoSuchUserNotificationDeliveryException nsee) {
1153 throw nsee;
1154 }
1155 catch (Exception e) {
1156 throw processException(e);
1157 }
1158 finally {
1159 closeSession(session);
1160 }
1161 }
1162
1163 @Override
1164 protected UserNotificationDelivery removeImpl(
1165 UserNotificationDelivery userNotificationDelivery)
1166 throws SystemException {
1167 userNotificationDelivery = toUnwrappedModel(userNotificationDelivery);
1168
1169 Session session = null;
1170
1171 try {
1172 session = openSession();
1173
1174 if (!session.contains(userNotificationDelivery)) {
1175 userNotificationDelivery = (UserNotificationDelivery)session.get(UserNotificationDeliveryImpl.class,
1176 userNotificationDelivery.getPrimaryKeyObj());
1177 }
1178
1179 if (userNotificationDelivery != null) {
1180 session.delete(userNotificationDelivery);
1181 }
1182 }
1183 catch (Exception e) {
1184 throw processException(e);
1185 }
1186 finally {
1187 closeSession(session);
1188 }
1189
1190 if (userNotificationDelivery != null) {
1191 clearCache(userNotificationDelivery);
1192 }
1193
1194 return userNotificationDelivery;
1195 }
1196
1197 @Override
1198 public UserNotificationDelivery updateImpl(
1199 com.liferay.portal.model.UserNotificationDelivery userNotificationDelivery)
1200 throws SystemException {
1201 userNotificationDelivery = toUnwrappedModel(userNotificationDelivery);
1202
1203 boolean isNew = userNotificationDelivery.isNew();
1204
1205 UserNotificationDeliveryModelImpl userNotificationDeliveryModelImpl = (UserNotificationDeliveryModelImpl)userNotificationDelivery;
1206
1207 Session session = null;
1208
1209 try {
1210 session = openSession();
1211
1212 if (userNotificationDelivery.isNew()) {
1213 session.save(userNotificationDelivery);
1214
1215 userNotificationDelivery.setNew(false);
1216 }
1217 else {
1218 session.merge(userNotificationDelivery);
1219 }
1220 }
1221 catch (Exception e) {
1222 throw processException(e);
1223 }
1224 finally {
1225 closeSession(session);
1226 }
1227
1228 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1229
1230 if (isNew || !UserNotificationDeliveryModelImpl.COLUMN_BITMASK_ENABLED) {
1231 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1232 }
1233
1234 else {
1235 if ((userNotificationDeliveryModelImpl.getColumnBitmask() &
1236 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
1237 Object[] args = new Object[] {
1238 userNotificationDeliveryModelImpl.getOriginalUserId()
1239 };
1240
1241 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
1242 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
1243 args);
1244
1245 args = new Object[] {
1246 userNotificationDeliveryModelImpl.getUserId()
1247 };
1248
1249 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
1250 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
1251 args);
1252 }
1253 }
1254
1255 EntityCacheUtil.putResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1256 UserNotificationDeliveryImpl.class,
1257 userNotificationDelivery.getPrimaryKey(), userNotificationDelivery);
1258
1259 clearUniqueFindersCache(userNotificationDelivery);
1260 cacheUniqueFindersCache(userNotificationDelivery);
1261
1262 return userNotificationDelivery;
1263 }
1264
1265 protected UserNotificationDelivery toUnwrappedModel(
1266 UserNotificationDelivery userNotificationDelivery) {
1267 if (userNotificationDelivery instanceof UserNotificationDeliveryImpl) {
1268 return userNotificationDelivery;
1269 }
1270
1271 UserNotificationDeliveryImpl userNotificationDeliveryImpl = new UserNotificationDeliveryImpl();
1272
1273 userNotificationDeliveryImpl.setNew(userNotificationDelivery.isNew());
1274 userNotificationDeliveryImpl.setPrimaryKey(userNotificationDelivery.getPrimaryKey());
1275
1276 userNotificationDeliveryImpl.setUserNotificationDeliveryId(userNotificationDelivery.getUserNotificationDeliveryId());
1277 userNotificationDeliveryImpl.setCompanyId(userNotificationDelivery.getCompanyId());
1278 userNotificationDeliveryImpl.setUserId(userNotificationDelivery.getUserId());
1279 userNotificationDeliveryImpl.setPortletId(userNotificationDelivery.getPortletId());
1280 userNotificationDeliveryImpl.setClassNameId(userNotificationDelivery.getClassNameId());
1281 userNotificationDeliveryImpl.setNotificationType(userNotificationDelivery.getNotificationType());
1282 userNotificationDeliveryImpl.setDeliveryType(userNotificationDelivery.getDeliveryType());
1283 userNotificationDeliveryImpl.setDeliver(userNotificationDelivery.isDeliver());
1284
1285 return userNotificationDeliveryImpl;
1286 }
1287
1288
1296 @Override
1297 public UserNotificationDelivery findByPrimaryKey(Serializable primaryKey)
1298 throws NoSuchUserNotificationDeliveryException, SystemException {
1299 UserNotificationDelivery userNotificationDelivery = fetchByPrimaryKey(primaryKey);
1300
1301 if (userNotificationDelivery == null) {
1302 if (_log.isWarnEnabled()) {
1303 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
1304 }
1305
1306 throw new NoSuchUserNotificationDeliveryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1307 primaryKey);
1308 }
1309
1310 return userNotificationDelivery;
1311 }
1312
1313
1321 @Override
1322 public UserNotificationDelivery findByPrimaryKey(
1323 long userNotificationDeliveryId)
1324 throws NoSuchUserNotificationDeliveryException, SystemException {
1325 return findByPrimaryKey((Serializable)userNotificationDeliveryId);
1326 }
1327
1328
1335 @Override
1336 public UserNotificationDelivery fetchByPrimaryKey(Serializable primaryKey)
1337 throws SystemException {
1338 UserNotificationDelivery userNotificationDelivery = (UserNotificationDelivery)EntityCacheUtil.getResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1339 UserNotificationDeliveryImpl.class, primaryKey);
1340
1341 if (userNotificationDelivery == _nullUserNotificationDelivery) {
1342 return null;
1343 }
1344
1345 if (userNotificationDelivery == null) {
1346 Session session = null;
1347
1348 try {
1349 session = openSession();
1350
1351 userNotificationDelivery = (UserNotificationDelivery)session.get(UserNotificationDeliveryImpl.class,
1352 primaryKey);
1353
1354 if (userNotificationDelivery != null) {
1355 cacheResult(userNotificationDelivery);
1356 }
1357 else {
1358 EntityCacheUtil.putResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1359 UserNotificationDeliveryImpl.class, primaryKey,
1360 _nullUserNotificationDelivery);
1361 }
1362 }
1363 catch (Exception e) {
1364 EntityCacheUtil.removeResult(UserNotificationDeliveryModelImpl.ENTITY_CACHE_ENABLED,
1365 UserNotificationDeliveryImpl.class, primaryKey);
1366
1367 throw processException(e);
1368 }
1369 finally {
1370 closeSession(session);
1371 }
1372 }
1373
1374 return userNotificationDelivery;
1375 }
1376
1377
1384 @Override
1385 public UserNotificationDelivery fetchByPrimaryKey(
1386 long userNotificationDeliveryId) throws SystemException {
1387 return fetchByPrimaryKey((Serializable)userNotificationDeliveryId);
1388 }
1389
1390
1396 @Override
1397 public List<UserNotificationDelivery> findAll() throws SystemException {
1398 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1399 }
1400
1401
1413 @Override
1414 public List<UserNotificationDelivery> findAll(int start, int end)
1415 throws SystemException {
1416 return findAll(start, end, null);
1417 }
1418
1419
1432 @Override
1433 public List<UserNotificationDelivery> findAll(int start, int end,
1434 OrderByComparator orderByComparator) throws SystemException {
1435 boolean pagination = true;
1436 FinderPath finderPath = null;
1437 Object[] finderArgs = null;
1438
1439 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1440 (orderByComparator == null)) {
1441 pagination = false;
1442 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1443 finderArgs = FINDER_ARGS_EMPTY;
1444 }
1445 else {
1446 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1447 finderArgs = new Object[] { start, end, orderByComparator };
1448 }
1449
1450 List<UserNotificationDelivery> list = (List<UserNotificationDelivery>)FinderCacheUtil.getResult(finderPath,
1451 finderArgs, this);
1452
1453 if (list == null) {
1454 StringBundler query = null;
1455 String sql = null;
1456
1457 if (orderByComparator != null) {
1458 query = new StringBundler(2 +
1459 (orderByComparator.getOrderByFields().length * 3));
1460
1461 query.append(_SQL_SELECT_USERNOTIFICATIONDELIVERY);
1462
1463 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1464 orderByComparator);
1465
1466 sql = query.toString();
1467 }
1468 else {
1469 sql = _SQL_SELECT_USERNOTIFICATIONDELIVERY;
1470
1471 if (pagination) {
1472 sql = sql.concat(UserNotificationDeliveryModelImpl.ORDER_BY_JPQL);
1473 }
1474 }
1475
1476 Session session = null;
1477
1478 try {
1479 session = openSession();
1480
1481 Query q = session.createQuery(sql);
1482
1483 if (!pagination) {
1484 list = (List<UserNotificationDelivery>)QueryUtil.list(q,
1485 getDialect(), start, end, false);
1486
1487 Collections.sort(list);
1488
1489 list = new UnmodifiableList<UserNotificationDelivery>(list);
1490 }
1491 else {
1492 list = (List<UserNotificationDelivery>)QueryUtil.list(q,
1493 getDialect(), start, end);
1494 }
1495
1496 cacheResult(list);
1497
1498 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1499 }
1500 catch (Exception e) {
1501 FinderCacheUtil.removeResult(finderPath, finderArgs);
1502
1503 throw processException(e);
1504 }
1505 finally {
1506 closeSession(session);
1507 }
1508 }
1509
1510 return list;
1511 }
1512
1513
1518 @Override
1519 public void removeAll() throws SystemException {
1520 for (UserNotificationDelivery userNotificationDelivery : findAll()) {
1521 remove(userNotificationDelivery);
1522 }
1523 }
1524
1525
1531 @Override
1532 public int countAll() throws SystemException {
1533 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1534 FINDER_ARGS_EMPTY, this);
1535
1536 if (count == null) {
1537 Session session = null;
1538
1539 try {
1540 session = openSession();
1541
1542 Query q = session.createQuery(_SQL_COUNT_USERNOTIFICATIONDELIVERY);
1543
1544 count = (Long)q.uniqueResult();
1545
1546 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1547 FINDER_ARGS_EMPTY, count);
1548 }
1549 catch (Exception e) {
1550 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1551 FINDER_ARGS_EMPTY);
1552
1553 throw processException(e);
1554 }
1555 finally {
1556 closeSession(session);
1557 }
1558 }
1559
1560 return count.intValue();
1561 }
1562
1563
1566 public void afterPropertiesSet() {
1567 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1568 com.liferay.portal.util.PropsUtil.get(
1569 "value.object.listener.com.liferay.portal.model.UserNotificationDelivery")));
1570
1571 if (listenerClassNames.length > 0) {
1572 try {
1573 List<ModelListener<UserNotificationDelivery>> listenersList = new ArrayList<ModelListener<UserNotificationDelivery>>();
1574
1575 for (String listenerClassName : listenerClassNames) {
1576 listenersList.add((ModelListener<UserNotificationDelivery>)InstanceFactory.newInstance(
1577 getClassLoader(), listenerClassName));
1578 }
1579
1580 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1581 }
1582 catch (Exception e) {
1583 _log.error(e);
1584 }
1585 }
1586 }
1587
1588 public void destroy() {
1589 EntityCacheUtil.removeCache(UserNotificationDeliveryImpl.class.getName());
1590 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1591 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1592 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1593 }
1594
1595 private static final String _SQL_SELECT_USERNOTIFICATIONDELIVERY = "SELECT userNotificationDelivery FROM UserNotificationDelivery userNotificationDelivery";
1596 private static final String _SQL_SELECT_USERNOTIFICATIONDELIVERY_WHERE = "SELECT userNotificationDelivery FROM UserNotificationDelivery userNotificationDelivery WHERE ";
1597 private static final String _SQL_COUNT_USERNOTIFICATIONDELIVERY = "SELECT COUNT(userNotificationDelivery) FROM UserNotificationDelivery userNotificationDelivery";
1598 private static final String _SQL_COUNT_USERNOTIFICATIONDELIVERY_WHERE = "SELECT COUNT(userNotificationDelivery) FROM UserNotificationDelivery userNotificationDelivery WHERE ";
1599 private static final String _ORDER_BY_ENTITY_ALIAS = "userNotificationDelivery.";
1600 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserNotificationDelivery exists with the primary key ";
1601 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserNotificationDelivery exists with the key {";
1602 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1603 private static Log _log = LogFactoryUtil.getLog(UserNotificationDeliveryPersistenceImpl.class);
1604 private static UserNotificationDelivery _nullUserNotificationDelivery = new UserNotificationDeliveryImpl() {
1605 @Override
1606 public Object clone() {
1607 return this;
1608 }
1609
1610 @Override
1611 public CacheModel<UserNotificationDelivery> toCacheModel() {
1612 return _nullUserNotificationDeliveryCacheModel;
1613 }
1614 };
1615
1616 private static CacheModel<UserNotificationDelivery> _nullUserNotificationDeliveryCacheModel =
1617 new CacheModel<UserNotificationDelivery>() {
1618 @Override
1619 public UserNotificationDelivery toEntityModel() {
1620 return _nullUserNotificationDelivery;
1621 }
1622 };
1623 }