001
014
015 package com.liferay.portal.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.dao.orm.EntityCache;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCache;
023 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024 import com.liferay.portal.kernel.dao.orm.FinderPath;
025 import com.liferay.portal.kernel.dao.orm.Query;
026 import com.liferay.portal.kernel.dao.orm.QueryPos;
027 import com.liferay.portal.kernel.dao.orm.QueryUtil;
028 import com.liferay.portal.kernel.dao.orm.Session;
029 import com.liferay.portal.kernel.exception.NoSuchUserNotificationEventException;
030 import com.liferay.portal.kernel.log.Log;
031 import com.liferay.portal.kernel.log.LogFactoryUtil;
032 import com.liferay.portal.kernel.model.CacheModel;
033 import com.liferay.portal.kernel.model.MVCCModel;
034 import com.liferay.portal.kernel.model.UserNotificationEvent;
035 import com.liferay.portal.kernel.service.persistence.CompanyProvider;
036 import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
037 import com.liferay.portal.kernel.service.persistence.UserNotificationEventPersistence;
038 import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.Validator;
044 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
045 import com.liferay.portal.model.impl.UserNotificationEventImpl;
046 import com.liferay.portal.model.impl.UserNotificationEventModelImpl;
047
048 import java.io.Serializable;
049
050 import java.util.Collections;
051 import java.util.HashMap;
052 import java.util.HashSet;
053 import java.util.Iterator;
054 import java.util.List;
055 import java.util.Map;
056 import java.util.Set;
057
058
070 @ProviderType
071 public class UserNotificationEventPersistenceImpl extends BasePersistenceImpl<UserNotificationEvent>
072 implements UserNotificationEventPersistence {
073
078 public static final String FINDER_CLASS_NAME_ENTITY = UserNotificationEventImpl.class.getName();
079 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List1";
081 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List2";
083 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
084 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
085 UserNotificationEventImpl.class,
086 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
087 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
088 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
089 UserNotificationEventImpl.class,
090 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
091 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
092 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
094 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
095 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
096 UserNotificationEventImpl.class,
097 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
098 new String[] {
099 String.class.getName(),
100
101 Integer.class.getName(), Integer.class.getName(),
102 OrderByComparator.class.getName()
103 });
104 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
105 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
106 UserNotificationEventImpl.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
108 new String[] { String.class.getName() },
109 UserNotificationEventModelImpl.UUID_COLUMN_BITMASK |
110 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
111 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
112 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
113 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
114 new String[] { String.class.getName() });
115
116
122 @Override
123 public List<UserNotificationEvent> findByUuid(String uuid) {
124 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
125 }
126
127
139 @Override
140 public List<UserNotificationEvent> findByUuid(String uuid, int start,
141 int end) {
142 return findByUuid(uuid, start, end, null);
143 }
144
145
158 @Override
159 public List<UserNotificationEvent> findByUuid(String uuid, int start,
160 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
161 return findByUuid(uuid, start, end, orderByComparator, true);
162 }
163
164
178 @Override
179 public List<UserNotificationEvent> findByUuid(String uuid, int start,
180 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
181 boolean retrieveFromCache) {
182 boolean pagination = true;
183 FinderPath finderPath = null;
184 Object[] finderArgs = null;
185
186 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
187 (orderByComparator == null)) {
188 pagination = false;
189 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
190 finderArgs = new Object[] { uuid };
191 }
192 else {
193 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
194 finderArgs = new Object[] { uuid, start, end, orderByComparator };
195 }
196
197 List<UserNotificationEvent> list = null;
198
199 if (retrieveFromCache) {
200 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
201 finderArgs, this);
202
203 if ((list != null) && !list.isEmpty()) {
204 for (UserNotificationEvent userNotificationEvent : list) {
205 if (!Validator.equals(uuid, userNotificationEvent.getUuid())) {
206 list = null;
207
208 break;
209 }
210 }
211 }
212 }
213
214 if (list == null) {
215 StringBundler query = null;
216
217 if (orderByComparator != null) {
218 query = new StringBundler(3 +
219 (orderByComparator.getOrderByFields().length * 2));
220 }
221 else {
222 query = new StringBundler(3);
223 }
224
225 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
226
227 boolean bindUuid = false;
228
229 if (uuid == null) {
230 query.append(_FINDER_COLUMN_UUID_UUID_1);
231 }
232 else if (uuid.equals(StringPool.BLANK)) {
233 query.append(_FINDER_COLUMN_UUID_UUID_3);
234 }
235 else {
236 bindUuid = true;
237
238 query.append(_FINDER_COLUMN_UUID_UUID_2);
239 }
240
241 if (orderByComparator != null) {
242 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
243 orderByComparator);
244 }
245 else
246 if (pagination) {
247 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
248 }
249
250 String sql = query.toString();
251
252 Session session = null;
253
254 try {
255 session = openSession();
256
257 Query q = session.createQuery(sql);
258
259 QueryPos qPos = QueryPos.getInstance(q);
260
261 if (bindUuid) {
262 qPos.add(uuid);
263 }
264
265 if (!pagination) {
266 list = (List<UserNotificationEvent>)QueryUtil.list(q,
267 getDialect(), start, end, false);
268
269 Collections.sort(list);
270
271 list = Collections.unmodifiableList(list);
272 }
273 else {
274 list = (List<UserNotificationEvent>)QueryUtil.list(q,
275 getDialect(), start, end);
276 }
277
278 cacheResult(list);
279
280 finderCache.putResult(finderPath, finderArgs, list);
281 }
282 catch (Exception e) {
283 finderCache.removeResult(finderPath, finderArgs);
284
285 throw processException(e);
286 }
287 finally {
288 closeSession(session);
289 }
290 }
291
292 return list;
293 }
294
295
303 @Override
304 public UserNotificationEvent findByUuid_First(String uuid,
305 OrderByComparator<UserNotificationEvent> orderByComparator)
306 throws NoSuchUserNotificationEventException {
307 UserNotificationEvent userNotificationEvent = fetchByUuid_First(uuid,
308 orderByComparator);
309
310 if (userNotificationEvent != null) {
311 return userNotificationEvent;
312 }
313
314 StringBundler msg = new StringBundler(4);
315
316 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
317
318 msg.append("uuid=");
319 msg.append(uuid);
320
321 msg.append(StringPool.CLOSE_CURLY_BRACE);
322
323 throw new NoSuchUserNotificationEventException(msg.toString());
324 }
325
326
333 @Override
334 public UserNotificationEvent fetchByUuid_First(String uuid,
335 OrderByComparator<UserNotificationEvent> orderByComparator) {
336 List<UserNotificationEvent> list = findByUuid(uuid, 0, 1,
337 orderByComparator);
338
339 if (!list.isEmpty()) {
340 return list.get(0);
341 }
342
343 return null;
344 }
345
346
354 @Override
355 public UserNotificationEvent findByUuid_Last(String uuid,
356 OrderByComparator<UserNotificationEvent> orderByComparator)
357 throws NoSuchUserNotificationEventException {
358 UserNotificationEvent userNotificationEvent = fetchByUuid_Last(uuid,
359 orderByComparator);
360
361 if (userNotificationEvent != null) {
362 return userNotificationEvent;
363 }
364
365 StringBundler msg = new StringBundler(4);
366
367 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
368
369 msg.append("uuid=");
370 msg.append(uuid);
371
372 msg.append(StringPool.CLOSE_CURLY_BRACE);
373
374 throw new NoSuchUserNotificationEventException(msg.toString());
375 }
376
377
384 @Override
385 public UserNotificationEvent fetchByUuid_Last(String uuid,
386 OrderByComparator<UserNotificationEvent> orderByComparator) {
387 int count = countByUuid(uuid);
388
389 if (count == 0) {
390 return null;
391 }
392
393 List<UserNotificationEvent> list = findByUuid(uuid, count - 1, count,
394 orderByComparator);
395
396 if (!list.isEmpty()) {
397 return list.get(0);
398 }
399
400 return null;
401 }
402
403
412 @Override
413 public UserNotificationEvent[] findByUuid_PrevAndNext(
414 long userNotificationEventId, String uuid,
415 OrderByComparator<UserNotificationEvent> orderByComparator)
416 throws NoSuchUserNotificationEventException {
417 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
418
419 Session session = null;
420
421 try {
422 session = openSession();
423
424 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
425
426 array[0] = getByUuid_PrevAndNext(session, userNotificationEvent,
427 uuid, orderByComparator, true);
428
429 array[1] = userNotificationEvent;
430
431 array[2] = getByUuid_PrevAndNext(session, userNotificationEvent,
432 uuid, orderByComparator, false);
433
434 return array;
435 }
436 catch (Exception e) {
437 throw processException(e);
438 }
439 finally {
440 closeSession(session);
441 }
442 }
443
444 protected UserNotificationEvent getByUuid_PrevAndNext(Session session,
445 UserNotificationEvent userNotificationEvent, String uuid,
446 OrderByComparator<UserNotificationEvent> orderByComparator,
447 boolean previous) {
448 StringBundler query = null;
449
450 if (orderByComparator != null) {
451 query = new StringBundler(4 +
452 (orderByComparator.getOrderByConditionFields().length * 3) +
453 (orderByComparator.getOrderByFields().length * 3));
454 }
455 else {
456 query = new StringBundler(3);
457 }
458
459 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
460
461 boolean bindUuid = false;
462
463 if (uuid == null) {
464 query.append(_FINDER_COLUMN_UUID_UUID_1);
465 }
466 else if (uuid.equals(StringPool.BLANK)) {
467 query.append(_FINDER_COLUMN_UUID_UUID_3);
468 }
469 else {
470 bindUuid = true;
471
472 query.append(_FINDER_COLUMN_UUID_UUID_2);
473 }
474
475 if (orderByComparator != null) {
476 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
477
478 if (orderByConditionFields.length > 0) {
479 query.append(WHERE_AND);
480 }
481
482 for (int i = 0; i < orderByConditionFields.length; i++) {
483 query.append(_ORDER_BY_ENTITY_ALIAS);
484 query.append(orderByConditionFields[i]);
485
486 if ((i + 1) < orderByConditionFields.length) {
487 if (orderByComparator.isAscending() ^ previous) {
488 query.append(WHERE_GREATER_THAN_HAS_NEXT);
489 }
490 else {
491 query.append(WHERE_LESSER_THAN_HAS_NEXT);
492 }
493 }
494 else {
495 if (orderByComparator.isAscending() ^ previous) {
496 query.append(WHERE_GREATER_THAN);
497 }
498 else {
499 query.append(WHERE_LESSER_THAN);
500 }
501 }
502 }
503
504 query.append(ORDER_BY_CLAUSE);
505
506 String[] orderByFields = orderByComparator.getOrderByFields();
507
508 for (int i = 0; i < orderByFields.length; i++) {
509 query.append(_ORDER_BY_ENTITY_ALIAS);
510 query.append(orderByFields[i]);
511
512 if ((i + 1) < orderByFields.length) {
513 if (orderByComparator.isAscending() ^ previous) {
514 query.append(ORDER_BY_ASC_HAS_NEXT);
515 }
516 else {
517 query.append(ORDER_BY_DESC_HAS_NEXT);
518 }
519 }
520 else {
521 if (orderByComparator.isAscending() ^ previous) {
522 query.append(ORDER_BY_ASC);
523 }
524 else {
525 query.append(ORDER_BY_DESC);
526 }
527 }
528 }
529 }
530 else {
531 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
532 }
533
534 String sql = query.toString();
535
536 Query q = session.createQuery(sql);
537
538 q.setFirstResult(0);
539 q.setMaxResults(2);
540
541 QueryPos qPos = QueryPos.getInstance(q);
542
543 if (bindUuid) {
544 qPos.add(uuid);
545 }
546
547 if (orderByComparator != null) {
548 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
549
550 for (Object value : values) {
551 qPos.add(value);
552 }
553 }
554
555 List<UserNotificationEvent> list = q.list();
556
557 if (list.size() == 2) {
558 return list.get(1);
559 }
560 else {
561 return null;
562 }
563 }
564
565
570 @Override
571 public void removeByUuid(String uuid) {
572 for (UserNotificationEvent userNotificationEvent : findByUuid(uuid,
573 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
574 remove(userNotificationEvent);
575 }
576 }
577
578
584 @Override
585 public int countByUuid(String uuid) {
586 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
587
588 Object[] finderArgs = new Object[] { uuid };
589
590 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
591
592 if (count == null) {
593 StringBundler query = new StringBundler(2);
594
595 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
596
597 boolean bindUuid = false;
598
599 if (uuid == null) {
600 query.append(_FINDER_COLUMN_UUID_UUID_1);
601 }
602 else if (uuid.equals(StringPool.BLANK)) {
603 query.append(_FINDER_COLUMN_UUID_UUID_3);
604 }
605 else {
606 bindUuid = true;
607
608 query.append(_FINDER_COLUMN_UUID_UUID_2);
609 }
610
611 String sql = query.toString();
612
613 Session session = null;
614
615 try {
616 session = openSession();
617
618 Query q = session.createQuery(sql);
619
620 QueryPos qPos = QueryPos.getInstance(q);
621
622 if (bindUuid) {
623 qPos.add(uuid);
624 }
625
626 count = (Long)q.uniqueResult();
627
628 finderCache.putResult(finderPath, finderArgs, count);
629 }
630 catch (Exception e) {
631 finderCache.removeResult(finderPath, finderArgs);
632
633 throw processException(e);
634 }
635 finally {
636 closeSession(session);
637 }
638 }
639
640 return count.intValue();
641 }
642
643 private static final String _FINDER_COLUMN_UUID_UUID_1 = "userNotificationEvent.uuid IS NULL";
644 private static final String _FINDER_COLUMN_UUID_UUID_2 = "userNotificationEvent.uuid = ?";
645 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = '')";
646 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
647 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
648 UserNotificationEventImpl.class,
649 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
650 new String[] {
651 String.class.getName(), Long.class.getName(),
652
653 Integer.class.getName(), Integer.class.getName(),
654 OrderByComparator.class.getName()
655 });
656 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
657 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
658 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
659 UserNotificationEventImpl.class,
660 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
661 new String[] { String.class.getName(), Long.class.getName() },
662 UserNotificationEventModelImpl.UUID_COLUMN_BITMASK |
663 UserNotificationEventModelImpl.COMPANYID_COLUMN_BITMASK |
664 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
665 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
666 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
667 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
668 new String[] { String.class.getName(), Long.class.getName() });
669
670
677 @Override
678 public List<UserNotificationEvent> findByUuid_C(String uuid, long companyId) {
679 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
680 QueryUtil.ALL_POS, null);
681 }
682
683
696 @Override
697 public List<UserNotificationEvent> findByUuid_C(String uuid,
698 long companyId, int start, int end) {
699 return findByUuid_C(uuid, companyId, start, end, null);
700 }
701
702
716 @Override
717 public List<UserNotificationEvent> findByUuid_C(String uuid,
718 long companyId, int start, int end,
719 OrderByComparator<UserNotificationEvent> orderByComparator) {
720 return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
721 }
722
723
738 @Override
739 public List<UserNotificationEvent> findByUuid_C(String uuid,
740 long companyId, int start, int end,
741 OrderByComparator<UserNotificationEvent> orderByComparator,
742 boolean retrieveFromCache) {
743 boolean pagination = true;
744 FinderPath finderPath = null;
745 Object[] finderArgs = null;
746
747 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
748 (orderByComparator == null)) {
749 pagination = false;
750 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
751 finderArgs = new Object[] { uuid, companyId };
752 }
753 else {
754 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
755 finderArgs = new Object[] {
756 uuid, companyId,
757
758 start, end, orderByComparator
759 };
760 }
761
762 List<UserNotificationEvent> list = null;
763
764 if (retrieveFromCache) {
765 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
766 finderArgs, this);
767
768 if ((list != null) && !list.isEmpty()) {
769 for (UserNotificationEvent userNotificationEvent : list) {
770 if (!Validator.equals(uuid, userNotificationEvent.getUuid()) ||
771 (companyId != userNotificationEvent.getCompanyId())) {
772 list = null;
773
774 break;
775 }
776 }
777 }
778 }
779
780 if (list == null) {
781 StringBundler query = null;
782
783 if (orderByComparator != null) {
784 query = new StringBundler(4 +
785 (orderByComparator.getOrderByFields().length * 2));
786 }
787 else {
788 query = new StringBundler(4);
789 }
790
791 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
792
793 boolean bindUuid = false;
794
795 if (uuid == null) {
796 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
797 }
798 else if (uuid.equals(StringPool.BLANK)) {
799 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
800 }
801 else {
802 bindUuid = true;
803
804 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
805 }
806
807 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
808
809 if (orderByComparator != null) {
810 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
811 orderByComparator);
812 }
813 else
814 if (pagination) {
815 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
816 }
817
818 String sql = query.toString();
819
820 Session session = null;
821
822 try {
823 session = openSession();
824
825 Query q = session.createQuery(sql);
826
827 QueryPos qPos = QueryPos.getInstance(q);
828
829 if (bindUuid) {
830 qPos.add(uuid);
831 }
832
833 qPos.add(companyId);
834
835 if (!pagination) {
836 list = (List<UserNotificationEvent>)QueryUtil.list(q,
837 getDialect(), start, end, false);
838
839 Collections.sort(list);
840
841 list = Collections.unmodifiableList(list);
842 }
843 else {
844 list = (List<UserNotificationEvent>)QueryUtil.list(q,
845 getDialect(), start, end);
846 }
847
848 cacheResult(list);
849
850 finderCache.putResult(finderPath, finderArgs, list);
851 }
852 catch (Exception e) {
853 finderCache.removeResult(finderPath, finderArgs);
854
855 throw processException(e);
856 }
857 finally {
858 closeSession(session);
859 }
860 }
861
862 return list;
863 }
864
865
874 @Override
875 public UserNotificationEvent findByUuid_C_First(String uuid,
876 long companyId,
877 OrderByComparator<UserNotificationEvent> orderByComparator)
878 throws NoSuchUserNotificationEventException {
879 UserNotificationEvent userNotificationEvent = fetchByUuid_C_First(uuid,
880 companyId, orderByComparator);
881
882 if (userNotificationEvent != null) {
883 return userNotificationEvent;
884 }
885
886 StringBundler msg = new StringBundler(6);
887
888 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
889
890 msg.append("uuid=");
891 msg.append(uuid);
892
893 msg.append(", companyId=");
894 msg.append(companyId);
895
896 msg.append(StringPool.CLOSE_CURLY_BRACE);
897
898 throw new NoSuchUserNotificationEventException(msg.toString());
899 }
900
901
909 @Override
910 public UserNotificationEvent fetchByUuid_C_First(String uuid,
911 long companyId,
912 OrderByComparator<UserNotificationEvent> orderByComparator) {
913 List<UserNotificationEvent> list = findByUuid_C(uuid, companyId, 0, 1,
914 orderByComparator);
915
916 if (!list.isEmpty()) {
917 return list.get(0);
918 }
919
920 return null;
921 }
922
923
932 @Override
933 public UserNotificationEvent findByUuid_C_Last(String uuid, long companyId,
934 OrderByComparator<UserNotificationEvent> orderByComparator)
935 throws NoSuchUserNotificationEventException {
936 UserNotificationEvent userNotificationEvent = fetchByUuid_C_Last(uuid,
937 companyId, orderByComparator);
938
939 if (userNotificationEvent != null) {
940 return userNotificationEvent;
941 }
942
943 StringBundler msg = new StringBundler(6);
944
945 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
946
947 msg.append("uuid=");
948 msg.append(uuid);
949
950 msg.append(", companyId=");
951 msg.append(companyId);
952
953 msg.append(StringPool.CLOSE_CURLY_BRACE);
954
955 throw new NoSuchUserNotificationEventException(msg.toString());
956 }
957
958
966 @Override
967 public UserNotificationEvent fetchByUuid_C_Last(String uuid,
968 long companyId,
969 OrderByComparator<UserNotificationEvent> orderByComparator) {
970 int count = countByUuid_C(uuid, companyId);
971
972 if (count == 0) {
973 return null;
974 }
975
976 List<UserNotificationEvent> list = findByUuid_C(uuid, companyId,
977 count - 1, count, orderByComparator);
978
979 if (!list.isEmpty()) {
980 return list.get(0);
981 }
982
983 return null;
984 }
985
986
996 @Override
997 public UserNotificationEvent[] findByUuid_C_PrevAndNext(
998 long userNotificationEventId, String uuid, long companyId,
999 OrderByComparator<UserNotificationEvent> orderByComparator)
1000 throws NoSuchUserNotificationEventException {
1001 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
1002
1003 Session session = null;
1004
1005 try {
1006 session = openSession();
1007
1008 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1009
1010 array[0] = getByUuid_C_PrevAndNext(session, userNotificationEvent,
1011 uuid, companyId, orderByComparator, true);
1012
1013 array[1] = userNotificationEvent;
1014
1015 array[2] = getByUuid_C_PrevAndNext(session, userNotificationEvent,
1016 uuid, companyId, orderByComparator, false);
1017
1018 return array;
1019 }
1020 catch (Exception e) {
1021 throw processException(e);
1022 }
1023 finally {
1024 closeSession(session);
1025 }
1026 }
1027
1028 protected UserNotificationEvent getByUuid_C_PrevAndNext(Session session,
1029 UserNotificationEvent userNotificationEvent, String uuid,
1030 long companyId,
1031 OrderByComparator<UserNotificationEvent> orderByComparator,
1032 boolean previous) {
1033 StringBundler query = null;
1034
1035 if (orderByComparator != null) {
1036 query = new StringBundler(5 +
1037 (orderByComparator.getOrderByConditionFields().length * 3) +
1038 (orderByComparator.getOrderByFields().length * 3));
1039 }
1040 else {
1041 query = new StringBundler(4);
1042 }
1043
1044 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1045
1046 boolean bindUuid = false;
1047
1048 if (uuid == null) {
1049 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1050 }
1051 else if (uuid.equals(StringPool.BLANK)) {
1052 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1053 }
1054 else {
1055 bindUuid = true;
1056
1057 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1058 }
1059
1060 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1061
1062 if (orderByComparator != null) {
1063 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1064
1065 if (orderByConditionFields.length > 0) {
1066 query.append(WHERE_AND);
1067 }
1068
1069 for (int i = 0; i < orderByConditionFields.length; i++) {
1070 query.append(_ORDER_BY_ENTITY_ALIAS);
1071 query.append(orderByConditionFields[i]);
1072
1073 if ((i + 1) < orderByConditionFields.length) {
1074 if (orderByComparator.isAscending() ^ previous) {
1075 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1076 }
1077 else {
1078 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1079 }
1080 }
1081 else {
1082 if (orderByComparator.isAscending() ^ previous) {
1083 query.append(WHERE_GREATER_THAN);
1084 }
1085 else {
1086 query.append(WHERE_LESSER_THAN);
1087 }
1088 }
1089 }
1090
1091 query.append(ORDER_BY_CLAUSE);
1092
1093 String[] orderByFields = orderByComparator.getOrderByFields();
1094
1095 for (int i = 0; i < orderByFields.length; i++) {
1096 query.append(_ORDER_BY_ENTITY_ALIAS);
1097 query.append(orderByFields[i]);
1098
1099 if ((i + 1) < orderByFields.length) {
1100 if (orderByComparator.isAscending() ^ previous) {
1101 query.append(ORDER_BY_ASC_HAS_NEXT);
1102 }
1103 else {
1104 query.append(ORDER_BY_DESC_HAS_NEXT);
1105 }
1106 }
1107 else {
1108 if (orderByComparator.isAscending() ^ previous) {
1109 query.append(ORDER_BY_ASC);
1110 }
1111 else {
1112 query.append(ORDER_BY_DESC);
1113 }
1114 }
1115 }
1116 }
1117 else {
1118 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1119 }
1120
1121 String sql = query.toString();
1122
1123 Query q = session.createQuery(sql);
1124
1125 q.setFirstResult(0);
1126 q.setMaxResults(2);
1127
1128 QueryPos qPos = QueryPos.getInstance(q);
1129
1130 if (bindUuid) {
1131 qPos.add(uuid);
1132 }
1133
1134 qPos.add(companyId);
1135
1136 if (orderByComparator != null) {
1137 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1138
1139 for (Object value : values) {
1140 qPos.add(value);
1141 }
1142 }
1143
1144 List<UserNotificationEvent> list = q.list();
1145
1146 if (list.size() == 2) {
1147 return list.get(1);
1148 }
1149 else {
1150 return null;
1151 }
1152 }
1153
1154
1160 @Override
1161 public void removeByUuid_C(String uuid, long companyId) {
1162 for (UserNotificationEvent userNotificationEvent : findByUuid_C(uuid,
1163 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1164 remove(userNotificationEvent);
1165 }
1166 }
1167
1168
1175 @Override
1176 public int countByUuid_C(String uuid, long companyId) {
1177 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1178
1179 Object[] finderArgs = new Object[] { uuid, companyId };
1180
1181 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1182
1183 if (count == null) {
1184 StringBundler query = new StringBundler(3);
1185
1186 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1187
1188 boolean bindUuid = false;
1189
1190 if (uuid == null) {
1191 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1192 }
1193 else if (uuid.equals(StringPool.BLANK)) {
1194 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1195 }
1196 else {
1197 bindUuid = true;
1198
1199 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1200 }
1201
1202 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1203
1204 String sql = query.toString();
1205
1206 Session session = null;
1207
1208 try {
1209 session = openSession();
1210
1211 Query q = session.createQuery(sql);
1212
1213 QueryPos qPos = QueryPos.getInstance(q);
1214
1215 if (bindUuid) {
1216 qPos.add(uuid);
1217 }
1218
1219 qPos.add(companyId);
1220
1221 count = (Long)q.uniqueResult();
1222
1223 finderCache.putResult(finderPath, finderArgs, count);
1224 }
1225 catch (Exception e) {
1226 finderCache.removeResult(finderPath, finderArgs);
1227
1228 throw processException(e);
1229 }
1230 finally {
1231 closeSession(session);
1232 }
1233 }
1234
1235 return count.intValue();
1236 }
1237
1238 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "userNotificationEvent.uuid IS NULL AND ";
1239 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "userNotificationEvent.uuid = ? AND ";
1240 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = '') AND ";
1241 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "userNotificationEvent.companyId = ?";
1242 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1243 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1244 UserNotificationEventImpl.class,
1245 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
1246 new String[] {
1247 Long.class.getName(),
1248
1249 Integer.class.getName(), Integer.class.getName(),
1250 OrderByComparator.class.getName()
1251 });
1252 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
1253 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1254 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1255 UserNotificationEventImpl.class,
1256 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
1257 new String[] { Long.class.getName() },
1258 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
1259 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
1260 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1261 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
1262 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
1263 new String[] { Long.class.getName() });
1264
1265
1271 @Override
1272 public List<UserNotificationEvent> findByUserId(long userId) {
1273 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1274 }
1275
1276
1288 @Override
1289 public List<UserNotificationEvent> findByUserId(long userId, int start,
1290 int end) {
1291 return findByUserId(userId, start, end, null);
1292 }
1293
1294
1307 @Override
1308 public List<UserNotificationEvent> findByUserId(long userId, int start,
1309 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
1310 return findByUserId(userId, start, end, orderByComparator, true);
1311 }
1312
1313
1327 @Override
1328 public List<UserNotificationEvent> findByUserId(long userId, int start,
1329 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
1330 boolean retrieveFromCache) {
1331 boolean pagination = true;
1332 FinderPath finderPath = null;
1333 Object[] finderArgs = null;
1334
1335 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1336 (orderByComparator == null)) {
1337 pagination = false;
1338 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1339 finderArgs = new Object[] { userId };
1340 }
1341 else {
1342 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1343 finderArgs = new Object[] { userId, start, end, orderByComparator };
1344 }
1345
1346 List<UserNotificationEvent> list = null;
1347
1348 if (retrieveFromCache) {
1349 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
1350 finderArgs, this);
1351
1352 if ((list != null) && !list.isEmpty()) {
1353 for (UserNotificationEvent userNotificationEvent : list) {
1354 if ((userId != userNotificationEvent.getUserId())) {
1355 list = null;
1356
1357 break;
1358 }
1359 }
1360 }
1361 }
1362
1363 if (list == null) {
1364 StringBundler query = null;
1365
1366 if (orderByComparator != null) {
1367 query = new StringBundler(3 +
1368 (orderByComparator.getOrderByFields().length * 2));
1369 }
1370 else {
1371 query = new StringBundler(3);
1372 }
1373
1374 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1375
1376 query.append(_FINDER_COLUMN_USERID_USERID_2);
1377
1378 if (orderByComparator != null) {
1379 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1380 orderByComparator);
1381 }
1382 else
1383 if (pagination) {
1384 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1385 }
1386
1387 String sql = query.toString();
1388
1389 Session session = null;
1390
1391 try {
1392 session = openSession();
1393
1394 Query q = session.createQuery(sql);
1395
1396 QueryPos qPos = QueryPos.getInstance(q);
1397
1398 qPos.add(userId);
1399
1400 if (!pagination) {
1401 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1402 getDialect(), start, end, false);
1403
1404 Collections.sort(list);
1405
1406 list = Collections.unmodifiableList(list);
1407 }
1408 else {
1409 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1410 getDialect(), start, end);
1411 }
1412
1413 cacheResult(list);
1414
1415 finderCache.putResult(finderPath, finderArgs, list);
1416 }
1417 catch (Exception e) {
1418 finderCache.removeResult(finderPath, finderArgs);
1419
1420 throw processException(e);
1421 }
1422 finally {
1423 closeSession(session);
1424 }
1425 }
1426
1427 return list;
1428 }
1429
1430
1438 @Override
1439 public UserNotificationEvent findByUserId_First(long userId,
1440 OrderByComparator<UserNotificationEvent> orderByComparator)
1441 throws NoSuchUserNotificationEventException {
1442 UserNotificationEvent userNotificationEvent = fetchByUserId_First(userId,
1443 orderByComparator);
1444
1445 if (userNotificationEvent != null) {
1446 return userNotificationEvent;
1447 }
1448
1449 StringBundler msg = new StringBundler(4);
1450
1451 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1452
1453 msg.append("userId=");
1454 msg.append(userId);
1455
1456 msg.append(StringPool.CLOSE_CURLY_BRACE);
1457
1458 throw new NoSuchUserNotificationEventException(msg.toString());
1459 }
1460
1461
1468 @Override
1469 public UserNotificationEvent fetchByUserId_First(long userId,
1470 OrderByComparator<UserNotificationEvent> orderByComparator) {
1471 List<UserNotificationEvent> list = findByUserId(userId, 0, 1,
1472 orderByComparator);
1473
1474 if (!list.isEmpty()) {
1475 return list.get(0);
1476 }
1477
1478 return null;
1479 }
1480
1481
1489 @Override
1490 public UserNotificationEvent findByUserId_Last(long userId,
1491 OrderByComparator<UserNotificationEvent> orderByComparator)
1492 throws NoSuchUserNotificationEventException {
1493 UserNotificationEvent userNotificationEvent = fetchByUserId_Last(userId,
1494 orderByComparator);
1495
1496 if (userNotificationEvent != null) {
1497 return userNotificationEvent;
1498 }
1499
1500 StringBundler msg = new StringBundler(4);
1501
1502 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1503
1504 msg.append("userId=");
1505 msg.append(userId);
1506
1507 msg.append(StringPool.CLOSE_CURLY_BRACE);
1508
1509 throw new NoSuchUserNotificationEventException(msg.toString());
1510 }
1511
1512
1519 @Override
1520 public UserNotificationEvent fetchByUserId_Last(long userId,
1521 OrderByComparator<UserNotificationEvent> orderByComparator) {
1522 int count = countByUserId(userId);
1523
1524 if (count == 0) {
1525 return null;
1526 }
1527
1528 List<UserNotificationEvent> list = findByUserId(userId, count - 1,
1529 count, orderByComparator);
1530
1531 if (!list.isEmpty()) {
1532 return list.get(0);
1533 }
1534
1535 return null;
1536 }
1537
1538
1547 @Override
1548 public UserNotificationEvent[] findByUserId_PrevAndNext(
1549 long userNotificationEventId, long userId,
1550 OrderByComparator<UserNotificationEvent> orderByComparator)
1551 throws NoSuchUserNotificationEventException {
1552 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
1553
1554 Session session = null;
1555
1556 try {
1557 session = openSession();
1558
1559 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1560
1561 array[0] = getByUserId_PrevAndNext(session, userNotificationEvent,
1562 userId, orderByComparator, true);
1563
1564 array[1] = userNotificationEvent;
1565
1566 array[2] = getByUserId_PrevAndNext(session, userNotificationEvent,
1567 userId, orderByComparator, false);
1568
1569 return array;
1570 }
1571 catch (Exception e) {
1572 throw processException(e);
1573 }
1574 finally {
1575 closeSession(session);
1576 }
1577 }
1578
1579 protected UserNotificationEvent getByUserId_PrevAndNext(Session session,
1580 UserNotificationEvent userNotificationEvent, long userId,
1581 OrderByComparator<UserNotificationEvent> orderByComparator,
1582 boolean previous) {
1583 StringBundler query = null;
1584
1585 if (orderByComparator != null) {
1586 query = new StringBundler(4 +
1587 (orderByComparator.getOrderByConditionFields().length * 3) +
1588 (orderByComparator.getOrderByFields().length * 3));
1589 }
1590 else {
1591 query = new StringBundler(3);
1592 }
1593
1594 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1595
1596 query.append(_FINDER_COLUMN_USERID_USERID_2);
1597
1598 if (orderByComparator != null) {
1599 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1600
1601 if (orderByConditionFields.length > 0) {
1602 query.append(WHERE_AND);
1603 }
1604
1605 for (int i = 0; i < orderByConditionFields.length; i++) {
1606 query.append(_ORDER_BY_ENTITY_ALIAS);
1607 query.append(orderByConditionFields[i]);
1608
1609 if ((i + 1) < orderByConditionFields.length) {
1610 if (orderByComparator.isAscending() ^ previous) {
1611 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1612 }
1613 else {
1614 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1615 }
1616 }
1617 else {
1618 if (orderByComparator.isAscending() ^ previous) {
1619 query.append(WHERE_GREATER_THAN);
1620 }
1621 else {
1622 query.append(WHERE_LESSER_THAN);
1623 }
1624 }
1625 }
1626
1627 query.append(ORDER_BY_CLAUSE);
1628
1629 String[] orderByFields = orderByComparator.getOrderByFields();
1630
1631 for (int i = 0; i < orderByFields.length; i++) {
1632 query.append(_ORDER_BY_ENTITY_ALIAS);
1633 query.append(orderByFields[i]);
1634
1635 if ((i + 1) < orderByFields.length) {
1636 if (orderByComparator.isAscending() ^ previous) {
1637 query.append(ORDER_BY_ASC_HAS_NEXT);
1638 }
1639 else {
1640 query.append(ORDER_BY_DESC_HAS_NEXT);
1641 }
1642 }
1643 else {
1644 if (orderByComparator.isAscending() ^ previous) {
1645 query.append(ORDER_BY_ASC);
1646 }
1647 else {
1648 query.append(ORDER_BY_DESC);
1649 }
1650 }
1651 }
1652 }
1653 else {
1654 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1655 }
1656
1657 String sql = query.toString();
1658
1659 Query q = session.createQuery(sql);
1660
1661 q.setFirstResult(0);
1662 q.setMaxResults(2);
1663
1664 QueryPos qPos = QueryPos.getInstance(q);
1665
1666 qPos.add(userId);
1667
1668 if (orderByComparator != null) {
1669 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1670
1671 for (Object value : values) {
1672 qPos.add(value);
1673 }
1674 }
1675
1676 List<UserNotificationEvent> list = q.list();
1677
1678 if (list.size() == 2) {
1679 return list.get(1);
1680 }
1681 else {
1682 return null;
1683 }
1684 }
1685
1686
1691 @Override
1692 public void removeByUserId(long userId) {
1693 for (UserNotificationEvent userNotificationEvent : findByUserId(
1694 userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1695 remove(userNotificationEvent);
1696 }
1697 }
1698
1699
1705 @Override
1706 public int countByUserId(long userId) {
1707 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
1708
1709 Object[] finderArgs = new Object[] { userId };
1710
1711 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1712
1713 if (count == null) {
1714 StringBundler query = new StringBundler(2);
1715
1716 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1717
1718 query.append(_FINDER_COLUMN_USERID_USERID_2);
1719
1720 String sql = query.toString();
1721
1722 Session session = null;
1723
1724 try {
1725 session = openSession();
1726
1727 Query q = session.createQuery(sql);
1728
1729 QueryPos qPos = QueryPos.getInstance(q);
1730
1731 qPos.add(userId);
1732
1733 count = (Long)q.uniqueResult();
1734
1735 finderCache.putResult(finderPath, finderArgs, count);
1736 }
1737 catch (Exception e) {
1738 finderCache.removeResult(finderPath, finderArgs);
1739
1740 throw processException(e);
1741 }
1742 finally {
1743 closeSession(session);
1744 }
1745 }
1746
1747 return count.intValue();
1748 }
1749
1750 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userNotificationEvent.userId = ?";
1751 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TYPE = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1752 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1753 UserNotificationEventImpl.class,
1754 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByType",
1755 new String[] {
1756 String.class.getName(),
1757
1758 Integer.class.getName(), Integer.class.getName(),
1759 OrderByComparator.class.getName()
1760 });
1761 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1762 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1763 UserNotificationEventImpl.class,
1764 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByType",
1765 new String[] { String.class.getName() },
1766 UserNotificationEventModelImpl.TYPE_COLUMN_BITMASK |
1767 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
1768 public static final FinderPath FINDER_PATH_COUNT_BY_TYPE = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1769 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
1770 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByType",
1771 new String[] { String.class.getName() });
1772
1773
1779 @Override
1780 public List<UserNotificationEvent> findByType(String type) {
1781 return findByType(type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1782 }
1783
1784
1796 @Override
1797 public List<UserNotificationEvent> findByType(String type, int start,
1798 int end) {
1799 return findByType(type, start, end, null);
1800 }
1801
1802
1815 @Override
1816 public List<UserNotificationEvent> findByType(String type, int start,
1817 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
1818 return findByType(type, start, end, orderByComparator, true);
1819 }
1820
1821
1835 @Override
1836 public List<UserNotificationEvent> findByType(String type, int start,
1837 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
1838 boolean retrieveFromCache) {
1839 boolean pagination = true;
1840 FinderPath finderPath = null;
1841 Object[] finderArgs = null;
1842
1843 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1844 (orderByComparator == null)) {
1845 pagination = false;
1846 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE;
1847 finderArgs = new Object[] { type };
1848 }
1849 else {
1850 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TYPE;
1851 finderArgs = new Object[] { type, start, end, orderByComparator };
1852 }
1853
1854 List<UserNotificationEvent> list = null;
1855
1856 if (retrieveFromCache) {
1857 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
1858 finderArgs, this);
1859
1860 if ((list != null) && !list.isEmpty()) {
1861 for (UserNotificationEvent userNotificationEvent : list) {
1862 if (!Validator.equals(type, userNotificationEvent.getType())) {
1863 list = null;
1864
1865 break;
1866 }
1867 }
1868 }
1869 }
1870
1871 if (list == null) {
1872 StringBundler query = null;
1873
1874 if (orderByComparator != null) {
1875 query = new StringBundler(3 +
1876 (orderByComparator.getOrderByFields().length * 2));
1877 }
1878 else {
1879 query = new StringBundler(3);
1880 }
1881
1882 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1883
1884 boolean bindType = false;
1885
1886 if (type == null) {
1887 query.append(_FINDER_COLUMN_TYPE_TYPE_1);
1888 }
1889 else if (type.equals(StringPool.BLANK)) {
1890 query.append(_FINDER_COLUMN_TYPE_TYPE_3);
1891 }
1892 else {
1893 bindType = true;
1894
1895 query.append(_FINDER_COLUMN_TYPE_TYPE_2);
1896 }
1897
1898 if (orderByComparator != null) {
1899 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1900 orderByComparator);
1901 }
1902 else
1903 if (pagination) {
1904 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1905 }
1906
1907 String sql = query.toString();
1908
1909 Session session = null;
1910
1911 try {
1912 session = openSession();
1913
1914 Query q = session.createQuery(sql);
1915
1916 QueryPos qPos = QueryPos.getInstance(q);
1917
1918 if (bindType) {
1919 qPos.add(type);
1920 }
1921
1922 if (!pagination) {
1923 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1924 getDialect(), start, end, false);
1925
1926 Collections.sort(list);
1927
1928 list = Collections.unmodifiableList(list);
1929 }
1930 else {
1931 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1932 getDialect(), start, end);
1933 }
1934
1935 cacheResult(list);
1936
1937 finderCache.putResult(finderPath, finderArgs, list);
1938 }
1939 catch (Exception e) {
1940 finderCache.removeResult(finderPath, finderArgs);
1941
1942 throw processException(e);
1943 }
1944 finally {
1945 closeSession(session);
1946 }
1947 }
1948
1949 return list;
1950 }
1951
1952
1960 @Override
1961 public UserNotificationEvent findByType_First(String type,
1962 OrderByComparator<UserNotificationEvent> orderByComparator)
1963 throws NoSuchUserNotificationEventException {
1964 UserNotificationEvent userNotificationEvent = fetchByType_First(type,
1965 orderByComparator);
1966
1967 if (userNotificationEvent != null) {
1968 return userNotificationEvent;
1969 }
1970
1971 StringBundler msg = new StringBundler(4);
1972
1973 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1974
1975 msg.append("type=");
1976 msg.append(type);
1977
1978 msg.append(StringPool.CLOSE_CURLY_BRACE);
1979
1980 throw new NoSuchUserNotificationEventException(msg.toString());
1981 }
1982
1983
1990 @Override
1991 public UserNotificationEvent fetchByType_First(String type,
1992 OrderByComparator<UserNotificationEvent> orderByComparator) {
1993 List<UserNotificationEvent> list = findByType(type, 0, 1,
1994 orderByComparator);
1995
1996 if (!list.isEmpty()) {
1997 return list.get(0);
1998 }
1999
2000 return null;
2001 }
2002
2003
2011 @Override
2012 public UserNotificationEvent findByType_Last(String type,
2013 OrderByComparator<UserNotificationEvent> orderByComparator)
2014 throws NoSuchUserNotificationEventException {
2015 UserNotificationEvent userNotificationEvent = fetchByType_Last(type,
2016 orderByComparator);
2017
2018 if (userNotificationEvent != null) {
2019 return userNotificationEvent;
2020 }
2021
2022 StringBundler msg = new StringBundler(4);
2023
2024 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2025
2026 msg.append("type=");
2027 msg.append(type);
2028
2029 msg.append(StringPool.CLOSE_CURLY_BRACE);
2030
2031 throw new NoSuchUserNotificationEventException(msg.toString());
2032 }
2033
2034
2041 @Override
2042 public UserNotificationEvent fetchByType_Last(String type,
2043 OrderByComparator<UserNotificationEvent> orderByComparator) {
2044 int count = countByType(type);
2045
2046 if (count == 0) {
2047 return null;
2048 }
2049
2050 List<UserNotificationEvent> list = findByType(type, count - 1, count,
2051 orderByComparator);
2052
2053 if (!list.isEmpty()) {
2054 return list.get(0);
2055 }
2056
2057 return null;
2058 }
2059
2060
2069 @Override
2070 public UserNotificationEvent[] findByType_PrevAndNext(
2071 long userNotificationEventId, String type,
2072 OrderByComparator<UserNotificationEvent> orderByComparator)
2073 throws NoSuchUserNotificationEventException {
2074 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
2075
2076 Session session = null;
2077
2078 try {
2079 session = openSession();
2080
2081 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
2082
2083 array[0] = getByType_PrevAndNext(session, userNotificationEvent,
2084 type, orderByComparator, true);
2085
2086 array[1] = userNotificationEvent;
2087
2088 array[2] = getByType_PrevAndNext(session, userNotificationEvent,
2089 type, orderByComparator, false);
2090
2091 return array;
2092 }
2093 catch (Exception e) {
2094 throw processException(e);
2095 }
2096 finally {
2097 closeSession(session);
2098 }
2099 }
2100
2101 protected UserNotificationEvent getByType_PrevAndNext(Session session,
2102 UserNotificationEvent userNotificationEvent, String type,
2103 OrderByComparator<UserNotificationEvent> orderByComparator,
2104 boolean previous) {
2105 StringBundler query = null;
2106
2107 if (orderByComparator != null) {
2108 query = new StringBundler(4 +
2109 (orderByComparator.getOrderByConditionFields().length * 3) +
2110 (orderByComparator.getOrderByFields().length * 3));
2111 }
2112 else {
2113 query = new StringBundler(3);
2114 }
2115
2116 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2117
2118 boolean bindType = false;
2119
2120 if (type == null) {
2121 query.append(_FINDER_COLUMN_TYPE_TYPE_1);
2122 }
2123 else if (type.equals(StringPool.BLANK)) {
2124 query.append(_FINDER_COLUMN_TYPE_TYPE_3);
2125 }
2126 else {
2127 bindType = true;
2128
2129 query.append(_FINDER_COLUMN_TYPE_TYPE_2);
2130 }
2131
2132 if (orderByComparator != null) {
2133 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2134
2135 if (orderByConditionFields.length > 0) {
2136 query.append(WHERE_AND);
2137 }
2138
2139 for (int i = 0; i < orderByConditionFields.length; i++) {
2140 query.append(_ORDER_BY_ENTITY_ALIAS);
2141 query.append(orderByConditionFields[i]);
2142
2143 if ((i + 1) < orderByConditionFields.length) {
2144 if (orderByComparator.isAscending() ^ previous) {
2145 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2146 }
2147 else {
2148 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2149 }
2150 }
2151 else {
2152 if (orderByComparator.isAscending() ^ previous) {
2153 query.append(WHERE_GREATER_THAN);
2154 }
2155 else {
2156 query.append(WHERE_LESSER_THAN);
2157 }
2158 }
2159 }
2160
2161 query.append(ORDER_BY_CLAUSE);
2162
2163 String[] orderByFields = orderByComparator.getOrderByFields();
2164
2165 for (int i = 0; i < orderByFields.length; i++) {
2166 query.append(_ORDER_BY_ENTITY_ALIAS);
2167 query.append(orderByFields[i]);
2168
2169 if ((i + 1) < orderByFields.length) {
2170 if (orderByComparator.isAscending() ^ previous) {
2171 query.append(ORDER_BY_ASC_HAS_NEXT);
2172 }
2173 else {
2174 query.append(ORDER_BY_DESC_HAS_NEXT);
2175 }
2176 }
2177 else {
2178 if (orderByComparator.isAscending() ^ previous) {
2179 query.append(ORDER_BY_ASC);
2180 }
2181 else {
2182 query.append(ORDER_BY_DESC);
2183 }
2184 }
2185 }
2186 }
2187 else {
2188 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2189 }
2190
2191 String sql = query.toString();
2192
2193 Query q = session.createQuery(sql);
2194
2195 q.setFirstResult(0);
2196 q.setMaxResults(2);
2197
2198 QueryPos qPos = QueryPos.getInstance(q);
2199
2200 if (bindType) {
2201 qPos.add(type);
2202 }
2203
2204 if (orderByComparator != null) {
2205 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
2206
2207 for (Object value : values) {
2208 qPos.add(value);
2209 }
2210 }
2211
2212 List<UserNotificationEvent> list = q.list();
2213
2214 if (list.size() == 2) {
2215 return list.get(1);
2216 }
2217 else {
2218 return null;
2219 }
2220 }
2221
2222
2227 @Override
2228 public void removeByType(String type) {
2229 for (UserNotificationEvent userNotificationEvent : findByType(type,
2230 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2231 remove(userNotificationEvent);
2232 }
2233 }
2234
2235
2241 @Override
2242 public int countByType(String type) {
2243 FinderPath finderPath = FINDER_PATH_COUNT_BY_TYPE;
2244
2245 Object[] finderArgs = new Object[] { type };
2246
2247 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2248
2249 if (count == null) {
2250 StringBundler query = new StringBundler(2);
2251
2252 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2253
2254 boolean bindType = false;
2255
2256 if (type == null) {
2257 query.append(_FINDER_COLUMN_TYPE_TYPE_1);
2258 }
2259 else if (type.equals(StringPool.BLANK)) {
2260 query.append(_FINDER_COLUMN_TYPE_TYPE_3);
2261 }
2262 else {
2263 bindType = true;
2264
2265 query.append(_FINDER_COLUMN_TYPE_TYPE_2);
2266 }
2267
2268 String sql = query.toString();
2269
2270 Session session = null;
2271
2272 try {
2273 session = openSession();
2274
2275 Query q = session.createQuery(sql);
2276
2277 QueryPos qPos = QueryPos.getInstance(q);
2278
2279 if (bindType) {
2280 qPos.add(type);
2281 }
2282
2283 count = (Long)q.uniqueResult();
2284
2285 finderCache.putResult(finderPath, finderArgs, count);
2286 }
2287 catch (Exception e) {
2288 finderCache.removeResult(finderPath, finderArgs);
2289
2290 throw processException(e);
2291 }
2292 finally {
2293 closeSession(session);
2294 }
2295 }
2296
2297 return count.intValue();
2298 }
2299
2300 private static final String _FINDER_COLUMN_TYPE_TYPE_1 = "userNotificationEvent.type IS NULL";
2301 private static final String _FINDER_COLUMN_TYPE_TYPE_2 = "userNotificationEvent.type = ?";
2302 private static final String _FINDER_COLUMN_TYPE_TYPE_3 = "(userNotificationEvent.type IS NULL OR userNotificationEvent.type = '')";
2303 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2304 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2305 UserNotificationEventImpl.class,
2306 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT",
2307 new String[] {
2308 Long.class.getName(), Integer.class.getName(),
2309
2310 Integer.class.getName(), Integer.class.getName(),
2311 OrderByComparator.class.getName()
2312 });
2313 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2314 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2315 UserNotificationEventImpl.class,
2316 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT",
2317 new String[] { Long.class.getName(), Integer.class.getName() },
2318 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
2319 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
2320 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
2321 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2322 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
2323 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT",
2324 new String[] { Long.class.getName(), Integer.class.getName() });
2325
2326
2333 @Override
2334 public List<UserNotificationEvent> findByU_DT(long userId, int deliveryType) {
2335 return findByU_DT(userId, deliveryType, QueryUtil.ALL_POS,
2336 QueryUtil.ALL_POS, null);
2337 }
2338
2339
2352 @Override
2353 public List<UserNotificationEvent> findByU_DT(long userId,
2354 int deliveryType, int start, int end) {
2355 return findByU_DT(userId, deliveryType, start, end, null);
2356 }
2357
2358
2372 @Override
2373 public List<UserNotificationEvent> findByU_DT(long userId,
2374 int deliveryType, int start, int end,
2375 OrderByComparator<UserNotificationEvent> orderByComparator) {
2376 return findByU_DT(userId, deliveryType, start, end, orderByComparator,
2377 true);
2378 }
2379
2380
2395 @Override
2396 public List<UserNotificationEvent> findByU_DT(long userId,
2397 int deliveryType, int start, int end,
2398 OrderByComparator<UserNotificationEvent> orderByComparator,
2399 boolean retrieveFromCache) {
2400 boolean pagination = true;
2401 FinderPath finderPath = null;
2402 Object[] finderArgs = null;
2403
2404 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2405 (orderByComparator == null)) {
2406 pagination = false;
2407 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT;
2408 finderArgs = new Object[] { userId, deliveryType };
2409 }
2410 else {
2411 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT;
2412 finderArgs = new Object[] {
2413 userId, deliveryType,
2414
2415 start, end, orderByComparator
2416 };
2417 }
2418
2419 List<UserNotificationEvent> list = null;
2420
2421 if (retrieveFromCache) {
2422 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
2423 finderArgs, this);
2424
2425 if ((list != null) && !list.isEmpty()) {
2426 for (UserNotificationEvent userNotificationEvent : list) {
2427 if ((userId != userNotificationEvent.getUserId()) ||
2428 (deliveryType != userNotificationEvent.getDeliveryType())) {
2429 list = null;
2430
2431 break;
2432 }
2433 }
2434 }
2435 }
2436
2437 if (list == null) {
2438 StringBundler query = null;
2439
2440 if (orderByComparator != null) {
2441 query = new StringBundler(4 +
2442 (orderByComparator.getOrderByFields().length * 2));
2443 }
2444 else {
2445 query = new StringBundler(4);
2446 }
2447
2448 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2449
2450 query.append(_FINDER_COLUMN_U_DT_USERID_2);
2451
2452 query.append(_FINDER_COLUMN_U_DT_DELIVERYTYPE_2);
2453
2454 if (orderByComparator != null) {
2455 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2456 orderByComparator);
2457 }
2458 else
2459 if (pagination) {
2460 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2461 }
2462
2463 String sql = query.toString();
2464
2465 Session session = null;
2466
2467 try {
2468 session = openSession();
2469
2470 Query q = session.createQuery(sql);
2471
2472 QueryPos qPos = QueryPos.getInstance(q);
2473
2474 qPos.add(userId);
2475
2476 qPos.add(deliveryType);
2477
2478 if (!pagination) {
2479 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2480 getDialect(), start, end, false);
2481
2482 Collections.sort(list);
2483
2484 list = Collections.unmodifiableList(list);
2485 }
2486 else {
2487 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2488 getDialect(), start, end);
2489 }
2490
2491 cacheResult(list);
2492
2493 finderCache.putResult(finderPath, finderArgs, list);
2494 }
2495 catch (Exception e) {
2496 finderCache.removeResult(finderPath, finderArgs);
2497
2498 throw processException(e);
2499 }
2500 finally {
2501 closeSession(session);
2502 }
2503 }
2504
2505 return list;
2506 }
2507
2508
2517 @Override
2518 public UserNotificationEvent findByU_DT_First(long userId,
2519 int deliveryType,
2520 OrderByComparator<UserNotificationEvent> orderByComparator)
2521 throws NoSuchUserNotificationEventException {
2522 UserNotificationEvent userNotificationEvent = fetchByU_DT_First(userId,
2523 deliveryType, orderByComparator);
2524
2525 if (userNotificationEvent != null) {
2526 return userNotificationEvent;
2527 }
2528
2529 StringBundler msg = new StringBundler(6);
2530
2531 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2532
2533 msg.append("userId=");
2534 msg.append(userId);
2535
2536 msg.append(", deliveryType=");
2537 msg.append(deliveryType);
2538
2539 msg.append(StringPool.CLOSE_CURLY_BRACE);
2540
2541 throw new NoSuchUserNotificationEventException(msg.toString());
2542 }
2543
2544
2552 @Override
2553 public UserNotificationEvent fetchByU_DT_First(long userId,
2554 int deliveryType,
2555 OrderByComparator<UserNotificationEvent> orderByComparator) {
2556 List<UserNotificationEvent> list = findByU_DT(userId, deliveryType, 0,
2557 1, orderByComparator);
2558
2559 if (!list.isEmpty()) {
2560 return list.get(0);
2561 }
2562
2563 return null;
2564 }
2565
2566
2575 @Override
2576 public UserNotificationEvent findByU_DT_Last(long userId, int deliveryType,
2577 OrderByComparator<UserNotificationEvent> orderByComparator)
2578 throws NoSuchUserNotificationEventException {
2579 UserNotificationEvent userNotificationEvent = fetchByU_DT_Last(userId,
2580 deliveryType, orderByComparator);
2581
2582 if (userNotificationEvent != null) {
2583 return userNotificationEvent;
2584 }
2585
2586 StringBundler msg = new StringBundler(6);
2587
2588 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2589
2590 msg.append("userId=");
2591 msg.append(userId);
2592
2593 msg.append(", deliveryType=");
2594 msg.append(deliveryType);
2595
2596 msg.append(StringPool.CLOSE_CURLY_BRACE);
2597
2598 throw new NoSuchUserNotificationEventException(msg.toString());
2599 }
2600
2601
2609 @Override
2610 public UserNotificationEvent fetchByU_DT_Last(long userId,
2611 int deliveryType,
2612 OrderByComparator<UserNotificationEvent> orderByComparator) {
2613 int count = countByU_DT(userId, deliveryType);
2614
2615 if (count == 0) {
2616 return null;
2617 }
2618
2619 List<UserNotificationEvent> list = findByU_DT(userId, deliveryType,
2620 count - 1, count, orderByComparator);
2621
2622 if (!list.isEmpty()) {
2623 return list.get(0);
2624 }
2625
2626 return null;
2627 }
2628
2629
2639 @Override
2640 public UserNotificationEvent[] findByU_DT_PrevAndNext(
2641 long userNotificationEventId, long userId, int deliveryType,
2642 OrderByComparator<UserNotificationEvent> orderByComparator)
2643 throws NoSuchUserNotificationEventException {
2644 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
2645
2646 Session session = null;
2647
2648 try {
2649 session = openSession();
2650
2651 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
2652
2653 array[0] = getByU_DT_PrevAndNext(session, userNotificationEvent,
2654 userId, deliveryType, orderByComparator, true);
2655
2656 array[1] = userNotificationEvent;
2657
2658 array[2] = getByU_DT_PrevAndNext(session, userNotificationEvent,
2659 userId, deliveryType, orderByComparator, false);
2660
2661 return array;
2662 }
2663 catch (Exception e) {
2664 throw processException(e);
2665 }
2666 finally {
2667 closeSession(session);
2668 }
2669 }
2670
2671 protected UserNotificationEvent getByU_DT_PrevAndNext(Session session,
2672 UserNotificationEvent userNotificationEvent, long userId,
2673 int deliveryType,
2674 OrderByComparator<UserNotificationEvent> orderByComparator,
2675 boolean previous) {
2676 StringBundler query = null;
2677
2678 if (orderByComparator != null) {
2679 query = new StringBundler(5 +
2680 (orderByComparator.getOrderByConditionFields().length * 3) +
2681 (orderByComparator.getOrderByFields().length * 3));
2682 }
2683 else {
2684 query = new StringBundler(4);
2685 }
2686
2687 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2688
2689 query.append(_FINDER_COLUMN_U_DT_USERID_2);
2690
2691 query.append(_FINDER_COLUMN_U_DT_DELIVERYTYPE_2);
2692
2693 if (orderByComparator != null) {
2694 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2695
2696 if (orderByConditionFields.length > 0) {
2697 query.append(WHERE_AND);
2698 }
2699
2700 for (int i = 0; i < orderByConditionFields.length; i++) {
2701 query.append(_ORDER_BY_ENTITY_ALIAS);
2702 query.append(orderByConditionFields[i]);
2703
2704 if ((i + 1) < orderByConditionFields.length) {
2705 if (orderByComparator.isAscending() ^ previous) {
2706 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2707 }
2708 else {
2709 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2710 }
2711 }
2712 else {
2713 if (orderByComparator.isAscending() ^ previous) {
2714 query.append(WHERE_GREATER_THAN);
2715 }
2716 else {
2717 query.append(WHERE_LESSER_THAN);
2718 }
2719 }
2720 }
2721
2722 query.append(ORDER_BY_CLAUSE);
2723
2724 String[] orderByFields = orderByComparator.getOrderByFields();
2725
2726 for (int i = 0; i < orderByFields.length; i++) {
2727 query.append(_ORDER_BY_ENTITY_ALIAS);
2728 query.append(orderByFields[i]);
2729
2730 if ((i + 1) < orderByFields.length) {
2731 if (orderByComparator.isAscending() ^ previous) {
2732 query.append(ORDER_BY_ASC_HAS_NEXT);
2733 }
2734 else {
2735 query.append(ORDER_BY_DESC_HAS_NEXT);
2736 }
2737 }
2738 else {
2739 if (orderByComparator.isAscending() ^ previous) {
2740 query.append(ORDER_BY_ASC);
2741 }
2742 else {
2743 query.append(ORDER_BY_DESC);
2744 }
2745 }
2746 }
2747 }
2748 else {
2749 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2750 }
2751
2752 String sql = query.toString();
2753
2754 Query q = session.createQuery(sql);
2755
2756 q.setFirstResult(0);
2757 q.setMaxResults(2);
2758
2759 QueryPos qPos = QueryPos.getInstance(q);
2760
2761 qPos.add(userId);
2762
2763 qPos.add(deliveryType);
2764
2765 if (orderByComparator != null) {
2766 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
2767
2768 for (Object value : values) {
2769 qPos.add(value);
2770 }
2771 }
2772
2773 List<UserNotificationEvent> list = q.list();
2774
2775 if (list.size() == 2) {
2776 return list.get(1);
2777 }
2778 else {
2779 return null;
2780 }
2781 }
2782
2783
2789 @Override
2790 public void removeByU_DT(long userId, int deliveryType) {
2791 for (UserNotificationEvent userNotificationEvent : findByU_DT(userId,
2792 deliveryType, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2793 remove(userNotificationEvent);
2794 }
2795 }
2796
2797
2804 @Override
2805 public int countByU_DT(long userId, int deliveryType) {
2806 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT;
2807
2808 Object[] finderArgs = new Object[] { userId, deliveryType };
2809
2810 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2811
2812 if (count == null) {
2813 StringBundler query = new StringBundler(3);
2814
2815 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2816
2817 query.append(_FINDER_COLUMN_U_DT_USERID_2);
2818
2819 query.append(_FINDER_COLUMN_U_DT_DELIVERYTYPE_2);
2820
2821 String sql = query.toString();
2822
2823 Session session = null;
2824
2825 try {
2826 session = openSession();
2827
2828 Query q = session.createQuery(sql);
2829
2830 QueryPos qPos = QueryPos.getInstance(q);
2831
2832 qPos.add(userId);
2833
2834 qPos.add(deliveryType);
2835
2836 count = (Long)q.uniqueResult();
2837
2838 finderCache.putResult(finderPath, finderArgs, count);
2839 }
2840 catch (Exception e) {
2841 finderCache.removeResult(finderPath, finderArgs);
2842
2843 throw processException(e);
2844 }
2845 finally {
2846 closeSession(session);
2847 }
2848 }
2849
2850 return count.intValue();
2851 }
2852
2853 private static final String _FINDER_COLUMN_U_DT_USERID_2 = "userNotificationEvent.userId = ? AND ";
2854 private static final String _FINDER_COLUMN_U_DT_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ?";
2855 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2856 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2857 UserNotificationEventImpl.class,
2858 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_D",
2859 new String[] {
2860 Long.class.getName(), Boolean.class.getName(),
2861
2862 Integer.class.getName(), Integer.class.getName(),
2863 OrderByComparator.class.getName()
2864 });
2865 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2866 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2867 UserNotificationEventImpl.class,
2868 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_D",
2869 new String[] { Long.class.getName(), Boolean.class.getName() },
2870 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
2871 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
2872 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
2873 public static final FinderPath FINDER_PATH_COUNT_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2874 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
2875 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_D",
2876 new String[] { Long.class.getName(), Boolean.class.getName() });
2877
2878
2885 @Override
2886 public List<UserNotificationEvent> findByU_D(long userId, boolean delivered) {
2887 return findByU_D(userId, delivered, QueryUtil.ALL_POS,
2888 QueryUtil.ALL_POS, null);
2889 }
2890
2891
2904 @Override
2905 public List<UserNotificationEvent> findByU_D(long userId,
2906 boolean delivered, int start, int end) {
2907 return findByU_D(userId, delivered, start, end, null);
2908 }
2909
2910
2924 @Override
2925 public List<UserNotificationEvent> findByU_D(long userId,
2926 boolean delivered, int start, int end,
2927 OrderByComparator<UserNotificationEvent> orderByComparator) {
2928 return findByU_D(userId, delivered, start, end, orderByComparator, true);
2929 }
2930
2931
2946 @Override
2947 public List<UserNotificationEvent> findByU_D(long userId,
2948 boolean delivered, int start, int end,
2949 OrderByComparator<UserNotificationEvent> orderByComparator,
2950 boolean retrieveFromCache) {
2951 boolean pagination = true;
2952 FinderPath finderPath = null;
2953 Object[] finderArgs = null;
2954
2955 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2956 (orderByComparator == null)) {
2957 pagination = false;
2958 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D;
2959 finderArgs = new Object[] { userId, delivered };
2960 }
2961 else {
2962 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D;
2963 finderArgs = new Object[] {
2964 userId, delivered,
2965
2966 start, end, orderByComparator
2967 };
2968 }
2969
2970 List<UserNotificationEvent> list = null;
2971
2972 if (retrieveFromCache) {
2973 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
2974 finderArgs, this);
2975
2976 if ((list != null) && !list.isEmpty()) {
2977 for (UserNotificationEvent userNotificationEvent : list) {
2978 if ((userId != userNotificationEvent.getUserId()) ||
2979 (delivered != userNotificationEvent.getDelivered())) {
2980 list = null;
2981
2982 break;
2983 }
2984 }
2985 }
2986 }
2987
2988 if (list == null) {
2989 StringBundler query = null;
2990
2991 if (orderByComparator != null) {
2992 query = new StringBundler(4 +
2993 (orderByComparator.getOrderByFields().length * 2));
2994 }
2995 else {
2996 query = new StringBundler(4);
2997 }
2998
2999 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3000
3001 query.append(_FINDER_COLUMN_U_D_USERID_2);
3002
3003 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
3004
3005 if (orderByComparator != null) {
3006 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3007 orderByComparator);
3008 }
3009 else
3010 if (pagination) {
3011 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3012 }
3013
3014 String sql = query.toString();
3015
3016 Session session = null;
3017
3018 try {
3019 session = openSession();
3020
3021 Query q = session.createQuery(sql);
3022
3023 QueryPos qPos = QueryPos.getInstance(q);
3024
3025 qPos.add(userId);
3026
3027 qPos.add(delivered);
3028
3029 if (!pagination) {
3030 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3031 getDialect(), start, end, false);
3032
3033 Collections.sort(list);
3034
3035 list = Collections.unmodifiableList(list);
3036 }
3037 else {
3038 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3039 getDialect(), start, end);
3040 }
3041
3042 cacheResult(list);
3043
3044 finderCache.putResult(finderPath, finderArgs, list);
3045 }
3046 catch (Exception e) {
3047 finderCache.removeResult(finderPath, finderArgs);
3048
3049 throw processException(e);
3050 }
3051 finally {
3052 closeSession(session);
3053 }
3054 }
3055
3056 return list;
3057 }
3058
3059
3068 @Override
3069 public UserNotificationEvent findByU_D_First(long userId,
3070 boolean delivered,
3071 OrderByComparator<UserNotificationEvent> orderByComparator)
3072 throws NoSuchUserNotificationEventException {
3073 UserNotificationEvent userNotificationEvent = fetchByU_D_First(userId,
3074 delivered, orderByComparator);
3075
3076 if (userNotificationEvent != null) {
3077 return userNotificationEvent;
3078 }
3079
3080 StringBundler msg = new StringBundler(6);
3081
3082 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3083
3084 msg.append("userId=");
3085 msg.append(userId);
3086
3087 msg.append(", delivered=");
3088 msg.append(delivered);
3089
3090 msg.append(StringPool.CLOSE_CURLY_BRACE);
3091
3092 throw new NoSuchUserNotificationEventException(msg.toString());
3093 }
3094
3095
3103 @Override
3104 public UserNotificationEvent fetchByU_D_First(long userId,
3105 boolean delivered,
3106 OrderByComparator<UserNotificationEvent> orderByComparator) {
3107 List<UserNotificationEvent> list = findByU_D(userId, delivered, 0, 1,
3108 orderByComparator);
3109
3110 if (!list.isEmpty()) {
3111 return list.get(0);
3112 }
3113
3114 return null;
3115 }
3116
3117
3126 @Override
3127 public UserNotificationEvent findByU_D_Last(long userId, boolean delivered,
3128 OrderByComparator<UserNotificationEvent> orderByComparator)
3129 throws NoSuchUserNotificationEventException {
3130 UserNotificationEvent userNotificationEvent = fetchByU_D_Last(userId,
3131 delivered, orderByComparator);
3132
3133 if (userNotificationEvent != null) {
3134 return userNotificationEvent;
3135 }
3136
3137 StringBundler msg = new StringBundler(6);
3138
3139 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3140
3141 msg.append("userId=");
3142 msg.append(userId);
3143
3144 msg.append(", delivered=");
3145 msg.append(delivered);
3146
3147 msg.append(StringPool.CLOSE_CURLY_BRACE);
3148
3149 throw new NoSuchUserNotificationEventException(msg.toString());
3150 }
3151
3152
3160 @Override
3161 public UserNotificationEvent fetchByU_D_Last(long userId,
3162 boolean delivered,
3163 OrderByComparator<UserNotificationEvent> orderByComparator) {
3164 int count = countByU_D(userId, delivered);
3165
3166 if (count == 0) {
3167 return null;
3168 }
3169
3170 List<UserNotificationEvent> list = findByU_D(userId, delivered,
3171 count - 1, count, orderByComparator);
3172
3173 if (!list.isEmpty()) {
3174 return list.get(0);
3175 }
3176
3177 return null;
3178 }
3179
3180
3190 @Override
3191 public UserNotificationEvent[] findByU_D_PrevAndNext(
3192 long userNotificationEventId, long userId, boolean delivered,
3193 OrderByComparator<UserNotificationEvent> orderByComparator)
3194 throws NoSuchUserNotificationEventException {
3195 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
3196
3197 Session session = null;
3198
3199 try {
3200 session = openSession();
3201
3202 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
3203
3204 array[0] = getByU_D_PrevAndNext(session, userNotificationEvent,
3205 userId, delivered, orderByComparator, true);
3206
3207 array[1] = userNotificationEvent;
3208
3209 array[2] = getByU_D_PrevAndNext(session, userNotificationEvent,
3210 userId, delivered, orderByComparator, false);
3211
3212 return array;
3213 }
3214 catch (Exception e) {
3215 throw processException(e);
3216 }
3217 finally {
3218 closeSession(session);
3219 }
3220 }
3221
3222 protected UserNotificationEvent getByU_D_PrevAndNext(Session session,
3223 UserNotificationEvent userNotificationEvent, long userId,
3224 boolean delivered,
3225 OrderByComparator<UserNotificationEvent> orderByComparator,
3226 boolean previous) {
3227 StringBundler query = null;
3228
3229 if (orderByComparator != null) {
3230 query = new StringBundler(5 +
3231 (orderByComparator.getOrderByConditionFields().length * 3) +
3232 (orderByComparator.getOrderByFields().length * 3));
3233 }
3234 else {
3235 query = new StringBundler(4);
3236 }
3237
3238 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3239
3240 query.append(_FINDER_COLUMN_U_D_USERID_2);
3241
3242 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
3243
3244 if (orderByComparator != null) {
3245 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3246
3247 if (orderByConditionFields.length > 0) {
3248 query.append(WHERE_AND);
3249 }
3250
3251 for (int i = 0; i < orderByConditionFields.length; i++) {
3252 query.append(_ORDER_BY_ENTITY_ALIAS);
3253 query.append(orderByConditionFields[i]);
3254
3255 if ((i + 1) < orderByConditionFields.length) {
3256 if (orderByComparator.isAscending() ^ previous) {
3257 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3258 }
3259 else {
3260 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3261 }
3262 }
3263 else {
3264 if (orderByComparator.isAscending() ^ previous) {
3265 query.append(WHERE_GREATER_THAN);
3266 }
3267 else {
3268 query.append(WHERE_LESSER_THAN);
3269 }
3270 }
3271 }
3272
3273 query.append(ORDER_BY_CLAUSE);
3274
3275 String[] orderByFields = orderByComparator.getOrderByFields();
3276
3277 for (int i = 0; i < orderByFields.length; i++) {
3278 query.append(_ORDER_BY_ENTITY_ALIAS);
3279 query.append(orderByFields[i]);
3280
3281 if ((i + 1) < orderByFields.length) {
3282 if (orderByComparator.isAscending() ^ previous) {
3283 query.append(ORDER_BY_ASC_HAS_NEXT);
3284 }
3285 else {
3286 query.append(ORDER_BY_DESC_HAS_NEXT);
3287 }
3288 }
3289 else {
3290 if (orderByComparator.isAscending() ^ previous) {
3291 query.append(ORDER_BY_ASC);
3292 }
3293 else {
3294 query.append(ORDER_BY_DESC);
3295 }
3296 }
3297 }
3298 }
3299 else {
3300 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3301 }
3302
3303 String sql = query.toString();
3304
3305 Query q = session.createQuery(sql);
3306
3307 q.setFirstResult(0);
3308 q.setMaxResults(2);
3309
3310 QueryPos qPos = QueryPos.getInstance(q);
3311
3312 qPos.add(userId);
3313
3314 qPos.add(delivered);
3315
3316 if (orderByComparator != null) {
3317 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
3318
3319 for (Object value : values) {
3320 qPos.add(value);
3321 }
3322 }
3323
3324 List<UserNotificationEvent> list = q.list();
3325
3326 if (list.size() == 2) {
3327 return list.get(1);
3328 }
3329 else {
3330 return null;
3331 }
3332 }
3333
3334
3340 @Override
3341 public void removeByU_D(long userId, boolean delivered) {
3342 for (UserNotificationEvent userNotificationEvent : findByU_D(userId,
3343 delivered, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3344 remove(userNotificationEvent);
3345 }
3346 }
3347
3348
3355 @Override
3356 public int countByU_D(long userId, boolean delivered) {
3357 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_D;
3358
3359 Object[] finderArgs = new Object[] { userId, delivered };
3360
3361 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3362
3363 if (count == null) {
3364 StringBundler query = new StringBundler(3);
3365
3366 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
3367
3368 query.append(_FINDER_COLUMN_U_D_USERID_2);
3369
3370 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
3371
3372 String sql = query.toString();
3373
3374 Session session = null;
3375
3376 try {
3377 session = openSession();
3378
3379 Query q = session.createQuery(sql);
3380
3381 QueryPos qPos = QueryPos.getInstance(q);
3382
3383 qPos.add(userId);
3384
3385 qPos.add(delivered);
3386
3387 count = (Long)q.uniqueResult();
3388
3389 finderCache.putResult(finderPath, finderArgs, count);
3390 }
3391 catch (Exception e) {
3392 finderCache.removeResult(finderPath, finderArgs);
3393
3394 throw processException(e);
3395 }
3396 finally {
3397 closeSession(session);
3398 }
3399 }
3400
3401 return count.intValue();
3402 }
3403
3404 private static final String _FINDER_COLUMN_U_D_USERID_2 = "userNotificationEvent.userId = ? AND ";
3405 private static final String _FINDER_COLUMN_U_D_DELIVERED_2 = "userNotificationEvent.delivered = ?";
3406 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3407 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3408 UserNotificationEventImpl.class,
3409 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_A",
3410 new String[] {
3411 Long.class.getName(), Boolean.class.getName(),
3412
3413 Integer.class.getName(), Integer.class.getName(),
3414 OrderByComparator.class.getName()
3415 });
3416 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3417 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3418 UserNotificationEventImpl.class,
3419 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_A",
3420 new String[] { Long.class.getName(), Boolean.class.getName() },
3421 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
3422 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
3423 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
3424 public static final FinderPath FINDER_PATH_COUNT_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3425 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
3426 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_A",
3427 new String[] { Long.class.getName(), Boolean.class.getName() });
3428
3429
3436 @Override
3437 public List<UserNotificationEvent> findByU_A(long userId, boolean archived) {
3438 return findByU_A(userId, archived, QueryUtil.ALL_POS,
3439 QueryUtil.ALL_POS, null);
3440 }
3441
3442
3455 @Override
3456 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
3457 int start, int end) {
3458 return findByU_A(userId, archived, start, end, null);
3459 }
3460
3461
3475 @Override
3476 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
3477 int start, int end,
3478 OrderByComparator<UserNotificationEvent> orderByComparator) {
3479 return findByU_A(userId, archived, start, end, orderByComparator, true);
3480 }
3481
3482
3497 @Override
3498 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
3499 int start, int end,
3500 OrderByComparator<UserNotificationEvent> orderByComparator,
3501 boolean retrieveFromCache) {
3502 boolean pagination = true;
3503 FinderPath finderPath = null;
3504 Object[] finderArgs = null;
3505
3506 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3507 (orderByComparator == null)) {
3508 pagination = false;
3509 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A;
3510 finderArgs = new Object[] { userId, archived };
3511 }
3512 else {
3513 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A;
3514 finderArgs = new Object[] {
3515 userId, archived,
3516
3517 start, end, orderByComparator
3518 };
3519 }
3520
3521 List<UserNotificationEvent> list = null;
3522
3523 if (retrieveFromCache) {
3524 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
3525 finderArgs, this);
3526
3527 if ((list != null) && !list.isEmpty()) {
3528 for (UserNotificationEvent userNotificationEvent : list) {
3529 if ((userId != userNotificationEvent.getUserId()) ||
3530 (archived != userNotificationEvent.getArchived())) {
3531 list = null;
3532
3533 break;
3534 }
3535 }
3536 }
3537 }
3538
3539 if (list == null) {
3540 StringBundler query = null;
3541
3542 if (orderByComparator != null) {
3543 query = new StringBundler(4 +
3544 (orderByComparator.getOrderByFields().length * 2));
3545 }
3546 else {
3547 query = new StringBundler(4);
3548 }
3549
3550 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3551
3552 query.append(_FINDER_COLUMN_U_A_USERID_2);
3553
3554 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
3555
3556 if (orderByComparator != null) {
3557 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3558 orderByComparator);
3559 }
3560 else
3561 if (pagination) {
3562 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3563 }
3564
3565 String sql = query.toString();
3566
3567 Session session = null;
3568
3569 try {
3570 session = openSession();
3571
3572 Query q = session.createQuery(sql);
3573
3574 QueryPos qPos = QueryPos.getInstance(q);
3575
3576 qPos.add(userId);
3577
3578 qPos.add(archived);
3579
3580 if (!pagination) {
3581 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3582 getDialect(), start, end, false);
3583
3584 Collections.sort(list);
3585
3586 list = Collections.unmodifiableList(list);
3587 }
3588 else {
3589 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3590 getDialect(), start, end);
3591 }
3592
3593 cacheResult(list);
3594
3595 finderCache.putResult(finderPath, finderArgs, list);
3596 }
3597 catch (Exception e) {
3598 finderCache.removeResult(finderPath, finderArgs);
3599
3600 throw processException(e);
3601 }
3602 finally {
3603 closeSession(session);
3604 }
3605 }
3606
3607 return list;
3608 }
3609
3610
3619 @Override
3620 public UserNotificationEvent findByU_A_First(long userId, boolean archived,
3621 OrderByComparator<UserNotificationEvent> orderByComparator)
3622 throws NoSuchUserNotificationEventException {
3623 UserNotificationEvent userNotificationEvent = fetchByU_A_First(userId,
3624 archived, orderByComparator);
3625
3626 if (userNotificationEvent != null) {
3627 return userNotificationEvent;
3628 }
3629
3630 StringBundler msg = new StringBundler(6);
3631
3632 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3633
3634 msg.append("userId=");
3635 msg.append(userId);
3636
3637 msg.append(", archived=");
3638 msg.append(archived);
3639
3640 msg.append(StringPool.CLOSE_CURLY_BRACE);
3641
3642 throw new NoSuchUserNotificationEventException(msg.toString());
3643 }
3644
3645
3653 @Override
3654 public UserNotificationEvent fetchByU_A_First(long userId,
3655 boolean archived,
3656 OrderByComparator<UserNotificationEvent> orderByComparator) {
3657 List<UserNotificationEvent> list = findByU_A(userId, archived, 0, 1,
3658 orderByComparator);
3659
3660 if (!list.isEmpty()) {
3661 return list.get(0);
3662 }
3663
3664 return null;
3665 }
3666
3667
3676 @Override
3677 public UserNotificationEvent findByU_A_Last(long userId, boolean archived,
3678 OrderByComparator<UserNotificationEvent> orderByComparator)
3679 throws NoSuchUserNotificationEventException {
3680 UserNotificationEvent userNotificationEvent = fetchByU_A_Last(userId,
3681 archived, orderByComparator);
3682
3683 if (userNotificationEvent != null) {
3684 return userNotificationEvent;
3685 }
3686
3687 StringBundler msg = new StringBundler(6);
3688
3689 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3690
3691 msg.append("userId=");
3692 msg.append(userId);
3693
3694 msg.append(", archived=");
3695 msg.append(archived);
3696
3697 msg.append(StringPool.CLOSE_CURLY_BRACE);
3698
3699 throw new NoSuchUserNotificationEventException(msg.toString());
3700 }
3701
3702
3710 @Override
3711 public UserNotificationEvent fetchByU_A_Last(long userId, boolean archived,
3712 OrderByComparator<UserNotificationEvent> orderByComparator) {
3713 int count = countByU_A(userId, archived);
3714
3715 if (count == 0) {
3716 return null;
3717 }
3718
3719 List<UserNotificationEvent> list = findByU_A(userId, archived,
3720 count - 1, count, orderByComparator);
3721
3722 if (!list.isEmpty()) {
3723 return list.get(0);
3724 }
3725
3726 return null;
3727 }
3728
3729
3739 @Override
3740 public UserNotificationEvent[] findByU_A_PrevAndNext(
3741 long userNotificationEventId, long userId, boolean archived,
3742 OrderByComparator<UserNotificationEvent> orderByComparator)
3743 throws NoSuchUserNotificationEventException {
3744 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
3745
3746 Session session = null;
3747
3748 try {
3749 session = openSession();
3750
3751 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
3752
3753 array[0] = getByU_A_PrevAndNext(session, userNotificationEvent,
3754 userId, archived, orderByComparator, true);
3755
3756 array[1] = userNotificationEvent;
3757
3758 array[2] = getByU_A_PrevAndNext(session, userNotificationEvent,
3759 userId, archived, orderByComparator, false);
3760
3761 return array;
3762 }
3763 catch (Exception e) {
3764 throw processException(e);
3765 }
3766 finally {
3767 closeSession(session);
3768 }
3769 }
3770
3771 protected UserNotificationEvent getByU_A_PrevAndNext(Session session,
3772 UserNotificationEvent userNotificationEvent, long userId,
3773 boolean archived,
3774 OrderByComparator<UserNotificationEvent> orderByComparator,
3775 boolean previous) {
3776 StringBundler query = null;
3777
3778 if (orderByComparator != null) {
3779 query = new StringBundler(5 +
3780 (orderByComparator.getOrderByConditionFields().length * 3) +
3781 (orderByComparator.getOrderByFields().length * 3));
3782 }
3783 else {
3784 query = new StringBundler(4);
3785 }
3786
3787 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3788
3789 query.append(_FINDER_COLUMN_U_A_USERID_2);
3790
3791 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
3792
3793 if (orderByComparator != null) {
3794 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3795
3796 if (orderByConditionFields.length > 0) {
3797 query.append(WHERE_AND);
3798 }
3799
3800 for (int i = 0; i < orderByConditionFields.length; i++) {
3801 query.append(_ORDER_BY_ENTITY_ALIAS);
3802 query.append(orderByConditionFields[i]);
3803
3804 if ((i + 1) < orderByConditionFields.length) {
3805 if (orderByComparator.isAscending() ^ previous) {
3806 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3807 }
3808 else {
3809 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3810 }
3811 }
3812 else {
3813 if (orderByComparator.isAscending() ^ previous) {
3814 query.append(WHERE_GREATER_THAN);
3815 }
3816 else {
3817 query.append(WHERE_LESSER_THAN);
3818 }
3819 }
3820 }
3821
3822 query.append(ORDER_BY_CLAUSE);
3823
3824 String[] orderByFields = orderByComparator.getOrderByFields();
3825
3826 for (int i = 0; i < orderByFields.length; i++) {
3827 query.append(_ORDER_BY_ENTITY_ALIAS);
3828 query.append(orderByFields[i]);
3829
3830 if ((i + 1) < orderByFields.length) {
3831 if (orderByComparator.isAscending() ^ previous) {
3832 query.append(ORDER_BY_ASC_HAS_NEXT);
3833 }
3834 else {
3835 query.append(ORDER_BY_DESC_HAS_NEXT);
3836 }
3837 }
3838 else {
3839 if (orderByComparator.isAscending() ^ previous) {
3840 query.append(ORDER_BY_ASC);
3841 }
3842 else {
3843 query.append(ORDER_BY_DESC);
3844 }
3845 }
3846 }
3847 }
3848 else {
3849 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3850 }
3851
3852 String sql = query.toString();
3853
3854 Query q = session.createQuery(sql);
3855
3856 q.setFirstResult(0);
3857 q.setMaxResults(2);
3858
3859 QueryPos qPos = QueryPos.getInstance(q);
3860
3861 qPos.add(userId);
3862
3863 qPos.add(archived);
3864
3865 if (orderByComparator != null) {
3866 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
3867
3868 for (Object value : values) {
3869 qPos.add(value);
3870 }
3871 }
3872
3873 List<UserNotificationEvent> list = q.list();
3874
3875 if (list.size() == 2) {
3876 return list.get(1);
3877 }
3878 else {
3879 return null;
3880 }
3881 }
3882
3883
3889 @Override
3890 public void removeByU_A(long userId, boolean archived) {
3891 for (UserNotificationEvent userNotificationEvent : findByU_A(userId,
3892 archived, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3893 remove(userNotificationEvent);
3894 }
3895 }
3896
3897
3904 @Override
3905 public int countByU_A(long userId, boolean archived) {
3906 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_A;
3907
3908 Object[] finderArgs = new Object[] { userId, archived };
3909
3910 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3911
3912 if (count == null) {
3913 StringBundler query = new StringBundler(3);
3914
3915 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
3916
3917 query.append(_FINDER_COLUMN_U_A_USERID_2);
3918
3919 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
3920
3921 String sql = query.toString();
3922
3923 Session session = null;
3924
3925 try {
3926 session = openSession();
3927
3928 Query q = session.createQuery(sql);
3929
3930 QueryPos qPos = QueryPos.getInstance(q);
3931
3932 qPos.add(userId);
3933
3934 qPos.add(archived);
3935
3936 count = (Long)q.uniqueResult();
3937
3938 finderCache.putResult(finderPath, finderArgs, count);
3939 }
3940 catch (Exception e) {
3941 finderCache.removeResult(finderPath, finderArgs);
3942
3943 throw processException(e);
3944 }
3945 finally {
3946 closeSession(session);
3947 }
3948 }
3949
3950 return count.intValue();
3951 }
3952
3953 private static final String _FINDER_COLUMN_U_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
3954 private static final String _FINDER_COLUMN_U_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
3955 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3956 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3957 UserNotificationEventImpl.class,
3958 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_D",
3959 new String[] {
3960 Long.class.getName(), Integer.class.getName(),
3961 Boolean.class.getName(),
3962
3963 Integer.class.getName(), Integer.class.getName(),
3964 OrderByComparator.class.getName()
3965 });
3966 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D =
3967 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3968 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3969 UserNotificationEventImpl.class,
3970 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_D",
3971 new String[] {
3972 Long.class.getName(), Integer.class.getName(),
3973 Boolean.class.getName()
3974 },
3975 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
3976 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
3977 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
3978 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
3979 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3980 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
3981 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_D",
3982 new String[] {
3983 Long.class.getName(), Integer.class.getName(),
3984 Boolean.class.getName()
3985 });
3986
3987
3995 @Override
3996 public List<UserNotificationEvent> findByU_DT_D(long userId,
3997 int deliveryType, boolean delivered) {
3998 return findByU_DT_D(userId, deliveryType, delivered, QueryUtil.ALL_POS,
3999 QueryUtil.ALL_POS, null);
4000 }
4001
4002
4016 @Override
4017 public List<UserNotificationEvent> findByU_DT_D(long userId,
4018 int deliveryType, boolean delivered, int start, int end) {
4019 return findByU_DT_D(userId, deliveryType, delivered, start, end, null);
4020 }
4021
4022
4037 @Override
4038 public List<UserNotificationEvent> findByU_DT_D(long userId,
4039 int deliveryType, boolean delivered, int start, int end,
4040 OrderByComparator<UserNotificationEvent> orderByComparator) {
4041 return findByU_DT_D(userId, deliveryType, delivered, start, end,
4042 orderByComparator, true);
4043 }
4044
4045
4061 @Override
4062 public List<UserNotificationEvent> findByU_DT_D(long userId,
4063 int deliveryType, boolean delivered, int start, int end,
4064 OrderByComparator<UserNotificationEvent> orderByComparator,
4065 boolean retrieveFromCache) {
4066 boolean pagination = true;
4067 FinderPath finderPath = null;
4068 Object[] finderArgs = null;
4069
4070 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4071 (orderByComparator == null)) {
4072 pagination = false;
4073 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D;
4074 finderArgs = new Object[] { userId, deliveryType, delivered };
4075 }
4076 else {
4077 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D;
4078 finderArgs = new Object[] {
4079 userId, deliveryType, delivered,
4080
4081 start, end, orderByComparator
4082 };
4083 }
4084
4085 List<UserNotificationEvent> list = null;
4086
4087 if (retrieveFromCache) {
4088 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
4089 finderArgs, this);
4090
4091 if ((list != null) && !list.isEmpty()) {
4092 for (UserNotificationEvent userNotificationEvent : list) {
4093 if ((userId != userNotificationEvent.getUserId()) ||
4094 (deliveryType != userNotificationEvent.getDeliveryType()) ||
4095 (delivered != userNotificationEvent.getDelivered())) {
4096 list = null;
4097
4098 break;
4099 }
4100 }
4101 }
4102 }
4103
4104 if (list == null) {
4105 StringBundler query = null;
4106
4107 if (orderByComparator != null) {
4108 query = new StringBundler(5 +
4109 (orderByComparator.getOrderByFields().length * 2));
4110 }
4111 else {
4112 query = new StringBundler(5);
4113 }
4114
4115 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4116
4117 query.append(_FINDER_COLUMN_U_DT_D_USERID_2);
4118
4119 query.append(_FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2);
4120
4121 query.append(_FINDER_COLUMN_U_DT_D_DELIVERED_2);
4122
4123 if (orderByComparator != null) {
4124 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4125 orderByComparator);
4126 }
4127 else
4128 if (pagination) {
4129 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
4130 }
4131
4132 String sql = query.toString();
4133
4134 Session session = null;
4135
4136 try {
4137 session = openSession();
4138
4139 Query q = session.createQuery(sql);
4140
4141 QueryPos qPos = QueryPos.getInstance(q);
4142
4143 qPos.add(userId);
4144
4145 qPos.add(deliveryType);
4146
4147 qPos.add(delivered);
4148
4149 if (!pagination) {
4150 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4151 getDialect(), start, end, false);
4152
4153 Collections.sort(list);
4154
4155 list = Collections.unmodifiableList(list);
4156 }
4157 else {
4158 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4159 getDialect(), start, end);
4160 }
4161
4162 cacheResult(list);
4163
4164 finderCache.putResult(finderPath, finderArgs, list);
4165 }
4166 catch (Exception e) {
4167 finderCache.removeResult(finderPath, finderArgs);
4168
4169 throw processException(e);
4170 }
4171 finally {
4172 closeSession(session);
4173 }
4174 }
4175
4176 return list;
4177 }
4178
4179
4189 @Override
4190 public UserNotificationEvent findByU_DT_D_First(long userId,
4191 int deliveryType, boolean delivered,
4192 OrderByComparator<UserNotificationEvent> orderByComparator)
4193 throws NoSuchUserNotificationEventException {
4194 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_First(userId,
4195 deliveryType, delivered, orderByComparator);
4196
4197 if (userNotificationEvent != null) {
4198 return userNotificationEvent;
4199 }
4200
4201 StringBundler msg = new StringBundler(8);
4202
4203 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4204
4205 msg.append("userId=");
4206 msg.append(userId);
4207
4208 msg.append(", deliveryType=");
4209 msg.append(deliveryType);
4210
4211 msg.append(", delivered=");
4212 msg.append(delivered);
4213
4214 msg.append(StringPool.CLOSE_CURLY_BRACE);
4215
4216 throw new NoSuchUserNotificationEventException(msg.toString());
4217 }
4218
4219
4228 @Override
4229 public UserNotificationEvent fetchByU_DT_D_First(long userId,
4230 int deliveryType, boolean delivered,
4231 OrderByComparator<UserNotificationEvent> orderByComparator) {
4232 List<UserNotificationEvent> list = findByU_DT_D(userId, deliveryType,
4233 delivered, 0, 1, orderByComparator);
4234
4235 if (!list.isEmpty()) {
4236 return list.get(0);
4237 }
4238
4239 return null;
4240 }
4241
4242
4252 @Override
4253 public UserNotificationEvent findByU_DT_D_Last(long userId,
4254 int deliveryType, boolean delivered,
4255 OrderByComparator<UserNotificationEvent> orderByComparator)
4256 throws NoSuchUserNotificationEventException {
4257 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_Last(userId,
4258 deliveryType, delivered, orderByComparator);
4259
4260 if (userNotificationEvent != null) {
4261 return userNotificationEvent;
4262 }
4263
4264 StringBundler msg = new StringBundler(8);
4265
4266 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4267
4268 msg.append("userId=");
4269 msg.append(userId);
4270
4271 msg.append(", deliveryType=");
4272 msg.append(deliveryType);
4273
4274 msg.append(", delivered=");
4275 msg.append(delivered);
4276
4277 msg.append(StringPool.CLOSE_CURLY_BRACE);
4278
4279 throw new NoSuchUserNotificationEventException(msg.toString());
4280 }
4281
4282
4291 @Override
4292 public UserNotificationEvent fetchByU_DT_D_Last(long userId,
4293 int deliveryType, boolean delivered,
4294 OrderByComparator<UserNotificationEvent> orderByComparator) {
4295 int count = countByU_DT_D(userId, deliveryType, delivered);
4296
4297 if (count == 0) {
4298 return null;
4299 }
4300
4301 List<UserNotificationEvent> list = findByU_DT_D(userId, deliveryType,
4302 delivered, count - 1, count, orderByComparator);
4303
4304 if (!list.isEmpty()) {
4305 return list.get(0);
4306 }
4307
4308 return null;
4309 }
4310
4311
4322 @Override
4323 public UserNotificationEvent[] findByU_DT_D_PrevAndNext(
4324 long userNotificationEventId, long userId, int deliveryType,
4325 boolean delivered,
4326 OrderByComparator<UserNotificationEvent> orderByComparator)
4327 throws NoSuchUserNotificationEventException {
4328 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
4329
4330 Session session = null;
4331
4332 try {
4333 session = openSession();
4334
4335 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
4336
4337 array[0] = getByU_DT_D_PrevAndNext(session, userNotificationEvent,
4338 userId, deliveryType, delivered, orderByComparator, true);
4339
4340 array[1] = userNotificationEvent;
4341
4342 array[2] = getByU_DT_D_PrevAndNext(session, userNotificationEvent,
4343 userId, deliveryType, delivered, orderByComparator, false);
4344
4345 return array;
4346 }
4347 catch (Exception e) {
4348 throw processException(e);
4349 }
4350 finally {
4351 closeSession(session);
4352 }
4353 }
4354
4355 protected UserNotificationEvent getByU_DT_D_PrevAndNext(Session session,
4356 UserNotificationEvent userNotificationEvent, long userId,
4357 int deliveryType, boolean delivered,
4358 OrderByComparator<UserNotificationEvent> orderByComparator,
4359 boolean previous) {
4360 StringBundler query = null;
4361
4362 if (orderByComparator != null) {
4363 query = new StringBundler(6 +
4364 (orderByComparator.getOrderByConditionFields().length * 3) +
4365 (orderByComparator.getOrderByFields().length * 3));
4366 }
4367 else {
4368 query = new StringBundler(5);
4369 }
4370
4371 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4372
4373 query.append(_FINDER_COLUMN_U_DT_D_USERID_2);
4374
4375 query.append(_FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2);
4376
4377 query.append(_FINDER_COLUMN_U_DT_D_DELIVERED_2);
4378
4379 if (orderByComparator != null) {
4380 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4381
4382 if (orderByConditionFields.length > 0) {
4383 query.append(WHERE_AND);
4384 }
4385
4386 for (int i = 0; i < orderByConditionFields.length; i++) {
4387 query.append(_ORDER_BY_ENTITY_ALIAS);
4388 query.append(orderByConditionFields[i]);
4389
4390 if ((i + 1) < orderByConditionFields.length) {
4391 if (orderByComparator.isAscending() ^ previous) {
4392 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4393 }
4394 else {
4395 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4396 }
4397 }
4398 else {
4399 if (orderByComparator.isAscending() ^ previous) {
4400 query.append(WHERE_GREATER_THAN);
4401 }
4402 else {
4403 query.append(WHERE_LESSER_THAN);
4404 }
4405 }
4406 }
4407
4408 query.append(ORDER_BY_CLAUSE);
4409
4410 String[] orderByFields = orderByComparator.getOrderByFields();
4411
4412 for (int i = 0; i < orderByFields.length; i++) {
4413 query.append(_ORDER_BY_ENTITY_ALIAS);
4414 query.append(orderByFields[i]);
4415
4416 if ((i + 1) < orderByFields.length) {
4417 if (orderByComparator.isAscending() ^ previous) {
4418 query.append(ORDER_BY_ASC_HAS_NEXT);
4419 }
4420 else {
4421 query.append(ORDER_BY_DESC_HAS_NEXT);
4422 }
4423 }
4424 else {
4425 if (orderByComparator.isAscending() ^ previous) {
4426 query.append(ORDER_BY_ASC);
4427 }
4428 else {
4429 query.append(ORDER_BY_DESC);
4430 }
4431 }
4432 }
4433 }
4434 else {
4435 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
4436 }
4437
4438 String sql = query.toString();
4439
4440 Query q = session.createQuery(sql);
4441
4442 q.setFirstResult(0);
4443 q.setMaxResults(2);
4444
4445 QueryPos qPos = QueryPos.getInstance(q);
4446
4447 qPos.add(userId);
4448
4449 qPos.add(deliveryType);
4450
4451 qPos.add(delivered);
4452
4453 if (orderByComparator != null) {
4454 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
4455
4456 for (Object value : values) {
4457 qPos.add(value);
4458 }
4459 }
4460
4461 List<UserNotificationEvent> list = q.list();
4462
4463 if (list.size() == 2) {
4464 return list.get(1);
4465 }
4466 else {
4467 return null;
4468 }
4469 }
4470
4471
4478 @Override
4479 public void removeByU_DT_D(long userId, int deliveryType, boolean delivered) {
4480 for (UserNotificationEvent userNotificationEvent : findByU_DT_D(
4481 userId, deliveryType, delivered, QueryUtil.ALL_POS,
4482 QueryUtil.ALL_POS, null)) {
4483 remove(userNotificationEvent);
4484 }
4485 }
4486
4487
4495 @Override
4496 public int countByU_DT_D(long userId, int deliveryType, boolean delivered) {
4497 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_D;
4498
4499 Object[] finderArgs = new Object[] { userId, deliveryType, delivered };
4500
4501 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4502
4503 if (count == null) {
4504 StringBundler query = new StringBundler(4);
4505
4506 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
4507
4508 query.append(_FINDER_COLUMN_U_DT_D_USERID_2);
4509
4510 query.append(_FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2);
4511
4512 query.append(_FINDER_COLUMN_U_DT_D_DELIVERED_2);
4513
4514 String sql = query.toString();
4515
4516 Session session = null;
4517
4518 try {
4519 session = openSession();
4520
4521 Query q = session.createQuery(sql);
4522
4523 QueryPos qPos = QueryPos.getInstance(q);
4524
4525 qPos.add(userId);
4526
4527 qPos.add(deliveryType);
4528
4529 qPos.add(delivered);
4530
4531 count = (Long)q.uniqueResult();
4532
4533 finderCache.putResult(finderPath, finderArgs, count);
4534 }
4535 catch (Exception e) {
4536 finderCache.removeResult(finderPath, finderArgs);
4537
4538 throw processException(e);
4539 }
4540 finally {
4541 closeSession(session);
4542 }
4543 }
4544
4545 return count.intValue();
4546 }
4547
4548 private static final String _FINDER_COLUMN_U_DT_D_USERID_2 = "userNotificationEvent.userId = ? AND ";
4549 private static final String _FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
4550 private static final String _FINDER_COLUMN_U_DT_D_DELIVERED_2 = "userNotificationEvent.delivered = ?";
4551 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4552 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
4553 UserNotificationEventImpl.class,
4554 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_A",
4555 new String[] {
4556 Long.class.getName(), Integer.class.getName(),
4557 Boolean.class.getName(),
4558
4559 Integer.class.getName(), Integer.class.getName(),
4560 OrderByComparator.class.getName()
4561 });
4562 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A =
4563 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4564 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
4565 UserNotificationEventImpl.class,
4566 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_A",
4567 new String[] {
4568 Long.class.getName(), Integer.class.getName(),
4569 Boolean.class.getName()
4570 },
4571 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
4572 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
4573 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
4574 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
4575 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4576 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
4577 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_A",
4578 new String[] {
4579 Long.class.getName(), Integer.class.getName(),
4580 Boolean.class.getName()
4581 });
4582
4583
4591 @Override
4592 public List<UserNotificationEvent> findByU_DT_A(long userId,
4593 int deliveryType, boolean archived) {
4594 return findByU_DT_A(userId, deliveryType, archived, QueryUtil.ALL_POS,
4595 QueryUtil.ALL_POS, null);
4596 }
4597
4598
4612 @Override
4613 public List<UserNotificationEvent> findByU_DT_A(long userId,
4614 int deliveryType, boolean archived, int start, int end) {
4615 return findByU_DT_A(userId, deliveryType, archived, start, end, null);
4616 }
4617
4618
4633 @Override
4634 public List<UserNotificationEvent> findByU_DT_A(long userId,
4635 int deliveryType, boolean archived, int start, int end,
4636 OrderByComparator<UserNotificationEvent> orderByComparator) {
4637 return findByU_DT_A(userId, deliveryType, archived, start, end,
4638 orderByComparator, true);
4639 }
4640
4641
4657 @Override
4658 public List<UserNotificationEvent> findByU_DT_A(long userId,
4659 int deliveryType, boolean archived, int start, int end,
4660 OrderByComparator<UserNotificationEvent> orderByComparator,
4661 boolean retrieveFromCache) {
4662 boolean pagination = true;
4663 FinderPath finderPath = null;
4664 Object[] finderArgs = null;
4665
4666 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4667 (orderByComparator == null)) {
4668 pagination = false;
4669 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A;
4670 finderArgs = new Object[] { userId, deliveryType, archived };
4671 }
4672 else {
4673 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A;
4674 finderArgs = new Object[] {
4675 userId, deliveryType, archived,
4676
4677 start, end, orderByComparator
4678 };
4679 }
4680
4681 List<UserNotificationEvent> list = null;
4682
4683 if (retrieveFromCache) {
4684 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
4685 finderArgs, this);
4686
4687 if ((list != null) && !list.isEmpty()) {
4688 for (UserNotificationEvent userNotificationEvent : list) {
4689 if ((userId != userNotificationEvent.getUserId()) ||
4690 (deliveryType != userNotificationEvent.getDeliveryType()) ||
4691 (archived != userNotificationEvent.getArchived())) {
4692 list = null;
4693
4694 break;
4695 }
4696 }
4697 }
4698 }
4699
4700 if (list == null) {
4701 StringBundler query = null;
4702
4703 if (orderByComparator != null) {
4704 query = new StringBundler(5 +
4705 (orderByComparator.getOrderByFields().length * 2));
4706 }
4707 else {
4708 query = new StringBundler(5);
4709 }
4710
4711 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4712
4713 query.append(_FINDER_COLUMN_U_DT_A_USERID_2);
4714
4715 query.append(_FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2);
4716
4717 query.append(_FINDER_COLUMN_U_DT_A_ARCHIVED_2);
4718
4719 if (orderByComparator != null) {
4720 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4721 orderByComparator);
4722 }
4723 else
4724 if (pagination) {
4725 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
4726 }
4727
4728 String sql = query.toString();
4729
4730 Session session = null;
4731
4732 try {
4733 session = openSession();
4734
4735 Query q = session.createQuery(sql);
4736
4737 QueryPos qPos = QueryPos.getInstance(q);
4738
4739 qPos.add(userId);
4740
4741 qPos.add(deliveryType);
4742
4743 qPos.add(archived);
4744
4745 if (!pagination) {
4746 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4747 getDialect(), start, end, false);
4748
4749 Collections.sort(list);
4750
4751 list = Collections.unmodifiableList(list);
4752 }
4753 else {
4754 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4755 getDialect(), start, end);
4756 }
4757
4758 cacheResult(list);
4759
4760 finderCache.putResult(finderPath, finderArgs, list);
4761 }
4762 catch (Exception e) {
4763 finderCache.removeResult(finderPath, finderArgs);
4764
4765 throw processException(e);
4766 }
4767 finally {
4768 closeSession(session);
4769 }
4770 }
4771
4772 return list;
4773 }
4774
4775
4785 @Override
4786 public UserNotificationEvent findByU_DT_A_First(long userId,
4787 int deliveryType, boolean archived,
4788 OrderByComparator<UserNotificationEvent> orderByComparator)
4789 throws NoSuchUserNotificationEventException {
4790 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_First(userId,
4791 deliveryType, archived, orderByComparator);
4792
4793 if (userNotificationEvent != null) {
4794 return userNotificationEvent;
4795 }
4796
4797 StringBundler msg = new StringBundler(8);
4798
4799 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4800
4801 msg.append("userId=");
4802 msg.append(userId);
4803
4804 msg.append(", deliveryType=");
4805 msg.append(deliveryType);
4806
4807 msg.append(", archived=");
4808 msg.append(archived);
4809
4810 msg.append(StringPool.CLOSE_CURLY_BRACE);
4811
4812 throw new NoSuchUserNotificationEventException(msg.toString());
4813 }
4814
4815
4824 @Override
4825 public UserNotificationEvent fetchByU_DT_A_First(long userId,
4826 int deliveryType, boolean archived,
4827 OrderByComparator<UserNotificationEvent> orderByComparator) {
4828 List<UserNotificationEvent> list = findByU_DT_A(userId, deliveryType,
4829 archived, 0, 1, orderByComparator);
4830
4831 if (!list.isEmpty()) {
4832 return list.get(0);
4833 }
4834
4835 return null;
4836 }
4837
4838
4848 @Override
4849 public UserNotificationEvent findByU_DT_A_Last(long userId,
4850 int deliveryType, boolean archived,
4851 OrderByComparator<UserNotificationEvent> orderByComparator)
4852 throws NoSuchUserNotificationEventException {
4853 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_Last(userId,
4854 deliveryType, archived, orderByComparator);
4855
4856 if (userNotificationEvent != null) {
4857 return userNotificationEvent;
4858 }
4859
4860 StringBundler msg = new StringBundler(8);
4861
4862 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4863
4864 msg.append("userId=");
4865 msg.append(userId);
4866
4867 msg.append(", deliveryType=");
4868 msg.append(deliveryType);
4869
4870 msg.append(", archived=");
4871 msg.append(archived);
4872
4873 msg.append(StringPool.CLOSE_CURLY_BRACE);
4874
4875 throw new NoSuchUserNotificationEventException(msg.toString());
4876 }
4877
4878
4887 @Override
4888 public UserNotificationEvent fetchByU_DT_A_Last(long userId,
4889 int deliveryType, boolean archived,
4890 OrderByComparator<UserNotificationEvent> orderByComparator) {
4891 int count = countByU_DT_A(userId, deliveryType, archived);
4892
4893 if (count == 0) {
4894 return null;
4895 }
4896
4897 List<UserNotificationEvent> list = findByU_DT_A(userId, deliveryType,
4898 archived, count - 1, count, orderByComparator);
4899
4900 if (!list.isEmpty()) {
4901 return list.get(0);
4902 }
4903
4904 return null;
4905 }
4906
4907
4918 @Override
4919 public UserNotificationEvent[] findByU_DT_A_PrevAndNext(
4920 long userNotificationEventId, long userId, int deliveryType,
4921 boolean archived,
4922 OrderByComparator<UserNotificationEvent> orderByComparator)
4923 throws NoSuchUserNotificationEventException {
4924 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
4925
4926 Session session = null;
4927
4928 try {
4929 session = openSession();
4930
4931 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
4932
4933 array[0] = getByU_DT_A_PrevAndNext(session, userNotificationEvent,
4934 userId, deliveryType, archived, orderByComparator, true);
4935
4936 array[1] = userNotificationEvent;
4937
4938 array[2] = getByU_DT_A_PrevAndNext(session, userNotificationEvent,
4939 userId, deliveryType, archived, orderByComparator, false);
4940
4941 return array;
4942 }
4943 catch (Exception e) {
4944 throw processException(e);
4945 }
4946 finally {
4947 closeSession(session);
4948 }
4949 }
4950
4951 protected UserNotificationEvent getByU_DT_A_PrevAndNext(Session session,
4952 UserNotificationEvent userNotificationEvent, long userId,
4953 int deliveryType, boolean archived,
4954 OrderByComparator<UserNotificationEvent> orderByComparator,
4955 boolean previous) {
4956 StringBundler query = null;
4957
4958 if (orderByComparator != null) {
4959 query = new StringBundler(6 +
4960 (orderByComparator.getOrderByConditionFields().length * 3) +
4961 (orderByComparator.getOrderByFields().length * 3));
4962 }
4963 else {
4964 query = new StringBundler(5);
4965 }
4966
4967 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4968
4969 query.append(_FINDER_COLUMN_U_DT_A_USERID_2);
4970
4971 query.append(_FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2);
4972
4973 query.append(_FINDER_COLUMN_U_DT_A_ARCHIVED_2);
4974
4975 if (orderByComparator != null) {
4976 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4977
4978 if (orderByConditionFields.length > 0) {
4979 query.append(WHERE_AND);
4980 }
4981
4982 for (int i = 0; i < orderByConditionFields.length; i++) {
4983 query.append(_ORDER_BY_ENTITY_ALIAS);
4984 query.append(orderByConditionFields[i]);
4985
4986 if ((i + 1) < orderByConditionFields.length) {
4987 if (orderByComparator.isAscending() ^ previous) {
4988 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4989 }
4990 else {
4991 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4992 }
4993 }
4994 else {
4995 if (orderByComparator.isAscending() ^ previous) {
4996 query.append(WHERE_GREATER_THAN);
4997 }
4998 else {
4999 query.append(WHERE_LESSER_THAN);
5000 }
5001 }
5002 }
5003
5004 query.append(ORDER_BY_CLAUSE);
5005
5006 String[] orderByFields = orderByComparator.getOrderByFields();
5007
5008 for (int i = 0; i < orderByFields.length; i++) {
5009 query.append(_ORDER_BY_ENTITY_ALIAS);
5010 query.append(orderByFields[i]);
5011
5012 if ((i + 1) < orderByFields.length) {
5013 if (orderByComparator.isAscending() ^ previous) {
5014 query.append(ORDER_BY_ASC_HAS_NEXT);
5015 }
5016 else {
5017 query.append(ORDER_BY_DESC_HAS_NEXT);
5018 }
5019 }
5020 else {
5021 if (orderByComparator.isAscending() ^ previous) {
5022 query.append(ORDER_BY_ASC);
5023 }
5024 else {
5025 query.append(ORDER_BY_DESC);
5026 }
5027 }
5028 }
5029 }
5030 else {
5031 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5032 }
5033
5034 String sql = query.toString();
5035
5036 Query q = session.createQuery(sql);
5037
5038 q.setFirstResult(0);
5039 q.setMaxResults(2);
5040
5041 QueryPos qPos = QueryPos.getInstance(q);
5042
5043 qPos.add(userId);
5044
5045 qPos.add(deliveryType);
5046
5047 qPos.add(archived);
5048
5049 if (orderByComparator != null) {
5050 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
5051
5052 for (Object value : values) {
5053 qPos.add(value);
5054 }
5055 }
5056
5057 List<UserNotificationEvent> list = q.list();
5058
5059 if (list.size() == 2) {
5060 return list.get(1);
5061 }
5062 else {
5063 return null;
5064 }
5065 }
5066
5067
5074 @Override
5075 public void removeByU_DT_A(long userId, int deliveryType, boolean archived) {
5076 for (UserNotificationEvent userNotificationEvent : findByU_DT_A(
5077 userId, deliveryType, archived, QueryUtil.ALL_POS,
5078 QueryUtil.ALL_POS, null)) {
5079 remove(userNotificationEvent);
5080 }
5081 }
5082
5083
5091 @Override
5092 public int countByU_DT_A(long userId, int deliveryType, boolean archived) {
5093 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_A;
5094
5095 Object[] finderArgs = new Object[] { userId, deliveryType, archived };
5096
5097 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5098
5099 if (count == null) {
5100 StringBundler query = new StringBundler(4);
5101
5102 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
5103
5104 query.append(_FINDER_COLUMN_U_DT_A_USERID_2);
5105
5106 query.append(_FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2);
5107
5108 query.append(_FINDER_COLUMN_U_DT_A_ARCHIVED_2);
5109
5110 String sql = query.toString();
5111
5112 Session session = null;
5113
5114 try {
5115 session = openSession();
5116
5117 Query q = session.createQuery(sql);
5118
5119 QueryPos qPos = QueryPos.getInstance(q);
5120
5121 qPos.add(userId);
5122
5123 qPos.add(deliveryType);
5124
5125 qPos.add(archived);
5126
5127 count = (Long)q.uniqueResult();
5128
5129 finderCache.putResult(finderPath, finderArgs, count);
5130 }
5131 catch (Exception e) {
5132 finderCache.removeResult(finderPath, finderArgs);
5133
5134 throw processException(e);
5135 }
5136 finally {
5137 closeSession(session);
5138 }
5139 }
5140
5141 return count.intValue();
5142 }
5143
5144 private static final String _FINDER_COLUMN_U_DT_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
5145 private static final String _FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
5146 private static final String _FINDER_COLUMN_U_DT_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
5147 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5148 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5149 UserNotificationEventImpl.class,
5150 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_D_A",
5151 new String[] {
5152 Long.class.getName(), Boolean.class.getName(),
5153 Boolean.class.getName(),
5154
5155 Integer.class.getName(), Integer.class.getName(),
5156 OrderByComparator.class.getName()
5157 });
5158 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5159 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5160 UserNotificationEventImpl.class,
5161 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_D_A",
5162 new String[] {
5163 Long.class.getName(), Boolean.class.getName(),
5164 Boolean.class.getName()
5165 },
5166 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
5167 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
5168 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
5169 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
5170 public static final FinderPath FINDER_PATH_COUNT_BY_U_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5171 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
5172 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_D_A",
5173 new String[] {
5174 Long.class.getName(), Boolean.class.getName(),
5175 Boolean.class.getName()
5176 });
5177
5178
5186 @Override
5187 public List<UserNotificationEvent> findByU_D_A(long userId,
5188 boolean delivered, boolean actionRequired) {
5189 return findByU_D_A(userId, delivered, actionRequired,
5190 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5191 }
5192
5193
5207 @Override
5208 public List<UserNotificationEvent> findByU_D_A(long userId,
5209 boolean delivered, boolean actionRequired, int start, int end) {
5210 return findByU_D_A(userId, delivered, actionRequired, start, end, null);
5211 }
5212
5213
5228 @Override
5229 public List<UserNotificationEvent> findByU_D_A(long userId,
5230 boolean delivered, boolean actionRequired, int start, int end,
5231 OrderByComparator<UserNotificationEvent> orderByComparator) {
5232 return findByU_D_A(userId, delivered, actionRequired, start, end,
5233 orderByComparator, true);
5234 }
5235
5236
5252 @Override
5253 public List<UserNotificationEvent> findByU_D_A(long userId,
5254 boolean delivered, boolean actionRequired, int start, int end,
5255 OrderByComparator<UserNotificationEvent> orderByComparator,
5256 boolean retrieveFromCache) {
5257 boolean pagination = true;
5258 FinderPath finderPath = null;
5259 Object[] finderArgs = null;
5260
5261 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5262 (orderByComparator == null)) {
5263 pagination = false;
5264 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A;
5265 finderArgs = new Object[] { userId, delivered, actionRequired };
5266 }
5267 else {
5268 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D_A;
5269 finderArgs = new Object[] {
5270 userId, delivered, actionRequired,
5271
5272 start, end, orderByComparator
5273 };
5274 }
5275
5276 List<UserNotificationEvent> list = null;
5277
5278 if (retrieveFromCache) {
5279 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
5280 finderArgs, this);
5281
5282 if ((list != null) && !list.isEmpty()) {
5283 for (UserNotificationEvent userNotificationEvent : list) {
5284 if ((userId != userNotificationEvent.getUserId()) ||
5285 (delivered != userNotificationEvent.getDelivered()) ||
5286 (actionRequired != userNotificationEvent.getActionRequired())) {
5287 list = null;
5288
5289 break;
5290 }
5291 }
5292 }
5293 }
5294
5295 if (list == null) {
5296 StringBundler query = null;
5297
5298 if (orderByComparator != null) {
5299 query = new StringBundler(5 +
5300 (orderByComparator.getOrderByFields().length * 2));
5301 }
5302 else {
5303 query = new StringBundler(5);
5304 }
5305
5306 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5307
5308 query.append(_FINDER_COLUMN_U_D_A_USERID_2);
5309
5310 query.append(_FINDER_COLUMN_U_D_A_DELIVERED_2);
5311
5312 query.append(_FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2);
5313
5314 if (orderByComparator != null) {
5315 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5316 orderByComparator);
5317 }
5318 else
5319 if (pagination) {
5320 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5321 }
5322
5323 String sql = query.toString();
5324
5325 Session session = null;
5326
5327 try {
5328 session = openSession();
5329
5330 Query q = session.createQuery(sql);
5331
5332 QueryPos qPos = QueryPos.getInstance(q);
5333
5334 qPos.add(userId);
5335
5336 qPos.add(delivered);
5337
5338 qPos.add(actionRequired);
5339
5340 if (!pagination) {
5341 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5342 getDialect(), start, end, false);
5343
5344 Collections.sort(list);
5345
5346 list = Collections.unmodifiableList(list);
5347 }
5348 else {
5349 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5350 getDialect(), start, end);
5351 }
5352
5353 cacheResult(list);
5354
5355 finderCache.putResult(finderPath, finderArgs, list);
5356 }
5357 catch (Exception e) {
5358 finderCache.removeResult(finderPath, finderArgs);
5359
5360 throw processException(e);
5361 }
5362 finally {
5363 closeSession(session);
5364 }
5365 }
5366
5367 return list;
5368 }
5369
5370
5380 @Override
5381 public UserNotificationEvent findByU_D_A_First(long userId,
5382 boolean delivered, boolean actionRequired,
5383 OrderByComparator<UserNotificationEvent> orderByComparator)
5384 throws NoSuchUserNotificationEventException {
5385 UserNotificationEvent userNotificationEvent = fetchByU_D_A_First(userId,
5386 delivered, actionRequired, orderByComparator);
5387
5388 if (userNotificationEvent != null) {
5389 return userNotificationEvent;
5390 }
5391
5392 StringBundler msg = new StringBundler(8);
5393
5394 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5395
5396 msg.append("userId=");
5397 msg.append(userId);
5398
5399 msg.append(", delivered=");
5400 msg.append(delivered);
5401
5402 msg.append(", actionRequired=");
5403 msg.append(actionRequired);
5404
5405 msg.append(StringPool.CLOSE_CURLY_BRACE);
5406
5407 throw new NoSuchUserNotificationEventException(msg.toString());
5408 }
5409
5410
5419 @Override
5420 public UserNotificationEvent fetchByU_D_A_First(long userId,
5421 boolean delivered, boolean actionRequired,
5422 OrderByComparator<UserNotificationEvent> orderByComparator) {
5423 List<UserNotificationEvent> list = findByU_D_A(userId, delivered,
5424 actionRequired, 0, 1, orderByComparator);
5425
5426 if (!list.isEmpty()) {
5427 return list.get(0);
5428 }
5429
5430 return null;
5431 }
5432
5433
5443 @Override
5444 public UserNotificationEvent findByU_D_A_Last(long userId,
5445 boolean delivered, boolean actionRequired,
5446 OrderByComparator<UserNotificationEvent> orderByComparator)
5447 throws NoSuchUserNotificationEventException {
5448 UserNotificationEvent userNotificationEvent = fetchByU_D_A_Last(userId,
5449 delivered, actionRequired, orderByComparator);
5450
5451 if (userNotificationEvent != null) {
5452 return userNotificationEvent;
5453 }
5454
5455 StringBundler msg = new StringBundler(8);
5456
5457 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5458
5459 msg.append("userId=");
5460 msg.append(userId);
5461
5462 msg.append(", delivered=");
5463 msg.append(delivered);
5464
5465 msg.append(", actionRequired=");
5466 msg.append(actionRequired);
5467
5468 msg.append(StringPool.CLOSE_CURLY_BRACE);
5469
5470 throw new NoSuchUserNotificationEventException(msg.toString());
5471 }
5472
5473
5482 @Override
5483 public UserNotificationEvent fetchByU_D_A_Last(long userId,
5484 boolean delivered, boolean actionRequired,
5485 OrderByComparator<UserNotificationEvent> orderByComparator) {
5486 int count = countByU_D_A(userId, delivered, actionRequired);
5487
5488 if (count == 0) {
5489 return null;
5490 }
5491
5492 List<UserNotificationEvent> list = findByU_D_A(userId, delivered,
5493 actionRequired, count - 1, count, orderByComparator);
5494
5495 if (!list.isEmpty()) {
5496 return list.get(0);
5497 }
5498
5499 return null;
5500 }
5501
5502
5513 @Override
5514 public UserNotificationEvent[] findByU_D_A_PrevAndNext(
5515 long userNotificationEventId, long userId, boolean delivered,
5516 boolean actionRequired,
5517 OrderByComparator<UserNotificationEvent> orderByComparator)
5518 throws NoSuchUserNotificationEventException {
5519 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
5520
5521 Session session = null;
5522
5523 try {
5524 session = openSession();
5525
5526 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
5527
5528 array[0] = getByU_D_A_PrevAndNext(session, userNotificationEvent,
5529 userId, delivered, actionRequired, orderByComparator, true);
5530
5531 array[1] = userNotificationEvent;
5532
5533 array[2] = getByU_D_A_PrevAndNext(session, userNotificationEvent,
5534 userId, delivered, actionRequired, orderByComparator, false);
5535
5536 return array;
5537 }
5538 catch (Exception e) {
5539 throw processException(e);
5540 }
5541 finally {
5542 closeSession(session);
5543 }
5544 }
5545
5546 protected UserNotificationEvent getByU_D_A_PrevAndNext(Session session,
5547 UserNotificationEvent userNotificationEvent, long userId,
5548 boolean delivered, boolean actionRequired,
5549 OrderByComparator<UserNotificationEvent> orderByComparator,
5550 boolean previous) {
5551 StringBundler query = null;
5552
5553 if (orderByComparator != null) {
5554 query = new StringBundler(6 +
5555 (orderByComparator.getOrderByConditionFields().length * 3) +
5556 (orderByComparator.getOrderByFields().length * 3));
5557 }
5558 else {
5559 query = new StringBundler(5);
5560 }
5561
5562 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5563
5564 query.append(_FINDER_COLUMN_U_D_A_USERID_2);
5565
5566 query.append(_FINDER_COLUMN_U_D_A_DELIVERED_2);
5567
5568 query.append(_FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2);
5569
5570 if (orderByComparator != null) {
5571 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5572
5573 if (orderByConditionFields.length > 0) {
5574 query.append(WHERE_AND);
5575 }
5576
5577 for (int i = 0; i < orderByConditionFields.length; i++) {
5578 query.append(_ORDER_BY_ENTITY_ALIAS);
5579 query.append(orderByConditionFields[i]);
5580
5581 if ((i + 1) < orderByConditionFields.length) {
5582 if (orderByComparator.isAscending() ^ previous) {
5583 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5584 }
5585 else {
5586 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5587 }
5588 }
5589 else {
5590 if (orderByComparator.isAscending() ^ previous) {
5591 query.append(WHERE_GREATER_THAN);
5592 }
5593 else {
5594 query.append(WHERE_LESSER_THAN);
5595 }
5596 }
5597 }
5598
5599 query.append(ORDER_BY_CLAUSE);
5600
5601 String[] orderByFields = orderByComparator.getOrderByFields();
5602
5603 for (int i = 0; i < orderByFields.length; i++) {
5604 query.append(_ORDER_BY_ENTITY_ALIAS);
5605 query.append(orderByFields[i]);
5606
5607 if ((i + 1) < orderByFields.length) {
5608 if (orderByComparator.isAscending() ^ previous) {
5609 query.append(ORDER_BY_ASC_HAS_NEXT);
5610 }
5611 else {
5612 query.append(ORDER_BY_DESC_HAS_NEXT);
5613 }
5614 }
5615 else {
5616 if (orderByComparator.isAscending() ^ previous) {
5617 query.append(ORDER_BY_ASC);
5618 }
5619 else {
5620 query.append(ORDER_BY_DESC);
5621 }
5622 }
5623 }
5624 }
5625 else {
5626 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5627 }
5628
5629 String sql = query.toString();
5630
5631 Query q = session.createQuery(sql);
5632
5633 q.setFirstResult(0);
5634 q.setMaxResults(2);
5635
5636 QueryPos qPos = QueryPos.getInstance(q);
5637
5638 qPos.add(userId);
5639
5640 qPos.add(delivered);
5641
5642 qPos.add(actionRequired);
5643
5644 if (orderByComparator != null) {
5645 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
5646
5647 for (Object value : values) {
5648 qPos.add(value);
5649 }
5650 }
5651
5652 List<UserNotificationEvent> list = q.list();
5653
5654 if (list.size() == 2) {
5655 return list.get(1);
5656 }
5657 else {
5658 return null;
5659 }
5660 }
5661
5662
5669 @Override
5670 public void removeByU_D_A(long userId, boolean delivered,
5671 boolean actionRequired) {
5672 for (UserNotificationEvent userNotificationEvent : findByU_D_A(userId,
5673 delivered, actionRequired, QueryUtil.ALL_POS,
5674 QueryUtil.ALL_POS, null)) {
5675 remove(userNotificationEvent);
5676 }
5677 }
5678
5679
5687 @Override
5688 public int countByU_D_A(long userId, boolean delivered,
5689 boolean actionRequired) {
5690 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_D_A;
5691
5692 Object[] finderArgs = new Object[] { userId, delivered, actionRequired };
5693
5694 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5695
5696 if (count == null) {
5697 StringBundler query = new StringBundler(4);
5698
5699 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
5700
5701 query.append(_FINDER_COLUMN_U_D_A_USERID_2);
5702
5703 query.append(_FINDER_COLUMN_U_D_A_DELIVERED_2);
5704
5705 query.append(_FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2);
5706
5707 String sql = query.toString();
5708
5709 Session session = null;
5710
5711 try {
5712 session = openSession();
5713
5714 Query q = session.createQuery(sql);
5715
5716 QueryPos qPos = QueryPos.getInstance(q);
5717
5718 qPos.add(userId);
5719
5720 qPos.add(delivered);
5721
5722 qPos.add(actionRequired);
5723
5724 count = (Long)q.uniqueResult();
5725
5726 finderCache.putResult(finderPath, finderArgs, count);
5727 }
5728 catch (Exception e) {
5729 finderCache.removeResult(finderPath, finderArgs);
5730
5731 throw processException(e);
5732 }
5733 finally {
5734 closeSession(session);
5735 }
5736 }
5737
5738 return count.intValue();
5739 }
5740
5741 private static final String _FINDER_COLUMN_U_D_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
5742 private static final String _FINDER_COLUMN_U_D_A_DELIVERED_2 = "userNotificationEvent.delivered = ? AND ";
5743 private static final String _FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ?";
5744 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5745 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5746 UserNotificationEventImpl.class,
5747 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_A_A",
5748 new String[] {
5749 Long.class.getName(), Boolean.class.getName(),
5750 Boolean.class.getName(),
5751
5752 Integer.class.getName(), Integer.class.getName(),
5753 OrderByComparator.class.getName()
5754 });
5755 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5756 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5757 UserNotificationEventImpl.class,
5758 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_A_A",
5759 new String[] {
5760 Long.class.getName(), Boolean.class.getName(),
5761 Boolean.class.getName()
5762 },
5763 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
5764 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
5765 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
5766 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
5767 public static final FinderPath FINDER_PATH_COUNT_BY_U_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5768 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
5769 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_A_A",
5770 new String[] {
5771 Long.class.getName(), Boolean.class.getName(),
5772 Boolean.class.getName()
5773 });
5774
5775
5783 @Override
5784 public List<UserNotificationEvent> findByU_A_A(long userId,
5785 boolean actionRequired, boolean archived) {
5786 return findByU_A_A(userId, actionRequired, archived, QueryUtil.ALL_POS,
5787 QueryUtil.ALL_POS, null);
5788 }
5789
5790
5804 @Override
5805 public List<UserNotificationEvent> findByU_A_A(long userId,
5806 boolean actionRequired, boolean archived, int start, int end) {
5807 return findByU_A_A(userId, actionRequired, archived, start, end, null);
5808 }
5809
5810
5825 @Override
5826 public List<UserNotificationEvent> findByU_A_A(long userId,
5827 boolean actionRequired, boolean archived, int start, int end,
5828 OrderByComparator<UserNotificationEvent> orderByComparator) {
5829 return findByU_A_A(userId, actionRequired, archived, start, end,
5830 orderByComparator, true);
5831 }
5832
5833
5849 @Override
5850 public List<UserNotificationEvent> findByU_A_A(long userId,
5851 boolean actionRequired, boolean archived, int start, int end,
5852 OrderByComparator<UserNotificationEvent> orderByComparator,
5853 boolean retrieveFromCache) {
5854 boolean pagination = true;
5855 FinderPath finderPath = null;
5856 Object[] finderArgs = null;
5857
5858 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5859 (orderByComparator == null)) {
5860 pagination = false;
5861 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A;
5862 finderArgs = new Object[] { userId, actionRequired, archived };
5863 }
5864 else {
5865 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A_A;
5866 finderArgs = new Object[] {
5867 userId, actionRequired, archived,
5868
5869 start, end, orderByComparator
5870 };
5871 }
5872
5873 List<UserNotificationEvent> list = null;
5874
5875 if (retrieveFromCache) {
5876 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
5877 finderArgs, this);
5878
5879 if ((list != null) && !list.isEmpty()) {
5880 for (UserNotificationEvent userNotificationEvent : list) {
5881 if ((userId != userNotificationEvent.getUserId()) ||
5882 (actionRequired != userNotificationEvent.getActionRequired()) ||
5883 (archived != userNotificationEvent.getArchived())) {
5884 list = null;
5885
5886 break;
5887 }
5888 }
5889 }
5890 }
5891
5892 if (list == null) {
5893 StringBundler query = null;
5894
5895 if (orderByComparator != null) {
5896 query = new StringBundler(5 +
5897 (orderByComparator.getOrderByFields().length * 2));
5898 }
5899 else {
5900 query = new StringBundler(5);
5901 }
5902
5903 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5904
5905 query.append(_FINDER_COLUMN_U_A_A_USERID_2);
5906
5907 query.append(_FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2);
5908
5909 query.append(_FINDER_COLUMN_U_A_A_ARCHIVED_2);
5910
5911 if (orderByComparator != null) {
5912 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5913 orderByComparator);
5914 }
5915 else
5916 if (pagination) {
5917 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5918 }
5919
5920 String sql = query.toString();
5921
5922 Session session = null;
5923
5924 try {
5925 session = openSession();
5926
5927 Query q = session.createQuery(sql);
5928
5929 QueryPos qPos = QueryPos.getInstance(q);
5930
5931 qPos.add(userId);
5932
5933 qPos.add(actionRequired);
5934
5935 qPos.add(archived);
5936
5937 if (!pagination) {
5938 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5939 getDialect(), start, end, false);
5940
5941 Collections.sort(list);
5942
5943 list = Collections.unmodifiableList(list);
5944 }
5945 else {
5946 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5947 getDialect(), start, end);
5948 }
5949
5950 cacheResult(list);
5951
5952 finderCache.putResult(finderPath, finderArgs, list);
5953 }
5954 catch (Exception e) {
5955 finderCache.removeResult(finderPath, finderArgs);
5956
5957 throw processException(e);
5958 }
5959 finally {
5960 closeSession(session);
5961 }
5962 }
5963
5964 return list;
5965 }
5966
5967
5977 @Override
5978 public UserNotificationEvent findByU_A_A_First(long userId,
5979 boolean actionRequired, boolean archived,
5980 OrderByComparator<UserNotificationEvent> orderByComparator)
5981 throws NoSuchUserNotificationEventException {
5982 UserNotificationEvent userNotificationEvent = fetchByU_A_A_First(userId,
5983 actionRequired, archived, orderByComparator);
5984
5985 if (userNotificationEvent != null) {
5986 return userNotificationEvent;
5987 }
5988
5989 StringBundler msg = new StringBundler(8);
5990
5991 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5992
5993 msg.append("userId=");
5994 msg.append(userId);
5995
5996 msg.append(", actionRequired=");
5997 msg.append(actionRequired);
5998
5999 msg.append(", archived=");
6000 msg.append(archived);
6001
6002 msg.append(StringPool.CLOSE_CURLY_BRACE);
6003
6004 throw new NoSuchUserNotificationEventException(msg.toString());
6005 }
6006
6007
6016 @Override
6017 public UserNotificationEvent fetchByU_A_A_First(long userId,
6018 boolean actionRequired, boolean archived,
6019 OrderByComparator<UserNotificationEvent> orderByComparator) {
6020 List<UserNotificationEvent> list = findByU_A_A(userId, actionRequired,
6021 archived, 0, 1, orderByComparator);
6022
6023 if (!list.isEmpty()) {
6024 return list.get(0);
6025 }
6026
6027 return null;
6028 }
6029
6030
6040 @Override
6041 public UserNotificationEvent findByU_A_A_Last(long userId,
6042 boolean actionRequired, boolean archived,
6043 OrderByComparator<UserNotificationEvent> orderByComparator)
6044 throws NoSuchUserNotificationEventException {
6045 UserNotificationEvent userNotificationEvent = fetchByU_A_A_Last(userId,
6046 actionRequired, archived, orderByComparator);
6047
6048 if (userNotificationEvent != null) {
6049 return userNotificationEvent;
6050 }
6051
6052 StringBundler msg = new StringBundler(8);
6053
6054 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6055
6056 msg.append("userId=");
6057 msg.append(userId);
6058
6059 msg.append(", actionRequired=");
6060 msg.append(actionRequired);
6061
6062 msg.append(", archived=");
6063 msg.append(archived);
6064
6065 msg.append(StringPool.CLOSE_CURLY_BRACE);
6066
6067 throw new NoSuchUserNotificationEventException(msg.toString());
6068 }
6069
6070
6079 @Override
6080 public UserNotificationEvent fetchByU_A_A_Last(long userId,
6081 boolean actionRequired, boolean archived,
6082 OrderByComparator<UserNotificationEvent> orderByComparator) {
6083 int count = countByU_A_A(userId, actionRequired, archived);
6084
6085 if (count == 0) {
6086 return null;
6087 }
6088
6089 List<UserNotificationEvent> list = findByU_A_A(userId, actionRequired,
6090 archived, count - 1, count, orderByComparator);
6091
6092 if (!list.isEmpty()) {
6093 return list.get(0);
6094 }
6095
6096 return null;
6097 }
6098
6099
6110 @Override
6111 public UserNotificationEvent[] findByU_A_A_PrevAndNext(
6112 long userNotificationEventId, long userId, boolean actionRequired,
6113 boolean archived,
6114 OrderByComparator<UserNotificationEvent> orderByComparator)
6115 throws NoSuchUserNotificationEventException {
6116 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
6117
6118 Session session = null;
6119
6120 try {
6121 session = openSession();
6122
6123 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
6124
6125 array[0] = getByU_A_A_PrevAndNext(session, userNotificationEvent,
6126 userId, actionRequired, archived, orderByComparator, true);
6127
6128 array[1] = userNotificationEvent;
6129
6130 array[2] = getByU_A_A_PrevAndNext(session, userNotificationEvent,
6131 userId, actionRequired, archived, orderByComparator, false);
6132
6133 return array;
6134 }
6135 catch (Exception e) {
6136 throw processException(e);
6137 }
6138 finally {
6139 closeSession(session);
6140 }
6141 }
6142
6143 protected UserNotificationEvent getByU_A_A_PrevAndNext(Session session,
6144 UserNotificationEvent userNotificationEvent, long userId,
6145 boolean actionRequired, boolean archived,
6146 OrderByComparator<UserNotificationEvent> orderByComparator,
6147 boolean previous) {
6148 StringBundler query = null;
6149
6150 if (orderByComparator != null) {
6151 query = new StringBundler(6 +
6152 (orderByComparator.getOrderByConditionFields().length * 3) +
6153 (orderByComparator.getOrderByFields().length * 3));
6154 }
6155 else {
6156 query = new StringBundler(5);
6157 }
6158
6159 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
6160
6161 query.append(_FINDER_COLUMN_U_A_A_USERID_2);
6162
6163 query.append(_FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2);
6164
6165 query.append(_FINDER_COLUMN_U_A_A_ARCHIVED_2);
6166
6167 if (orderByComparator != null) {
6168 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6169
6170 if (orderByConditionFields.length > 0) {
6171 query.append(WHERE_AND);
6172 }
6173
6174 for (int i = 0; i < orderByConditionFields.length; i++) {
6175 query.append(_ORDER_BY_ENTITY_ALIAS);
6176 query.append(orderByConditionFields[i]);
6177
6178 if ((i + 1) < orderByConditionFields.length) {
6179 if (orderByComparator.isAscending() ^ previous) {
6180 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6181 }
6182 else {
6183 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6184 }
6185 }
6186 else {
6187 if (orderByComparator.isAscending() ^ previous) {
6188 query.append(WHERE_GREATER_THAN);
6189 }
6190 else {
6191 query.append(WHERE_LESSER_THAN);
6192 }
6193 }
6194 }
6195
6196 query.append(ORDER_BY_CLAUSE);
6197
6198 String[] orderByFields = orderByComparator.getOrderByFields();
6199
6200 for (int i = 0; i < orderByFields.length; i++) {
6201 query.append(_ORDER_BY_ENTITY_ALIAS);
6202 query.append(orderByFields[i]);
6203
6204 if ((i + 1) < orderByFields.length) {
6205 if (orderByComparator.isAscending() ^ previous) {
6206 query.append(ORDER_BY_ASC_HAS_NEXT);
6207 }
6208 else {
6209 query.append(ORDER_BY_DESC_HAS_NEXT);
6210 }
6211 }
6212 else {
6213 if (orderByComparator.isAscending() ^ previous) {
6214 query.append(ORDER_BY_ASC);
6215 }
6216 else {
6217 query.append(ORDER_BY_DESC);
6218 }
6219 }
6220 }
6221 }
6222 else {
6223 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
6224 }
6225
6226 String sql = query.toString();
6227
6228 Query q = session.createQuery(sql);
6229
6230 q.setFirstResult(0);
6231 q.setMaxResults(2);
6232
6233 QueryPos qPos = QueryPos.getInstance(q);
6234
6235 qPos.add(userId);
6236
6237 qPos.add(actionRequired);
6238
6239 qPos.add(archived);
6240
6241 if (orderByComparator != null) {
6242 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
6243
6244 for (Object value : values) {
6245 qPos.add(value);
6246 }
6247 }
6248
6249 List<UserNotificationEvent> list = q.list();
6250
6251 if (list.size() == 2) {
6252 return list.get(1);
6253 }
6254 else {
6255 return null;
6256 }
6257 }
6258
6259
6266 @Override
6267 public void removeByU_A_A(long userId, boolean actionRequired,
6268 boolean archived) {
6269 for (UserNotificationEvent userNotificationEvent : findByU_A_A(userId,
6270 actionRequired, archived, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
6271 null)) {
6272 remove(userNotificationEvent);
6273 }
6274 }
6275
6276
6284 @Override
6285 public int countByU_A_A(long userId, boolean actionRequired,
6286 boolean archived) {
6287 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_A_A;
6288
6289 Object[] finderArgs = new Object[] { userId, actionRequired, archived };
6290
6291 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6292
6293 if (count == null) {
6294 StringBundler query = new StringBundler(4);
6295
6296 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
6297
6298 query.append(_FINDER_COLUMN_U_A_A_USERID_2);
6299
6300 query.append(_FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2);
6301
6302 query.append(_FINDER_COLUMN_U_A_A_ARCHIVED_2);
6303
6304 String sql = query.toString();
6305
6306 Session session = null;
6307
6308 try {
6309 session = openSession();
6310
6311 Query q = session.createQuery(sql);
6312
6313 QueryPos qPos = QueryPos.getInstance(q);
6314
6315 qPos.add(userId);
6316
6317 qPos.add(actionRequired);
6318
6319 qPos.add(archived);
6320
6321 count = (Long)q.uniqueResult();
6322
6323 finderCache.putResult(finderPath, finderArgs, count);
6324 }
6325 catch (Exception e) {
6326 finderCache.removeResult(finderPath, finderArgs);
6327
6328 throw processException(e);
6329 }
6330 finally {
6331 closeSession(session);
6332 }
6333 }
6334
6335 return count.intValue();
6336 }
6337
6338 private static final String _FINDER_COLUMN_U_A_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
6339 private static final String _FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ? AND ";
6340 private static final String _FINDER_COLUMN_U_A_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
6341 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_T_DT_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6342 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
6343 UserNotificationEventImpl.class,
6344 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_T_DT_D",
6345 new String[] {
6346 Long.class.getName(), String.class.getName(),
6347 Integer.class.getName(), Boolean.class.getName(),
6348
6349 Integer.class.getName(), Integer.class.getName(),
6350 OrderByComparator.class.getName()
6351 });
6352 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_T_DT_D =
6353 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6354 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
6355 UserNotificationEventImpl.class,
6356 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_T_DT_D",
6357 new String[] {
6358 Long.class.getName(), String.class.getName(),
6359 Integer.class.getName(), Boolean.class.getName()
6360 },
6361 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
6362 UserNotificationEventModelImpl.TYPE_COLUMN_BITMASK |
6363 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
6364 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
6365 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
6366 public static final FinderPath FINDER_PATH_COUNT_BY_U_T_DT_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6367 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
6368 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_T_DT_D",
6369 new String[] {
6370 Long.class.getName(), String.class.getName(),
6371 Integer.class.getName(), Boolean.class.getName()
6372 });
6373
6374
6383 @Override
6384 public List<UserNotificationEvent> findByU_T_DT_D(long userId, String type,
6385 int deliveryType, boolean delivered) {
6386 return findByU_T_DT_D(userId, type, deliveryType, delivered,
6387 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6388 }
6389
6390
6405 @Override
6406 public List<UserNotificationEvent> findByU_T_DT_D(long userId, String type,
6407 int deliveryType, boolean delivered, int start, int end) {
6408 return findByU_T_DT_D(userId, type, deliveryType, delivered, start,
6409 end, null);
6410 }
6411
6412
6428 @Override
6429 public List<UserNotificationEvent> findByU_T_DT_D(long userId, String type,
6430 int deliveryType, boolean delivered, int start, int end,
6431 OrderByComparator<UserNotificationEvent> orderByComparator) {
6432 return findByU_T_DT_D(userId, type, deliveryType, delivered, start,
6433 end, orderByComparator, true);
6434 }
6435
6436
6453 @Override
6454 public List<UserNotificationEvent> findByU_T_DT_D(long userId, String type,
6455 int deliveryType, boolean delivered, int start, int end,
6456 OrderByComparator<UserNotificationEvent> orderByComparator,
6457 boolean retrieveFromCache) {
6458 boolean pagination = true;
6459 FinderPath finderPath = null;
6460 Object[] finderArgs = null;
6461
6462 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6463 (orderByComparator == null)) {
6464 pagination = false;
6465 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_T_DT_D;
6466 finderArgs = new Object[] { userId, type, deliveryType, delivered };
6467 }
6468 else {
6469 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_T_DT_D;
6470 finderArgs = new Object[] {
6471 userId, type, deliveryType, delivered,
6472
6473 start, end, orderByComparator
6474 };
6475 }
6476
6477 List<UserNotificationEvent> list = null;
6478
6479 if (retrieveFromCache) {
6480 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
6481 finderArgs, this);
6482
6483 if ((list != null) && !list.isEmpty()) {
6484 for (UserNotificationEvent userNotificationEvent : list) {
6485 if ((userId != userNotificationEvent.getUserId()) ||
6486 !Validator.equals(type,
6487 userNotificationEvent.getType()) ||
6488 (deliveryType != userNotificationEvent.getDeliveryType()) ||
6489 (delivered != userNotificationEvent.getDelivered())) {
6490 list = null;
6491
6492 break;
6493 }
6494 }
6495 }
6496 }
6497
6498 if (list == null) {
6499 StringBundler query = null;
6500
6501 if (orderByComparator != null) {
6502 query = new StringBundler(6 +
6503 (orderByComparator.getOrderByFields().length * 2));
6504 }
6505 else {
6506 query = new StringBundler(6);
6507 }
6508
6509 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
6510
6511 query.append(_FINDER_COLUMN_U_T_DT_D_USERID_2);
6512
6513 boolean bindType = false;
6514
6515 if (type == null) {
6516 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_1);
6517 }
6518 else if (type.equals(StringPool.BLANK)) {
6519 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_3);
6520 }
6521 else {
6522 bindType = true;
6523
6524 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_2);
6525 }
6526
6527 query.append(_FINDER_COLUMN_U_T_DT_D_DELIVERYTYPE_2);
6528
6529 query.append(_FINDER_COLUMN_U_T_DT_D_DELIVERED_2);
6530
6531 if (orderByComparator != null) {
6532 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6533 orderByComparator);
6534 }
6535 else
6536 if (pagination) {
6537 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
6538 }
6539
6540 String sql = query.toString();
6541
6542 Session session = null;
6543
6544 try {
6545 session = openSession();
6546
6547 Query q = session.createQuery(sql);
6548
6549 QueryPos qPos = QueryPos.getInstance(q);
6550
6551 qPos.add(userId);
6552
6553 if (bindType) {
6554 qPos.add(type);
6555 }
6556
6557 qPos.add(deliveryType);
6558
6559 qPos.add(delivered);
6560
6561 if (!pagination) {
6562 list = (List<UserNotificationEvent>)QueryUtil.list(q,
6563 getDialect(), start, end, false);
6564
6565 Collections.sort(list);
6566
6567 list = Collections.unmodifiableList(list);
6568 }
6569 else {
6570 list = (List<UserNotificationEvent>)QueryUtil.list(q,
6571 getDialect(), start, end);
6572 }
6573
6574 cacheResult(list);
6575
6576 finderCache.putResult(finderPath, finderArgs, list);
6577 }
6578 catch (Exception e) {
6579 finderCache.removeResult(finderPath, finderArgs);
6580
6581 throw processException(e);
6582 }
6583 finally {
6584 closeSession(session);
6585 }
6586 }
6587
6588 return list;
6589 }
6590
6591
6602 @Override
6603 public UserNotificationEvent findByU_T_DT_D_First(long userId, String type,
6604 int deliveryType, boolean delivered,
6605 OrderByComparator<UserNotificationEvent> orderByComparator)
6606 throws NoSuchUserNotificationEventException {
6607 UserNotificationEvent userNotificationEvent = fetchByU_T_DT_D_First(userId,
6608 type, deliveryType, delivered, orderByComparator);
6609
6610 if (userNotificationEvent != null) {
6611 return userNotificationEvent;
6612 }
6613
6614 StringBundler msg = new StringBundler(10);
6615
6616 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6617
6618 msg.append("userId=");
6619 msg.append(userId);
6620
6621 msg.append(", type=");
6622 msg.append(type);
6623
6624 msg.append(", deliveryType=");
6625 msg.append(deliveryType);
6626
6627 msg.append(", delivered=");
6628 msg.append(delivered);
6629
6630 msg.append(StringPool.CLOSE_CURLY_BRACE);
6631
6632 throw new NoSuchUserNotificationEventException(msg.toString());
6633 }
6634
6635
6645 @Override
6646 public UserNotificationEvent fetchByU_T_DT_D_First(long userId,
6647 String type, int deliveryType, boolean delivered,
6648 OrderByComparator<UserNotificationEvent> orderByComparator) {
6649 List<UserNotificationEvent> list = findByU_T_DT_D(userId, type,
6650 deliveryType, delivered, 0, 1, orderByComparator);
6651
6652 if (!list.isEmpty()) {
6653 return list.get(0);
6654 }
6655
6656 return null;
6657 }
6658
6659
6670 @Override
6671 public UserNotificationEvent findByU_T_DT_D_Last(long userId, String type,
6672 int deliveryType, boolean delivered,
6673 OrderByComparator<UserNotificationEvent> orderByComparator)
6674 throws NoSuchUserNotificationEventException {
6675 UserNotificationEvent userNotificationEvent = fetchByU_T_DT_D_Last(userId,
6676 type, deliveryType, delivered, orderByComparator);
6677
6678 if (userNotificationEvent != null) {
6679 return userNotificationEvent;
6680 }
6681
6682 StringBundler msg = new StringBundler(10);
6683
6684 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6685
6686 msg.append("userId=");
6687 msg.append(userId);
6688
6689 msg.append(", type=");
6690 msg.append(type);
6691
6692 msg.append(", deliveryType=");
6693 msg.append(deliveryType);
6694
6695 msg.append(", delivered=");
6696 msg.append(delivered);
6697
6698 msg.append(StringPool.CLOSE_CURLY_BRACE);
6699
6700 throw new NoSuchUserNotificationEventException(msg.toString());
6701 }
6702
6703
6713 @Override
6714 public UserNotificationEvent fetchByU_T_DT_D_Last(long userId, String type,
6715 int deliveryType, boolean delivered,
6716 OrderByComparator<UserNotificationEvent> orderByComparator) {
6717 int count = countByU_T_DT_D(userId, type, deliveryType, delivered);
6718
6719 if (count == 0) {
6720 return null;
6721 }
6722
6723 List<UserNotificationEvent> list = findByU_T_DT_D(userId, type,
6724 deliveryType, delivered, count - 1, count, orderByComparator);
6725
6726 if (!list.isEmpty()) {
6727 return list.get(0);
6728 }
6729
6730 return null;
6731 }
6732
6733
6745 @Override
6746 public UserNotificationEvent[] findByU_T_DT_D_PrevAndNext(
6747 long userNotificationEventId, long userId, String type,
6748 int deliveryType, boolean delivered,
6749 OrderByComparator<UserNotificationEvent> orderByComparator)
6750 throws NoSuchUserNotificationEventException {
6751 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
6752
6753 Session session = null;
6754
6755 try {
6756 session = openSession();
6757
6758 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
6759
6760 array[0] = getByU_T_DT_D_PrevAndNext(session,
6761 userNotificationEvent, userId, type, deliveryType,
6762 delivered, orderByComparator, true);
6763
6764 array[1] = userNotificationEvent;
6765
6766 array[2] = getByU_T_DT_D_PrevAndNext(session,
6767 userNotificationEvent, userId, type, deliveryType,
6768 delivered, orderByComparator, false);
6769
6770 return array;
6771 }
6772 catch (Exception e) {
6773 throw processException(e);
6774 }
6775 finally {
6776 closeSession(session);
6777 }
6778 }
6779
6780 protected UserNotificationEvent getByU_T_DT_D_PrevAndNext(Session session,
6781 UserNotificationEvent userNotificationEvent, long userId, String type,
6782 int deliveryType, boolean delivered,
6783 OrderByComparator<UserNotificationEvent> orderByComparator,
6784 boolean previous) {
6785 StringBundler query = null;
6786
6787 if (orderByComparator != null) {
6788 query = new StringBundler(7 +
6789 (orderByComparator.getOrderByConditionFields().length * 3) +
6790 (orderByComparator.getOrderByFields().length * 3));
6791 }
6792 else {
6793 query = new StringBundler(6);
6794 }
6795
6796 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
6797
6798 query.append(_FINDER_COLUMN_U_T_DT_D_USERID_2);
6799
6800 boolean bindType = false;
6801
6802 if (type == null) {
6803 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_1);
6804 }
6805 else if (type.equals(StringPool.BLANK)) {
6806 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_3);
6807 }
6808 else {
6809 bindType = true;
6810
6811 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_2);
6812 }
6813
6814 query.append(_FINDER_COLUMN_U_T_DT_D_DELIVERYTYPE_2);
6815
6816 query.append(_FINDER_COLUMN_U_T_DT_D_DELIVERED_2);
6817
6818 if (orderByComparator != null) {
6819 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6820
6821 if (orderByConditionFields.length > 0) {
6822 query.append(WHERE_AND);
6823 }
6824
6825 for (int i = 0; i < orderByConditionFields.length; i++) {
6826 query.append(_ORDER_BY_ENTITY_ALIAS);
6827 query.append(orderByConditionFields[i]);
6828
6829 if ((i + 1) < orderByConditionFields.length) {
6830 if (orderByComparator.isAscending() ^ previous) {
6831 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6832 }
6833 else {
6834 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6835 }
6836 }
6837 else {
6838 if (orderByComparator.isAscending() ^ previous) {
6839 query.append(WHERE_GREATER_THAN);
6840 }
6841 else {
6842 query.append(WHERE_LESSER_THAN);
6843 }
6844 }
6845 }
6846
6847 query.append(ORDER_BY_CLAUSE);
6848
6849 String[] orderByFields = orderByComparator.getOrderByFields();
6850
6851 for (int i = 0; i < orderByFields.length; i++) {
6852 query.append(_ORDER_BY_ENTITY_ALIAS);
6853 query.append(orderByFields[i]);
6854
6855 if ((i + 1) < orderByFields.length) {
6856 if (orderByComparator.isAscending() ^ previous) {
6857 query.append(ORDER_BY_ASC_HAS_NEXT);
6858 }
6859 else {
6860 query.append(ORDER_BY_DESC_HAS_NEXT);
6861 }
6862 }
6863 else {
6864 if (orderByComparator.isAscending() ^ previous) {
6865 query.append(ORDER_BY_ASC);
6866 }
6867 else {
6868 query.append(ORDER_BY_DESC);
6869 }
6870 }
6871 }
6872 }
6873 else {
6874 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
6875 }
6876
6877 String sql = query.toString();
6878
6879 Query q = session.createQuery(sql);
6880
6881 q.setFirstResult(0);
6882 q.setMaxResults(2);
6883
6884 QueryPos qPos = QueryPos.getInstance(q);
6885
6886 qPos.add(userId);
6887
6888 if (bindType) {
6889 qPos.add(type);
6890 }
6891
6892 qPos.add(deliveryType);
6893
6894 qPos.add(delivered);
6895
6896 if (orderByComparator != null) {
6897 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
6898
6899 for (Object value : values) {
6900 qPos.add(value);
6901 }
6902 }
6903
6904 List<UserNotificationEvent> list = q.list();
6905
6906 if (list.size() == 2) {
6907 return list.get(1);
6908 }
6909 else {
6910 return null;
6911 }
6912 }
6913
6914
6922 @Override
6923 public void removeByU_T_DT_D(long userId, String type, int deliveryType,
6924 boolean delivered) {
6925 for (UserNotificationEvent userNotificationEvent : findByU_T_DT_D(
6926 userId, type, deliveryType, delivered, QueryUtil.ALL_POS,
6927 QueryUtil.ALL_POS, null)) {
6928 remove(userNotificationEvent);
6929 }
6930 }
6931
6932
6941 @Override
6942 public int countByU_T_DT_D(long userId, String type, int deliveryType,
6943 boolean delivered) {
6944 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_T_DT_D;
6945
6946 Object[] finderArgs = new Object[] { userId, type, deliveryType, delivered };
6947
6948 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6949
6950 if (count == null) {
6951 StringBundler query = new StringBundler(5);
6952
6953 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
6954
6955 query.append(_FINDER_COLUMN_U_T_DT_D_USERID_2);
6956
6957 boolean bindType = false;
6958
6959 if (type == null) {
6960 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_1);
6961 }
6962 else if (type.equals(StringPool.BLANK)) {
6963 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_3);
6964 }
6965 else {
6966 bindType = true;
6967
6968 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_2);
6969 }
6970
6971 query.append(_FINDER_COLUMN_U_T_DT_D_DELIVERYTYPE_2);
6972
6973 query.append(_FINDER_COLUMN_U_T_DT_D_DELIVERED_2);
6974
6975 String sql = query.toString();
6976
6977 Session session = null;
6978
6979 try {
6980 session = openSession();
6981
6982 Query q = session.createQuery(sql);
6983
6984 QueryPos qPos = QueryPos.getInstance(q);
6985
6986 qPos.add(userId);
6987
6988 if (bindType) {
6989 qPos.add(type);
6990 }
6991
6992 qPos.add(deliveryType);
6993
6994 qPos.add(delivered);
6995
6996 count = (Long)q.uniqueResult();
6997
6998 finderCache.putResult(finderPath, finderArgs, count);
6999 }
7000 catch (Exception e) {
7001 finderCache.removeResult(finderPath, finderArgs);
7002
7003 throw processException(e);
7004 }
7005 finally {
7006 closeSession(session);
7007 }
7008 }
7009
7010 return count.intValue();
7011 }
7012
7013 private static final String _FINDER_COLUMN_U_T_DT_D_USERID_2 = "userNotificationEvent.userId = ? AND ";
7014 private static final String _FINDER_COLUMN_U_T_DT_D_TYPE_1 = "userNotificationEvent.type IS NULL AND ";
7015 private static final String _FINDER_COLUMN_U_T_DT_D_TYPE_2 = "userNotificationEvent.type = ? AND ";
7016 private static final String _FINDER_COLUMN_U_T_DT_D_TYPE_3 = "(userNotificationEvent.type IS NULL OR userNotificationEvent.type = '') AND ";
7017 private static final String _FINDER_COLUMN_U_T_DT_D_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
7018 private static final String _FINDER_COLUMN_U_T_DT_D_DELIVERED_2 = "userNotificationEvent.delivered = ?";
7019 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7020 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
7021 UserNotificationEventImpl.class,
7022 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_D_A",
7023 new String[] {
7024 Long.class.getName(), Integer.class.getName(),
7025 Boolean.class.getName(), Boolean.class.getName(),
7026
7027 Integer.class.getName(), Integer.class.getName(),
7028 OrderByComparator.class.getName()
7029 });
7030 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A =
7031 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7032 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
7033 UserNotificationEventImpl.class,
7034 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_D_A",
7035 new String[] {
7036 Long.class.getName(), Integer.class.getName(),
7037 Boolean.class.getName(), Boolean.class.getName()
7038 },
7039 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
7040 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
7041 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
7042 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
7043 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
7044 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7045 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
7046 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_D_A",
7047 new String[] {
7048 Long.class.getName(), Integer.class.getName(),
7049 Boolean.class.getName(), Boolean.class.getName()
7050 });
7051
7052
7061 @Override
7062 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
7063 int deliveryType, boolean delivered, boolean actionRequired) {
7064 return findByU_DT_D_A(userId, deliveryType, delivered, actionRequired,
7065 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7066 }
7067
7068
7083 @Override
7084 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
7085 int deliveryType, boolean delivered, boolean actionRequired, int start,
7086 int end) {
7087 return findByU_DT_D_A(userId, deliveryType, delivered, actionRequired,
7088 start, end, null);
7089 }
7090
7091
7107 @Override
7108 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
7109 int deliveryType, boolean delivered, boolean actionRequired, int start,
7110 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
7111 return findByU_DT_D_A(userId, deliveryType, delivered, actionRequired,
7112 start, end, orderByComparator, true);
7113 }
7114
7115
7132 @Override
7133 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
7134 int deliveryType, boolean delivered, boolean actionRequired, int start,
7135 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
7136 boolean retrieveFromCache) {
7137 boolean pagination = true;
7138 FinderPath finderPath = null;
7139 Object[] finderArgs = null;
7140
7141 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7142 (orderByComparator == null)) {
7143 pagination = false;
7144 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A;
7145 finderArgs = new Object[] {
7146 userId, deliveryType, delivered, actionRequired
7147 };
7148 }
7149 else {
7150 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D_A;
7151 finderArgs = new Object[] {
7152 userId, deliveryType, delivered, actionRequired,
7153
7154 start, end, orderByComparator
7155 };
7156 }
7157
7158 List<UserNotificationEvent> list = null;
7159
7160 if (retrieveFromCache) {
7161 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
7162 finderArgs, this);
7163
7164 if ((list != null) && !list.isEmpty()) {
7165 for (UserNotificationEvent userNotificationEvent : list) {
7166 if ((userId != userNotificationEvent.getUserId()) ||
7167 (deliveryType != userNotificationEvent.getDeliveryType()) ||
7168 (delivered != userNotificationEvent.getDelivered()) ||
7169 (actionRequired != userNotificationEvent.getActionRequired())) {
7170 list = null;
7171
7172 break;
7173 }
7174 }
7175 }
7176 }
7177
7178 if (list == null) {
7179 StringBundler query = null;
7180
7181 if (orderByComparator != null) {
7182 query = new StringBundler(6 +
7183 (orderByComparator.getOrderByFields().length * 2));
7184 }
7185 else {
7186 query = new StringBundler(6);
7187 }
7188
7189 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
7190
7191 query.append(_FINDER_COLUMN_U_DT_D_A_USERID_2);
7192
7193 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2);
7194
7195 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERED_2);
7196
7197 query.append(_FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2);
7198
7199 if (orderByComparator != null) {
7200 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7201 orderByComparator);
7202 }
7203 else
7204 if (pagination) {
7205 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
7206 }
7207
7208 String sql = query.toString();
7209
7210 Session session = null;
7211
7212 try {
7213 session = openSession();
7214
7215 Query q = session.createQuery(sql);
7216
7217 QueryPos qPos = QueryPos.getInstance(q);
7218
7219 qPos.add(userId);
7220
7221 qPos.add(deliveryType);
7222
7223 qPos.add(delivered);
7224
7225 qPos.add(actionRequired);
7226
7227 if (!pagination) {
7228 list = (List<UserNotificationEvent>)QueryUtil.list(q,
7229 getDialect(), start, end, false);
7230
7231 Collections.sort(list);
7232
7233 list = Collections.unmodifiableList(list);
7234 }
7235 else {
7236 list = (List<UserNotificationEvent>)QueryUtil.list(q,
7237 getDialect(), start, end);
7238 }
7239
7240 cacheResult(list);
7241
7242 finderCache.putResult(finderPath, finderArgs, list);
7243 }
7244 catch (Exception e) {
7245 finderCache.removeResult(finderPath, finderArgs);
7246
7247 throw processException(e);
7248 }
7249 finally {
7250 closeSession(session);
7251 }
7252 }
7253
7254 return list;
7255 }
7256
7257
7268 @Override
7269 public UserNotificationEvent findByU_DT_D_A_First(long userId,
7270 int deliveryType, boolean delivered, boolean actionRequired,
7271 OrderByComparator<UserNotificationEvent> orderByComparator)
7272 throws NoSuchUserNotificationEventException {
7273 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_A_First(userId,
7274 deliveryType, delivered, actionRequired, orderByComparator);
7275
7276 if (userNotificationEvent != null) {
7277 return userNotificationEvent;
7278 }
7279
7280 StringBundler msg = new StringBundler(10);
7281
7282 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7283
7284 msg.append("userId=");
7285 msg.append(userId);
7286
7287 msg.append(", deliveryType=");
7288 msg.append(deliveryType);
7289
7290 msg.append(", delivered=");
7291 msg.append(delivered);
7292
7293 msg.append(", actionRequired=");
7294 msg.append(actionRequired);
7295
7296 msg.append(StringPool.CLOSE_CURLY_BRACE);
7297
7298 throw new NoSuchUserNotificationEventException(msg.toString());
7299 }
7300
7301
7311 @Override
7312 public UserNotificationEvent fetchByU_DT_D_A_First(long userId,
7313 int deliveryType, boolean delivered, boolean actionRequired,
7314 OrderByComparator<UserNotificationEvent> orderByComparator) {
7315 List<UserNotificationEvent> list = findByU_DT_D_A(userId, deliveryType,
7316 delivered, actionRequired, 0, 1, orderByComparator);
7317
7318 if (!list.isEmpty()) {
7319 return list.get(0);
7320 }
7321
7322 return null;
7323 }
7324
7325
7336 @Override
7337 public UserNotificationEvent findByU_DT_D_A_Last(long userId,
7338 int deliveryType, boolean delivered, boolean actionRequired,
7339 OrderByComparator<UserNotificationEvent> orderByComparator)
7340 throws NoSuchUserNotificationEventException {
7341 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_A_Last(userId,
7342 deliveryType, delivered, actionRequired, orderByComparator);
7343
7344 if (userNotificationEvent != null) {
7345 return userNotificationEvent;
7346 }
7347
7348 StringBundler msg = new StringBundler(10);
7349
7350 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7351
7352 msg.append("userId=");
7353 msg.append(userId);
7354
7355 msg.append(", deliveryType=");
7356 msg.append(deliveryType);
7357
7358 msg.append(", delivered=");
7359 msg.append(delivered);
7360
7361 msg.append(", actionRequired=");
7362 msg.append(actionRequired);
7363
7364 msg.append(StringPool.CLOSE_CURLY_BRACE);
7365
7366 throw new NoSuchUserNotificationEventException(msg.toString());
7367 }
7368
7369
7379 @Override
7380 public UserNotificationEvent fetchByU_DT_D_A_Last(long userId,
7381 int deliveryType, boolean delivered, boolean actionRequired,
7382 OrderByComparator<UserNotificationEvent> orderByComparator) {
7383 int count = countByU_DT_D_A(userId, deliveryType, delivered,
7384 actionRequired);
7385
7386 if (count == 0) {
7387 return null;
7388 }
7389
7390 List<UserNotificationEvent> list = findByU_DT_D_A(userId, deliveryType,
7391 delivered, actionRequired, count - 1, count, orderByComparator);
7392
7393 if (!list.isEmpty()) {
7394 return list.get(0);
7395 }
7396
7397 return null;
7398 }
7399
7400
7412 @Override
7413 public UserNotificationEvent[] findByU_DT_D_A_PrevAndNext(
7414 long userNotificationEventId, long userId, int deliveryType,
7415 boolean delivered, boolean actionRequired,
7416 OrderByComparator<UserNotificationEvent> orderByComparator)
7417 throws NoSuchUserNotificationEventException {
7418 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
7419
7420 Session session = null;
7421
7422 try {
7423 session = openSession();
7424
7425 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
7426
7427 array[0] = getByU_DT_D_A_PrevAndNext(session,
7428 userNotificationEvent, userId, deliveryType, delivered,
7429 actionRequired, orderByComparator, true);
7430
7431 array[1] = userNotificationEvent;
7432
7433 array[2] = getByU_DT_D_A_PrevAndNext(session,
7434 userNotificationEvent, userId, deliveryType, delivered,
7435 actionRequired, orderByComparator, false);
7436
7437 return array;
7438 }
7439 catch (Exception e) {
7440 throw processException(e);
7441 }
7442 finally {
7443 closeSession(session);
7444 }
7445 }
7446
7447 protected UserNotificationEvent getByU_DT_D_A_PrevAndNext(Session session,
7448 UserNotificationEvent userNotificationEvent, long userId,
7449 int deliveryType, boolean delivered, boolean actionRequired,
7450 OrderByComparator<UserNotificationEvent> orderByComparator,
7451 boolean previous) {
7452 StringBundler query = null;
7453
7454 if (orderByComparator != null) {
7455 query = new StringBundler(7 +
7456 (orderByComparator.getOrderByConditionFields().length * 3) +
7457 (orderByComparator.getOrderByFields().length * 3));
7458 }
7459 else {
7460 query = new StringBundler(6);
7461 }
7462
7463 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
7464
7465 query.append(_FINDER_COLUMN_U_DT_D_A_USERID_2);
7466
7467 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2);
7468
7469 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERED_2);
7470
7471 query.append(_FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2);
7472
7473 if (orderByComparator != null) {
7474 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7475
7476 if (orderByConditionFields.length > 0) {
7477 query.append(WHERE_AND);
7478 }
7479
7480 for (int i = 0; i < orderByConditionFields.length; i++) {
7481 query.append(_ORDER_BY_ENTITY_ALIAS);
7482 query.append(orderByConditionFields[i]);
7483
7484 if ((i + 1) < orderByConditionFields.length) {
7485 if (orderByComparator.isAscending() ^ previous) {
7486 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7487 }
7488 else {
7489 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7490 }
7491 }
7492 else {
7493 if (orderByComparator.isAscending() ^ previous) {
7494 query.append(WHERE_GREATER_THAN);
7495 }
7496 else {
7497 query.append(WHERE_LESSER_THAN);
7498 }
7499 }
7500 }
7501
7502 query.append(ORDER_BY_CLAUSE);
7503
7504 String[] orderByFields = orderByComparator.getOrderByFields();
7505
7506 for (int i = 0; i < orderByFields.length; i++) {
7507 query.append(_ORDER_BY_ENTITY_ALIAS);
7508 query.append(orderByFields[i]);
7509
7510 if ((i + 1) < orderByFields.length) {
7511 if (orderByComparator.isAscending() ^ previous) {
7512 query.append(ORDER_BY_ASC_HAS_NEXT);
7513 }
7514 else {
7515 query.append(ORDER_BY_DESC_HAS_NEXT);
7516 }
7517 }
7518 else {
7519 if (orderByComparator.isAscending() ^ previous) {
7520 query.append(ORDER_BY_ASC);
7521 }
7522 else {
7523 query.append(ORDER_BY_DESC);
7524 }
7525 }
7526 }
7527 }
7528 else {
7529 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
7530 }
7531
7532 String sql = query.toString();
7533
7534 Query q = session.createQuery(sql);
7535
7536 q.setFirstResult(0);
7537 q.setMaxResults(2);
7538
7539 QueryPos qPos = QueryPos.getInstance(q);
7540
7541 qPos.add(userId);
7542
7543 qPos.add(deliveryType);
7544
7545 qPos.add(delivered);
7546
7547 qPos.add(actionRequired);
7548
7549 if (orderByComparator != null) {
7550 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
7551
7552 for (Object value : values) {
7553 qPos.add(value);
7554 }
7555 }
7556
7557 List<UserNotificationEvent> list = q.list();
7558
7559 if (list.size() == 2) {
7560 return list.get(1);
7561 }
7562 else {
7563 return null;
7564 }
7565 }
7566
7567
7575 @Override
7576 public void removeByU_DT_D_A(long userId, int deliveryType,
7577 boolean delivered, boolean actionRequired) {
7578 for (UserNotificationEvent userNotificationEvent : findByU_DT_D_A(
7579 userId, deliveryType, delivered, actionRequired,
7580 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7581 remove(userNotificationEvent);
7582 }
7583 }
7584
7585
7594 @Override
7595 public int countByU_DT_D_A(long userId, int deliveryType,
7596 boolean delivered, boolean actionRequired) {
7597 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_D_A;
7598
7599 Object[] finderArgs = new Object[] {
7600 userId, deliveryType, delivered, actionRequired
7601 };
7602
7603 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7604
7605 if (count == null) {
7606 StringBundler query = new StringBundler(5);
7607
7608 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
7609
7610 query.append(_FINDER_COLUMN_U_DT_D_A_USERID_2);
7611
7612 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2);
7613
7614 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERED_2);
7615
7616 query.append(_FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2);
7617
7618 String sql = query.toString();
7619
7620 Session session = null;
7621
7622 try {
7623 session = openSession();
7624
7625 Query q = session.createQuery(sql);
7626
7627 QueryPos qPos = QueryPos.getInstance(q);
7628
7629 qPos.add(userId);
7630
7631 qPos.add(deliveryType);
7632
7633 qPos.add(delivered);
7634
7635 qPos.add(actionRequired);
7636
7637 count = (Long)q.uniqueResult();
7638
7639 finderCache.putResult(finderPath, finderArgs, count);
7640 }
7641 catch (Exception e) {
7642 finderCache.removeResult(finderPath, finderArgs);
7643
7644 throw processException(e);
7645 }
7646 finally {
7647 closeSession(session);
7648 }
7649 }
7650
7651 return count.intValue();
7652 }
7653
7654 private static final String _FINDER_COLUMN_U_DT_D_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
7655 private static final String _FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
7656 private static final String _FINDER_COLUMN_U_DT_D_A_DELIVERED_2 = "userNotificationEvent.delivered = ? AND ";
7657 private static final String _FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ?";
7658 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7659 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
7660 UserNotificationEventImpl.class,
7661 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_A_A",
7662 new String[] {
7663 Long.class.getName(), Integer.class.getName(),
7664 Boolean.class.getName(), Boolean.class.getName(),
7665
7666 Integer.class.getName(), Integer.class.getName(),
7667 OrderByComparator.class.getName()
7668 });
7669 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A =
7670 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7671 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
7672 UserNotificationEventImpl.class,
7673 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_A_A",
7674 new String[] {
7675 Long.class.getName(), Integer.class.getName(),
7676 Boolean.class.getName(), Boolean.class.getName()
7677 },
7678 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
7679 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
7680 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
7681 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
7682 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
7683 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7684 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
7685 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_A_A",
7686 new String[] {
7687 Long.class.getName(), Integer.class.getName(),
7688 Boolean.class.getName(), Boolean.class.getName()
7689 });
7690
7691
7700 @Override
7701 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
7702 int deliveryType, boolean actionRequired, boolean archived) {
7703 return findByU_DT_A_A(userId, deliveryType, actionRequired, archived,
7704 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7705 }
7706
7707
7722 @Override
7723 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
7724 int deliveryType, boolean actionRequired, boolean archived, int start,
7725 int end) {
7726 return findByU_DT_A_A(userId, deliveryType, actionRequired, archived,
7727 start, end, null);
7728 }
7729
7730
7746 @Override
7747 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
7748 int deliveryType, boolean actionRequired, boolean archived, int start,
7749 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
7750 return findByU_DT_A_A(userId, deliveryType, actionRequired, archived,
7751 start, end, orderByComparator, true);
7752 }
7753
7754
7771 @Override
7772 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
7773 int deliveryType, boolean actionRequired, boolean archived, int start,
7774 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
7775 boolean retrieveFromCache) {
7776 boolean pagination = true;
7777 FinderPath finderPath = null;
7778 Object[] finderArgs = null;
7779
7780 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7781 (orderByComparator == null)) {
7782 pagination = false;
7783 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A;
7784 finderArgs = new Object[] {
7785 userId, deliveryType, actionRequired, archived
7786 };
7787 }
7788 else {
7789 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A_A;
7790 finderArgs = new Object[] {
7791 userId, deliveryType, actionRequired, archived,
7792
7793 start, end, orderByComparator
7794 };
7795 }
7796
7797 List<UserNotificationEvent> list = null;
7798
7799 if (retrieveFromCache) {
7800 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
7801 finderArgs, this);
7802
7803 if ((list != null) && !list.isEmpty()) {
7804 for (UserNotificationEvent userNotificationEvent : list) {
7805 if ((userId != userNotificationEvent.getUserId()) ||
7806 (deliveryType != userNotificationEvent.getDeliveryType()) ||
7807 (actionRequired != userNotificationEvent.getActionRequired()) ||
7808 (archived != userNotificationEvent.getArchived())) {
7809 list = null;
7810
7811 break;
7812 }
7813 }
7814 }
7815 }
7816
7817 if (list == null) {
7818 StringBundler query = null;
7819
7820 if (orderByComparator != null) {
7821 query = new StringBundler(6 +
7822 (orderByComparator.getOrderByFields().length * 2));
7823 }
7824 else {
7825 query = new StringBundler(6);
7826 }
7827
7828 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
7829
7830 query.append(_FINDER_COLUMN_U_DT_A_A_USERID_2);
7831
7832 query.append(_FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2);
7833
7834 query.append(_FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2);
7835
7836 query.append(_FINDER_COLUMN_U_DT_A_A_ARCHIVED_2);
7837
7838 if (orderByComparator != null) {
7839 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7840 orderByComparator);
7841 }
7842 else
7843 if (pagination) {
7844 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
7845 }
7846
7847 String sql = query.toString();
7848
7849 Session session = null;
7850
7851 try {
7852 session = openSession();
7853
7854 Query q = session.createQuery(sql);
7855
7856 QueryPos qPos = QueryPos.getInstance(q);
7857
7858 qPos.add(userId);
7859
7860 qPos.add(deliveryType);
7861
7862 qPos.add(actionRequired);
7863
7864 qPos.add(archived);
7865
7866 if (!pagination) {
7867 list = (List<UserNotificationEvent>)QueryUtil.list(q,
7868 getDialect(), start, end, false);
7869
7870 Collections.sort(list);
7871
7872 list = Collections.unmodifiableList(list);
7873 }
7874 else {
7875 list = (List<UserNotificationEvent>)QueryUtil.list(q,
7876 getDialect(), start, end);
7877 }
7878
7879 cacheResult(list);
7880
7881 finderCache.putResult(finderPath, finderArgs, list);
7882 }
7883 catch (Exception e) {
7884 finderCache.removeResult(finderPath, finderArgs);
7885
7886 throw processException(e);
7887 }
7888 finally {
7889 closeSession(session);
7890 }
7891 }
7892
7893 return list;
7894 }
7895
7896
7907 @Override
7908 public UserNotificationEvent findByU_DT_A_A_First(long userId,
7909 int deliveryType, boolean actionRequired, boolean archived,
7910 OrderByComparator<UserNotificationEvent> orderByComparator)
7911 throws NoSuchUserNotificationEventException {
7912 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_A_First(userId,
7913 deliveryType, actionRequired, archived, orderByComparator);
7914
7915 if (userNotificationEvent != null) {
7916 return userNotificationEvent;
7917 }
7918
7919 StringBundler msg = new StringBundler(10);
7920
7921 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7922
7923 msg.append("userId=");
7924 msg.append(userId);
7925
7926 msg.append(", deliveryType=");
7927 msg.append(deliveryType);
7928
7929 msg.append(", actionRequired=");
7930 msg.append(actionRequired);
7931
7932 msg.append(", archived=");
7933 msg.append(archived);
7934
7935 msg.append(StringPool.CLOSE_CURLY_BRACE);
7936
7937 throw new NoSuchUserNotificationEventException(msg.toString());
7938 }
7939
7940
7950 @Override
7951 public UserNotificationEvent fetchByU_DT_A_A_First(long userId,
7952 int deliveryType, boolean actionRequired, boolean archived,
7953 OrderByComparator<UserNotificationEvent> orderByComparator) {
7954 List<UserNotificationEvent> list = findByU_DT_A_A(userId, deliveryType,
7955 actionRequired, archived, 0, 1, orderByComparator);
7956
7957 if (!list.isEmpty()) {
7958 return list.get(0);
7959 }
7960
7961 return null;
7962 }
7963
7964
7975 @Override
7976 public UserNotificationEvent findByU_DT_A_A_Last(long userId,
7977 int deliveryType, boolean actionRequired, boolean archived,
7978 OrderByComparator<UserNotificationEvent> orderByComparator)
7979 throws NoSuchUserNotificationEventException {
7980 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_A_Last(userId,
7981 deliveryType, actionRequired, archived, orderByComparator);
7982
7983 if (userNotificationEvent != null) {
7984 return userNotificationEvent;
7985 }
7986
7987 StringBundler msg = new StringBundler(10);
7988
7989 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7990
7991 msg.append("userId=");
7992 msg.append(userId);
7993
7994 msg.append(", deliveryType=");
7995 msg.append(deliveryType);
7996
7997 msg.append(", actionRequired=");
7998 msg.append(actionRequired);
7999
8000 msg.append(", archived=");
8001 msg.append(archived);
8002
8003 msg.append(StringPool.CLOSE_CURLY_BRACE);
8004
8005 throw new NoSuchUserNotificationEventException(msg.toString());
8006 }
8007
8008
8018 @Override
8019 public UserNotificationEvent fetchByU_DT_A_A_Last(long userId,
8020 int deliveryType, boolean actionRequired, boolean archived,
8021 OrderByComparator<UserNotificationEvent> orderByComparator) {
8022 int count = countByU_DT_A_A(userId, deliveryType, actionRequired,
8023 archived);
8024
8025 if (count == 0) {
8026 return null;
8027 }
8028
8029 List<UserNotificationEvent> list = findByU_DT_A_A(userId, deliveryType,
8030 actionRequired, archived, count - 1, count, orderByComparator);
8031
8032 if (!list.isEmpty()) {
8033 return list.get(0);
8034 }
8035
8036 return null;
8037 }
8038
8039
8051 @Override
8052 public UserNotificationEvent[] findByU_DT_A_A_PrevAndNext(
8053 long userNotificationEventId, long userId, int deliveryType,
8054 boolean actionRequired, boolean archived,
8055 OrderByComparator<UserNotificationEvent> orderByComparator)
8056 throws NoSuchUserNotificationEventException {
8057 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
8058
8059 Session session = null;
8060
8061 try {
8062 session = openSession();
8063
8064 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
8065
8066 array[0] = getByU_DT_A_A_PrevAndNext(session,
8067 userNotificationEvent, userId, deliveryType,
8068 actionRequired, archived, orderByComparator, true);
8069
8070 array[1] = userNotificationEvent;
8071
8072 array[2] = getByU_DT_A_A_PrevAndNext(session,
8073 userNotificationEvent, userId, deliveryType,
8074 actionRequired, archived, orderByComparator, false);
8075
8076 return array;
8077 }
8078 catch (Exception e) {
8079 throw processException(e);
8080 }
8081 finally {
8082 closeSession(session);
8083 }
8084 }
8085
8086 protected UserNotificationEvent getByU_DT_A_A_PrevAndNext(Session session,
8087 UserNotificationEvent userNotificationEvent, long userId,
8088 int deliveryType, boolean actionRequired, boolean archived,
8089 OrderByComparator<UserNotificationEvent> orderByComparator,
8090 boolean previous) {
8091 StringBundler query = null;
8092
8093 if (orderByComparator != null) {
8094 query = new StringBundler(7 +
8095 (orderByComparator.getOrderByConditionFields().length * 3) +
8096 (orderByComparator.getOrderByFields().length * 3));
8097 }
8098 else {
8099 query = new StringBundler(6);
8100 }
8101
8102 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
8103
8104 query.append(_FINDER_COLUMN_U_DT_A_A_USERID_2);
8105
8106 query.append(_FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2);
8107
8108 query.append(_FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2);
8109
8110 query.append(_FINDER_COLUMN_U_DT_A_A_ARCHIVED_2);
8111
8112 if (orderByComparator != null) {
8113 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8114
8115 if (orderByConditionFields.length > 0) {
8116 query.append(WHERE_AND);
8117 }
8118
8119 for (int i = 0; i < orderByConditionFields.length; i++) {
8120 query.append(_ORDER_BY_ENTITY_ALIAS);
8121 query.append(orderByConditionFields[i]);
8122
8123 if ((i + 1) < orderByConditionFields.length) {
8124 if (orderByComparator.isAscending() ^ previous) {
8125 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8126 }
8127 else {
8128 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8129 }
8130 }
8131 else {
8132 if (orderByComparator.isAscending() ^ previous) {
8133 query.append(WHERE_GREATER_THAN);
8134 }
8135 else {
8136 query.append(WHERE_LESSER_THAN);
8137 }
8138 }
8139 }
8140
8141 query.append(ORDER_BY_CLAUSE);
8142
8143 String[] orderByFields = orderByComparator.getOrderByFields();
8144
8145 for (int i = 0; i < orderByFields.length; i++) {
8146 query.append(_ORDER_BY_ENTITY_ALIAS);
8147 query.append(orderByFields[i]);
8148
8149 if ((i + 1) < orderByFields.length) {
8150 if (orderByComparator.isAscending() ^ previous) {
8151 query.append(ORDER_BY_ASC_HAS_NEXT);
8152 }
8153 else {
8154 query.append(ORDER_BY_DESC_HAS_NEXT);
8155 }
8156 }
8157 else {
8158 if (orderByComparator.isAscending() ^ previous) {
8159 query.append(ORDER_BY_ASC);
8160 }
8161 else {
8162 query.append(ORDER_BY_DESC);
8163 }
8164 }
8165 }
8166 }
8167 else {
8168 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
8169 }
8170
8171 String sql = query.toString();
8172
8173 Query q = session.createQuery(sql);
8174
8175 q.setFirstResult(0);
8176 q.setMaxResults(2);
8177
8178 QueryPos qPos = QueryPos.getInstance(q);
8179
8180 qPos.add(userId);
8181
8182 qPos.add(deliveryType);
8183
8184 qPos.add(actionRequired);
8185
8186 qPos.add(archived);
8187
8188 if (orderByComparator != null) {
8189 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
8190
8191 for (Object value : values) {
8192 qPos.add(value);
8193 }
8194 }
8195
8196 List<UserNotificationEvent> list = q.list();
8197
8198 if (list.size() == 2) {
8199 return list.get(1);
8200 }
8201 else {
8202 return null;
8203 }
8204 }
8205
8206
8214 @Override
8215 public void removeByU_DT_A_A(long userId, int deliveryType,
8216 boolean actionRequired, boolean archived) {
8217 for (UserNotificationEvent userNotificationEvent : findByU_DT_A_A(
8218 userId, deliveryType, actionRequired, archived,
8219 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8220 remove(userNotificationEvent);
8221 }
8222 }
8223
8224
8233 @Override
8234 public int countByU_DT_A_A(long userId, int deliveryType,
8235 boolean actionRequired, boolean archived) {
8236 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_A_A;
8237
8238 Object[] finderArgs = new Object[] {
8239 userId, deliveryType, actionRequired, archived
8240 };
8241
8242 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8243
8244 if (count == null) {
8245 StringBundler query = new StringBundler(5);
8246
8247 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
8248
8249 query.append(_FINDER_COLUMN_U_DT_A_A_USERID_2);
8250
8251 query.append(_FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2);
8252
8253 query.append(_FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2);
8254
8255 query.append(_FINDER_COLUMN_U_DT_A_A_ARCHIVED_2);
8256
8257 String sql = query.toString();
8258
8259 Session session = null;
8260
8261 try {
8262 session = openSession();
8263
8264 Query q = session.createQuery(sql);
8265
8266 QueryPos qPos = QueryPos.getInstance(q);
8267
8268 qPos.add(userId);
8269
8270 qPos.add(deliveryType);
8271
8272 qPos.add(actionRequired);
8273
8274 qPos.add(archived);
8275
8276 count = (Long)q.uniqueResult();
8277
8278 finderCache.putResult(finderPath, finderArgs, count);
8279 }
8280 catch (Exception e) {
8281 finderCache.removeResult(finderPath, finderArgs);
8282
8283 throw processException(e);
8284 }
8285 finally {
8286 closeSession(session);
8287 }
8288 }
8289
8290 return count.intValue();
8291 }
8292
8293 private static final String _FINDER_COLUMN_U_DT_A_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
8294 private static final String _FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
8295 private static final String _FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ? AND ";
8296 private static final String _FINDER_COLUMN_U_DT_A_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
8297
8298 public UserNotificationEventPersistenceImpl() {
8299 setModelClass(UserNotificationEvent.class);
8300 }
8301
8302
8307 @Override
8308 public void cacheResult(UserNotificationEvent userNotificationEvent) {
8309 entityCache.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8310 UserNotificationEventImpl.class,
8311 userNotificationEvent.getPrimaryKey(), userNotificationEvent);
8312
8313 userNotificationEvent.resetOriginalValues();
8314 }
8315
8316
8321 @Override
8322 public void cacheResult(List<UserNotificationEvent> userNotificationEvents) {
8323 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
8324 if (entityCache.getResult(
8325 UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8326 UserNotificationEventImpl.class,
8327 userNotificationEvent.getPrimaryKey()) == null) {
8328 cacheResult(userNotificationEvent);
8329 }
8330 else {
8331 userNotificationEvent.resetOriginalValues();
8332 }
8333 }
8334 }
8335
8336
8343 @Override
8344 public void clearCache() {
8345 entityCache.clearCache(UserNotificationEventImpl.class);
8346
8347 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
8348 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8349 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8350 }
8351
8352
8359 @Override
8360 public void clearCache(UserNotificationEvent userNotificationEvent) {
8361 entityCache.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8362 UserNotificationEventImpl.class,
8363 userNotificationEvent.getPrimaryKey());
8364
8365 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8366 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8367 }
8368
8369 @Override
8370 public void clearCache(List<UserNotificationEvent> userNotificationEvents) {
8371 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8372 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8373
8374 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
8375 entityCache.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8376 UserNotificationEventImpl.class,
8377 userNotificationEvent.getPrimaryKey());
8378 }
8379 }
8380
8381
8387 @Override
8388 public UserNotificationEvent create(long userNotificationEventId) {
8389 UserNotificationEvent userNotificationEvent = new UserNotificationEventImpl();
8390
8391 userNotificationEvent.setNew(true);
8392 userNotificationEvent.setPrimaryKey(userNotificationEventId);
8393
8394 String uuid = PortalUUIDUtil.generate();
8395
8396 userNotificationEvent.setUuid(uuid);
8397
8398 userNotificationEvent.setCompanyId(companyProvider.getCompanyId());
8399
8400 return userNotificationEvent;
8401 }
8402
8403
8410 @Override
8411 public UserNotificationEvent remove(long userNotificationEventId)
8412 throws NoSuchUserNotificationEventException {
8413 return remove((Serializable)userNotificationEventId);
8414 }
8415
8416
8423 @Override
8424 public UserNotificationEvent remove(Serializable primaryKey)
8425 throws NoSuchUserNotificationEventException {
8426 Session session = null;
8427
8428 try {
8429 session = openSession();
8430
8431 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
8432 primaryKey);
8433
8434 if (userNotificationEvent == null) {
8435 if (_log.isWarnEnabled()) {
8436 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
8437 }
8438
8439 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
8440 primaryKey);
8441 }
8442
8443 return remove(userNotificationEvent);
8444 }
8445 catch (NoSuchUserNotificationEventException nsee) {
8446 throw nsee;
8447 }
8448 catch (Exception e) {
8449 throw processException(e);
8450 }
8451 finally {
8452 closeSession(session);
8453 }
8454 }
8455
8456 @Override
8457 protected UserNotificationEvent removeImpl(
8458 UserNotificationEvent userNotificationEvent) {
8459 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
8460
8461 Session session = null;
8462
8463 try {
8464 session = openSession();
8465
8466 if (!session.contains(userNotificationEvent)) {
8467 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
8468 userNotificationEvent.getPrimaryKeyObj());
8469 }
8470
8471 if (userNotificationEvent != null) {
8472 session.delete(userNotificationEvent);
8473 }
8474 }
8475 catch (Exception e) {
8476 throw processException(e);
8477 }
8478 finally {
8479 closeSession(session);
8480 }
8481
8482 if (userNotificationEvent != null) {
8483 clearCache(userNotificationEvent);
8484 }
8485
8486 return userNotificationEvent;
8487 }
8488
8489 @Override
8490 public UserNotificationEvent updateImpl(
8491 UserNotificationEvent userNotificationEvent) {
8492 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
8493
8494 boolean isNew = userNotificationEvent.isNew();
8495
8496 UserNotificationEventModelImpl userNotificationEventModelImpl = (UserNotificationEventModelImpl)userNotificationEvent;
8497
8498 if (Validator.isNull(userNotificationEvent.getUuid())) {
8499 String uuid = PortalUUIDUtil.generate();
8500
8501 userNotificationEvent.setUuid(uuid);
8502 }
8503
8504 Session session = null;
8505
8506 try {
8507 session = openSession();
8508
8509 if (userNotificationEvent.isNew()) {
8510 session.save(userNotificationEvent);
8511
8512 userNotificationEvent.setNew(false);
8513 }
8514 else {
8515 userNotificationEvent = (UserNotificationEvent)session.merge(userNotificationEvent);
8516 }
8517 }
8518 catch (Exception e) {
8519 throw processException(e);
8520 }
8521 finally {
8522 closeSession(session);
8523 }
8524
8525 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8526
8527 if (isNew || !UserNotificationEventModelImpl.COLUMN_BITMASK_ENABLED) {
8528 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8529 }
8530
8531 else {
8532 if ((userNotificationEventModelImpl.getColumnBitmask() &
8533 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
8534 Object[] args = new Object[] {
8535 userNotificationEventModelImpl.getOriginalUuid()
8536 };
8537
8538 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
8539 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
8540 args);
8541
8542 args = new Object[] { userNotificationEventModelImpl.getUuid() };
8543
8544 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
8545 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
8546 args);
8547 }
8548
8549 if ((userNotificationEventModelImpl.getColumnBitmask() &
8550 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
8551 Object[] args = new Object[] {
8552 userNotificationEventModelImpl.getOriginalUuid(),
8553 userNotificationEventModelImpl.getOriginalCompanyId()
8554 };
8555
8556 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
8557 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
8558 args);
8559
8560 args = new Object[] {
8561 userNotificationEventModelImpl.getUuid(),
8562 userNotificationEventModelImpl.getCompanyId()
8563 };
8564
8565 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
8566 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
8567 args);
8568 }
8569
8570 if ((userNotificationEventModelImpl.getColumnBitmask() &
8571 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
8572 Object[] args = new Object[] {
8573 userNotificationEventModelImpl.getOriginalUserId()
8574 };
8575
8576 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
8577 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
8578 args);
8579
8580 args = new Object[] { userNotificationEventModelImpl.getUserId() };
8581
8582 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
8583 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
8584 args);
8585 }
8586
8587 if ((userNotificationEventModelImpl.getColumnBitmask() &
8588 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE.getColumnBitmask()) != 0) {
8589 Object[] args = new Object[] {
8590 userNotificationEventModelImpl.getOriginalType()
8591 };
8592
8593 finderCache.removeResult(FINDER_PATH_COUNT_BY_TYPE, args);
8594 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE,
8595 args);
8596
8597 args = new Object[] { userNotificationEventModelImpl.getType() };
8598
8599 finderCache.removeResult(FINDER_PATH_COUNT_BY_TYPE, args);
8600 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE,
8601 args);
8602 }
8603
8604 if ((userNotificationEventModelImpl.getColumnBitmask() &
8605 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT.getColumnBitmask()) != 0) {
8606 Object[] args = new Object[] {
8607 userNotificationEventModelImpl.getOriginalUserId(),
8608 userNotificationEventModelImpl.getOriginalDeliveryType()
8609 };
8610
8611 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT, args);
8612 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT,
8613 args);
8614
8615 args = new Object[] {
8616 userNotificationEventModelImpl.getUserId(),
8617 userNotificationEventModelImpl.getDeliveryType()
8618 };
8619
8620 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT, args);
8621 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT,
8622 args);
8623 }
8624
8625 if ((userNotificationEventModelImpl.getColumnBitmask() &
8626 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D.getColumnBitmask()) != 0) {
8627 Object[] args = new Object[] {
8628 userNotificationEventModelImpl.getOriginalUserId(),
8629 userNotificationEventModelImpl.getOriginalDelivered()
8630 };
8631
8632 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_D, args);
8633 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D,
8634 args);
8635
8636 args = new Object[] {
8637 userNotificationEventModelImpl.getUserId(),
8638 userNotificationEventModelImpl.getDelivered()
8639 };
8640
8641 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_D, args);
8642 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D,
8643 args);
8644 }
8645
8646 if ((userNotificationEventModelImpl.getColumnBitmask() &
8647 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A.getColumnBitmask()) != 0) {
8648 Object[] args = new Object[] {
8649 userNotificationEventModelImpl.getOriginalUserId(),
8650 userNotificationEventModelImpl.getOriginalArchived()
8651 };
8652
8653 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
8654 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
8655 args);
8656
8657 args = new Object[] {
8658 userNotificationEventModelImpl.getUserId(),
8659 userNotificationEventModelImpl.getArchived()
8660 };
8661
8662 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
8663 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
8664 args);
8665 }
8666
8667 if ((userNotificationEventModelImpl.getColumnBitmask() &
8668 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D.getColumnBitmask()) != 0) {
8669 Object[] args = new Object[] {
8670 userNotificationEventModelImpl.getOriginalUserId(),
8671 userNotificationEventModelImpl.getOriginalDeliveryType(),
8672 userNotificationEventModelImpl.getOriginalDelivered()
8673 };
8674
8675 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_D, args);
8676 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D,
8677 args);
8678
8679 args = new Object[] {
8680 userNotificationEventModelImpl.getUserId(),
8681 userNotificationEventModelImpl.getDeliveryType(),
8682 userNotificationEventModelImpl.getDelivered()
8683 };
8684
8685 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_D, args);
8686 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D,
8687 args);
8688 }
8689
8690 if ((userNotificationEventModelImpl.getColumnBitmask() &
8691 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A.getColumnBitmask()) != 0) {
8692 Object[] args = new Object[] {
8693 userNotificationEventModelImpl.getOriginalUserId(),
8694 userNotificationEventModelImpl.getOriginalDeliveryType(),
8695 userNotificationEventModelImpl.getOriginalArchived()
8696 };
8697
8698 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_A, args);
8699 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A,
8700 args);
8701
8702 args = new Object[] {
8703 userNotificationEventModelImpl.getUserId(),
8704 userNotificationEventModelImpl.getDeliveryType(),
8705 userNotificationEventModelImpl.getArchived()
8706 };
8707
8708 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_A, args);
8709 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A,
8710 args);
8711 }
8712
8713 if ((userNotificationEventModelImpl.getColumnBitmask() &
8714 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A.getColumnBitmask()) != 0) {
8715 Object[] args = new Object[] {
8716 userNotificationEventModelImpl.getOriginalUserId(),
8717 userNotificationEventModelImpl.getOriginalDelivered(),
8718 userNotificationEventModelImpl.getOriginalActionRequired()
8719 };
8720
8721 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_D_A, args);
8722 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A,
8723 args);
8724
8725 args = new Object[] {
8726 userNotificationEventModelImpl.getUserId(),
8727 userNotificationEventModelImpl.getDelivered(),
8728 userNotificationEventModelImpl.getActionRequired()
8729 };
8730
8731 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_D_A, args);
8732 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A,
8733 args);
8734 }
8735
8736 if ((userNotificationEventModelImpl.getColumnBitmask() &
8737 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A.getColumnBitmask()) != 0) {
8738 Object[] args = new Object[] {
8739 userNotificationEventModelImpl.getOriginalUserId(),
8740 userNotificationEventModelImpl.getOriginalActionRequired(),
8741 userNotificationEventModelImpl.getOriginalArchived()
8742 };
8743
8744 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_A_A, args);
8745 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A,
8746 args);
8747
8748 args = new Object[] {
8749 userNotificationEventModelImpl.getUserId(),
8750 userNotificationEventModelImpl.getActionRequired(),
8751 userNotificationEventModelImpl.getArchived()
8752 };
8753
8754 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_A_A, args);
8755 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A,
8756 args);
8757 }
8758
8759 if ((userNotificationEventModelImpl.getColumnBitmask() &
8760 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_T_DT_D.getColumnBitmask()) != 0) {
8761 Object[] args = new Object[] {
8762 userNotificationEventModelImpl.getOriginalUserId(),
8763 userNotificationEventModelImpl.getOriginalType(),
8764 userNotificationEventModelImpl.getOriginalDeliveryType(),
8765 userNotificationEventModelImpl.getOriginalDelivered()
8766 };
8767
8768 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_T_DT_D, args);
8769 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_T_DT_D,
8770 args);
8771
8772 args = new Object[] {
8773 userNotificationEventModelImpl.getUserId(),
8774 userNotificationEventModelImpl.getType(),
8775 userNotificationEventModelImpl.getDeliveryType(),
8776 userNotificationEventModelImpl.getDelivered()
8777 };
8778
8779 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_T_DT_D, args);
8780 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_T_DT_D,
8781 args);
8782 }
8783
8784 if ((userNotificationEventModelImpl.getColumnBitmask() &
8785 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A.getColumnBitmask()) != 0) {
8786 Object[] args = new Object[] {
8787 userNotificationEventModelImpl.getOriginalUserId(),
8788 userNotificationEventModelImpl.getOriginalDeliveryType(),
8789 userNotificationEventModelImpl.getOriginalDelivered(),
8790 userNotificationEventModelImpl.getOriginalActionRequired()
8791 };
8792
8793 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_D_A, args);
8794 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A,
8795 args);
8796
8797 args = new Object[] {
8798 userNotificationEventModelImpl.getUserId(),
8799 userNotificationEventModelImpl.getDeliveryType(),
8800 userNotificationEventModelImpl.getDelivered(),
8801 userNotificationEventModelImpl.getActionRequired()
8802 };
8803
8804 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_D_A, args);
8805 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A,
8806 args);
8807 }
8808
8809 if ((userNotificationEventModelImpl.getColumnBitmask() &
8810 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A.getColumnBitmask()) != 0) {
8811 Object[] args = new Object[] {
8812 userNotificationEventModelImpl.getOriginalUserId(),
8813 userNotificationEventModelImpl.getOriginalDeliveryType(),
8814 userNotificationEventModelImpl.getOriginalActionRequired(),
8815 userNotificationEventModelImpl.getOriginalArchived()
8816 };
8817
8818 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_A_A, args);
8819 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A,
8820 args);
8821
8822 args = new Object[] {
8823 userNotificationEventModelImpl.getUserId(),
8824 userNotificationEventModelImpl.getDeliveryType(),
8825 userNotificationEventModelImpl.getActionRequired(),
8826 userNotificationEventModelImpl.getArchived()
8827 };
8828
8829 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_A_A, args);
8830 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A,
8831 args);
8832 }
8833 }
8834
8835 entityCache.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8836 UserNotificationEventImpl.class,
8837 userNotificationEvent.getPrimaryKey(), userNotificationEvent, false);
8838
8839 userNotificationEvent.resetOriginalValues();
8840
8841 return userNotificationEvent;
8842 }
8843
8844 protected UserNotificationEvent toUnwrappedModel(
8845 UserNotificationEvent userNotificationEvent) {
8846 if (userNotificationEvent instanceof UserNotificationEventImpl) {
8847 return userNotificationEvent;
8848 }
8849
8850 UserNotificationEventImpl userNotificationEventImpl = new UserNotificationEventImpl();
8851
8852 userNotificationEventImpl.setNew(userNotificationEvent.isNew());
8853 userNotificationEventImpl.setPrimaryKey(userNotificationEvent.getPrimaryKey());
8854
8855 userNotificationEventImpl.setMvccVersion(userNotificationEvent.getMvccVersion());
8856 userNotificationEventImpl.setUuid(userNotificationEvent.getUuid());
8857 userNotificationEventImpl.setUserNotificationEventId(userNotificationEvent.getUserNotificationEventId());
8858 userNotificationEventImpl.setCompanyId(userNotificationEvent.getCompanyId());
8859 userNotificationEventImpl.setUserId(userNotificationEvent.getUserId());
8860 userNotificationEventImpl.setType(userNotificationEvent.getType());
8861 userNotificationEventImpl.setTimestamp(userNotificationEvent.getTimestamp());
8862 userNotificationEventImpl.setDeliveryType(userNotificationEvent.getDeliveryType());
8863 userNotificationEventImpl.setDeliverBy(userNotificationEvent.getDeliverBy());
8864 userNotificationEventImpl.setDelivered(userNotificationEvent.isDelivered());
8865 userNotificationEventImpl.setPayload(userNotificationEvent.getPayload());
8866 userNotificationEventImpl.setActionRequired(userNotificationEvent.isActionRequired());
8867 userNotificationEventImpl.setArchived(userNotificationEvent.isArchived());
8868
8869 return userNotificationEventImpl;
8870 }
8871
8872
8879 @Override
8880 public UserNotificationEvent findByPrimaryKey(Serializable primaryKey)
8881 throws NoSuchUserNotificationEventException {
8882 UserNotificationEvent userNotificationEvent = fetchByPrimaryKey(primaryKey);
8883
8884 if (userNotificationEvent == null) {
8885 if (_log.isWarnEnabled()) {
8886 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
8887 }
8888
8889 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
8890 primaryKey);
8891 }
8892
8893 return userNotificationEvent;
8894 }
8895
8896
8903 @Override
8904 public UserNotificationEvent findByPrimaryKey(long userNotificationEventId)
8905 throws NoSuchUserNotificationEventException {
8906 return findByPrimaryKey((Serializable)userNotificationEventId);
8907 }
8908
8909
8915 @Override
8916 public UserNotificationEvent fetchByPrimaryKey(Serializable primaryKey) {
8917 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)entityCache.getResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8918 UserNotificationEventImpl.class, primaryKey);
8919
8920 if (userNotificationEvent == _nullUserNotificationEvent) {
8921 return null;
8922 }
8923
8924 if (userNotificationEvent == null) {
8925 Session session = null;
8926
8927 try {
8928 session = openSession();
8929
8930 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
8931 primaryKey);
8932
8933 if (userNotificationEvent != null) {
8934 cacheResult(userNotificationEvent);
8935 }
8936 else {
8937 entityCache.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8938 UserNotificationEventImpl.class, primaryKey,
8939 _nullUserNotificationEvent);
8940 }
8941 }
8942 catch (Exception e) {
8943 entityCache.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8944 UserNotificationEventImpl.class, primaryKey);
8945
8946 throw processException(e);
8947 }
8948 finally {
8949 closeSession(session);
8950 }
8951 }
8952
8953 return userNotificationEvent;
8954 }
8955
8956
8962 @Override
8963 public UserNotificationEvent fetchByPrimaryKey(long userNotificationEventId) {
8964 return fetchByPrimaryKey((Serializable)userNotificationEventId);
8965 }
8966
8967 @Override
8968 public Map<Serializable, UserNotificationEvent> fetchByPrimaryKeys(
8969 Set<Serializable> primaryKeys) {
8970 if (primaryKeys.isEmpty()) {
8971 return Collections.emptyMap();
8972 }
8973
8974 Map<Serializable, UserNotificationEvent> map = new HashMap<Serializable, UserNotificationEvent>();
8975
8976 if (primaryKeys.size() == 1) {
8977 Iterator<Serializable> iterator = primaryKeys.iterator();
8978
8979 Serializable primaryKey = iterator.next();
8980
8981 UserNotificationEvent userNotificationEvent = fetchByPrimaryKey(primaryKey);
8982
8983 if (userNotificationEvent != null) {
8984 map.put(primaryKey, userNotificationEvent);
8985 }
8986
8987 return map;
8988 }
8989
8990 Set<Serializable> uncachedPrimaryKeys = null;
8991
8992 for (Serializable primaryKey : primaryKeys) {
8993 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)entityCache.getResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8994 UserNotificationEventImpl.class, primaryKey);
8995
8996 if (userNotificationEvent == null) {
8997 if (uncachedPrimaryKeys == null) {
8998 uncachedPrimaryKeys = new HashSet<Serializable>();
8999 }
9000
9001 uncachedPrimaryKeys.add(primaryKey);
9002 }
9003 else {
9004 map.put(primaryKey, userNotificationEvent);
9005 }
9006 }
9007
9008 if (uncachedPrimaryKeys == null) {
9009 return map;
9010 }
9011
9012 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
9013 1);
9014
9015 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE_PKS_IN);
9016
9017 for (Serializable primaryKey : uncachedPrimaryKeys) {
9018 query.append(String.valueOf(primaryKey));
9019
9020 query.append(StringPool.COMMA);
9021 }
9022
9023 query.setIndex(query.index() - 1);
9024
9025 query.append(StringPool.CLOSE_PARENTHESIS);
9026
9027 String sql = query.toString();
9028
9029 Session session = null;
9030
9031 try {
9032 session = openSession();
9033
9034 Query q = session.createQuery(sql);
9035
9036 for (UserNotificationEvent userNotificationEvent : (List<UserNotificationEvent>)q.list()) {
9037 map.put(userNotificationEvent.getPrimaryKeyObj(),
9038 userNotificationEvent);
9039
9040 cacheResult(userNotificationEvent);
9041
9042 uncachedPrimaryKeys.remove(userNotificationEvent.getPrimaryKeyObj());
9043 }
9044
9045 for (Serializable primaryKey : uncachedPrimaryKeys) {
9046 entityCache.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
9047 UserNotificationEventImpl.class, primaryKey,
9048 _nullUserNotificationEvent);
9049 }
9050 }
9051 catch (Exception e) {
9052 throw processException(e);
9053 }
9054 finally {
9055 closeSession(session);
9056 }
9057
9058 return map;
9059 }
9060
9061
9066 @Override
9067 public List<UserNotificationEvent> findAll() {
9068 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9069 }
9070
9071
9082 @Override
9083 public List<UserNotificationEvent> findAll(int start, int end) {
9084 return findAll(start, end, null);
9085 }
9086
9087
9099 @Override
9100 public List<UserNotificationEvent> findAll(int start, int end,
9101 OrderByComparator<UserNotificationEvent> orderByComparator) {
9102 return findAll(start, end, orderByComparator, true);
9103 }
9104
9105
9118 @Override
9119 public List<UserNotificationEvent> findAll(int start, int end,
9120 OrderByComparator<UserNotificationEvent> orderByComparator,
9121 boolean retrieveFromCache) {
9122 boolean pagination = true;
9123 FinderPath finderPath = null;
9124 Object[] finderArgs = null;
9125
9126 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9127 (orderByComparator == null)) {
9128 pagination = false;
9129 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
9130 finderArgs = FINDER_ARGS_EMPTY;
9131 }
9132 else {
9133 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
9134 finderArgs = new Object[] { start, end, orderByComparator };
9135 }
9136
9137 List<UserNotificationEvent> list = null;
9138
9139 if (retrieveFromCache) {
9140 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
9141 finderArgs, this);
9142 }
9143
9144 if (list == null) {
9145 StringBundler query = null;
9146 String sql = null;
9147
9148 if (orderByComparator != null) {
9149 query = new StringBundler(2 +
9150 (orderByComparator.getOrderByFields().length * 2));
9151
9152 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT);
9153
9154 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9155 orderByComparator);
9156
9157 sql = query.toString();
9158 }
9159 else {
9160 sql = _SQL_SELECT_USERNOTIFICATIONEVENT;
9161
9162 if (pagination) {
9163 sql = sql.concat(UserNotificationEventModelImpl.ORDER_BY_JPQL);
9164 }
9165 }
9166
9167 Session session = null;
9168
9169 try {
9170 session = openSession();
9171
9172 Query q = session.createQuery(sql);
9173
9174 if (!pagination) {
9175 list = (List<UserNotificationEvent>)QueryUtil.list(q,
9176 getDialect(), start, end, false);
9177
9178 Collections.sort(list);
9179
9180 list = Collections.unmodifiableList(list);
9181 }
9182 else {
9183 list = (List<UserNotificationEvent>)QueryUtil.list(q,
9184 getDialect(), start, end);
9185 }
9186
9187 cacheResult(list);
9188
9189 finderCache.putResult(finderPath, finderArgs, list);
9190 }
9191 catch (Exception e) {
9192 finderCache.removeResult(finderPath, finderArgs);
9193
9194 throw processException(e);
9195 }
9196 finally {
9197 closeSession(session);
9198 }
9199 }
9200
9201 return list;
9202 }
9203
9204
9208 @Override
9209 public void removeAll() {
9210 for (UserNotificationEvent userNotificationEvent : findAll()) {
9211 remove(userNotificationEvent);
9212 }
9213 }
9214
9215
9220 @Override
9221 public int countAll() {
9222 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
9223 FINDER_ARGS_EMPTY, this);
9224
9225 if (count == null) {
9226 Session session = null;
9227
9228 try {
9229 session = openSession();
9230
9231 Query q = session.createQuery(_SQL_COUNT_USERNOTIFICATIONEVENT);
9232
9233 count = (Long)q.uniqueResult();
9234
9235 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
9236 count);
9237 }
9238 catch (Exception e) {
9239 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
9240 FINDER_ARGS_EMPTY);
9241
9242 throw processException(e);
9243 }
9244 finally {
9245 closeSession(session);
9246 }
9247 }
9248
9249 return count.intValue();
9250 }
9251
9252 @Override
9253 public Set<String> getBadColumnNames() {
9254 return _badColumnNames;
9255 }
9256
9257 @Override
9258 protected Map<String, Integer> getTableColumnsMap() {
9259 return UserNotificationEventModelImpl.TABLE_COLUMNS_MAP;
9260 }
9261
9262
9265 public void afterPropertiesSet() {
9266 }
9267
9268 public void destroy() {
9269 entityCache.removeCache(UserNotificationEventImpl.class.getName());
9270 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
9271 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
9272 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
9273 }
9274
9275 @BeanReference(type = CompanyProviderWrapper.class)
9276 protected CompanyProvider companyProvider;
9277 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
9278 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
9279 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent";
9280 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT_WHERE_PKS_IN = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent WHERE userNotificationEventId IN (";
9281 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT_WHERE = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent WHERE ";
9282 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent";
9283 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT_WHERE = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent WHERE ";
9284 private static final String _ORDER_BY_ENTITY_ALIAS = "userNotificationEvent.";
9285 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserNotificationEvent exists with the primary key ";
9286 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserNotificationEvent exists with the key {";
9287 private static final Log _log = LogFactoryUtil.getLog(UserNotificationEventPersistenceImpl.class);
9288 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
9289 "uuid", "type"
9290 });
9291 private static final UserNotificationEvent _nullUserNotificationEvent = new UserNotificationEventImpl() {
9292 @Override
9293 public Object clone() {
9294 return this;
9295 }
9296
9297 @Override
9298 public CacheModel<UserNotificationEvent> toCacheModel() {
9299 return _nullUserNotificationEventCacheModel;
9300 }
9301 };
9302
9303 private static final CacheModel<UserNotificationEvent> _nullUserNotificationEventCacheModel =
9304 new NullCacheModel();
9305
9306 private static class NullCacheModel implements CacheModel<UserNotificationEvent>,
9307 MVCCModel {
9308 @Override
9309 public long getMvccVersion() {
9310 return -1;
9311 }
9312
9313 @Override
9314 public void setMvccVersion(long mvccVersion) {
9315 }
9316
9317 @Override
9318 public UserNotificationEvent toEntityModel() {
9319 return _nullUserNotificationEvent;
9320 }
9321 }
9322 }