001
014
015 package com.liferay.portal.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.NoSuchUserNotificationEventException;
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.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.kernel.util.SetUtil;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.Validator;
036 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.MVCCModel;
039 import com.liferay.portal.model.UserNotificationEvent;
040 import com.liferay.portal.model.impl.UserNotificationEventImpl;
041 import com.liferay.portal.model.impl.UserNotificationEventModelImpl;
042 import com.liferay.portal.service.persistence.UserNotificationEventPersistence;
043
044 import java.io.Serializable;
045
046 import java.util.Collections;
047 import java.util.HashMap;
048 import java.util.HashSet;
049 import java.util.Iterator;
050 import java.util.List;
051 import java.util.Map;
052 import java.util.Set;
053
054
066 @ProviderType
067 public class UserNotificationEventPersistenceImpl extends BasePersistenceImpl<UserNotificationEvent>
068 implements UserNotificationEventPersistence {
069
074 public static final String FINDER_CLASS_NAME_ENTITY = UserNotificationEventImpl.class.getName();
075 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List1";
077 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List2";
079 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
080 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
081 UserNotificationEventImpl.class,
082 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
083 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
084 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
085 UserNotificationEventImpl.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
087 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
088 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
090 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
091 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
092 UserNotificationEventImpl.class,
093 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
094 new String[] {
095 String.class.getName(),
096
097 Integer.class.getName(), Integer.class.getName(),
098 OrderByComparator.class.getName()
099 });
100 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
101 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
102 UserNotificationEventImpl.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
104 new String[] { String.class.getName() },
105 UserNotificationEventModelImpl.UUID_COLUMN_BITMASK |
106 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
107 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
108 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
109 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
110 new String[] { String.class.getName() });
111
112
118 @Override
119 public List<UserNotificationEvent> findByUuid(String uuid) {
120 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
121 }
122
123
135 @Override
136 public List<UserNotificationEvent> findByUuid(String uuid, int start,
137 int end) {
138 return findByUuid(uuid, start, end, null);
139 }
140
141
154 @Override
155 public List<UserNotificationEvent> findByUuid(String uuid, int start,
156 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
157 return findByUuid(uuid, start, end, orderByComparator, true);
158 }
159
160
174 @Override
175 public List<UserNotificationEvent> findByUuid(String uuid, int start,
176 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
177 boolean retrieveFromCache) {
178 boolean pagination = true;
179 FinderPath finderPath = null;
180 Object[] finderArgs = null;
181
182 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
183 (orderByComparator == null)) {
184 pagination = false;
185 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
186 finderArgs = new Object[] { uuid };
187 }
188 else {
189 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
190 finderArgs = new Object[] { uuid, start, end, orderByComparator };
191 }
192
193 List<UserNotificationEvent> list = null;
194
195 if (retrieveFromCache) {
196 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
197 finderArgs, this);
198
199 if ((list != null) && !list.isEmpty()) {
200 for (UserNotificationEvent userNotificationEvent : list) {
201 if (!Validator.equals(uuid, userNotificationEvent.getUuid())) {
202 list = null;
203
204 break;
205 }
206 }
207 }
208 }
209
210 if (list == null) {
211 StringBundler query = null;
212
213 if (orderByComparator != null) {
214 query = new StringBundler(3 +
215 (orderByComparator.getOrderByFields().length * 3));
216 }
217 else {
218 query = new StringBundler(3);
219 }
220
221 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
222
223 boolean bindUuid = false;
224
225 if (uuid == null) {
226 query.append(_FINDER_COLUMN_UUID_UUID_1);
227 }
228 else if (uuid.equals(StringPool.BLANK)) {
229 query.append(_FINDER_COLUMN_UUID_UUID_3);
230 }
231 else {
232 bindUuid = true;
233
234 query.append(_FINDER_COLUMN_UUID_UUID_2);
235 }
236
237 if (orderByComparator != null) {
238 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
239 orderByComparator);
240 }
241 else
242 if (pagination) {
243 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
244 }
245
246 String sql = query.toString();
247
248 Session session = null;
249
250 try {
251 session = openSession();
252
253 Query q = session.createQuery(sql);
254
255 QueryPos qPos = QueryPos.getInstance(q);
256
257 if (bindUuid) {
258 qPos.add(uuid);
259 }
260
261 if (!pagination) {
262 list = (List<UserNotificationEvent>)QueryUtil.list(q,
263 getDialect(), start, end, false);
264
265 Collections.sort(list);
266
267 list = Collections.unmodifiableList(list);
268 }
269 else {
270 list = (List<UserNotificationEvent>)QueryUtil.list(q,
271 getDialect(), start, end);
272 }
273
274 cacheResult(list);
275
276 finderCache.putResult(finderPath, finderArgs, list);
277 }
278 catch (Exception e) {
279 finderCache.removeResult(finderPath, finderArgs);
280
281 throw processException(e);
282 }
283 finally {
284 closeSession(session);
285 }
286 }
287
288 return list;
289 }
290
291
299 @Override
300 public UserNotificationEvent findByUuid_First(String uuid,
301 OrderByComparator<UserNotificationEvent> orderByComparator)
302 throws NoSuchUserNotificationEventException {
303 UserNotificationEvent userNotificationEvent = fetchByUuid_First(uuid,
304 orderByComparator);
305
306 if (userNotificationEvent != null) {
307 return userNotificationEvent;
308 }
309
310 StringBundler msg = new StringBundler(4);
311
312 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
313
314 msg.append("uuid=");
315 msg.append(uuid);
316
317 msg.append(StringPool.CLOSE_CURLY_BRACE);
318
319 throw new NoSuchUserNotificationEventException(msg.toString());
320 }
321
322
329 @Override
330 public UserNotificationEvent fetchByUuid_First(String uuid,
331 OrderByComparator<UserNotificationEvent> orderByComparator) {
332 List<UserNotificationEvent> list = findByUuid(uuid, 0, 1,
333 orderByComparator);
334
335 if (!list.isEmpty()) {
336 return list.get(0);
337 }
338
339 return null;
340 }
341
342
350 @Override
351 public UserNotificationEvent findByUuid_Last(String uuid,
352 OrderByComparator<UserNotificationEvent> orderByComparator)
353 throws NoSuchUserNotificationEventException {
354 UserNotificationEvent userNotificationEvent = fetchByUuid_Last(uuid,
355 orderByComparator);
356
357 if (userNotificationEvent != null) {
358 return userNotificationEvent;
359 }
360
361 StringBundler msg = new StringBundler(4);
362
363 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
364
365 msg.append("uuid=");
366 msg.append(uuid);
367
368 msg.append(StringPool.CLOSE_CURLY_BRACE);
369
370 throw new NoSuchUserNotificationEventException(msg.toString());
371 }
372
373
380 @Override
381 public UserNotificationEvent fetchByUuid_Last(String uuid,
382 OrderByComparator<UserNotificationEvent> orderByComparator) {
383 int count = countByUuid(uuid);
384
385 if (count == 0) {
386 return null;
387 }
388
389 List<UserNotificationEvent> list = findByUuid(uuid, count - 1, count,
390 orderByComparator);
391
392 if (!list.isEmpty()) {
393 return list.get(0);
394 }
395
396 return null;
397 }
398
399
408 @Override
409 public UserNotificationEvent[] findByUuid_PrevAndNext(
410 long userNotificationEventId, String uuid,
411 OrderByComparator<UserNotificationEvent> orderByComparator)
412 throws NoSuchUserNotificationEventException {
413 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
414
415 Session session = null;
416
417 try {
418 session = openSession();
419
420 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
421
422 array[0] = getByUuid_PrevAndNext(session, userNotificationEvent,
423 uuid, orderByComparator, true);
424
425 array[1] = userNotificationEvent;
426
427 array[2] = getByUuid_PrevAndNext(session, userNotificationEvent,
428 uuid, orderByComparator, false);
429
430 return array;
431 }
432 catch (Exception e) {
433 throw processException(e);
434 }
435 finally {
436 closeSession(session);
437 }
438 }
439
440 protected UserNotificationEvent getByUuid_PrevAndNext(Session session,
441 UserNotificationEvent userNotificationEvent, String uuid,
442 OrderByComparator<UserNotificationEvent> orderByComparator,
443 boolean previous) {
444 StringBundler query = null;
445
446 if (orderByComparator != null) {
447 query = new StringBundler(6 +
448 (orderByComparator.getOrderByFields().length * 6));
449 }
450 else {
451 query = new StringBundler(3);
452 }
453
454 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
455
456 boolean bindUuid = false;
457
458 if (uuid == null) {
459 query.append(_FINDER_COLUMN_UUID_UUID_1);
460 }
461 else if (uuid.equals(StringPool.BLANK)) {
462 query.append(_FINDER_COLUMN_UUID_UUID_3);
463 }
464 else {
465 bindUuid = true;
466
467 query.append(_FINDER_COLUMN_UUID_UUID_2);
468 }
469
470 if (orderByComparator != null) {
471 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
472
473 if (orderByConditionFields.length > 0) {
474 query.append(WHERE_AND);
475 }
476
477 for (int i = 0; i < orderByConditionFields.length; i++) {
478 query.append(_ORDER_BY_ENTITY_ALIAS);
479 query.append(orderByConditionFields[i]);
480
481 if ((i + 1) < orderByConditionFields.length) {
482 if (orderByComparator.isAscending() ^ previous) {
483 query.append(WHERE_GREATER_THAN_HAS_NEXT);
484 }
485 else {
486 query.append(WHERE_LESSER_THAN_HAS_NEXT);
487 }
488 }
489 else {
490 if (orderByComparator.isAscending() ^ previous) {
491 query.append(WHERE_GREATER_THAN);
492 }
493 else {
494 query.append(WHERE_LESSER_THAN);
495 }
496 }
497 }
498
499 query.append(ORDER_BY_CLAUSE);
500
501 String[] orderByFields = orderByComparator.getOrderByFields();
502
503 for (int i = 0; i < orderByFields.length; i++) {
504 query.append(_ORDER_BY_ENTITY_ALIAS);
505 query.append(orderByFields[i]);
506
507 if ((i + 1) < orderByFields.length) {
508 if (orderByComparator.isAscending() ^ previous) {
509 query.append(ORDER_BY_ASC_HAS_NEXT);
510 }
511 else {
512 query.append(ORDER_BY_DESC_HAS_NEXT);
513 }
514 }
515 else {
516 if (orderByComparator.isAscending() ^ previous) {
517 query.append(ORDER_BY_ASC);
518 }
519 else {
520 query.append(ORDER_BY_DESC);
521 }
522 }
523 }
524 }
525 else {
526 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
527 }
528
529 String sql = query.toString();
530
531 Query q = session.createQuery(sql);
532
533 q.setFirstResult(0);
534 q.setMaxResults(2);
535
536 QueryPos qPos = QueryPos.getInstance(q);
537
538 if (bindUuid) {
539 qPos.add(uuid);
540 }
541
542 if (orderByComparator != null) {
543 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
544
545 for (Object value : values) {
546 qPos.add(value);
547 }
548 }
549
550 List<UserNotificationEvent> list = q.list();
551
552 if (list.size() == 2) {
553 return list.get(1);
554 }
555 else {
556 return null;
557 }
558 }
559
560
565 @Override
566 public void removeByUuid(String uuid) {
567 for (UserNotificationEvent userNotificationEvent : findByUuid(uuid,
568 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
569 remove(userNotificationEvent);
570 }
571 }
572
573
579 @Override
580 public int countByUuid(String uuid) {
581 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
582
583 Object[] finderArgs = new Object[] { uuid };
584
585 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
586
587 if (count == null) {
588 StringBundler query = new StringBundler(2);
589
590 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
591
592 boolean bindUuid = false;
593
594 if (uuid == null) {
595 query.append(_FINDER_COLUMN_UUID_UUID_1);
596 }
597 else if (uuid.equals(StringPool.BLANK)) {
598 query.append(_FINDER_COLUMN_UUID_UUID_3);
599 }
600 else {
601 bindUuid = true;
602
603 query.append(_FINDER_COLUMN_UUID_UUID_2);
604 }
605
606 String sql = query.toString();
607
608 Session session = null;
609
610 try {
611 session = openSession();
612
613 Query q = session.createQuery(sql);
614
615 QueryPos qPos = QueryPos.getInstance(q);
616
617 if (bindUuid) {
618 qPos.add(uuid);
619 }
620
621 count = (Long)q.uniqueResult();
622
623 finderCache.putResult(finderPath, finderArgs, count);
624 }
625 catch (Exception e) {
626 finderCache.removeResult(finderPath, finderArgs);
627
628 throw processException(e);
629 }
630 finally {
631 closeSession(session);
632 }
633 }
634
635 return count.intValue();
636 }
637
638 private static final String _FINDER_COLUMN_UUID_UUID_1 = "userNotificationEvent.uuid IS NULL";
639 private static final String _FINDER_COLUMN_UUID_UUID_2 = "userNotificationEvent.uuid = ?";
640 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = '')";
641 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
642 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
643 UserNotificationEventImpl.class,
644 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
645 new String[] {
646 String.class.getName(), Long.class.getName(),
647
648 Integer.class.getName(), Integer.class.getName(),
649 OrderByComparator.class.getName()
650 });
651 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
652 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
653 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
654 UserNotificationEventImpl.class,
655 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
656 new String[] { String.class.getName(), Long.class.getName() },
657 UserNotificationEventModelImpl.UUID_COLUMN_BITMASK |
658 UserNotificationEventModelImpl.COMPANYID_COLUMN_BITMASK |
659 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
660 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
661 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
662 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
663 new String[] { String.class.getName(), Long.class.getName() });
664
665
672 @Override
673 public List<UserNotificationEvent> findByUuid_C(String uuid, long companyId) {
674 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
675 QueryUtil.ALL_POS, null);
676 }
677
678
691 @Override
692 public List<UserNotificationEvent> findByUuid_C(String uuid,
693 long companyId, int start, int end) {
694 return findByUuid_C(uuid, companyId, start, end, null);
695 }
696
697
711 @Override
712 public List<UserNotificationEvent> findByUuid_C(String uuid,
713 long companyId, int start, int end,
714 OrderByComparator<UserNotificationEvent> orderByComparator) {
715 return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
716 }
717
718
733 @Override
734 public List<UserNotificationEvent> findByUuid_C(String uuid,
735 long companyId, int start, int end,
736 OrderByComparator<UserNotificationEvent> orderByComparator,
737 boolean retrieveFromCache) {
738 boolean pagination = true;
739 FinderPath finderPath = null;
740 Object[] finderArgs = null;
741
742 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
743 (orderByComparator == null)) {
744 pagination = false;
745 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
746 finderArgs = new Object[] { uuid, companyId };
747 }
748 else {
749 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
750 finderArgs = new Object[] {
751 uuid, companyId,
752
753 start, end, orderByComparator
754 };
755 }
756
757 List<UserNotificationEvent> list = null;
758
759 if (retrieveFromCache) {
760 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
761 finderArgs, this);
762
763 if ((list != null) && !list.isEmpty()) {
764 for (UserNotificationEvent userNotificationEvent : list) {
765 if (!Validator.equals(uuid, userNotificationEvent.getUuid()) ||
766 (companyId != userNotificationEvent.getCompanyId())) {
767 list = null;
768
769 break;
770 }
771 }
772 }
773 }
774
775 if (list == null) {
776 StringBundler query = null;
777
778 if (orderByComparator != null) {
779 query = new StringBundler(4 +
780 (orderByComparator.getOrderByFields().length * 3));
781 }
782 else {
783 query = new StringBundler(4);
784 }
785
786 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
787
788 boolean bindUuid = false;
789
790 if (uuid == null) {
791 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
792 }
793 else if (uuid.equals(StringPool.BLANK)) {
794 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
795 }
796 else {
797 bindUuid = true;
798
799 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
800 }
801
802 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
803
804 if (orderByComparator != null) {
805 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
806 orderByComparator);
807 }
808 else
809 if (pagination) {
810 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
811 }
812
813 String sql = query.toString();
814
815 Session session = null;
816
817 try {
818 session = openSession();
819
820 Query q = session.createQuery(sql);
821
822 QueryPos qPos = QueryPos.getInstance(q);
823
824 if (bindUuid) {
825 qPos.add(uuid);
826 }
827
828 qPos.add(companyId);
829
830 if (!pagination) {
831 list = (List<UserNotificationEvent>)QueryUtil.list(q,
832 getDialect(), start, end, false);
833
834 Collections.sort(list);
835
836 list = Collections.unmodifiableList(list);
837 }
838 else {
839 list = (List<UserNotificationEvent>)QueryUtil.list(q,
840 getDialect(), start, end);
841 }
842
843 cacheResult(list);
844
845 finderCache.putResult(finderPath, finderArgs, list);
846 }
847 catch (Exception e) {
848 finderCache.removeResult(finderPath, finderArgs);
849
850 throw processException(e);
851 }
852 finally {
853 closeSession(session);
854 }
855 }
856
857 return list;
858 }
859
860
869 @Override
870 public UserNotificationEvent findByUuid_C_First(String uuid,
871 long companyId,
872 OrderByComparator<UserNotificationEvent> orderByComparator)
873 throws NoSuchUserNotificationEventException {
874 UserNotificationEvent userNotificationEvent = fetchByUuid_C_First(uuid,
875 companyId, orderByComparator);
876
877 if (userNotificationEvent != null) {
878 return userNotificationEvent;
879 }
880
881 StringBundler msg = new StringBundler(6);
882
883 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
884
885 msg.append("uuid=");
886 msg.append(uuid);
887
888 msg.append(", companyId=");
889 msg.append(companyId);
890
891 msg.append(StringPool.CLOSE_CURLY_BRACE);
892
893 throw new NoSuchUserNotificationEventException(msg.toString());
894 }
895
896
904 @Override
905 public UserNotificationEvent fetchByUuid_C_First(String uuid,
906 long companyId,
907 OrderByComparator<UserNotificationEvent> orderByComparator) {
908 List<UserNotificationEvent> list = findByUuid_C(uuid, companyId, 0, 1,
909 orderByComparator);
910
911 if (!list.isEmpty()) {
912 return list.get(0);
913 }
914
915 return null;
916 }
917
918
927 @Override
928 public UserNotificationEvent findByUuid_C_Last(String uuid, long companyId,
929 OrderByComparator<UserNotificationEvent> orderByComparator)
930 throws NoSuchUserNotificationEventException {
931 UserNotificationEvent userNotificationEvent = fetchByUuid_C_Last(uuid,
932 companyId, orderByComparator);
933
934 if (userNotificationEvent != null) {
935 return userNotificationEvent;
936 }
937
938 StringBundler msg = new StringBundler(6);
939
940 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
941
942 msg.append("uuid=");
943 msg.append(uuid);
944
945 msg.append(", companyId=");
946 msg.append(companyId);
947
948 msg.append(StringPool.CLOSE_CURLY_BRACE);
949
950 throw new NoSuchUserNotificationEventException(msg.toString());
951 }
952
953
961 @Override
962 public UserNotificationEvent fetchByUuid_C_Last(String uuid,
963 long companyId,
964 OrderByComparator<UserNotificationEvent> orderByComparator) {
965 int count = countByUuid_C(uuid, companyId);
966
967 if (count == 0) {
968 return null;
969 }
970
971 List<UserNotificationEvent> list = findByUuid_C(uuid, companyId,
972 count - 1, count, orderByComparator);
973
974 if (!list.isEmpty()) {
975 return list.get(0);
976 }
977
978 return null;
979 }
980
981
991 @Override
992 public UserNotificationEvent[] findByUuid_C_PrevAndNext(
993 long userNotificationEventId, String uuid, long companyId,
994 OrderByComparator<UserNotificationEvent> orderByComparator)
995 throws NoSuchUserNotificationEventException {
996 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
997
998 Session session = null;
999
1000 try {
1001 session = openSession();
1002
1003 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1004
1005 array[0] = getByUuid_C_PrevAndNext(session, userNotificationEvent,
1006 uuid, companyId, orderByComparator, true);
1007
1008 array[1] = userNotificationEvent;
1009
1010 array[2] = getByUuid_C_PrevAndNext(session, userNotificationEvent,
1011 uuid, companyId, orderByComparator, false);
1012
1013 return array;
1014 }
1015 catch (Exception e) {
1016 throw processException(e);
1017 }
1018 finally {
1019 closeSession(session);
1020 }
1021 }
1022
1023 protected UserNotificationEvent getByUuid_C_PrevAndNext(Session session,
1024 UserNotificationEvent userNotificationEvent, String uuid,
1025 long companyId,
1026 OrderByComparator<UserNotificationEvent> orderByComparator,
1027 boolean previous) {
1028 StringBundler query = null;
1029
1030 if (orderByComparator != null) {
1031 query = new StringBundler(6 +
1032 (orderByComparator.getOrderByFields().length * 6));
1033 }
1034 else {
1035 query = new StringBundler(3);
1036 }
1037
1038 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1039
1040 boolean bindUuid = false;
1041
1042 if (uuid == null) {
1043 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1044 }
1045 else if (uuid.equals(StringPool.BLANK)) {
1046 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1047 }
1048 else {
1049 bindUuid = true;
1050
1051 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1052 }
1053
1054 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1055
1056 if (orderByComparator != null) {
1057 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1058
1059 if (orderByConditionFields.length > 0) {
1060 query.append(WHERE_AND);
1061 }
1062
1063 for (int i = 0; i < orderByConditionFields.length; i++) {
1064 query.append(_ORDER_BY_ENTITY_ALIAS);
1065 query.append(orderByConditionFields[i]);
1066
1067 if ((i + 1) < orderByConditionFields.length) {
1068 if (orderByComparator.isAscending() ^ previous) {
1069 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1070 }
1071 else {
1072 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1073 }
1074 }
1075 else {
1076 if (orderByComparator.isAscending() ^ previous) {
1077 query.append(WHERE_GREATER_THAN);
1078 }
1079 else {
1080 query.append(WHERE_LESSER_THAN);
1081 }
1082 }
1083 }
1084
1085 query.append(ORDER_BY_CLAUSE);
1086
1087 String[] orderByFields = orderByComparator.getOrderByFields();
1088
1089 for (int i = 0; i < orderByFields.length; i++) {
1090 query.append(_ORDER_BY_ENTITY_ALIAS);
1091 query.append(orderByFields[i]);
1092
1093 if ((i + 1) < orderByFields.length) {
1094 if (orderByComparator.isAscending() ^ previous) {
1095 query.append(ORDER_BY_ASC_HAS_NEXT);
1096 }
1097 else {
1098 query.append(ORDER_BY_DESC_HAS_NEXT);
1099 }
1100 }
1101 else {
1102 if (orderByComparator.isAscending() ^ previous) {
1103 query.append(ORDER_BY_ASC);
1104 }
1105 else {
1106 query.append(ORDER_BY_DESC);
1107 }
1108 }
1109 }
1110 }
1111 else {
1112 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1113 }
1114
1115 String sql = query.toString();
1116
1117 Query q = session.createQuery(sql);
1118
1119 q.setFirstResult(0);
1120 q.setMaxResults(2);
1121
1122 QueryPos qPos = QueryPos.getInstance(q);
1123
1124 if (bindUuid) {
1125 qPos.add(uuid);
1126 }
1127
1128 qPos.add(companyId);
1129
1130 if (orderByComparator != null) {
1131 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1132
1133 for (Object value : values) {
1134 qPos.add(value);
1135 }
1136 }
1137
1138 List<UserNotificationEvent> list = q.list();
1139
1140 if (list.size() == 2) {
1141 return list.get(1);
1142 }
1143 else {
1144 return null;
1145 }
1146 }
1147
1148
1154 @Override
1155 public void removeByUuid_C(String uuid, long companyId) {
1156 for (UserNotificationEvent userNotificationEvent : findByUuid_C(uuid,
1157 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1158 remove(userNotificationEvent);
1159 }
1160 }
1161
1162
1169 @Override
1170 public int countByUuid_C(String uuid, long companyId) {
1171 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1172
1173 Object[] finderArgs = new Object[] { uuid, companyId };
1174
1175 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1176
1177 if (count == null) {
1178 StringBundler query = new StringBundler(3);
1179
1180 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1181
1182 boolean bindUuid = false;
1183
1184 if (uuid == null) {
1185 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1186 }
1187 else if (uuid.equals(StringPool.BLANK)) {
1188 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1189 }
1190 else {
1191 bindUuid = true;
1192
1193 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1194 }
1195
1196 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1197
1198 String sql = query.toString();
1199
1200 Session session = null;
1201
1202 try {
1203 session = openSession();
1204
1205 Query q = session.createQuery(sql);
1206
1207 QueryPos qPos = QueryPos.getInstance(q);
1208
1209 if (bindUuid) {
1210 qPos.add(uuid);
1211 }
1212
1213 qPos.add(companyId);
1214
1215 count = (Long)q.uniqueResult();
1216
1217 finderCache.putResult(finderPath, finderArgs, count);
1218 }
1219 catch (Exception e) {
1220 finderCache.removeResult(finderPath, finderArgs);
1221
1222 throw processException(e);
1223 }
1224 finally {
1225 closeSession(session);
1226 }
1227 }
1228
1229 return count.intValue();
1230 }
1231
1232 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "userNotificationEvent.uuid IS NULL AND ";
1233 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "userNotificationEvent.uuid = ? AND ";
1234 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = '') AND ";
1235 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "userNotificationEvent.companyId = ?";
1236 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1237 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1238 UserNotificationEventImpl.class,
1239 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
1240 new String[] {
1241 Long.class.getName(),
1242
1243 Integer.class.getName(), Integer.class.getName(),
1244 OrderByComparator.class.getName()
1245 });
1246 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
1247 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1248 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1249 UserNotificationEventImpl.class,
1250 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
1251 new String[] { Long.class.getName() },
1252 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
1253 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
1254 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1255 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
1256 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
1257 new String[] { Long.class.getName() });
1258
1259
1265 @Override
1266 public List<UserNotificationEvent> findByUserId(long userId) {
1267 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1268 }
1269
1270
1282 @Override
1283 public List<UserNotificationEvent> findByUserId(long userId, int start,
1284 int end) {
1285 return findByUserId(userId, start, end, null);
1286 }
1287
1288
1301 @Override
1302 public List<UserNotificationEvent> findByUserId(long userId, int start,
1303 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
1304 return findByUserId(userId, start, end, orderByComparator, true);
1305 }
1306
1307
1321 @Override
1322 public List<UserNotificationEvent> findByUserId(long userId, int start,
1323 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
1324 boolean retrieveFromCache) {
1325 boolean pagination = true;
1326 FinderPath finderPath = null;
1327 Object[] finderArgs = null;
1328
1329 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1330 (orderByComparator == null)) {
1331 pagination = false;
1332 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1333 finderArgs = new Object[] { userId };
1334 }
1335 else {
1336 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1337 finderArgs = new Object[] { userId, start, end, orderByComparator };
1338 }
1339
1340 List<UserNotificationEvent> list = null;
1341
1342 if (retrieveFromCache) {
1343 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
1344 finderArgs, this);
1345
1346 if ((list != null) && !list.isEmpty()) {
1347 for (UserNotificationEvent userNotificationEvent : list) {
1348 if ((userId != userNotificationEvent.getUserId())) {
1349 list = null;
1350
1351 break;
1352 }
1353 }
1354 }
1355 }
1356
1357 if (list == null) {
1358 StringBundler query = null;
1359
1360 if (orderByComparator != null) {
1361 query = new StringBundler(3 +
1362 (orderByComparator.getOrderByFields().length * 3));
1363 }
1364 else {
1365 query = new StringBundler(3);
1366 }
1367
1368 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1369
1370 query.append(_FINDER_COLUMN_USERID_USERID_2);
1371
1372 if (orderByComparator != null) {
1373 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1374 orderByComparator);
1375 }
1376 else
1377 if (pagination) {
1378 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1379 }
1380
1381 String sql = query.toString();
1382
1383 Session session = null;
1384
1385 try {
1386 session = openSession();
1387
1388 Query q = session.createQuery(sql);
1389
1390 QueryPos qPos = QueryPos.getInstance(q);
1391
1392 qPos.add(userId);
1393
1394 if (!pagination) {
1395 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1396 getDialect(), start, end, false);
1397
1398 Collections.sort(list);
1399
1400 list = Collections.unmodifiableList(list);
1401 }
1402 else {
1403 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1404 getDialect(), start, end);
1405 }
1406
1407 cacheResult(list);
1408
1409 finderCache.putResult(finderPath, finderArgs, list);
1410 }
1411 catch (Exception e) {
1412 finderCache.removeResult(finderPath, finderArgs);
1413
1414 throw processException(e);
1415 }
1416 finally {
1417 closeSession(session);
1418 }
1419 }
1420
1421 return list;
1422 }
1423
1424
1432 @Override
1433 public UserNotificationEvent findByUserId_First(long userId,
1434 OrderByComparator<UserNotificationEvent> orderByComparator)
1435 throws NoSuchUserNotificationEventException {
1436 UserNotificationEvent userNotificationEvent = fetchByUserId_First(userId,
1437 orderByComparator);
1438
1439 if (userNotificationEvent != null) {
1440 return userNotificationEvent;
1441 }
1442
1443 StringBundler msg = new StringBundler(4);
1444
1445 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1446
1447 msg.append("userId=");
1448 msg.append(userId);
1449
1450 msg.append(StringPool.CLOSE_CURLY_BRACE);
1451
1452 throw new NoSuchUserNotificationEventException(msg.toString());
1453 }
1454
1455
1462 @Override
1463 public UserNotificationEvent fetchByUserId_First(long userId,
1464 OrderByComparator<UserNotificationEvent> orderByComparator) {
1465 List<UserNotificationEvent> list = findByUserId(userId, 0, 1,
1466 orderByComparator);
1467
1468 if (!list.isEmpty()) {
1469 return list.get(0);
1470 }
1471
1472 return null;
1473 }
1474
1475
1483 @Override
1484 public UserNotificationEvent findByUserId_Last(long userId,
1485 OrderByComparator<UserNotificationEvent> orderByComparator)
1486 throws NoSuchUserNotificationEventException {
1487 UserNotificationEvent userNotificationEvent = fetchByUserId_Last(userId,
1488 orderByComparator);
1489
1490 if (userNotificationEvent != null) {
1491 return userNotificationEvent;
1492 }
1493
1494 StringBundler msg = new StringBundler(4);
1495
1496 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1497
1498 msg.append("userId=");
1499 msg.append(userId);
1500
1501 msg.append(StringPool.CLOSE_CURLY_BRACE);
1502
1503 throw new NoSuchUserNotificationEventException(msg.toString());
1504 }
1505
1506
1513 @Override
1514 public UserNotificationEvent fetchByUserId_Last(long userId,
1515 OrderByComparator<UserNotificationEvent> orderByComparator) {
1516 int count = countByUserId(userId);
1517
1518 if (count == 0) {
1519 return null;
1520 }
1521
1522 List<UserNotificationEvent> list = findByUserId(userId, count - 1,
1523 count, orderByComparator);
1524
1525 if (!list.isEmpty()) {
1526 return list.get(0);
1527 }
1528
1529 return null;
1530 }
1531
1532
1541 @Override
1542 public UserNotificationEvent[] findByUserId_PrevAndNext(
1543 long userNotificationEventId, long userId,
1544 OrderByComparator<UserNotificationEvent> orderByComparator)
1545 throws NoSuchUserNotificationEventException {
1546 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
1547
1548 Session session = null;
1549
1550 try {
1551 session = openSession();
1552
1553 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1554
1555 array[0] = getByUserId_PrevAndNext(session, userNotificationEvent,
1556 userId, orderByComparator, true);
1557
1558 array[1] = userNotificationEvent;
1559
1560 array[2] = getByUserId_PrevAndNext(session, userNotificationEvent,
1561 userId, orderByComparator, false);
1562
1563 return array;
1564 }
1565 catch (Exception e) {
1566 throw processException(e);
1567 }
1568 finally {
1569 closeSession(session);
1570 }
1571 }
1572
1573 protected UserNotificationEvent getByUserId_PrevAndNext(Session session,
1574 UserNotificationEvent userNotificationEvent, long userId,
1575 OrderByComparator<UserNotificationEvent> orderByComparator,
1576 boolean previous) {
1577 StringBundler query = null;
1578
1579 if (orderByComparator != null) {
1580 query = new StringBundler(6 +
1581 (orderByComparator.getOrderByFields().length * 6));
1582 }
1583 else {
1584 query = new StringBundler(3);
1585 }
1586
1587 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1588
1589 query.append(_FINDER_COLUMN_USERID_USERID_2);
1590
1591 if (orderByComparator != null) {
1592 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1593
1594 if (orderByConditionFields.length > 0) {
1595 query.append(WHERE_AND);
1596 }
1597
1598 for (int i = 0; i < orderByConditionFields.length; i++) {
1599 query.append(_ORDER_BY_ENTITY_ALIAS);
1600 query.append(orderByConditionFields[i]);
1601
1602 if ((i + 1) < orderByConditionFields.length) {
1603 if (orderByComparator.isAscending() ^ previous) {
1604 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1605 }
1606 else {
1607 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1608 }
1609 }
1610 else {
1611 if (orderByComparator.isAscending() ^ previous) {
1612 query.append(WHERE_GREATER_THAN);
1613 }
1614 else {
1615 query.append(WHERE_LESSER_THAN);
1616 }
1617 }
1618 }
1619
1620 query.append(ORDER_BY_CLAUSE);
1621
1622 String[] orderByFields = orderByComparator.getOrderByFields();
1623
1624 for (int i = 0; i < orderByFields.length; i++) {
1625 query.append(_ORDER_BY_ENTITY_ALIAS);
1626 query.append(orderByFields[i]);
1627
1628 if ((i + 1) < orderByFields.length) {
1629 if (orderByComparator.isAscending() ^ previous) {
1630 query.append(ORDER_BY_ASC_HAS_NEXT);
1631 }
1632 else {
1633 query.append(ORDER_BY_DESC_HAS_NEXT);
1634 }
1635 }
1636 else {
1637 if (orderByComparator.isAscending() ^ previous) {
1638 query.append(ORDER_BY_ASC);
1639 }
1640 else {
1641 query.append(ORDER_BY_DESC);
1642 }
1643 }
1644 }
1645 }
1646 else {
1647 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1648 }
1649
1650 String sql = query.toString();
1651
1652 Query q = session.createQuery(sql);
1653
1654 q.setFirstResult(0);
1655 q.setMaxResults(2);
1656
1657 QueryPos qPos = QueryPos.getInstance(q);
1658
1659 qPos.add(userId);
1660
1661 if (orderByComparator != null) {
1662 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1663
1664 for (Object value : values) {
1665 qPos.add(value);
1666 }
1667 }
1668
1669 List<UserNotificationEvent> list = q.list();
1670
1671 if (list.size() == 2) {
1672 return list.get(1);
1673 }
1674 else {
1675 return null;
1676 }
1677 }
1678
1679
1684 @Override
1685 public void removeByUserId(long userId) {
1686 for (UserNotificationEvent userNotificationEvent : findByUserId(
1687 userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1688 remove(userNotificationEvent);
1689 }
1690 }
1691
1692
1698 @Override
1699 public int countByUserId(long userId) {
1700 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
1701
1702 Object[] finderArgs = new Object[] { userId };
1703
1704 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1705
1706 if (count == null) {
1707 StringBundler query = new StringBundler(2);
1708
1709 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1710
1711 query.append(_FINDER_COLUMN_USERID_USERID_2);
1712
1713 String sql = query.toString();
1714
1715 Session session = null;
1716
1717 try {
1718 session = openSession();
1719
1720 Query q = session.createQuery(sql);
1721
1722 QueryPos qPos = QueryPos.getInstance(q);
1723
1724 qPos.add(userId);
1725
1726 count = (Long)q.uniqueResult();
1727
1728 finderCache.putResult(finderPath, finderArgs, count);
1729 }
1730 catch (Exception e) {
1731 finderCache.removeResult(finderPath, finderArgs);
1732
1733 throw processException(e);
1734 }
1735 finally {
1736 closeSession(session);
1737 }
1738 }
1739
1740 return count.intValue();
1741 }
1742
1743 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userNotificationEvent.userId = ?";
1744 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1745 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1746 UserNotificationEventImpl.class,
1747 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT",
1748 new String[] {
1749 Long.class.getName(), Integer.class.getName(),
1750
1751 Integer.class.getName(), Integer.class.getName(),
1752 OrderByComparator.class.getName()
1753 });
1754 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1755 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1756 UserNotificationEventImpl.class,
1757 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT",
1758 new String[] { Long.class.getName(), Integer.class.getName() },
1759 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
1760 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
1761 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
1762 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1763 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
1764 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT",
1765 new String[] { Long.class.getName(), Integer.class.getName() });
1766
1767
1774 @Override
1775 public List<UserNotificationEvent> findByU_DT(long userId, int deliveryType) {
1776 return findByU_DT(userId, deliveryType, QueryUtil.ALL_POS,
1777 QueryUtil.ALL_POS, null);
1778 }
1779
1780
1793 @Override
1794 public List<UserNotificationEvent> findByU_DT(long userId,
1795 int deliveryType, int start, int end) {
1796 return findByU_DT(userId, deliveryType, start, end, null);
1797 }
1798
1799
1813 @Override
1814 public List<UserNotificationEvent> findByU_DT(long userId,
1815 int deliveryType, int start, int end,
1816 OrderByComparator<UserNotificationEvent> orderByComparator) {
1817 return findByU_DT(userId, deliveryType, start, end, orderByComparator,
1818 true);
1819 }
1820
1821
1836 @Override
1837 public List<UserNotificationEvent> findByU_DT(long userId,
1838 int deliveryType, int start, int end,
1839 OrderByComparator<UserNotificationEvent> orderByComparator,
1840 boolean retrieveFromCache) {
1841 boolean pagination = true;
1842 FinderPath finderPath = null;
1843 Object[] finderArgs = null;
1844
1845 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1846 (orderByComparator == null)) {
1847 pagination = false;
1848 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT;
1849 finderArgs = new Object[] { userId, deliveryType };
1850 }
1851 else {
1852 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT;
1853 finderArgs = new Object[] {
1854 userId, deliveryType,
1855
1856 start, end, orderByComparator
1857 };
1858 }
1859
1860 List<UserNotificationEvent> list = null;
1861
1862 if (retrieveFromCache) {
1863 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
1864 finderArgs, this);
1865
1866 if ((list != null) && !list.isEmpty()) {
1867 for (UserNotificationEvent userNotificationEvent : list) {
1868 if ((userId != userNotificationEvent.getUserId()) ||
1869 (deliveryType != userNotificationEvent.getDeliveryType())) {
1870 list = null;
1871
1872 break;
1873 }
1874 }
1875 }
1876 }
1877
1878 if (list == null) {
1879 StringBundler query = null;
1880
1881 if (orderByComparator != null) {
1882 query = new StringBundler(4 +
1883 (orderByComparator.getOrderByFields().length * 3));
1884 }
1885 else {
1886 query = new StringBundler(4);
1887 }
1888
1889 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1890
1891 query.append(_FINDER_COLUMN_U_DT_USERID_2);
1892
1893 query.append(_FINDER_COLUMN_U_DT_DELIVERYTYPE_2);
1894
1895 if (orderByComparator != null) {
1896 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1897 orderByComparator);
1898 }
1899 else
1900 if (pagination) {
1901 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1902 }
1903
1904 String sql = query.toString();
1905
1906 Session session = null;
1907
1908 try {
1909 session = openSession();
1910
1911 Query q = session.createQuery(sql);
1912
1913 QueryPos qPos = QueryPos.getInstance(q);
1914
1915 qPos.add(userId);
1916
1917 qPos.add(deliveryType);
1918
1919 if (!pagination) {
1920 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1921 getDialect(), start, end, false);
1922
1923 Collections.sort(list);
1924
1925 list = Collections.unmodifiableList(list);
1926 }
1927 else {
1928 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1929 getDialect(), start, end);
1930 }
1931
1932 cacheResult(list);
1933
1934 finderCache.putResult(finderPath, finderArgs, list);
1935 }
1936 catch (Exception e) {
1937 finderCache.removeResult(finderPath, finderArgs);
1938
1939 throw processException(e);
1940 }
1941 finally {
1942 closeSession(session);
1943 }
1944 }
1945
1946 return list;
1947 }
1948
1949
1958 @Override
1959 public UserNotificationEvent findByU_DT_First(long userId,
1960 int deliveryType,
1961 OrderByComparator<UserNotificationEvent> orderByComparator)
1962 throws NoSuchUserNotificationEventException {
1963 UserNotificationEvent userNotificationEvent = fetchByU_DT_First(userId,
1964 deliveryType, orderByComparator);
1965
1966 if (userNotificationEvent != null) {
1967 return userNotificationEvent;
1968 }
1969
1970 StringBundler msg = new StringBundler(6);
1971
1972 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1973
1974 msg.append("userId=");
1975 msg.append(userId);
1976
1977 msg.append(", deliveryType=");
1978 msg.append(deliveryType);
1979
1980 msg.append(StringPool.CLOSE_CURLY_BRACE);
1981
1982 throw new NoSuchUserNotificationEventException(msg.toString());
1983 }
1984
1985
1993 @Override
1994 public UserNotificationEvent fetchByU_DT_First(long userId,
1995 int deliveryType,
1996 OrderByComparator<UserNotificationEvent> orderByComparator) {
1997 List<UserNotificationEvent> list = findByU_DT(userId, deliveryType, 0,
1998 1, orderByComparator);
1999
2000 if (!list.isEmpty()) {
2001 return list.get(0);
2002 }
2003
2004 return null;
2005 }
2006
2007
2016 @Override
2017 public UserNotificationEvent findByU_DT_Last(long userId, int deliveryType,
2018 OrderByComparator<UserNotificationEvent> orderByComparator)
2019 throws NoSuchUserNotificationEventException {
2020 UserNotificationEvent userNotificationEvent = fetchByU_DT_Last(userId,
2021 deliveryType, orderByComparator);
2022
2023 if (userNotificationEvent != null) {
2024 return userNotificationEvent;
2025 }
2026
2027 StringBundler msg = new StringBundler(6);
2028
2029 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2030
2031 msg.append("userId=");
2032 msg.append(userId);
2033
2034 msg.append(", deliveryType=");
2035 msg.append(deliveryType);
2036
2037 msg.append(StringPool.CLOSE_CURLY_BRACE);
2038
2039 throw new NoSuchUserNotificationEventException(msg.toString());
2040 }
2041
2042
2050 @Override
2051 public UserNotificationEvent fetchByU_DT_Last(long userId,
2052 int deliveryType,
2053 OrderByComparator<UserNotificationEvent> orderByComparator) {
2054 int count = countByU_DT(userId, deliveryType);
2055
2056 if (count == 0) {
2057 return null;
2058 }
2059
2060 List<UserNotificationEvent> list = findByU_DT(userId, deliveryType,
2061 count - 1, count, orderByComparator);
2062
2063 if (!list.isEmpty()) {
2064 return list.get(0);
2065 }
2066
2067 return null;
2068 }
2069
2070
2080 @Override
2081 public UserNotificationEvent[] findByU_DT_PrevAndNext(
2082 long userNotificationEventId, long userId, int deliveryType,
2083 OrderByComparator<UserNotificationEvent> orderByComparator)
2084 throws NoSuchUserNotificationEventException {
2085 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
2086
2087 Session session = null;
2088
2089 try {
2090 session = openSession();
2091
2092 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
2093
2094 array[0] = getByU_DT_PrevAndNext(session, userNotificationEvent,
2095 userId, deliveryType, orderByComparator, true);
2096
2097 array[1] = userNotificationEvent;
2098
2099 array[2] = getByU_DT_PrevAndNext(session, userNotificationEvent,
2100 userId, deliveryType, orderByComparator, false);
2101
2102 return array;
2103 }
2104 catch (Exception e) {
2105 throw processException(e);
2106 }
2107 finally {
2108 closeSession(session);
2109 }
2110 }
2111
2112 protected UserNotificationEvent getByU_DT_PrevAndNext(Session session,
2113 UserNotificationEvent userNotificationEvent, long userId,
2114 int deliveryType,
2115 OrderByComparator<UserNotificationEvent> orderByComparator,
2116 boolean previous) {
2117 StringBundler query = null;
2118
2119 if (orderByComparator != null) {
2120 query = new StringBundler(6 +
2121 (orderByComparator.getOrderByFields().length * 6));
2122 }
2123 else {
2124 query = new StringBundler(3);
2125 }
2126
2127 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2128
2129 query.append(_FINDER_COLUMN_U_DT_USERID_2);
2130
2131 query.append(_FINDER_COLUMN_U_DT_DELIVERYTYPE_2);
2132
2133 if (orderByComparator != null) {
2134 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2135
2136 if (orderByConditionFields.length > 0) {
2137 query.append(WHERE_AND);
2138 }
2139
2140 for (int i = 0; i < orderByConditionFields.length; i++) {
2141 query.append(_ORDER_BY_ENTITY_ALIAS);
2142 query.append(orderByConditionFields[i]);
2143
2144 if ((i + 1) < orderByConditionFields.length) {
2145 if (orderByComparator.isAscending() ^ previous) {
2146 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2147 }
2148 else {
2149 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2150 }
2151 }
2152 else {
2153 if (orderByComparator.isAscending() ^ previous) {
2154 query.append(WHERE_GREATER_THAN);
2155 }
2156 else {
2157 query.append(WHERE_LESSER_THAN);
2158 }
2159 }
2160 }
2161
2162 query.append(ORDER_BY_CLAUSE);
2163
2164 String[] orderByFields = orderByComparator.getOrderByFields();
2165
2166 for (int i = 0; i < orderByFields.length; i++) {
2167 query.append(_ORDER_BY_ENTITY_ALIAS);
2168 query.append(orderByFields[i]);
2169
2170 if ((i + 1) < orderByFields.length) {
2171 if (orderByComparator.isAscending() ^ previous) {
2172 query.append(ORDER_BY_ASC_HAS_NEXT);
2173 }
2174 else {
2175 query.append(ORDER_BY_DESC_HAS_NEXT);
2176 }
2177 }
2178 else {
2179 if (orderByComparator.isAscending() ^ previous) {
2180 query.append(ORDER_BY_ASC);
2181 }
2182 else {
2183 query.append(ORDER_BY_DESC);
2184 }
2185 }
2186 }
2187 }
2188 else {
2189 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2190 }
2191
2192 String sql = query.toString();
2193
2194 Query q = session.createQuery(sql);
2195
2196 q.setFirstResult(0);
2197 q.setMaxResults(2);
2198
2199 QueryPos qPos = QueryPos.getInstance(q);
2200
2201 qPos.add(userId);
2202
2203 qPos.add(deliveryType);
2204
2205 if (orderByComparator != null) {
2206 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
2207
2208 for (Object value : values) {
2209 qPos.add(value);
2210 }
2211 }
2212
2213 List<UserNotificationEvent> list = q.list();
2214
2215 if (list.size() == 2) {
2216 return list.get(1);
2217 }
2218 else {
2219 return null;
2220 }
2221 }
2222
2223
2229 @Override
2230 public void removeByU_DT(long userId, int deliveryType) {
2231 for (UserNotificationEvent userNotificationEvent : findByU_DT(userId,
2232 deliveryType, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2233 remove(userNotificationEvent);
2234 }
2235 }
2236
2237
2244 @Override
2245 public int countByU_DT(long userId, int deliveryType) {
2246 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT;
2247
2248 Object[] finderArgs = new Object[] { userId, deliveryType };
2249
2250 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2251
2252 if (count == null) {
2253 StringBundler query = new StringBundler(3);
2254
2255 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2256
2257 query.append(_FINDER_COLUMN_U_DT_USERID_2);
2258
2259 query.append(_FINDER_COLUMN_U_DT_DELIVERYTYPE_2);
2260
2261 String sql = query.toString();
2262
2263 Session session = null;
2264
2265 try {
2266 session = openSession();
2267
2268 Query q = session.createQuery(sql);
2269
2270 QueryPos qPos = QueryPos.getInstance(q);
2271
2272 qPos.add(userId);
2273
2274 qPos.add(deliveryType);
2275
2276 count = (Long)q.uniqueResult();
2277
2278 finderCache.putResult(finderPath, finderArgs, count);
2279 }
2280 catch (Exception e) {
2281 finderCache.removeResult(finderPath, finderArgs);
2282
2283 throw processException(e);
2284 }
2285 finally {
2286 closeSession(session);
2287 }
2288 }
2289
2290 return count.intValue();
2291 }
2292
2293 private static final String _FINDER_COLUMN_U_DT_USERID_2 = "userNotificationEvent.userId = ? AND ";
2294 private static final String _FINDER_COLUMN_U_DT_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ?";
2295 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2296 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2297 UserNotificationEventImpl.class,
2298 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_D",
2299 new String[] {
2300 Long.class.getName(), Boolean.class.getName(),
2301
2302 Integer.class.getName(), Integer.class.getName(),
2303 OrderByComparator.class.getName()
2304 });
2305 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2306 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2307 UserNotificationEventImpl.class,
2308 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_D",
2309 new String[] { Long.class.getName(), Boolean.class.getName() },
2310 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
2311 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
2312 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
2313 public static final FinderPath FINDER_PATH_COUNT_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2314 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
2315 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_D",
2316 new String[] { Long.class.getName(), Boolean.class.getName() });
2317
2318
2325 @Override
2326 public List<UserNotificationEvent> findByU_D(long userId, boolean delivered) {
2327 return findByU_D(userId, delivered, QueryUtil.ALL_POS,
2328 QueryUtil.ALL_POS, null);
2329 }
2330
2331
2344 @Override
2345 public List<UserNotificationEvent> findByU_D(long userId,
2346 boolean delivered, int start, int end) {
2347 return findByU_D(userId, delivered, start, end, null);
2348 }
2349
2350
2364 @Override
2365 public List<UserNotificationEvent> findByU_D(long userId,
2366 boolean delivered, int start, int end,
2367 OrderByComparator<UserNotificationEvent> orderByComparator) {
2368 return findByU_D(userId, delivered, start, end, orderByComparator, true);
2369 }
2370
2371
2386 @Override
2387 public List<UserNotificationEvent> findByU_D(long userId,
2388 boolean delivered, int start, int end,
2389 OrderByComparator<UserNotificationEvent> orderByComparator,
2390 boolean retrieveFromCache) {
2391 boolean pagination = true;
2392 FinderPath finderPath = null;
2393 Object[] finderArgs = null;
2394
2395 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2396 (orderByComparator == null)) {
2397 pagination = false;
2398 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D;
2399 finderArgs = new Object[] { userId, delivered };
2400 }
2401 else {
2402 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D;
2403 finderArgs = new Object[] {
2404 userId, delivered,
2405
2406 start, end, orderByComparator
2407 };
2408 }
2409
2410 List<UserNotificationEvent> list = null;
2411
2412 if (retrieveFromCache) {
2413 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
2414 finderArgs, this);
2415
2416 if ((list != null) && !list.isEmpty()) {
2417 for (UserNotificationEvent userNotificationEvent : list) {
2418 if ((userId != userNotificationEvent.getUserId()) ||
2419 (delivered != userNotificationEvent.getDelivered())) {
2420 list = null;
2421
2422 break;
2423 }
2424 }
2425 }
2426 }
2427
2428 if (list == null) {
2429 StringBundler query = null;
2430
2431 if (orderByComparator != null) {
2432 query = new StringBundler(4 +
2433 (orderByComparator.getOrderByFields().length * 3));
2434 }
2435 else {
2436 query = new StringBundler(4);
2437 }
2438
2439 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2440
2441 query.append(_FINDER_COLUMN_U_D_USERID_2);
2442
2443 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
2444
2445 if (orderByComparator != null) {
2446 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2447 orderByComparator);
2448 }
2449 else
2450 if (pagination) {
2451 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2452 }
2453
2454 String sql = query.toString();
2455
2456 Session session = null;
2457
2458 try {
2459 session = openSession();
2460
2461 Query q = session.createQuery(sql);
2462
2463 QueryPos qPos = QueryPos.getInstance(q);
2464
2465 qPos.add(userId);
2466
2467 qPos.add(delivered);
2468
2469 if (!pagination) {
2470 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2471 getDialect(), start, end, false);
2472
2473 Collections.sort(list);
2474
2475 list = Collections.unmodifiableList(list);
2476 }
2477 else {
2478 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2479 getDialect(), start, end);
2480 }
2481
2482 cacheResult(list);
2483
2484 finderCache.putResult(finderPath, finderArgs, list);
2485 }
2486 catch (Exception e) {
2487 finderCache.removeResult(finderPath, finderArgs);
2488
2489 throw processException(e);
2490 }
2491 finally {
2492 closeSession(session);
2493 }
2494 }
2495
2496 return list;
2497 }
2498
2499
2508 @Override
2509 public UserNotificationEvent findByU_D_First(long userId,
2510 boolean delivered,
2511 OrderByComparator<UserNotificationEvent> orderByComparator)
2512 throws NoSuchUserNotificationEventException {
2513 UserNotificationEvent userNotificationEvent = fetchByU_D_First(userId,
2514 delivered, orderByComparator);
2515
2516 if (userNotificationEvent != null) {
2517 return userNotificationEvent;
2518 }
2519
2520 StringBundler msg = new StringBundler(6);
2521
2522 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2523
2524 msg.append("userId=");
2525 msg.append(userId);
2526
2527 msg.append(", delivered=");
2528 msg.append(delivered);
2529
2530 msg.append(StringPool.CLOSE_CURLY_BRACE);
2531
2532 throw new NoSuchUserNotificationEventException(msg.toString());
2533 }
2534
2535
2543 @Override
2544 public UserNotificationEvent fetchByU_D_First(long userId,
2545 boolean delivered,
2546 OrderByComparator<UserNotificationEvent> orderByComparator) {
2547 List<UserNotificationEvent> list = findByU_D(userId, delivered, 0, 1,
2548 orderByComparator);
2549
2550 if (!list.isEmpty()) {
2551 return list.get(0);
2552 }
2553
2554 return null;
2555 }
2556
2557
2566 @Override
2567 public UserNotificationEvent findByU_D_Last(long userId, boolean delivered,
2568 OrderByComparator<UserNotificationEvent> orderByComparator)
2569 throws NoSuchUserNotificationEventException {
2570 UserNotificationEvent userNotificationEvent = fetchByU_D_Last(userId,
2571 delivered, orderByComparator);
2572
2573 if (userNotificationEvent != null) {
2574 return userNotificationEvent;
2575 }
2576
2577 StringBundler msg = new StringBundler(6);
2578
2579 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2580
2581 msg.append("userId=");
2582 msg.append(userId);
2583
2584 msg.append(", delivered=");
2585 msg.append(delivered);
2586
2587 msg.append(StringPool.CLOSE_CURLY_BRACE);
2588
2589 throw new NoSuchUserNotificationEventException(msg.toString());
2590 }
2591
2592
2600 @Override
2601 public UserNotificationEvent fetchByU_D_Last(long userId,
2602 boolean delivered,
2603 OrderByComparator<UserNotificationEvent> orderByComparator) {
2604 int count = countByU_D(userId, delivered);
2605
2606 if (count == 0) {
2607 return null;
2608 }
2609
2610 List<UserNotificationEvent> list = findByU_D(userId, delivered,
2611 count - 1, count, orderByComparator);
2612
2613 if (!list.isEmpty()) {
2614 return list.get(0);
2615 }
2616
2617 return null;
2618 }
2619
2620
2630 @Override
2631 public UserNotificationEvent[] findByU_D_PrevAndNext(
2632 long userNotificationEventId, long userId, boolean delivered,
2633 OrderByComparator<UserNotificationEvent> orderByComparator)
2634 throws NoSuchUserNotificationEventException {
2635 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
2636
2637 Session session = null;
2638
2639 try {
2640 session = openSession();
2641
2642 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
2643
2644 array[0] = getByU_D_PrevAndNext(session, userNotificationEvent,
2645 userId, delivered, orderByComparator, true);
2646
2647 array[1] = userNotificationEvent;
2648
2649 array[2] = getByU_D_PrevAndNext(session, userNotificationEvent,
2650 userId, delivered, orderByComparator, false);
2651
2652 return array;
2653 }
2654 catch (Exception e) {
2655 throw processException(e);
2656 }
2657 finally {
2658 closeSession(session);
2659 }
2660 }
2661
2662 protected UserNotificationEvent getByU_D_PrevAndNext(Session session,
2663 UserNotificationEvent userNotificationEvent, long userId,
2664 boolean delivered,
2665 OrderByComparator<UserNotificationEvent> orderByComparator,
2666 boolean previous) {
2667 StringBundler query = null;
2668
2669 if (orderByComparator != null) {
2670 query = new StringBundler(6 +
2671 (orderByComparator.getOrderByFields().length * 6));
2672 }
2673 else {
2674 query = new StringBundler(3);
2675 }
2676
2677 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2678
2679 query.append(_FINDER_COLUMN_U_D_USERID_2);
2680
2681 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
2682
2683 if (orderByComparator != null) {
2684 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2685
2686 if (orderByConditionFields.length > 0) {
2687 query.append(WHERE_AND);
2688 }
2689
2690 for (int i = 0; i < orderByConditionFields.length; i++) {
2691 query.append(_ORDER_BY_ENTITY_ALIAS);
2692 query.append(orderByConditionFields[i]);
2693
2694 if ((i + 1) < orderByConditionFields.length) {
2695 if (orderByComparator.isAscending() ^ previous) {
2696 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2697 }
2698 else {
2699 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2700 }
2701 }
2702 else {
2703 if (orderByComparator.isAscending() ^ previous) {
2704 query.append(WHERE_GREATER_THAN);
2705 }
2706 else {
2707 query.append(WHERE_LESSER_THAN);
2708 }
2709 }
2710 }
2711
2712 query.append(ORDER_BY_CLAUSE);
2713
2714 String[] orderByFields = orderByComparator.getOrderByFields();
2715
2716 for (int i = 0; i < orderByFields.length; i++) {
2717 query.append(_ORDER_BY_ENTITY_ALIAS);
2718 query.append(orderByFields[i]);
2719
2720 if ((i + 1) < orderByFields.length) {
2721 if (orderByComparator.isAscending() ^ previous) {
2722 query.append(ORDER_BY_ASC_HAS_NEXT);
2723 }
2724 else {
2725 query.append(ORDER_BY_DESC_HAS_NEXT);
2726 }
2727 }
2728 else {
2729 if (orderByComparator.isAscending() ^ previous) {
2730 query.append(ORDER_BY_ASC);
2731 }
2732 else {
2733 query.append(ORDER_BY_DESC);
2734 }
2735 }
2736 }
2737 }
2738 else {
2739 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2740 }
2741
2742 String sql = query.toString();
2743
2744 Query q = session.createQuery(sql);
2745
2746 q.setFirstResult(0);
2747 q.setMaxResults(2);
2748
2749 QueryPos qPos = QueryPos.getInstance(q);
2750
2751 qPos.add(userId);
2752
2753 qPos.add(delivered);
2754
2755 if (orderByComparator != null) {
2756 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
2757
2758 for (Object value : values) {
2759 qPos.add(value);
2760 }
2761 }
2762
2763 List<UserNotificationEvent> list = q.list();
2764
2765 if (list.size() == 2) {
2766 return list.get(1);
2767 }
2768 else {
2769 return null;
2770 }
2771 }
2772
2773
2779 @Override
2780 public void removeByU_D(long userId, boolean delivered) {
2781 for (UserNotificationEvent userNotificationEvent : findByU_D(userId,
2782 delivered, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2783 remove(userNotificationEvent);
2784 }
2785 }
2786
2787
2794 @Override
2795 public int countByU_D(long userId, boolean delivered) {
2796 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_D;
2797
2798 Object[] finderArgs = new Object[] { userId, delivered };
2799
2800 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2801
2802 if (count == null) {
2803 StringBundler query = new StringBundler(3);
2804
2805 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2806
2807 query.append(_FINDER_COLUMN_U_D_USERID_2);
2808
2809 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
2810
2811 String sql = query.toString();
2812
2813 Session session = null;
2814
2815 try {
2816 session = openSession();
2817
2818 Query q = session.createQuery(sql);
2819
2820 QueryPos qPos = QueryPos.getInstance(q);
2821
2822 qPos.add(userId);
2823
2824 qPos.add(delivered);
2825
2826 count = (Long)q.uniqueResult();
2827
2828 finderCache.putResult(finderPath, finderArgs, count);
2829 }
2830 catch (Exception e) {
2831 finderCache.removeResult(finderPath, finderArgs);
2832
2833 throw processException(e);
2834 }
2835 finally {
2836 closeSession(session);
2837 }
2838 }
2839
2840 return count.intValue();
2841 }
2842
2843 private static final String _FINDER_COLUMN_U_D_USERID_2 = "userNotificationEvent.userId = ? AND ";
2844 private static final String _FINDER_COLUMN_U_D_DELIVERED_2 = "userNotificationEvent.delivered = ?";
2845 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2846 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2847 UserNotificationEventImpl.class,
2848 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_A",
2849 new String[] {
2850 Long.class.getName(), Boolean.class.getName(),
2851
2852 Integer.class.getName(), Integer.class.getName(),
2853 OrderByComparator.class.getName()
2854 });
2855 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2856 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2857 UserNotificationEventImpl.class,
2858 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_A",
2859 new String[] { Long.class.getName(), Boolean.class.getName() },
2860 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
2861 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
2862 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
2863 public static final FinderPath FINDER_PATH_COUNT_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2864 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
2865 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_A",
2866 new String[] { Long.class.getName(), Boolean.class.getName() });
2867
2868
2875 @Override
2876 public List<UserNotificationEvent> findByU_A(long userId, boolean archived) {
2877 return findByU_A(userId, archived, QueryUtil.ALL_POS,
2878 QueryUtil.ALL_POS, null);
2879 }
2880
2881
2894 @Override
2895 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
2896 int start, int end) {
2897 return findByU_A(userId, archived, start, end, null);
2898 }
2899
2900
2914 @Override
2915 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
2916 int start, int end,
2917 OrderByComparator<UserNotificationEvent> orderByComparator) {
2918 return findByU_A(userId, archived, start, end, orderByComparator, true);
2919 }
2920
2921
2936 @Override
2937 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
2938 int start, int end,
2939 OrderByComparator<UserNotificationEvent> orderByComparator,
2940 boolean retrieveFromCache) {
2941 boolean pagination = true;
2942 FinderPath finderPath = null;
2943 Object[] finderArgs = null;
2944
2945 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2946 (orderByComparator == null)) {
2947 pagination = false;
2948 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A;
2949 finderArgs = new Object[] { userId, archived };
2950 }
2951 else {
2952 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A;
2953 finderArgs = new Object[] {
2954 userId, archived,
2955
2956 start, end, orderByComparator
2957 };
2958 }
2959
2960 List<UserNotificationEvent> list = null;
2961
2962 if (retrieveFromCache) {
2963 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
2964 finderArgs, this);
2965
2966 if ((list != null) && !list.isEmpty()) {
2967 for (UserNotificationEvent userNotificationEvent : list) {
2968 if ((userId != userNotificationEvent.getUserId()) ||
2969 (archived != userNotificationEvent.getArchived())) {
2970 list = null;
2971
2972 break;
2973 }
2974 }
2975 }
2976 }
2977
2978 if (list == null) {
2979 StringBundler query = null;
2980
2981 if (orderByComparator != null) {
2982 query = new StringBundler(4 +
2983 (orderByComparator.getOrderByFields().length * 3));
2984 }
2985 else {
2986 query = new StringBundler(4);
2987 }
2988
2989 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2990
2991 query.append(_FINDER_COLUMN_U_A_USERID_2);
2992
2993 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
2994
2995 if (orderByComparator != null) {
2996 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2997 orderByComparator);
2998 }
2999 else
3000 if (pagination) {
3001 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3002 }
3003
3004 String sql = query.toString();
3005
3006 Session session = null;
3007
3008 try {
3009 session = openSession();
3010
3011 Query q = session.createQuery(sql);
3012
3013 QueryPos qPos = QueryPos.getInstance(q);
3014
3015 qPos.add(userId);
3016
3017 qPos.add(archived);
3018
3019 if (!pagination) {
3020 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3021 getDialect(), start, end, false);
3022
3023 Collections.sort(list);
3024
3025 list = Collections.unmodifiableList(list);
3026 }
3027 else {
3028 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3029 getDialect(), start, end);
3030 }
3031
3032 cacheResult(list);
3033
3034 finderCache.putResult(finderPath, finderArgs, list);
3035 }
3036 catch (Exception e) {
3037 finderCache.removeResult(finderPath, finderArgs);
3038
3039 throw processException(e);
3040 }
3041 finally {
3042 closeSession(session);
3043 }
3044 }
3045
3046 return list;
3047 }
3048
3049
3058 @Override
3059 public UserNotificationEvent findByU_A_First(long userId, boolean archived,
3060 OrderByComparator<UserNotificationEvent> orderByComparator)
3061 throws NoSuchUserNotificationEventException {
3062 UserNotificationEvent userNotificationEvent = fetchByU_A_First(userId,
3063 archived, orderByComparator);
3064
3065 if (userNotificationEvent != null) {
3066 return userNotificationEvent;
3067 }
3068
3069 StringBundler msg = new StringBundler(6);
3070
3071 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3072
3073 msg.append("userId=");
3074 msg.append(userId);
3075
3076 msg.append(", archived=");
3077 msg.append(archived);
3078
3079 msg.append(StringPool.CLOSE_CURLY_BRACE);
3080
3081 throw new NoSuchUserNotificationEventException(msg.toString());
3082 }
3083
3084
3092 @Override
3093 public UserNotificationEvent fetchByU_A_First(long userId,
3094 boolean archived,
3095 OrderByComparator<UserNotificationEvent> orderByComparator) {
3096 List<UserNotificationEvent> list = findByU_A(userId, archived, 0, 1,
3097 orderByComparator);
3098
3099 if (!list.isEmpty()) {
3100 return list.get(0);
3101 }
3102
3103 return null;
3104 }
3105
3106
3115 @Override
3116 public UserNotificationEvent findByU_A_Last(long userId, boolean archived,
3117 OrderByComparator<UserNotificationEvent> orderByComparator)
3118 throws NoSuchUserNotificationEventException {
3119 UserNotificationEvent userNotificationEvent = fetchByU_A_Last(userId,
3120 archived, orderByComparator);
3121
3122 if (userNotificationEvent != null) {
3123 return userNotificationEvent;
3124 }
3125
3126 StringBundler msg = new StringBundler(6);
3127
3128 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3129
3130 msg.append("userId=");
3131 msg.append(userId);
3132
3133 msg.append(", archived=");
3134 msg.append(archived);
3135
3136 msg.append(StringPool.CLOSE_CURLY_BRACE);
3137
3138 throw new NoSuchUserNotificationEventException(msg.toString());
3139 }
3140
3141
3149 @Override
3150 public UserNotificationEvent fetchByU_A_Last(long userId, boolean archived,
3151 OrderByComparator<UserNotificationEvent> orderByComparator) {
3152 int count = countByU_A(userId, archived);
3153
3154 if (count == 0) {
3155 return null;
3156 }
3157
3158 List<UserNotificationEvent> list = findByU_A(userId, archived,
3159 count - 1, count, orderByComparator);
3160
3161 if (!list.isEmpty()) {
3162 return list.get(0);
3163 }
3164
3165 return null;
3166 }
3167
3168
3178 @Override
3179 public UserNotificationEvent[] findByU_A_PrevAndNext(
3180 long userNotificationEventId, long userId, boolean archived,
3181 OrderByComparator<UserNotificationEvent> orderByComparator)
3182 throws NoSuchUserNotificationEventException {
3183 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
3184
3185 Session session = null;
3186
3187 try {
3188 session = openSession();
3189
3190 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
3191
3192 array[0] = getByU_A_PrevAndNext(session, userNotificationEvent,
3193 userId, archived, orderByComparator, true);
3194
3195 array[1] = userNotificationEvent;
3196
3197 array[2] = getByU_A_PrevAndNext(session, userNotificationEvent,
3198 userId, archived, orderByComparator, false);
3199
3200 return array;
3201 }
3202 catch (Exception e) {
3203 throw processException(e);
3204 }
3205 finally {
3206 closeSession(session);
3207 }
3208 }
3209
3210 protected UserNotificationEvent getByU_A_PrevAndNext(Session session,
3211 UserNotificationEvent userNotificationEvent, long userId,
3212 boolean archived,
3213 OrderByComparator<UserNotificationEvent> orderByComparator,
3214 boolean previous) {
3215 StringBundler query = null;
3216
3217 if (orderByComparator != null) {
3218 query = new StringBundler(6 +
3219 (orderByComparator.getOrderByFields().length * 6));
3220 }
3221 else {
3222 query = new StringBundler(3);
3223 }
3224
3225 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3226
3227 query.append(_FINDER_COLUMN_U_A_USERID_2);
3228
3229 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
3230
3231 if (orderByComparator != null) {
3232 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3233
3234 if (orderByConditionFields.length > 0) {
3235 query.append(WHERE_AND);
3236 }
3237
3238 for (int i = 0; i < orderByConditionFields.length; i++) {
3239 query.append(_ORDER_BY_ENTITY_ALIAS);
3240 query.append(orderByConditionFields[i]);
3241
3242 if ((i + 1) < orderByConditionFields.length) {
3243 if (orderByComparator.isAscending() ^ previous) {
3244 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3245 }
3246 else {
3247 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3248 }
3249 }
3250 else {
3251 if (orderByComparator.isAscending() ^ previous) {
3252 query.append(WHERE_GREATER_THAN);
3253 }
3254 else {
3255 query.append(WHERE_LESSER_THAN);
3256 }
3257 }
3258 }
3259
3260 query.append(ORDER_BY_CLAUSE);
3261
3262 String[] orderByFields = orderByComparator.getOrderByFields();
3263
3264 for (int i = 0; i < orderByFields.length; i++) {
3265 query.append(_ORDER_BY_ENTITY_ALIAS);
3266 query.append(orderByFields[i]);
3267
3268 if ((i + 1) < orderByFields.length) {
3269 if (orderByComparator.isAscending() ^ previous) {
3270 query.append(ORDER_BY_ASC_HAS_NEXT);
3271 }
3272 else {
3273 query.append(ORDER_BY_DESC_HAS_NEXT);
3274 }
3275 }
3276 else {
3277 if (orderByComparator.isAscending() ^ previous) {
3278 query.append(ORDER_BY_ASC);
3279 }
3280 else {
3281 query.append(ORDER_BY_DESC);
3282 }
3283 }
3284 }
3285 }
3286 else {
3287 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3288 }
3289
3290 String sql = query.toString();
3291
3292 Query q = session.createQuery(sql);
3293
3294 q.setFirstResult(0);
3295 q.setMaxResults(2);
3296
3297 QueryPos qPos = QueryPos.getInstance(q);
3298
3299 qPos.add(userId);
3300
3301 qPos.add(archived);
3302
3303 if (orderByComparator != null) {
3304 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
3305
3306 for (Object value : values) {
3307 qPos.add(value);
3308 }
3309 }
3310
3311 List<UserNotificationEvent> list = q.list();
3312
3313 if (list.size() == 2) {
3314 return list.get(1);
3315 }
3316 else {
3317 return null;
3318 }
3319 }
3320
3321
3327 @Override
3328 public void removeByU_A(long userId, boolean archived) {
3329 for (UserNotificationEvent userNotificationEvent : findByU_A(userId,
3330 archived, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3331 remove(userNotificationEvent);
3332 }
3333 }
3334
3335
3342 @Override
3343 public int countByU_A(long userId, boolean archived) {
3344 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_A;
3345
3346 Object[] finderArgs = new Object[] { userId, archived };
3347
3348 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3349
3350 if (count == null) {
3351 StringBundler query = new StringBundler(3);
3352
3353 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
3354
3355 query.append(_FINDER_COLUMN_U_A_USERID_2);
3356
3357 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
3358
3359 String sql = query.toString();
3360
3361 Session session = null;
3362
3363 try {
3364 session = openSession();
3365
3366 Query q = session.createQuery(sql);
3367
3368 QueryPos qPos = QueryPos.getInstance(q);
3369
3370 qPos.add(userId);
3371
3372 qPos.add(archived);
3373
3374 count = (Long)q.uniqueResult();
3375
3376 finderCache.putResult(finderPath, finderArgs, count);
3377 }
3378 catch (Exception e) {
3379 finderCache.removeResult(finderPath, finderArgs);
3380
3381 throw processException(e);
3382 }
3383 finally {
3384 closeSession(session);
3385 }
3386 }
3387
3388 return count.intValue();
3389 }
3390
3391 private static final String _FINDER_COLUMN_U_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
3392 private static final String _FINDER_COLUMN_U_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
3393 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3394 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3395 UserNotificationEventImpl.class,
3396 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_D",
3397 new String[] {
3398 Long.class.getName(), Integer.class.getName(),
3399 Boolean.class.getName(),
3400
3401 Integer.class.getName(), Integer.class.getName(),
3402 OrderByComparator.class.getName()
3403 });
3404 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D =
3405 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3406 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3407 UserNotificationEventImpl.class,
3408 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_D",
3409 new String[] {
3410 Long.class.getName(), Integer.class.getName(),
3411 Boolean.class.getName()
3412 },
3413 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
3414 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
3415 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
3416 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
3417 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3418 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
3419 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_D",
3420 new String[] {
3421 Long.class.getName(), Integer.class.getName(),
3422 Boolean.class.getName()
3423 });
3424
3425
3433 @Override
3434 public List<UserNotificationEvent> findByU_DT_D(long userId,
3435 int deliveryType, boolean delivered) {
3436 return findByU_DT_D(userId, deliveryType, delivered, QueryUtil.ALL_POS,
3437 QueryUtil.ALL_POS, null);
3438 }
3439
3440
3454 @Override
3455 public List<UserNotificationEvent> findByU_DT_D(long userId,
3456 int deliveryType, boolean delivered, int start, int end) {
3457 return findByU_DT_D(userId, deliveryType, delivered, start, end, null);
3458 }
3459
3460
3475 @Override
3476 public List<UserNotificationEvent> findByU_DT_D(long userId,
3477 int deliveryType, boolean delivered, int start, int end,
3478 OrderByComparator<UserNotificationEvent> orderByComparator) {
3479 return findByU_DT_D(userId, deliveryType, delivered, start, end,
3480 orderByComparator, true);
3481 }
3482
3483
3499 @Override
3500 public List<UserNotificationEvent> findByU_DT_D(long userId,
3501 int deliveryType, boolean delivered, int start, int end,
3502 OrderByComparator<UserNotificationEvent> orderByComparator,
3503 boolean retrieveFromCache) {
3504 boolean pagination = true;
3505 FinderPath finderPath = null;
3506 Object[] finderArgs = null;
3507
3508 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3509 (orderByComparator == null)) {
3510 pagination = false;
3511 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D;
3512 finderArgs = new Object[] { userId, deliveryType, delivered };
3513 }
3514 else {
3515 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D;
3516 finderArgs = new Object[] {
3517 userId, deliveryType, delivered,
3518
3519 start, end, orderByComparator
3520 };
3521 }
3522
3523 List<UserNotificationEvent> list = null;
3524
3525 if (retrieveFromCache) {
3526 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
3527 finderArgs, this);
3528
3529 if ((list != null) && !list.isEmpty()) {
3530 for (UserNotificationEvent userNotificationEvent : list) {
3531 if ((userId != userNotificationEvent.getUserId()) ||
3532 (deliveryType != userNotificationEvent.getDeliveryType()) ||
3533 (delivered != userNotificationEvent.getDelivered())) {
3534 list = null;
3535
3536 break;
3537 }
3538 }
3539 }
3540 }
3541
3542 if (list == null) {
3543 StringBundler query = null;
3544
3545 if (orderByComparator != null) {
3546 query = new StringBundler(5 +
3547 (orderByComparator.getOrderByFields().length * 3));
3548 }
3549 else {
3550 query = new StringBundler(5);
3551 }
3552
3553 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3554
3555 query.append(_FINDER_COLUMN_U_DT_D_USERID_2);
3556
3557 query.append(_FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2);
3558
3559 query.append(_FINDER_COLUMN_U_DT_D_DELIVERED_2);
3560
3561 if (orderByComparator != null) {
3562 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3563 orderByComparator);
3564 }
3565 else
3566 if (pagination) {
3567 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3568 }
3569
3570 String sql = query.toString();
3571
3572 Session session = null;
3573
3574 try {
3575 session = openSession();
3576
3577 Query q = session.createQuery(sql);
3578
3579 QueryPos qPos = QueryPos.getInstance(q);
3580
3581 qPos.add(userId);
3582
3583 qPos.add(deliveryType);
3584
3585 qPos.add(delivered);
3586
3587 if (!pagination) {
3588 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3589 getDialect(), start, end, false);
3590
3591 Collections.sort(list);
3592
3593 list = Collections.unmodifiableList(list);
3594 }
3595 else {
3596 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3597 getDialect(), start, end);
3598 }
3599
3600 cacheResult(list);
3601
3602 finderCache.putResult(finderPath, finderArgs, list);
3603 }
3604 catch (Exception e) {
3605 finderCache.removeResult(finderPath, finderArgs);
3606
3607 throw processException(e);
3608 }
3609 finally {
3610 closeSession(session);
3611 }
3612 }
3613
3614 return list;
3615 }
3616
3617
3627 @Override
3628 public UserNotificationEvent findByU_DT_D_First(long userId,
3629 int deliveryType, boolean delivered,
3630 OrderByComparator<UserNotificationEvent> orderByComparator)
3631 throws NoSuchUserNotificationEventException {
3632 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_First(userId,
3633 deliveryType, delivered, orderByComparator);
3634
3635 if (userNotificationEvent != null) {
3636 return userNotificationEvent;
3637 }
3638
3639 StringBundler msg = new StringBundler(8);
3640
3641 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3642
3643 msg.append("userId=");
3644 msg.append(userId);
3645
3646 msg.append(", deliveryType=");
3647 msg.append(deliveryType);
3648
3649 msg.append(", delivered=");
3650 msg.append(delivered);
3651
3652 msg.append(StringPool.CLOSE_CURLY_BRACE);
3653
3654 throw new NoSuchUserNotificationEventException(msg.toString());
3655 }
3656
3657
3666 @Override
3667 public UserNotificationEvent fetchByU_DT_D_First(long userId,
3668 int deliveryType, boolean delivered,
3669 OrderByComparator<UserNotificationEvent> orderByComparator) {
3670 List<UserNotificationEvent> list = findByU_DT_D(userId, deliveryType,
3671 delivered, 0, 1, orderByComparator);
3672
3673 if (!list.isEmpty()) {
3674 return list.get(0);
3675 }
3676
3677 return null;
3678 }
3679
3680
3690 @Override
3691 public UserNotificationEvent findByU_DT_D_Last(long userId,
3692 int deliveryType, boolean delivered,
3693 OrderByComparator<UserNotificationEvent> orderByComparator)
3694 throws NoSuchUserNotificationEventException {
3695 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_Last(userId,
3696 deliveryType, delivered, orderByComparator);
3697
3698 if (userNotificationEvent != null) {
3699 return userNotificationEvent;
3700 }
3701
3702 StringBundler msg = new StringBundler(8);
3703
3704 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3705
3706 msg.append("userId=");
3707 msg.append(userId);
3708
3709 msg.append(", deliveryType=");
3710 msg.append(deliveryType);
3711
3712 msg.append(", delivered=");
3713 msg.append(delivered);
3714
3715 msg.append(StringPool.CLOSE_CURLY_BRACE);
3716
3717 throw new NoSuchUserNotificationEventException(msg.toString());
3718 }
3719
3720
3729 @Override
3730 public UserNotificationEvent fetchByU_DT_D_Last(long userId,
3731 int deliveryType, boolean delivered,
3732 OrderByComparator<UserNotificationEvent> orderByComparator) {
3733 int count = countByU_DT_D(userId, deliveryType, delivered);
3734
3735 if (count == 0) {
3736 return null;
3737 }
3738
3739 List<UserNotificationEvent> list = findByU_DT_D(userId, deliveryType,
3740 delivered, count - 1, count, orderByComparator);
3741
3742 if (!list.isEmpty()) {
3743 return list.get(0);
3744 }
3745
3746 return null;
3747 }
3748
3749
3760 @Override
3761 public UserNotificationEvent[] findByU_DT_D_PrevAndNext(
3762 long userNotificationEventId, long userId, int deliveryType,
3763 boolean delivered,
3764 OrderByComparator<UserNotificationEvent> orderByComparator)
3765 throws NoSuchUserNotificationEventException {
3766 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
3767
3768 Session session = null;
3769
3770 try {
3771 session = openSession();
3772
3773 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
3774
3775 array[0] = getByU_DT_D_PrevAndNext(session, userNotificationEvent,
3776 userId, deliveryType, delivered, orderByComparator, true);
3777
3778 array[1] = userNotificationEvent;
3779
3780 array[2] = getByU_DT_D_PrevAndNext(session, userNotificationEvent,
3781 userId, deliveryType, delivered, orderByComparator, false);
3782
3783 return array;
3784 }
3785 catch (Exception e) {
3786 throw processException(e);
3787 }
3788 finally {
3789 closeSession(session);
3790 }
3791 }
3792
3793 protected UserNotificationEvent getByU_DT_D_PrevAndNext(Session session,
3794 UserNotificationEvent userNotificationEvent, long userId,
3795 int deliveryType, boolean delivered,
3796 OrderByComparator<UserNotificationEvent> orderByComparator,
3797 boolean previous) {
3798 StringBundler query = null;
3799
3800 if (orderByComparator != null) {
3801 query = new StringBundler(6 +
3802 (orderByComparator.getOrderByFields().length * 6));
3803 }
3804 else {
3805 query = new StringBundler(3);
3806 }
3807
3808 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3809
3810 query.append(_FINDER_COLUMN_U_DT_D_USERID_2);
3811
3812 query.append(_FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2);
3813
3814 query.append(_FINDER_COLUMN_U_DT_D_DELIVERED_2);
3815
3816 if (orderByComparator != null) {
3817 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3818
3819 if (orderByConditionFields.length > 0) {
3820 query.append(WHERE_AND);
3821 }
3822
3823 for (int i = 0; i < orderByConditionFields.length; i++) {
3824 query.append(_ORDER_BY_ENTITY_ALIAS);
3825 query.append(orderByConditionFields[i]);
3826
3827 if ((i + 1) < orderByConditionFields.length) {
3828 if (orderByComparator.isAscending() ^ previous) {
3829 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3830 }
3831 else {
3832 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3833 }
3834 }
3835 else {
3836 if (orderByComparator.isAscending() ^ previous) {
3837 query.append(WHERE_GREATER_THAN);
3838 }
3839 else {
3840 query.append(WHERE_LESSER_THAN);
3841 }
3842 }
3843 }
3844
3845 query.append(ORDER_BY_CLAUSE);
3846
3847 String[] orderByFields = orderByComparator.getOrderByFields();
3848
3849 for (int i = 0; i < orderByFields.length; i++) {
3850 query.append(_ORDER_BY_ENTITY_ALIAS);
3851 query.append(orderByFields[i]);
3852
3853 if ((i + 1) < orderByFields.length) {
3854 if (orderByComparator.isAscending() ^ previous) {
3855 query.append(ORDER_BY_ASC_HAS_NEXT);
3856 }
3857 else {
3858 query.append(ORDER_BY_DESC_HAS_NEXT);
3859 }
3860 }
3861 else {
3862 if (orderByComparator.isAscending() ^ previous) {
3863 query.append(ORDER_BY_ASC);
3864 }
3865 else {
3866 query.append(ORDER_BY_DESC);
3867 }
3868 }
3869 }
3870 }
3871 else {
3872 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3873 }
3874
3875 String sql = query.toString();
3876
3877 Query q = session.createQuery(sql);
3878
3879 q.setFirstResult(0);
3880 q.setMaxResults(2);
3881
3882 QueryPos qPos = QueryPos.getInstance(q);
3883
3884 qPos.add(userId);
3885
3886 qPos.add(deliveryType);
3887
3888 qPos.add(delivered);
3889
3890 if (orderByComparator != null) {
3891 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
3892
3893 for (Object value : values) {
3894 qPos.add(value);
3895 }
3896 }
3897
3898 List<UserNotificationEvent> list = q.list();
3899
3900 if (list.size() == 2) {
3901 return list.get(1);
3902 }
3903 else {
3904 return null;
3905 }
3906 }
3907
3908
3915 @Override
3916 public void removeByU_DT_D(long userId, int deliveryType, boolean delivered) {
3917 for (UserNotificationEvent userNotificationEvent : findByU_DT_D(
3918 userId, deliveryType, delivered, QueryUtil.ALL_POS,
3919 QueryUtil.ALL_POS, null)) {
3920 remove(userNotificationEvent);
3921 }
3922 }
3923
3924
3932 @Override
3933 public int countByU_DT_D(long userId, int deliveryType, boolean delivered) {
3934 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_D;
3935
3936 Object[] finderArgs = new Object[] { userId, deliveryType, delivered };
3937
3938 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3939
3940 if (count == null) {
3941 StringBundler query = new StringBundler(4);
3942
3943 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
3944
3945 query.append(_FINDER_COLUMN_U_DT_D_USERID_2);
3946
3947 query.append(_FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2);
3948
3949 query.append(_FINDER_COLUMN_U_DT_D_DELIVERED_2);
3950
3951 String sql = query.toString();
3952
3953 Session session = null;
3954
3955 try {
3956 session = openSession();
3957
3958 Query q = session.createQuery(sql);
3959
3960 QueryPos qPos = QueryPos.getInstance(q);
3961
3962 qPos.add(userId);
3963
3964 qPos.add(deliveryType);
3965
3966 qPos.add(delivered);
3967
3968 count = (Long)q.uniqueResult();
3969
3970 finderCache.putResult(finderPath, finderArgs, count);
3971 }
3972 catch (Exception e) {
3973 finderCache.removeResult(finderPath, finderArgs);
3974
3975 throw processException(e);
3976 }
3977 finally {
3978 closeSession(session);
3979 }
3980 }
3981
3982 return count.intValue();
3983 }
3984
3985 private static final String _FINDER_COLUMN_U_DT_D_USERID_2 = "userNotificationEvent.userId = ? AND ";
3986 private static final String _FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
3987 private static final String _FINDER_COLUMN_U_DT_D_DELIVERED_2 = "userNotificationEvent.delivered = ?";
3988 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3989 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3990 UserNotificationEventImpl.class,
3991 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_A",
3992 new String[] {
3993 Long.class.getName(), Integer.class.getName(),
3994 Boolean.class.getName(),
3995
3996 Integer.class.getName(), Integer.class.getName(),
3997 OrderByComparator.class.getName()
3998 });
3999 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A =
4000 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4001 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
4002 UserNotificationEventImpl.class,
4003 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_A",
4004 new String[] {
4005 Long.class.getName(), Integer.class.getName(),
4006 Boolean.class.getName()
4007 },
4008 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
4009 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
4010 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
4011 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
4012 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4013 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
4014 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_A",
4015 new String[] {
4016 Long.class.getName(), Integer.class.getName(),
4017 Boolean.class.getName()
4018 });
4019
4020
4028 @Override
4029 public List<UserNotificationEvent> findByU_DT_A(long userId,
4030 int deliveryType, boolean archived) {
4031 return findByU_DT_A(userId, deliveryType, archived, QueryUtil.ALL_POS,
4032 QueryUtil.ALL_POS, null);
4033 }
4034
4035
4049 @Override
4050 public List<UserNotificationEvent> findByU_DT_A(long userId,
4051 int deliveryType, boolean archived, int start, int end) {
4052 return findByU_DT_A(userId, deliveryType, archived, start, end, null);
4053 }
4054
4055
4070 @Override
4071 public List<UserNotificationEvent> findByU_DT_A(long userId,
4072 int deliveryType, boolean archived, int start, int end,
4073 OrderByComparator<UserNotificationEvent> orderByComparator) {
4074 return findByU_DT_A(userId, deliveryType, archived, start, end,
4075 orderByComparator, true);
4076 }
4077
4078
4094 @Override
4095 public List<UserNotificationEvent> findByU_DT_A(long userId,
4096 int deliveryType, boolean archived, int start, int end,
4097 OrderByComparator<UserNotificationEvent> orderByComparator,
4098 boolean retrieveFromCache) {
4099 boolean pagination = true;
4100 FinderPath finderPath = null;
4101 Object[] finderArgs = null;
4102
4103 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4104 (orderByComparator == null)) {
4105 pagination = false;
4106 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A;
4107 finderArgs = new Object[] { userId, deliveryType, archived };
4108 }
4109 else {
4110 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A;
4111 finderArgs = new Object[] {
4112 userId, deliveryType, archived,
4113
4114 start, end, orderByComparator
4115 };
4116 }
4117
4118 List<UserNotificationEvent> list = null;
4119
4120 if (retrieveFromCache) {
4121 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
4122 finderArgs, this);
4123
4124 if ((list != null) && !list.isEmpty()) {
4125 for (UserNotificationEvent userNotificationEvent : list) {
4126 if ((userId != userNotificationEvent.getUserId()) ||
4127 (deliveryType != userNotificationEvent.getDeliveryType()) ||
4128 (archived != userNotificationEvent.getArchived())) {
4129 list = null;
4130
4131 break;
4132 }
4133 }
4134 }
4135 }
4136
4137 if (list == null) {
4138 StringBundler query = null;
4139
4140 if (orderByComparator != null) {
4141 query = new StringBundler(5 +
4142 (orderByComparator.getOrderByFields().length * 3));
4143 }
4144 else {
4145 query = new StringBundler(5);
4146 }
4147
4148 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4149
4150 query.append(_FINDER_COLUMN_U_DT_A_USERID_2);
4151
4152 query.append(_FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2);
4153
4154 query.append(_FINDER_COLUMN_U_DT_A_ARCHIVED_2);
4155
4156 if (orderByComparator != null) {
4157 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4158 orderByComparator);
4159 }
4160 else
4161 if (pagination) {
4162 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
4163 }
4164
4165 String sql = query.toString();
4166
4167 Session session = null;
4168
4169 try {
4170 session = openSession();
4171
4172 Query q = session.createQuery(sql);
4173
4174 QueryPos qPos = QueryPos.getInstance(q);
4175
4176 qPos.add(userId);
4177
4178 qPos.add(deliveryType);
4179
4180 qPos.add(archived);
4181
4182 if (!pagination) {
4183 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4184 getDialect(), start, end, false);
4185
4186 Collections.sort(list);
4187
4188 list = Collections.unmodifiableList(list);
4189 }
4190 else {
4191 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4192 getDialect(), start, end);
4193 }
4194
4195 cacheResult(list);
4196
4197 finderCache.putResult(finderPath, finderArgs, list);
4198 }
4199 catch (Exception e) {
4200 finderCache.removeResult(finderPath, finderArgs);
4201
4202 throw processException(e);
4203 }
4204 finally {
4205 closeSession(session);
4206 }
4207 }
4208
4209 return list;
4210 }
4211
4212
4222 @Override
4223 public UserNotificationEvent findByU_DT_A_First(long userId,
4224 int deliveryType, boolean archived,
4225 OrderByComparator<UserNotificationEvent> orderByComparator)
4226 throws NoSuchUserNotificationEventException {
4227 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_First(userId,
4228 deliveryType, archived, orderByComparator);
4229
4230 if (userNotificationEvent != null) {
4231 return userNotificationEvent;
4232 }
4233
4234 StringBundler msg = new StringBundler(8);
4235
4236 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4237
4238 msg.append("userId=");
4239 msg.append(userId);
4240
4241 msg.append(", deliveryType=");
4242 msg.append(deliveryType);
4243
4244 msg.append(", archived=");
4245 msg.append(archived);
4246
4247 msg.append(StringPool.CLOSE_CURLY_BRACE);
4248
4249 throw new NoSuchUserNotificationEventException(msg.toString());
4250 }
4251
4252
4261 @Override
4262 public UserNotificationEvent fetchByU_DT_A_First(long userId,
4263 int deliveryType, boolean archived,
4264 OrderByComparator<UserNotificationEvent> orderByComparator) {
4265 List<UserNotificationEvent> list = findByU_DT_A(userId, deliveryType,
4266 archived, 0, 1, orderByComparator);
4267
4268 if (!list.isEmpty()) {
4269 return list.get(0);
4270 }
4271
4272 return null;
4273 }
4274
4275
4285 @Override
4286 public UserNotificationEvent findByU_DT_A_Last(long userId,
4287 int deliveryType, boolean archived,
4288 OrderByComparator<UserNotificationEvent> orderByComparator)
4289 throws NoSuchUserNotificationEventException {
4290 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_Last(userId,
4291 deliveryType, archived, orderByComparator);
4292
4293 if (userNotificationEvent != null) {
4294 return userNotificationEvent;
4295 }
4296
4297 StringBundler msg = new StringBundler(8);
4298
4299 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4300
4301 msg.append("userId=");
4302 msg.append(userId);
4303
4304 msg.append(", deliveryType=");
4305 msg.append(deliveryType);
4306
4307 msg.append(", archived=");
4308 msg.append(archived);
4309
4310 msg.append(StringPool.CLOSE_CURLY_BRACE);
4311
4312 throw new NoSuchUserNotificationEventException(msg.toString());
4313 }
4314
4315
4324 @Override
4325 public UserNotificationEvent fetchByU_DT_A_Last(long userId,
4326 int deliveryType, boolean archived,
4327 OrderByComparator<UserNotificationEvent> orderByComparator) {
4328 int count = countByU_DT_A(userId, deliveryType, archived);
4329
4330 if (count == 0) {
4331 return null;
4332 }
4333
4334 List<UserNotificationEvent> list = findByU_DT_A(userId, deliveryType,
4335 archived, count - 1, count, orderByComparator);
4336
4337 if (!list.isEmpty()) {
4338 return list.get(0);
4339 }
4340
4341 return null;
4342 }
4343
4344
4355 @Override
4356 public UserNotificationEvent[] findByU_DT_A_PrevAndNext(
4357 long userNotificationEventId, long userId, int deliveryType,
4358 boolean archived,
4359 OrderByComparator<UserNotificationEvent> orderByComparator)
4360 throws NoSuchUserNotificationEventException {
4361 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
4362
4363 Session session = null;
4364
4365 try {
4366 session = openSession();
4367
4368 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
4369
4370 array[0] = getByU_DT_A_PrevAndNext(session, userNotificationEvent,
4371 userId, deliveryType, archived, orderByComparator, true);
4372
4373 array[1] = userNotificationEvent;
4374
4375 array[2] = getByU_DT_A_PrevAndNext(session, userNotificationEvent,
4376 userId, deliveryType, archived, orderByComparator, false);
4377
4378 return array;
4379 }
4380 catch (Exception e) {
4381 throw processException(e);
4382 }
4383 finally {
4384 closeSession(session);
4385 }
4386 }
4387
4388 protected UserNotificationEvent getByU_DT_A_PrevAndNext(Session session,
4389 UserNotificationEvent userNotificationEvent, long userId,
4390 int deliveryType, boolean archived,
4391 OrderByComparator<UserNotificationEvent> orderByComparator,
4392 boolean previous) {
4393 StringBundler query = null;
4394
4395 if (orderByComparator != null) {
4396 query = new StringBundler(6 +
4397 (orderByComparator.getOrderByFields().length * 6));
4398 }
4399 else {
4400 query = new StringBundler(3);
4401 }
4402
4403 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4404
4405 query.append(_FINDER_COLUMN_U_DT_A_USERID_2);
4406
4407 query.append(_FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2);
4408
4409 query.append(_FINDER_COLUMN_U_DT_A_ARCHIVED_2);
4410
4411 if (orderByComparator != null) {
4412 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4413
4414 if (orderByConditionFields.length > 0) {
4415 query.append(WHERE_AND);
4416 }
4417
4418 for (int i = 0; i < orderByConditionFields.length; i++) {
4419 query.append(_ORDER_BY_ENTITY_ALIAS);
4420 query.append(orderByConditionFields[i]);
4421
4422 if ((i + 1) < orderByConditionFields.length) {
4423 if (orderByComparator.isAscending() ^ previous) {
4424 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4425 }
4426 else {
4427 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4428 }
4429 }
4430 else {
4431 if (orderByComparator.isAscending() ^ previous) {
4432 query.append(WHERE_GREATER_THAN);
4433 }
4434 else {
4435 query.append(WHERE_LESSER_THAN);
4436 }
4437 }
4438 }
4439
4440 query.append(ORDER_BY_CLAUSE);
4441
4442 String[] orderByFields = orderByComparator.getOrderByFields();
4443
4444 for (int i = 0; i < orderByFields.length; i++) {
4445 query.append(_ORDER_BY_ENTITY_ALIAS);
4446 query.append(orderByFields[i]);
4447
4448 if ((i + 1) < orderByFields.length) {
4449 if (orderByComparator.isAscending() ^ previous) {
4450 query.append(ORDER_BY_ASC_HAS_NEXT);
4451 }
4452 else {
4453 query.append(ORDER_BY_DESC_HAS_NEXT);
4454 }
4455 }
4456 else {
4457 if (orderByComparator.isAscending() ^ previous) {
4458 query.append(ORDER_BY_ASC);
4459 }
4460 else {
4461 query.append(ORDER_BY_DESC);
4462 }
4463 }
4464 }
4465 }
4466 else {
4467 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
4468 }
4469
4470 String sql = query.toString();
4471
4472 Query q = session.createQuery(sql);
4473
4474 q.setFirstResult(0);
4475 q.setMaxResults(2);
4476
4477 QueryPos qPos = QueryPos.getInstance(q);
4478
4479 qPos.add(userId);
4480
4481 qPos.add(deliveryType);
4482
4483 qPos.add(archived);
4484
4485 if (orderByComparator != null) {
4486 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
4487
4488 for (Object value : values) {
4489 qPos.add(value);
4490 }
4491 }
4492
4493 List<UserNotificationEvent> list = q.list();
4494
4495 if (list.size() == 2) {
4496 return list.get(1);
4497 }
4498 else {
4499 return null;
4500 }
4501 }
4502
4503
4510 @Override
4511 public void removeByU_DT_A(long userId, int deliveryType, boolean archived) {
4512 for (UserNotificationEvent userNotificationEvent : findByU_DT_A(
4513 userId, deliveryType, archived, QueryUtil.ALL_POS,
4514 QueryUtil.ALL_POS, null)) {
4515 remove(userNotificationEvent);
4516 }
4517 }
4518
4519
4527 @Override
4528 public int countByU_DT_A(long userId, int deliveryType, boolean archived) {
4529 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_A;
4530
4531 Object[] finderArgs = new Object[] { userId, deliveryType, archived };
4532
4533 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4534
4535 if (count == null) {
4536 StringBundler query = new StringBundler(4);
4537
4538 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
4539
4540 query.append(_FINDER_COLUMN_U_DT_A_USERID_2);
4541
4542 query.append(_FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2);
4543
4544 query.append(_FINDER_COLUMN_U_DT_A_ARCHIVED_2);
4545
4546 String sql = query.toString();
4547
4548 Session session = null;
4549
4550 try {
4551 session = openSession();
4552
4553 Query q = session.createQuery(sql);
4554
4555 QueryPos qPos = QueryPos.getInstance(q);
4556
4557 qPos.add(userId);
4558
4559 qPos.add(deliveryType);
4560
4561 qPos.add(archived);
4562
4563 count = (Long)q.uniqueResult();
4564
4565 finderCache.putResult(finderPath, finderArgs, count);
4566 }
4567 catch (Exception e) {
4568 finderCache.removeResult(finderPath, finderArgs);
4569
4570 throw processException(e);
4571 }
4572 finally {
4573 closeSession(session);
4574 }
4575 }
4576
4577 return count.intValue();
4578 }
4579
4580 private static final String _FINDER_COLUMN_U_DT_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
4581 private static final String _FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
4582 private static final String _FINDER_COLUMN_U_DT_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
4583 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4584 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
4585 UserNotificationEventImpl.class,
4586 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_D_A",
4587 new String[] {
4588 Long.class.getName(), Boolean.class.getName(),
4589 Boolean.class.getName(),
4590
4591 Integer.class.getName(), Integer.class.getName(),
4592 OrderByComparator.class.getName()
4593 });
4594 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4595 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
4596 UserNotificationEventImpl.class,
4597 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_D_A",
4598 new String[] {
4599 Long.class.getName(), Boolean.class.getName(),
4600 Boolean.class.getName()
4601 },
4602 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
4603 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
4604 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
4605 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
4606 public static final FinderPath FINDER_PATH_COUNT_BY_U_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4607 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
4608 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_D_A",
4609 new String[] {
4610 Long.class.getName(), Boolean.class.getName(),
4611 Boolean.class.getName()
4612 });
4613
4614
4622 @Override
4623 public List<UserNotificationEvent> findByU_D_A(long userId,
4624 boolean delivered, boolean actionRequired) {
4625 return findByU_D_A(userId, delivered, actionRequired,
4626 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4627 }
4628
4629
4643 @Override
4644 public List<UserNotificationEvent> findByU_D_A(long userId,
4645 boolean delivered, boolean actionRequired, int start, int end) {
4646 return findByU_D_A(userId, delivered, actionRequired, start, end, null);
4647 }
4648
4649
4664 @Override
4665 public List<UserNotificationEvent> findByU_D_A(long userId,
4666 boolean delivered, boolean actionRequired, int start, int end,
4667 OrderByComparator<UserNotificationEvent> orderByComparator) {
4668 return findByU_D_A(userId, delivered, actionRequired, start, end,
4669 orderByComparator, true);
4670 }
4671
4672
4688 @Override
4689 public List<UserNotificationEvent> findByU_D_A(long userId,
4690 boolean delivered, boolean actionRequired, int start, int end,
4691 OrderByComparator<UserNotificationEvent> orderByComparator,
4692 boolean retrieveFromCache) {
4693 boolean pagination = true;
4694 FinderPath finderPath = null;
4695 Object[] finderArgs = null;
4696
4697 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4698 (orderByComparator == null)) {
4699 pagination = false;
4700 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A;
4701 finderArgs = new Object[] { userId, delivered, actionRequired };
4702 }
4703 else {
4704 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D_A;
4705 finderArgs = new Object[] {
4706 userId, delivered, actionRequired,
4707
4708 start, end, orderByComparator
4709 };
4710 }
4711
4712 List<UserNotificationEvent> list = null;
4713
4714 if (retrieveFromCache) {
4715 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
4716 finderArgs, this);
4717
4718 if ((list != null) && !list.isEmpty()) {
4719 for (UserNotificationEvent userNotificationEvent : list) {
4720 if ((userId != userNotificationEvent.getUserId()) ||
4721 (delivered != userNotificationEvent.getDelivered()) ||
4722 (actionRequired != userNotificationEvent.getActionRequired())) {
4723 list = null;
4724
4725 break;
4726 }
4727 }
4728 }
4729 }
4730
4731 if (list == null) {
4732 StringBundler query = null;
4733
4734 if (orderByComparator != null) {
4735 query = new StringBundler(5 +
4736 (orderByComparator.getOrderByFields().length * 3));
4737 }
4738 else {
4739 query = new StringBundler(5);
4740 }
4741
4742 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4743
4744 query.append(_FINDER_COLUMN_U_D_A_USERID_2);
4745
4746 query.append(_FINDER_COLUMN_U_D_A_DELIVERED_2);
4747
4748 query.append(_FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2);
4749
4750 if (orderByComparator != null) {
4751 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4752 orderByComparator);
4753 }
4754 else
4755 if (pagination) {
4756 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
4757 }
4758
4759 String sql = query.toString();
4760
4761 Session session = null;
4762
4763 try {
4764 session = openSession();
4765
4766 Query q = session.createQuery(sql);
4767
4768 QueryPos qPos = QueryPos.getInstance(q);
4769
4770 qPos.add(userId);
4771
4772 qPos.add(delivered);
4773
4774 qPos.add(actionRequired);
4775
4776 if (!pagination) {
4777 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4778 getDialect(), start, end, false);
4779
4780 Collections.sort(list);
4781
4782 list = Collections.unmodifiableList(list);
4783 }
4784 else {
4785 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4786 getDialect(), start, end);
4787 }
4788
4789 cacheResult(list);
4790
4791 finderCache.putResult(finderPath, finderArgs, list);
4792 }
4793 catch (Exception e) {
4794 finderCache.removeResult(finderPath, finderArgs);
4795
4796 throw processException(e);
4797 }
4798 finally {
4799 closeSession(session);
4800 }
4801 }
4802
4803 return list;
4804 }
4805
4806
4816 @Override
4817 public UserNotificationEvent findByU_D_A_First(long userId,
4818 boolean delivered, boolean actionRequired,
4819 OrderByComparator<UserNotificationEvent> orderByComparator)
4820 throws NoSuchUserNotificationEventException {
4821 UserNotificationEvent userNotificationEvent = fetchByU_D_A_First(userId,
4822 delivered, actionRequired, orderByComparator);
4823
4824 if (userNotificationEvent != null) {
4825 return userNotificationEvent;
4826 }
4827
4828 StringBundler msg = new StringBundler(8);
4829
4830 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4831
4832 msg.append("userId=");
4833 msg.append(userId);
4834
4835 msg.append(", delivered=");
4836 msg.append(delivered);
4837
4838 msg.append(", actionRequired=");
4839 msg.append(actionRequired);
4840
4841 msg.append(StringPool.CLOSE_CURLY_BRACE);
4842
4843 throw new NoSuchUserNotificationEventException(msg.toString());
4844 }
4845
4846
4855 @Override
4856 public UserNotificationEvent fetchByU_D_A_First(long userId,
4857 boolean delivered, boolean actionRequired,
4858 OrderByComparator<UserNotificationEvent> orderByComparator) {
4859 List<UserNotificationEvent> list = findByU_D_A(userId, delivered,
4860 actionRequired, 0, 1, orderByComparator);
4861
4862 if (!list.isEmpty()) {
4863 return list.get(0);
4864 }
4865
4866 return null;
4867 }
4868
4869
4879 @Override
4880 public UserNotificationEvent findByU_D_A_Last(long userId,
4881 boolean delivered, boolean actionRequired,
4882 OrderByComparator<UserNotificationEvent> orderByComparator)
4883 throws NoSuchUserNotificationEventException {
4884 UserNotificationEvent userNotificationEvent = fetchByU_D_A_Last(userId,
4885 delivered, actionRequired, orderByComparator);
4886
4887 if (userNotificationEvent != null) {
4888 return userNotificationEvent;
4889 }
4890
4891 StringBundler msg = new StringBundler(8);
4892
4893 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4894
4895 msg.append("userId=");
4896 msg.append(userId);
4897
4898 msg.append(", delivered=");
4899 msg.append(delivered);
4900
4901 msg.append(", actionRequired=");
4902 msg.append(actionRequired);
4903
4904 msg.append(StringPool.CLOSE_CURLY_BRACE);
4905
4906 throw new NoSuchUserNotificationEventException(msg.toString());
4907 }
4908
4909
4918 @Override
4919 public UserNotificationEvent fetchByU_D_A_Last(long userId,
4920 boolean delivered, boolean actionRequired,
4921 OrderByComparator<UserNotificationEvent> orderByComparator) {
4922 int count = countByU_D_A(userId, delivered, actionRequired);
4923
4924 if (count == 0) {
4925 return null;
4926 }
4927
4928 List<UserNotificationEvent> list = findByU_D_A(userId, delivered,
4929 actionRequired, count - 1, count, orderByComparator);
4930
4931 if (!list.isEmpty()) {
4932 return list.get(0);
4933 }
4934
4935 return null;
4936 }
4937
4938
4949 @Override
4950 public UserNotificationEvent[] findByU_D_A_PrevAndNext(
4951 long userNotificationEventId, long userId, boolean delivered,
4952 boolean actionRequired,
4953 OrderByComparator<UserNotificationEvent> orderByComparator)
4954 throws NoSuchUserNotificationEventException {
4955 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
4956
4957 Session session = null;
4958
4959 try {
4960 session = openSession();
4961
4962 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
4963
4964 array[0] = getByU_D_A_PrevAndNext(session, userNotificationEvent,
4965 userId, delivered, actionRequired, orderByComparator, true);
4966
4967 array[1] = userNotificationEvent;
4968
4969 array[2] = getByU_D_A_PrevAndNext(session, userNotificationEvent,
4970 userId, delivered, actionRequired, orderByComparator, false);
4971
4972 return array;
4973 }
4974 catch (Exception e) {
4975 throw processException(e);
4976 }
4977 finally {
4978 closeSession(session);
4979 }
4980 }
4981
4982 protected UserNotificationEvent getByU_D_A_PrevAndNext(Session session,
4983 UserNotificationEvent userNotificationEvent, long userId,
4984 boolean delivered, boolean actionRequired,
4985 OrderByComparator<UserNotificationEvent> orderByComparator,
4986 boolean previous) {
4987 StringBundler query = null;
4988
4989 if (orderByComparator != null) {
4990 query = new StringBundler(6 +
4991 (orderByComparator.getOrderByFields().length * 6));
4992 }
4993 else {
4994 query = new StringBundler(3);
4995 }
4996
4997 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4998
4999 query.append(_FINDER_COLUMN_U_D_A_USERID_2);
5000
5001 query.append(_FINDER_COLUMN_U_D_A_DELIVERED_2);
5002
5003 query.append(_FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2);
5004
5005 if (orderByComparator != null) {
5006 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5007
5008 if (orderByConditionFields.length > 0) {
5009 query.append(WHERE_AND);
5010 }
5011
5012 for (int i = 0; i < orderByConditionFields.length; i++) {
5013 query.append(_ORDER_BY_ENTITY_ALIAS);
5014 query.append(orderByConditionFields[i]);
5015
5016 if ((i + 1) < orderByConditionFields.length) {
5017 if (orderByComparator.isAscending() ^ previous) {
5018 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5019 }
5020 else {
5021 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5022 }
5023 }
5024 else {
5025 if (orderByComparator.isAscending() ^ previous) {
5026 query.append(WHERE_GREATER_THAN);
5027 }
5028 else {
5029 query.append(WHERE_LESSER_THAN);
5030 }
5031 }
5032 }
5033
5034 query.append(ORDER_BY_CLAUSE);
5035
5036 String[] orderByFields = orderByComparator.getOrderByFields();
5037
5038 for (int i = 0; i < orderByFields.length; i++) {
5039 query.append(_ORDER_BY_ENTITY_ALIAS);
5040 query.append(orderByFields[i]);
5041
5042 if ((i + 1) < orderByFields.length) {
5043 if (orderByComparator.isAscending() ^ previous) {
5044 query.append(ORDER_BY_ASC_HAS_NEXT);
5045 }
5046 else {
5047 query.append(ORDER_BY_DESC_HAS_NEXT);
5048 }
5049 }
5050 else {
5051 if (orderByComparator.isAscending() ^ previous) {
5052 query.append(ORDER_BY_ASC);
5053 }
5054 else {
5055 query.append(ORDER_BY_DESC);
5056 }
5057 }
5058 }
5059 }
5060 else {
5061 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5062 }
5063
5064 String sql = query.toString();
5065
5066 Query q = session.createQuery(sql);
5067
5068 q.setFirstResult(0);
5069 q.setMaxResults(2);
5070
5071 QueryPos qPos = QueryPos.getInstance(q);
5072
5073 qPos.add(userId);
5074
5075 qPos.add(delivered);
5076
5077 qPos.add(actionRequired);
5078
5079 if (orderByComparator != null) {
5080 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
5081
5082 for (Object value : values) {
5083 qPos.add(value);
5084 }
5085 }
5086
5087 List<UserNotificationEvent> list = q.list();
5088
5089 if (list.size() == 2) {
5090 return list.get(1);
5091 }
5092 else {
5093 return null;
5094 }
5095 }
5096
5097
5104 @Override
5105 public void removeByU_D_A(long userId, boolean delivered,
5106 boolean actionRequired) {
5107 for (UserNotificationEvent userNotificationEvent : findByU_D_A(userId,
5108 delivered, actionRequired, QueryUtil.ALL_POS,
5109 QueryUtil.ALL_POS, null)) {
5110 remove(userNotificationEvent);
5111 }
5112 }
5113
5114
5122 @Override
5123 public int countByU_D_A(long userId, boolean delivered,
5124 boolean actionRequired) {
5125 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_D_A;
5126
5127 Object[] finderArgs = new Object[] { userId, delivered, actionRequired };
5128
5129 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5130
5131 if (count == null) {
5132 StringBundler query = new StringBundler(4);
5133
5134 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
5135
5136 query.append(_FINDER_COLUMN_U_D_A_USERID_2);
5137
5138 query.append(_FINDER_COLUMN_U_D_A_DELIVERED_2);
5139
5140 query.append(_FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2);
5141
5142 String sql = query.toString();
5143
5144 Session session = null;
5145
5146 try {
5147 session = openSession();
5148
5149 Query q = session.createQuery(sql);
5150
5151 QueryPos qPos = QueryPos.getInstance(q);
5152
5153 qPos.add(userId);
5154
5155 qPos.add(delivered);
5156
5157 qPos.add(actionRequired);
5158
5159 count = (Long)q.uniqueResult();
5160
5161 finderCache.putResult(finderPath, finderArgs, count);
5162 }
5163 catch (Exception e) {
5164 finderCache.removeResult(finderPath, finderArgs);
5165
5166 throw processException(e);
5167 }
5168 finally {
5169 closeSession(session);
5170 }
5171 }
5172
5173 return count.intValue();
5174 }
5175
5176 private static final String _FINDER_COLUMN_U_D_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
5177 private static final String _FINDER_COLUMN_U_D_A_DELIVERED_2 = "userNotificationEvent.delivered = ? AND ";
5178 private static final String _FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ?";
5179 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5180 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5181 UserNotificationEventImpl.class,
5182 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_A_A",
5183 new String[] {
5184 Long.class.getName(), Boolean.class.getName(),
5185 Boolean.class.getName(),
5186
5187 Integer.class.getName(), Integer.class.getName(),
5188 OrderByComparator.class.getName()
5189 });
5190 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5191 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5192 UserNotificationEventImpl.class,
5193 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_A_A",
5194 new String[] {
5195 Long.class.getName(), Boolean.class.getName(),
5196 Boolean.class.getName()
5197 },
5198 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
5199 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
5200 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
5201 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
5202 public static final FinderPath FINDER_PATH_COUNT_BY_U_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5203 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
5204 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_A_A",
5205 new String[] {
5206 Long.class.getName(), Boolean.class.getName(),
5207 Boolean.class.getName()
5208 });
5209
5210
5218 @Override
5219 public List<UserNotificationEvent> findByU_A_A(long userId,
5220 boolean actionRequired, boolean archived) {
5221 return findByU_A_A(userId, actionRequired, archived, QueryUtil.ALL_POS,
5222 QueryUtil.ALL_POS, null);
5223 }
5224
5225
5239 @Override
5240 public List<UserNotificationEvent> findByU_A_A(long userId,
5241 boolean actionRequired, boolean archived, int start, int end) {
5242 return findByU_A_A(userId, actionRequired, archived, start, end, null);
5243 }
5244
5245
5260 @Override
5261 public List<UserNotificationEvent> findByU_A_A(long userId,
5262 boolean actionRequired, boolean archived, int start, int end,
5263 OrderByComparator<UserNotificationEvent> orderByComparator) {
5264 return findByU_A_A(userId, actionRequired, archived, start, end,
5265 orderByComparator, true);
5266 }
5267
5268
5284 @Override
5285 public List<UserNotificationEvent> findByU_A_A(long userId,
5286 boolean actionRequired, boolean archived, int start, int end,
5287 OrderByComparator<UserNotificationEvent> orderByComparator,
5288 boolean retrieveFromCache) {
5289 boolean pagination = true;
5290 FinderPath finderPath = null;
5291 Object[] finderArgs = null;
5292
5293 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5294 (orderByComparator == null)) {
5295 pagination = false;
5296 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A;
5297 finderArgs = new Object[] { userId, actionRequired, archived };
5298 }
5299 else {
5300 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A_A;
5301 finderArgs = new Object[] {
5302 userId, actionRequired, archived,
5303
5304 start, end, orderByComparator
5305 };
5306 }
5307
5308 List<UserNotificationEvent> list = null;
5309
5310 if (retrieveFromCache) {
5311 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
5312 finderArgs, this);
5313
5314 if ((list != null) && !list.isEmpty()) {
5315 for (UserNotificationEvent userNotificationEvent : list) {
5316 if ((userId != userNotificationEvent.getUserId()) ||
5317 (actionRequired != userNotificationEvent.getActionRequired()) ||
5318 (archived != userNotificationEvent.getArchived())) {
5319 list = null;
5320
5321 break;
5322 }
5323 }
5324 }
5325 }
5326
5327 if (list == null) {
5328 StringBundler query = null;
5329
5330 if (orderByComparator != null) {
5331 query = new StringBundler(5 +
5332 (orderByComparator.getOrderByFields().length * 3));
5333 }
5334 else {
5335 query = new StringBundler(5);
5336 }
5337
5338 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5339
5340 query.append(_FINDER_COLUMN_U_A_A_USERID_2);
5341
5342 query.append(_FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2);
5343
5344 query.append(_FINDER_COLUMN_U_A_A_ARCHIVED_2);
5345
5346 if (orderByComparator != null) {
5347 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5348 orderByComparator);
5349 }
5350 else
5351 if (pagination) {
5352 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5353 }
5354
5355 String sql = query.toString();
5356
5357 Session session = null;
5358
5359 try {
5360 session = openSession();
5361
5362 Query q = session.createQuery(sql);
5363
5364 QueryPos qPos = QueryPos.getInstance(q);
5365
5366 qPos.add(userId);
5367
5368 qPos.add(actionRequired);
5369
5370 qPos.add(archived);
5371
5372 if (!pagination) {
5373 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5374 getDialect(), start, end, false);
5375
5376 Collections.sort(list);
5377
5378 list = Collections.unmodifiableList(list);
5379 }
5380 else {
5381 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5382 getDialect(), start, end);
5383 }
5384
5385 cacheResult(list);
5386
5387 finderCache.putResult(finderPath, finderArgs, list);
5388 }
5389 catch (Exception e) {
5390 finderCache.removeResult(finderPath, finderArgs);
5391
5392 throw processException(e);
5393 }
5394 finally {
5395 closeSession(session);
5396 }
5397 }
5398
5399 return list;
5400 }
5401
5402
5412 @Override
5413 public UserNotificationEvent findByU_A_A_First(long userId,
5414 boolean actionRequired, boolean archived,
5415 OrderByComparator<UserNotificationEvent> orderByComparator)
5416 throws NoSuchUserNotificationEventException {
5417 UserNotificationEvent userNotificationEvent = fetchByU_A_A_First(userId,
5418 actionRequired, archived, orderByComparator);
5419
5420 if (userNotificationEvent != null) {
5421 return userNotificationEvent;
5422 }
5423
5424 StringBundler msg = new StringBundler(8);
5425
5426 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5427
5428 msg.append("userId=");
5429 msg.append(userId);
5430
5431 msg.append(", actionRequired=");
5432 msg.append(actionRequired);
5433
5434 msg.append(", archived=");
5435 msg.append(archived);
5436
5437 msg.append(StringPool.CLOSE_CURLY_BRACE);
5438
5439 throw new NoSuchUserNotificationEventException(msg.toString());
5440 }
5441
5442
5451 @Override
5452 public UserNotificationEvent fetchByU_A_A_First(long userId,
5453 boolean actionRequired, boolean archived,
5454 OrderByComparator<UserNotificationEvent> orderByComparator) {
5455 List<UserNotificationEvent> list = findByU_A_A(userId, actionRequired,
5456 archived, 0, 1, orderByComparator);
5457
5458 if (!list.isEmpty()) {
5459 return list.get(0);
5460 }
5461
5462 return null;
5463 }
5464
5465
5475 @Override
5476 public UserNotificationEvent findByU_A_A_Last(long userId,
5477 boolean actionRequired, boolean archived,
5478 OrderByComparator<UserNotificationEvent> orderByComparator)
5479 throws NoSuchUserNotificationEventException {
5480 UserNotificationEvent userNotificationEvent = fetchByU_A_A_Last(userId,
5481 actionRequired, archived, orderByComparator);
5482
5483 if (userNotificationEvent != null) {
5484 return userNotificationEvent;
5485 }
5486
5487 StringBundler msg = new StringBundler(8);
5488
5489 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5490
5491 msg.append("userId=");
5492 msg.append(userId);
5493
5494 msg.append(", actionRequired=");
5495 msg.append(actionRequired);
5496
5497 msg.append(", archived=");
5498 msg.append(archived);
5499
5500 msg.append(StringPool.CLOSE_CURLY_BRACE);
5501
5502 throw new NoSuchUserNotificationEventException(msg.toString());
5503 }
5504
5505
5514 @Override
5515 public UserNotificationEvent fetchByU_A_A_Last(long userId,
5516 boolean actionRequired, boolean archived,
5517 OrderByComparator<UserNotificationEvent> orderByComparator) {
5518 int count = countByU_A_A(userId, actionRequired, archived);
5519
5520 if (count == 0) {
5521 return null;
5522 }
5523
5524 List<UserNotificationEvent> list = findByU_A_A(userId, actionRequired,
5525 archived, count - 1, count, orderByComparator);
5526
5527 if (!list.isEmpty()) {
5528 return list.get(0);
5529 }
5530
5531 return null;
5532 }
5533
5534
5545 @Override
5546 public UserNotificationEvent[] findByU_A_A_PrevAndNext(
5547 long userNotificationEventId, long userId, boolean actionRequired,
5548 boolean archived,
5549 OrderByComparator<UserNotificationEvent> orderByComparator)
5550 throws NoSuchUserNotificationEventException {
5551 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
5552
5553 Session session = null;
5554
5555 try {
5556 session = openSession();
5557
5558 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
5559
5560 array[0] = getByU_A_A_PrevAndNext(session, userNotificationEvent,
5561 userId, actionRequired, archived, orderByComparator, true);
5562
5563 array[1] = userNotificationEvent;
5564
5565 array[2] = getByU_A_A_PrevAndNext(session, userNotificationEvent,
5566 userId, actionRequired, archived, orderByComparator, false);
5567
5568 return array;
5569 }
5570 catch (Exception e) {
5571 throw processException(e);
5572 }
5573 finally {
5574 closeSession(session);
5575 }
5576 }
5577
5578 protected UserNotificationEvent getByU_A_A_PrevAndNext(Session session,
5579 UserNotificationEvent userNotificationEvent, long userId,
5580 boolean actionRequired, boolean archived,
5581 OrderByComparator<UserNotificationEvent> orderByComparator,
5582 boolean previous) {
5583 StringBundler query = null;
5584
5585 if (orderByComparator != null) {
5586 query = new StringBundler(6 +
5587 (orderByComparator.getOrderByFields().length * 6));
5588 }
5589 else {
5590 query = new StringBundler(3);
5591 }
5592
5593 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5594
5595 query.append(_FINDER_COLUMN_U_A_A_USERID_2);
5596
5597 query.append(_FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2);
5598
5599 query.append(_FINDER_COLUMN_U_A_A_ARCHIVED_2);
5600
5601 if (orderByComparator != null) {
5602 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5603
5604 if (orderByConditionFields.length > 0) {
5605 query.append(WHERE_AND);
5606 }
5607
5608 for (int i = 0; i < orderByConditionFields.length; i++) {
5609 query.append(_ORDER_BY_ENTITY_ALIAS);
5610 query.append(orderByConditionFields[i]);
5611
5612 if ((i + 1) < orderByConditionFields.length) {
5613 if (orderByComparator.isAscending() ^ previous) {
5614 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5615 }
5616 else {
5617 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5618 }
5619 }
5620 else {
5621 if (orderByComparator.isAscending() ^ previous) {
5622 query.append(WHERE_GREATER_THAN);
5623 }
5624 else {
5625 query.append(WHERE_LESSER_THAN);
5626 }
5627 }
5628 }
5629
5630 query.append(ORDER_BY_CLAUSE);
5631
5632 String[] orderByFields = orderByComparator.getOrderByFields();
5633
5634 for (int i = 0; i < orderByFields.length; i++) {
5635 query.append(_ORDER_BY_ENTITY_ALIAS);
5636 query.append(orderByFields[i]);
5637
5638 if ((i + 1) < orderByFields.length) {
5639 if (orderByComparator.isAscending() ^ previous) {
5640 query.append(ORDER_BY_ASC_HAS_NEXT);
5641 }
5642 else {
5643 query.append(ORDER_BY_DESC_HAS_NEXT);
5644 }
5645 }
5646 else {
5647 if (orderByComparator.isAscending() ^ previous) {
5648 query.append(ORDER_BY_ASC);
5649 }
5650 else {
5651 query.append(ORDER_BY_DESC);
5652 }
5653 }
5654 }
5655 }
5656 else {
5657 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5658 }
5659
5660 String sql = query.toString();
5661
5662 Query q = session.createQuery(sql);
5663
5664 q.setFirstResult(0);
5665 q.setMaxResults(2);
5666
5667 QueryPos qPos = QueryPos.getInstance(q);
5668
5669 qPos.add(userId);
5670
5671 qPos.add(actionRequired);
5672
5673 qPos.add(archived);
5674
5675 if (orderByComparator != null) {
5676 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
5677
5678 for (Object value : values) {
5679 qPos.add(value);
5680 }
5681 }
5682
5683 List<UserNotificationEvent> list = q.list();
5684
5685 if (list.size() == 2) {
5686 return list.get(1);
5687 }
5688 else {
5689 return null;
5690 }
5691 }
5692
5693
5700 @Override
5701 public void removeByU_A_A(long userId, boolean actionRequired,
5702 boolean archived) {
5703 for (UserNotificationEvent userNotificationEvent : findByU_A_A(userId,
5704 actionRequired, archived, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
5705 null)) {
5706 remove(userNotificationEvent);
5707 }
5708 }
5709
5710
5718 @Override
5719 public int countByU_A_A(long userId, boolean actionRequired,
5720 boolean archived) {
5721 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_A_A;
5722
5723 Object[] finderArgs = new Object[] { userId, actionRequired, archived };
5724
5725 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5726
5727 if (count == null) {
5728 StringBundler query = new StringBundler(4);
5729
5730 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
5731
5732 query.append(_FINDER_COLUMN_U_A_A_USERID_2);
5733
5734 query.append(_FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2);
5735
5736 query.append(_FINDER_COLUMN_U_A_A_ARCHIVED_2);
5737
5738 String sql = query.toString();
5739
5740 Session session = null;
5741
5742 try {
5743 session = openSession();
5744
5745 Query q = session.createQuery(sql);
5746
5747 QueryPos qPos = QueryPos.getInstance(q);
5748
5749 qPos.add(userId);
5750
5751 qPos.add(actionRequired);
5752
5753 qPos.add(archived);
5754
5755 count = (Long)q.uniqueResult();
5756
5757 finderCache.putResult(finderPath, finderArgs, count);
5758 }
5759 catch (Exception e) {
5760 finderCache.removeResult(finderPath, finderArgs);
5761
5762 throw processException(e);
5763 }
5764 finally {
5765 closeSession(session);
5766 }
5767 }
5768
5769 return count.intValue();
5770 }
5771
5772 private static final String _FINDER_COLUMN_U_A_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
5773 private static final String _FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ? AND ";
5774 private static final String _FINDER_COLUMN_U_A_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
5775 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5776 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5777 UserNotificationEventImpl.class,
5778 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_D_A",
5779 new String[] {
5780 Long.class.getName(), Integer.class.getName(),
5781 Boolean.class.getName(), Boolean.class.getName(),
5782
5783 Integer.class.getName(), Integer.class.getName(),
5784 OrderByComparator.class.getName()
5785 });
5786 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A =
5787 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5788 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5789 UserNotificationEventImpl.class,
5790 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_D_A",
5791 new String[] {
5792 Long.class.getName(), Integer.class.getName(),
5793 Boolean.class.getName(), Boolean.class.getName()
5794 },
5795 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
5796 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
5797 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
5798 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
5799 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
5800 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5801 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
5802 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_D_A",
5803 new String[] {
5804 Long.class.getName(), Integer.class.getName(),
5805 Boolean.class.getName(), Boolean.class.getName()
5806 });
5807
5808
5817 @Override
5818 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
5819 int deliveryType, boolean delivered, boolean actionRequired) {
5820 return findByU_DT_D_A(userId, deliveryType, delivered, actionRequired,
5821 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5822 }
5823
5824
5839 @Override
5840 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
5841 int deliveryType, boolean delivered, boolean actionRequired, int start,
5842 int end) {
5843 return findByU_DT_D_A(userId, deliveryType, delivered, actionRequired,
5844 start, end, null);
5845 }
5846
5847
5863 @Override
5864 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
5865 int deliveryType, boolean delivered, boolean actionRequired, int start,
5866 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
5867 return findByU_DT_D_A(userId, deliveryType, delivered, actionRequired,
5868 start, end, orderByComparator, true);
5869 }
5870
5871
5888 @Override
5889 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
5890 int deliveryType, boolean delivered, boolean actionRequired, int start,
5891 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
5892 boolean retrieveFromCache) {
5893 boolean pagination = true;
5894 FinderPath finderPath = null;
5895 Object[] finderArgs = null;
5896
5897 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5898 (orderByComparator == null)) {
5899 pagination = false;
5900 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A;
5901 finderArgs = new Object[] {
5902 userId, deliveryType, delivered, actionRequired
5903 };
5904 }
5905 else {
5906 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D_A;
5907 finderArgs = new Object[] {
5908 userId, deliveryType, delivered, actionRequired,
5909
5910 start, end, orderByComparator
5911 };
5912 }
5913
5914 List<UserNotificationEvent> list = null;
5915
5916 if (retrieveFromCache) {
5917 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
5918 finderArgs, this);
5919
5920 if ((list != null) && !list.isEmpty()) {
5921 for (UserNotificationEvent userNotificationEvent : list) {
5922 if ((userId != userNotificationEvent.getUserId()) ||
5923 (deliveryType != userNotificationEvent.getDeliveryType()) ||
5924 (delivered != userNotificationEvent.getDelivered()) ||
5925 (actionRequired != userNotificationEvent.getActionRequired())) {
5926 list = null;
5927
5928 break;
5929 }
5930 }
5931 }
5932 }
5933
5934 if (list == null) {
5935 StringBundler query = null;
5936
5937 if (orderByComparator != null) {
5938 query = new StringBundler(6 +
5939 (orderByComparator.getOrderByFields().length * 3));
5940 }
5941 else {
5942 query = new StringBundler(6);
5943 }
5944
5945 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5946
5947 query.append(_FINDER_COLUMN_U_DT_D_A_USERID_2);
5948
5949 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2);
5950
5951 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERED_2);
5952
5953 query.append(_FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2);
5954
5955 if (orderByComparator != null) {
5956 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5957 orderByComparator);
5958 }
5959 else
5960 if (pagination) {
5961 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5962 }
5963
5964 String sql = query.toString();
5965
5966 Session session = null;
5967
5968 try {
5969 session = openSession();
5970
5971 Query q = session.createQuery(sql);
5972
5973 QueryPos qPos = QueryPos.getInstance(q);
5974
5975 qPos.add(userId);
5976
5977 qPos.add(deliveryType);
5978
5979 qPos.add(delivered);
5980
5981 qPos.add(actionRequired);
5982
5983 if (!pagination) {
5984 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5985 getDialect(), start, end, false);
5986
5987 Collections.sort(list);
5988
5989 list = Collections.unmodifiableList(list);
5990 }
5991 else {
5992 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5993 getDialect(), start, end);
5994 }
5995
5996 cacheResult(list);
5997
5998 finderCache.putResult(finderPath, finderArgs, list);
5999 }
6000 catch (Exception e) {
6001 finderCache.removeResult(finderPath, finderArgs);
6002
6003 throw processException(e);
6004 }
6005 finally {
6006 closeSession(session);
6007 }
6008 }
6009
6010 return list;
6011 }
6012
6013
6024 @Override
6025 public UserNotificationEvent findByU_DT_D_A_First(long userId,
6026 int deliveryType, boolean delivered, boolean actionRequired,
6027 OrderByComparator<UserNotificationEvent> orderByComparator)
6028 throws NoSuchUserNotificationEventException {
6029 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_A_First(userId,
6030 deliveryType, delivered, actionRequired, orderByComparator);
6031
6032 if (userNotificationEvent != null) {
6033 return userNotificationEvent;
6034 }
6035
6036 StringBundler msg = new StringBundler(10);
6037
6038 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6039
6040 msg.append("userId=");
6041 msg.append(userId);
6042
6043 msg.append(", deliveryType=");
6044 msg.append(deliveryType);
6045
6046 msg.append(", delivered=");
6047 msg.append(delivered);
6048
6049 msg.append(", actionRequired=");
6050 msg.append(actionRequired);
6051
6052 msg.append(StringPool.CLOSE_CURLY_BRACE);
6053
6054 throw new NoSuchUserNotificationEventException(msg.toString());
6055 }
6056
6057
6067 @Override
6068 public UserNotificationEvent fetchByU_DT_D_A_First(long userId,
6069 int deliveryType, boolean delivered, boolean actionRequired,
6070 OrderByComparator<UserNotificationEvent> orderByComparator) {
6071 List<UserNotificationEvent> list = findByU_DT_D_A(userId, deliveryType,
6072 delivered, actionRequired, 0, 1, orderByComparator);
6073
6074 if (!list.isEmpty()) {
6075 return list.get(0);
6076 }
6077
6078 return null;
6079 }
6080
6081
6092 @Override
6093 public UserNotificationEvent findByU_DT_D_A_Last(long userId,
6094 int deliveryType, boolean delivered, boolean actionRequired,
6095 OrderByComparator<UserNotificationEvent> orderByComparator)
6096 throws NoSuchUserNotificationEventException {
6097 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_A_Last(userId,
6098 deliveryType, delivered, actionRequired, orderByComparator);
6099
6100 if (userNotificationEvent != null) {
6101 return userNotificationEvent;
6102 }
6103
6104 StringBundler msg = new StringBundler(10);
6105
6106 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6107
6108 msg.append("userId=");
6109 msg.append(userId);
6110
6111 msg.append(", deliveryType=");
6112 msg.append(deliveryType);
6113
6114 msg.append(", delivered=");
6115 msg.append(delivered);
6116
6117 msg.append(", actionRequired=");
6118 msg.append(actionRequired);
6119
6120 msg.append(StringPool.CLOSE_CURLY_BRACE);
6121
6122 throw new NoSuchUserNotificationEventException(msg.toString());
6123 }
6124
6125
6135 @Override
6136 public UserNotificationEvent fetchByU_DT_D_A_Last(long userId,
6137 int deliveryType, boolean delivered, boolean actionRequired,
6138 OrderByComparator<UserNotificationEvent> orderByComparator) {
6139 int count = countByU_DT_D_A(userId, deliveryType, delivered,
6140 actionRequired);
6141
6142 if (count == 0) {
6143 return null;
6144 }
6145
6146 List<UserNotificationEvent> list = findByU_DT_D_A(userId, deliveryType,
6147 delivered, actionRequired, count - 1, count, orderByComparator);
6148
6149 if (!list.isEmpty()) {
6150 return list.get(0);
6151 }
6152
6153 return null;
6154 }
6155
6156
6168 @Override
6169 public UserNotificationEvent[] findByU_DT_D_A_PrevAndNext(
6170 long userNotificationEventId, long userId, int deliveryType,
6171 boolean delivered, boolean actionRequired,
6172 OrderByComparator<UserNotificationEvent> orderByComparator)
6173 throws NoSuchUserNotificationEventException {
6174 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
6175
6176 Session session = null;
6177
6178 try {
6179 session = openSession();
6180
6181 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
6182
6183 array[0] = getByU_DT_D_A_PrevAndNext(session,
6184 userNotificationEvent, userId, deliveryType, delivered,
6185 actionRequired, orderByComparator, true);
6186
6187 array[1] = userNotificationEvent;
6188
6189 array[2] = getByU_DT_D_A_PrevAndNext(session,
6190 userNotificationEvent, userId, deliveryType, delivered,
6191 actionRequired, orderByComparator, false);
6192
6193 return array;
6194 }
6195 catch (Exception e) {
6196 throw processException(e);
6197 }
6198 finally {
6199 closeSession(session);
6200 }
6201 }
6202
6203 protected UserNotificationEvent getByU_DT_D_A_PrevAndNext(Session session,
6204 UserNotificationEvent userNotificationEvent, long userId,
6205 int deliveryType, boolean delivered, boolean actionRequired,
6206 OrderByComparator<UserNotificationEvent> orderByComparator,
6207 boolean previous) {
6208 StringBundler query = null;
6209
6210 if (orderByComparator != null) {
6211 query = new StringBundler(6 +
6212 (orderByComparator.getOrderByFields().length * 6));
6213 }
6214 else {
6215 query = new StringBundler(3);
6216 }
6217
6218 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
6219
6220 query.append(_FINDER_COLUMN_U_DT_D_A_USERID_2);
6221
6222 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2);
6223
6224 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERED_2);
6225
6226 query.append(_FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2);
6227
6228 if (orderByComparator != null) {
6229 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6230
6231 if (orderByConditionFields.length > 0) {
6232 query.append(WHERE_AND);
6233 }
6234
6235 for (int i = 0; i < orderByConditionFields.length; i++) {
6236 query.append(_ORDER_BY_ENTITY_ALIAS);
6237 query.append(orderByConditionFields[i]);
6238
6239 if ((i + 1) < orderByConditionFields.length) {
6240 if (orderByComparator.isAscending() ^ previous) {
6241 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6242 }
6243 else {
6244 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6245 }
6246 }
6247 else {
6248 if (orderByComparator.isAscending() ^ previous) {
6249 query.append(WHERE_GREATER_THAN);
6250 }
6251 else {
6252 query.append(WHERE_LESSER_THAN);
6253 }
6254 }
6255 }
6256
6257 query.append(ORDER_BY_CLAUSE);
6258
6259 String[] orderByFields = orderByComparator.getOrderByFields();
6260
6261 for (int i = 0; i < orderByFields.length; i++) {
6262 query.append(_ORDER_BY_ENTITY_ALIAS);
6263 query.append(orderByFields[i]);
6264
6265 if ((i + 1) < orderByFields.length) {
6266 if (orderByComparator.isAscending() ^ previous) {
6267 query.append(ORDER_BY_ASC_HAS_NEXT);
6268 }
6269 else {
6270 query.append(ORDER_BY_DESC_HAS_NEXT);
6271 }
6272 }
6273 else {
6274 if (orderByComparator.isAscending() ^ previous) {
6275 query.append(ORDER_BY_ASC);
6276 }
6277 else {
6278 query.append(ORDER_BY_DESC);
6279 }
6280 }
6281 }
6282 }
6283 else {
6284 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
6285 }
6286
6287 String sql = query.toString();
6288
6289 Query q = session.createQuery(sql);
6290
6291 q.setFirstResult(0);
6292 q.setMaxResults(2);
6293
6294 QueryPos qPos = QueryPos.getInstance(q);
6295
6296 qPos.add(userId);
6297
6298 qPos.add(deliveryType);
6299
6300 qPos.add(delivered);
6301
6302 qPos.add(actionRequired);
6303
6304 if (orderByComparator != null) {
6305 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
6306
6307 for (Object value : values) {
6308 qPos.add(value);
6309 }
6310 }
6311
6312 List<UserNotificationEvent> list = q.list();
6313
6314 if (list.size() == 2) {
6315 return list.get(1);
6316 }
6317 else {
6318 return null;
6319 }
6320 }
6321
6322
6330 @Override
6331 public void removeByU_DT_D_A(long userId, int deliveryType,
6332 boolean delivered, boolean actionRequired) {
6333 for (UserNotificationEvent userNotificationEvent : findByU_DT_D_A(
6334 userId, deliveryType, delivered, actionRequired,
6335 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6336 remove(userNotificationEvent);
6337 }
6338 }
6339
6340
6349 @Override
6350 public int countByU_DT_D_A(long userId, int deliveryType,
6351 boolean delivered, boolean actionRequired) {
6352 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_D_A;
6353
6354 Object[] finderArgs = new Object[] {
6355 userId, deliveryType, delivered, actionRequired
6356 };
6357
6358 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6359
6360 if (count == null) {
6361 StringBundler query = new StringBundler(5);
6362
6363 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
6364
6365 query.append(_FINDER_COLUMN_U_DT_D_A_USERID_2);
6366
6367 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2);
6368
6369 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERED_2);
6370
6371 query.append(_FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2);
6372
6373 String sql = query.toString();
6374
6375 Session session = null;
6376
6377 try {
6378 session = openSession();
6379
6380 Query q = session.createQuery(sql);
6381
6382 QueryPos qPos = QueryPos.getInstance(q);
6383
6384 qPos.add(userId);
6385
6386 qPos.add(deliveryType);
6387
6388 qPos.add(delivered);
6389
6390 qPos.add(actionRequired);
6391
6392 count = (Long)q.uniqueResult();
6393
6394 finderCache.putResult(finderPath, finderArgs, count);
6395 }
6396 catch (Exception e) {
6397 finderCache.removeResult(finderPath, finderArgs);
6398
6399 throw processException(e);
6400 }
6401 finally {
6402 closeSession(session);
6403 }
6404 }
6405
6406 return count.intValue();
6407 }
6408
6409 private static final String _FINDER_COLUMN_U_DT_D_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
6410 private static final String _FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
6411 private static final String _FINDER_COLUMN_U_DT_D_A_DELIVERED_2 = "userNotificationEvent.delivered = ? AND ";
6412 private static final String _FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ?";
6413 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6414 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
6415 UserNotificationEventImpl.class,
6416 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_A_A",
6417 new String[] {
6418 Long.class.getName(), Integer.class.getName(),
6419 Boolean.class.getName(), Boolean.class.getName(),
6420
6421 Integer.class.getName(), Integer.class.getName(),
6422 OrderByComparator.class.getName()
6423 });
6424 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A =
6425 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6426 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
6427 UserNotificationEventImpl.class,
6428 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_A_A",
6429 new String[] {
6430 Long.class.getName(), Integer.class.getName(),
6431 Boolean.class.getName(), Boolean.class.getName()
6432 },
6433 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
6434 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
6435 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
6436 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
6437 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
6438 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6439 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
6440 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_A_A",
6441 new String[] {
6442 Long.class.getName(), Integer.class.getName(),
6443 Boolean.class.getName(), Boolean.class.getName()
6444 });
6445
6446
6455 @Override
6456 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
6457 int deliveryType, boolean actionRequired, boolean archived) {
6458 return findByU_DT_A_A(userId, deliveryType, actionRequired, archived,
6459 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6460 }
6461
6462
6477 @Override
6478 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
6479 int deliveryType, boolean actionRequired, boolean archived, int start,
6480 int end) {
6481 return findByU_DT_A_A(userId, deliveryType, actionRequired, archived,
6482 start, end, null);
6483 }
6484
6485
6501 @Override
6502 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
6503 int deliveryType, boolean actionRequired, boolean archived, int start,
6504 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
6505 return findByU_DT_A_A(userId, deliveryType, actionRequired, archived,
6506 start, end, orderByComparator, true);
6507 }
6508
6509
6526 @Override
6527 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
6528 int deliveryType, boolean actionRequired, boolean archived, int start,
6529 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
6530 boolean retrieveFromCache) {
6531 boolean pagination = true;
6532 FinderPath finderPath = null;
6533 Object[] finderArgs = null;
6534
6535 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6536 (orderByComparator == null)) {
6537 pagination = false;
6538 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A;
6539 finderArgs = new Object[] {
6540 userId, deliveryType, actionRequired, archived
6541 };
6542 }
6543 else {
6544 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A_A;
6545 finderArgs = new Object[] {
6546 userId, deliveryType, actionRequired, archived,
6547
6548 start, end, orderByComparator
6549 };
6550 }
6551
6552 List<UserNotificationEvent> list = null;
6553
6554 if (retrieveFromCache) {
6555 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
6556 finderArgs, this);
6557
6558 if ((list != null) && !list.isEmpty()) {
6559 for (UserNotificationEvent userNotificationEvent : list) {
6560 if ((userId != userNotificationEvent.getUserId()) ||
6561 (deliveryType != userNotificationEvent.getDeliveryType()) ||
6562 (actionRequired != userNotificationEvent.getActionRequired()) ||
6563 (archived != userNotificationEvent.getArchived())) {
6564 list = null;
6565
6566 break;
6567 }
6568 }
6569 }
6570 }
6571
6572 if (list == null) {
6573 StringBundler query = null;
6574
6575 if (orderByComparator != null) {
6576 query = new StringBundler(6 +
6577 (orderByComparator.getOrderByFields().length * 3));
6578 }
6579 else {
6580 query = new StringBundler(6);
6581 }
6582
6583 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
6584
6585 query.append(_FINDER_COLUMN_U_DT_A_A_USERID_2);
6586
6587 query.append(_FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2);
6588
6589 query.append(_FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2);
6590
6591 query.append(_FINDER_COLUMN_U_DT_A_A_ARCHIVED_2);
6592
6593 if (orderByComparator != null) {
6594 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6595 orderByComparator);
6596 }
6597 else
6598 if (pagination) {
6599 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
6600 }
6601
6602 String sql = query.toString();
6603
6604 Session session = null;
6605
6606 try {
6607 session = openSession();
6608
6609 Query q = session.createQuery(sql);
6610
6611 QueryPos qPos = QueryPos.getInstance(q);
6612
6613 qPos.add(userId);
6614
6615 qPos.add(deliveryType);
6616
6617 qPos.add(actionRequired);
6618
6619 qPos.add(archived);
6620
6621 if (!pagination) {
6622 list = (List<UserNotificationEvent>)QueryUtil.list(q,
6623 getDialect(), start, end, false);
6624
6625 Collections.sort(list);
6626
6627 list = Collections.unmodifiableList(list);
6628 }
6629 else {
6630 list = (List<UserNotificationEvent>)QueryUtil.list(q,
6631 getDialect(), start, end);
6632 }
6633
6634 cacheResult(list);
6635
6636 finderCache.putResult(finderPath, finderArgs, list);
6637 }
6638 catch (Exception e) {
6639 finderCache.removeResult(finderPath, finderArgs);
6640
6641 throw processException(e);
6642 }
6643 finally {
6644 closeSession(session);
6645 }
6646 }
6647
6648 return list;
6649 }
6650
6651
6662 @Override
6663 public UserNotificationEvent findByU_DT_A_A_First(long userId,
6664 int deliveryType, boolean actionRequired, boolean archived,
6665 OrderByComparator<UserNotificationEvent> orderByComparator)
6666 throws NoSuchUserNotificationEventException {
6667 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_A_First(userId,
6668 deliveryType, actionRequired, archived, orderByComparator);
6669
6670 if (userNotificationEvent != null) {
6671 return userNotificationEvent;
6672 }
6673
6674 StringBundler msg = new StringBundler(10);
6675
6676 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6677
6678 msg.append("userId=");
6679 msg.append(userId);
6680
6681 msg.append(", deliveryType=");
6682 msg.append(deliveryType);
6683
6684 msg.append(", actionRequired=");
6685 msg.append(actionRequired);
6686
6687 msg.append(", archived=");
6688 msg.append(archived);
6689
6690 msg.append(StringPool.CLOSE_CURLY_BRACE);
6691
6692 throw new NoSuchUserNotificationEventException(msg.toString());
6693 }
6694
6695
6705 @Override
6706 public UserNotificationEvent fetchByU_DT_A_A_First(long userId,
6707 int deliveryType, boolean actionRequired, boolean archived,
6708 OrderByComparator<UserNotificationEvent> orderByComparator) {
6709 List<UserNotificationEvent> list = findByU_DT_A_A(userId, deliveryType,
6710 actionRequired, archived, 0, 1, orderByComparator);
6711
6712 if (!list.isEmpty()) {
6713 return list.get(0);
6714 }
6715
6716 return null;
6717 }
6718
6719
6730 @Override
6731 public UserNotificationEvent findByU_DT_A_A_Last(long userId,
6732 int deliveryType, boolean actionRequired, boolean archived,
6733 OrderByComparator<UserNotificationEvent> orderByComparator)
6734 throws NoSuchUserNotificationEventException {
6735 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_A_Last(userId,
6736 deliveryType, actionRequired, archived, orderByComparator);
6737
6738 if (userNotificationEvent != null) {
6739 return userNotificationEvent;
6740 }
6741
6742 StringBundler msg = new StringBundler(10);
6743
6744 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6745
6746 msg.append("userId=");
6747 msg.append(userId);
6748
6749 msg.append(", deliveryType=");
6750 msg.append(deliveryType);
6751
6752 msg.append(", actionRequired=");
6753 msg.append(actionRequired);
6754
6755 msg.append(", archived=");
6756 msg.append(archived);
6757
6758 msg.append(StringPool.CLOSE_CURLY_BRACE);
6759
6760 throw new NoSuchUserNotificationEventException(msg.toString());
6761 }
6762
6763
6773 @Override
6774 public UserNotificationEvent fetchByU_DT_A_A_Last(long userId,
6775 int deliveryType, boolean actionRequired, boolean archived,
6776 OrderByComparator<UserNotificationEvent> orderByComparator) {
6777 int count = countByU_DT_A_A(userId, deliveryType, actionRequired,
6778 archived);
6779
6780 if (count == 0) {
6781 return null;
6782 }
6783
6784 List<UserNotificationEvent> list = findByU_DT_A_A(userId, deliveryType,
6785 actionRequired, archived, count - 1, count, orderByComparator);
6786
6787 if (!list.isEmpty()) {
6788 return list.get(0);
6789 }
6790
6791 return null;
6792 }
6793
6794
6806 @Override
6807 public UserNotificationEvent[] findByU_DT_A_A_PrevAndNext(
6808 long userNotificationEventId, long userId, int deliveryType,
6809 boolean actionRequired, boolean archived,
6810 OrderByComparator<UserNotificationEvent> orderByComparator)
6811 throws NoSuchUserNotificationEventException {
6812 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
6813
6814 Session session = null;
6815
6816 try {
6817 session = openSession();
6818
6819 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
6820
6821 array[0] = getByU_DT_A_A_PrevAndNext(session,
6822 userNotificationEvent, userId, deliveryType,
6823 actionRequired, archived, orderByComparator, true);
6824
6825 array[1] = userNotificationEvent;
6826
6827 array[2] = getByU_DT_A_A_PrevAndNext(session,
6828 userNotificationEvent, userId, deliveryType,
6829 actionRequired, archived, orderByComparator, false);
6830
6831 return array;
6832 }
6833 catch (Exception e) {
6834 throw processException(e);
6835 }
6836 finally {
6837 closeSession(session);
6838 }
6839 }
6840
6841 protected UserNotificationEvent getByU_DT_A_A_PrevAndNext(Session session,
6842 UserNotificationEvent userNotificationEvent, long userId,
6843 int deliveryType, boolean actionRequired, boolean archived,
6844 OrderByComparator<UserNotificationEvent> orderByComparator,
6845 boolean previous) {
6846 StringBundler query = null;
6847
6848 if (orderByComparator != null) {
6849 query = new StringBundler(6 +
6850 (orderByComparator.getOrderByFields().length * 6));
6851 }
6852 else {
6853 query = new StringBundler(3);
6854 }
6855
6856 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
6857
6858 query.append(_FINDER_COLUMN_U_DT_A_A_USERID_2);
6859
6860 query.append(_FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2);
6861
6862 query.append(_FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2);
6863
6864 query.append(_FINDER_COLUMN_U_DT_A_A_ARCHIVED_2);
6865
6866 if (orderByComparator != null) {
6867 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6868
6869 if (orderByConditionFields.length > 0) {
6870 query.append(WHERE_AND);
6871 }
6872
6873 for (int i = 0; i < orderByConditionFields.length; i++) {
6874 query.append(_ORDER_BY_ENTITY_ALIAS);
6875 query.append(orderByConditionFields[i]);
6876
6877 if ((i + 1) < orderByConditionFields.length) {
6878 if (orderByComparator.isAscending() ^ previous) {
6879 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6880 }
6881 else {
6882 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6883 }
6884 }
6885 else {
6886 if (orderByComparator.isAscending() ^ previous) {
6887 query.append(WHERE_GREATER_THAN);
6888 }
6889 else {
6890 query.append(WHERE_LESSER_THAN);
6891 }
6892 }
6893 }
6894
6895 query.append(ORDER_BY_CLAUSE);
6896
6897 String[] orderByFields = orderByComparator.getOrderByFields();
6898
6899 for (int i = 0; i < orderByFields.length; i++) {
6900 query.append(_ORDER_BY_ENTITY_ALIAS);
6901 query.append(orderByFields[i]);
6902
6903 if ((i + 1) < orderByFields.length) {
6904 if (orderByComparator.isAscending() ^ previous) {
6905 query.append(ORDER_BY_ASC_HAS_NEXT);
6906 }
6907 else {
6908 query.append(ORDER_BY_DESC_HAS_NEXT);
6909 }
6910 }
6911 else {
6912 if (orderByComparator.isAscending() ^ previous) {
6913 query.append(ORDER_BY_ASC);
6914 }
6915 else {
6916 query.append(ORDER_BY_DESC);
6917 }
6918 }
6919 }
6920 }
6921 else {
6922 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
6923 }
6924
6925 String sql = query.toString();
6926
6927 Query q = session.createQuery(sql);
6928
6929 q.setFirstResult(0);
6930 q.setMaxResults(2);
6931
6932 QueryPos qPos = QueryPos.getInstance(q);
6933
6934 qPos.add(userId);
6935
6936 qPos.add(deliveryType);
6937
6938 qPos.add(actionRequired);
6939
6940 qPos.add(archived);
6941
6942 if (orderByComparator != null) {
6943 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
6944
6945 for (Object value : values) {
6946 qPos.add(value);
6947 }
6948 }
6949
6950 List<UserNotificationEvent> list = q.list();
6951
6952 if (list.size() == 2) {
6953 return list.get(1);
6954 }
6955 else {
6956 return null;
6957 }
6958 }
6959
6960
6968 @Override
6969 public void removeByU_DT_A_A(long userId, int deliveryType,
6970 boolean actionRequired, boolean archived) {
6971 for (UserNotificationEvent userNotificationEvent : findByU_DT_A_A(
6972 userId, deliveryType, actionRequired, archived,
6973 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6974 remove(userNotificationEvent);
6975 }
6976 }
6977
6978
6987 @Override
6988 public int countByU_DT_A_A(long userId, int deliveryType,
6989 boolean actionRequired, boolean archived) {
6990 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_A_A;
6991
6992 Object[] finderArgs = new Object[] {
6993 userId, deliveryType, actionRequired, archived
6994 };
6995
6996 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6997
6998 if (count == null) {
6999 StringBundler query = new StringBundler(5);
7000
7001 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
7002
7003 query.append(_FINDER_COLUMN_U_DT_A_A_USERID_2);
7004
7005 query.append(_FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2);
7006
7007 query.append(_FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2);
7008
7009 query.append(_FINDER_COLUMN_U_DT_A_A_ARCHIVED_2);
7010
7011 String sql = query.toString();
7012
7013 Session session = null;
7014
7015 try {
7016 session = openSession();
7017
7018 Query q = session.createQuery(sql);
7019
7020 QueryPos qPos = QueryPos.getInstance(q);
7021
7022 qPos.add(userId);
7023
7024 qPos.add(deliveryType);
7025
7026 qPos.add(actionRequired);
7027
7028 qPos.add(archived);
7029
7030 count = (Long)q.uniqueResult();
7031
7032 finderCache.putResult(finderPath, finderArgs, count);
7033 }
7034 catch (Exception e) {
7035 finderCache.removeResult(finderPath, finderArgs);
7036
7037 throw processException(e);
7038 }
7039 finally {
7040 closeSession(session);
7041 }
7042 }
7043
7044 return count.intValue();
7045 }
7046
7047 private static final String _FINDER_COLUMN_U_DT_A_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
7048 private static final String _FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
7049 private static final String _FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ? AND ";
7050 private static final String _FINDER_COLUMN_U_DT_A_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
7051
7052 public UserNotificationEventPersistenceImpl() {
7053 setModelClass(UserNotificationEvent.class);
7054 }
7055
7056
7061 @Override
7062 public void cacheResult(UserNotificationEvent userNotificationEvent) {
7063 entityCache.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7064 UserNotificationEventImpl.class,
7065 userNotificationEvent.getPrimaryKey(), userNotificationEvent);
7066
7067 userNotificationEvent.resetOriginalValues();
7068 }
7069
7070
7075 @Override
7076 public void cacheResult(List<UserNotificationEvent> userNotificationEvents) {
7077 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
7078 if (entityCache.getResult(
7079 UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7080 UserNotificationEventImpl.class,
7081 userNotificationEvent.getPrimaryKey()) == null) {
7082 cacheResult(userNotificationEvent);
7083 }
7084 else {
7085 userNotificationEvent.resetOriginalValues();
7086 }
7087 }
7088 }
7089
7090
7097 @Override
7098 public void clearCache() {
7099 entityCache.clearCache(UserNotificationEventImpl.class);
7100
7101 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
7102 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
7103 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7104 }
7105
7106
7113 @Override
7114 public void clearCache(UserNotificationEvent userNotificationEvent) {
7115 entityCache.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7116 UserNotificationEventImpl.class,
7117 userNotificationEvent.getPrimaryKey());
7118
7119 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
7120 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7121 }
7122
7123 @Override
7124 public void clearCache(List<UserNotificationEvent> userNotificationEvents) {
7125 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
7126 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7127
7128 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
7129 entityCache.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7130 UserNotificationEventImpl.class,
7131 userNotificationEvent.getPrimaryKey());
7132 }
7133 }
7134
7135
7141 @Override
7142 public UserNotificationEvent create(long userNotificationEventId) {
7143 UserNotificationEvent userNotificationEvent = new UserNotificationEventImpl();
7144
7145 userNotificationEvent.setNew(true);
7146 userNotificationEvent.setPrimaryKey(userNotificationEventId);
7147
7148 String uuid = PortalUUIDUtil.generate();
7149
7150 userNotificationEvent.setUuid(uuid);
7151
7152 return userNotificationEvent;
7153 }
7154
7155
7162 @Override
7163 public UserNotificationEvent remove(long userNotificationEventId)
7164 throws NoSuchUserNotificationEventException {
7165 return remove((Serializable)userNotificationEventId);
7166 }
7167
7168
7175 @Override
7176 public UserNotificationEvent remove(Serializable primaryKey)
7177 throws NoSuchUserNotificationEventException {
7178 Session session = null;
7179
7180 try {
7181 session = openSession();
7182
7183 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
7184 primaryKey);
7185
7186 if (userNotificationEvent == null) {
7187 if (_log.isWarnEnabled()) {
7188 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
7189 }
7190
7191 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
7192 primaryKey);
7193 }
7194
7195 return remove(userNotificationEvent);
7196 }
7197 catch (NoSuchUserNotificationEventException nsee) {
7198 throw nsee;
7199 }
7200 catch (Exception e) {
7201 throw processException(e);
7202 }
7203 finally {
7204 closeSession(session);
7205 }
7206 }
7207
7208 @Override
7209 protected UserNotificationEvent removeImpl(
7210 UserNotificationEvent userNotificationEvent) {
7211 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
7212
7213 Session session = null;
7214
7215 try {
7216 session = openSession();
7217
7218 if (!session.contains(userNotificationEvent)) {
7219 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
7220 userNotificationEvent.getPrimaryKeyObj());
7221 }
7222
7223 if (userNotificationEvent != null) {
7224 session.delete(userNotificationEvent);
7225 }
7226 }
7227 catch (Exception e) {
7228 throw processException(e);
7229 }
7230 finally {
7231 closeSession(session);
7232 }
7233
7234 if (userNotificationEvent != null) {
7235 clearCache(userNotificationEvent);
7236 }
7237
7238 return userNotificationEvent;
7239 }
7240
7241 @Override
7242 public UserNotificationEvent updateImpl(
7243 UserNotificationEvent userNotificationEvent) {
7244 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
7245
7246 boolean isNew = userNotificationEvent.isNew();
7247
7248 UserNotificationEventModelImpl userNotificationEventModelImpl = (UserNotificationEventModelImpl)userNotificationEvent;
7249
7250 if (Validator.isNull(userNotificationEvent.getUuid())) {
7251 String uuid = PortalUUIDUtil.generate();
7252
7253 userNotificationEvent.setUuid(uuid);
7254 }
7255
7256 Session session = null;
7257
7258 try {
7259 session = openSession();
7260
7261 if (userNotificationEvent.isNew()) {
7262 session.save(userNotificationEvent);
7263
7264 userNotificationEvent.setNew(false);
7265 }
7266 else {
7267 userNotificationEvent = (UserNotificationEvent)session.merge(userNotificationEvent);
7268 }
7269 }
7270 catch (Exception e) {
7271 throw processException(e);
7272 }
7273 finally {
7274 closeSession(session);
7275 }
7276
7277 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
7278
7279 if (isNew || !UserNotificationEventModelImpl.COLUMN_BITMASK_ENABLED) {
7280 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7281 }
7282
7283 else {
7284 if ((userNotificationEventModelImpl.getColumnBitmask() &
7285 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
7286 Object[] args = new Object[] {
7287 userNotificationEventModelImpl.getOriginalUuid()
7288 };
7289
7290 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
7291 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
7292 args);
7293
7294 args = new Object[] { userNotificationEventModelImpl.getUuid() };
7295
7296 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
7297 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
7298 args);
7299 }
7300
7301 if ((userNotificationEventModelImpl.getColumnBitmask() &
7302 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
7303 Object[] args = new Object[] {
7304 userNotificationEventModelImpl.getOriginalUuid(),
7305 userNotificationEventModelImpl.getOriginalCompanyId()
7306 };
7307
7308 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
7309 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
7310 args);
7311
7312 args = new Object[] {
7313 userNotificationEventModelImpl.getUuid(),
7314 userNotificationEventModelImpl.getCompanyId()
7315 };
7316
7317 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
7318 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
7319 args);
7320 }
7321
7322 if ((userNotificationEventModelImpl.getColumnBitmask() &
7323 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
7324 Object[] args = new Object[] {
7325 userNotificationEventModelImpl.getOriginalUserId()
7326 };
7327
7328 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
7329 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
7330 args);
7331
7332 args = new Object[] { userNotificationEventModelImpl.getUserId() };
7333
7334 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
7335 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
7336 args);
7337 }
7338
7339 if ((userNotificationEventModelImpl.getColumnBitmask() &
7340 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT.getColumnBitmask()) != 0) {
7341 Object[] args = new Object[] {
7342 userNotificationEventModelImpl.getOriginalUserId(),
7343 userNotificationEventModelImpl.getOriginalDeliveryType()
7344 };
7345
7346 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT, args);
7347 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT,
7348 args);
7349
7350 args = new Object[] {
7351 userNotificationEventModelImpl.getUserId(),
7352 userNotificationEventModelImpl.getDeliveryType()
7353 };
7354
7355 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT, args);
7356 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT,
7357 args);
7358 }
7359
7360 if ((userNotificationEventModelImpl.getColumnBitmask() &
7361 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D.getColumnBitmask()) != 0) {
7362 Object[] args = new Object[] {
7363 userNotificationEventModelImpl.getOriginalUserId(),
7364 userNotificationEventModelImpl.getOriginalDelivered()
7365 };
7366
7367 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_D, args);
7368 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D,
7369 args);
7370
7371 args = new Object[] {
7372 userNotificationEventModelImpl.getUserId(),
7373 userNotificationEventModelImpl.getDelivered()
7374 };
7375
7376 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_D, args);
7377 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D,
7378 args);
7379 }
7380
7381 if ((userNotificationEventModelImpl.getColumnBitmask() &
7382 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A.getColumnBitmask()) != 0) {
7383 Object[] args = new Object[] {
7384 userNotificationEventModelImpl.getOriginalUserId(),
7385 userNotificationEventModelImpl.getOriginalArchived()
7386 };
7387
7388 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
7389 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
7390 args);
7391
7392 args = new Object[] {
7393 userNotificationEventModelImpl.getUserId(),
7394 userNotificationEventModelImpl.getArchived()
7395 };
7396
7397 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
7398 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
7399 args);
7400 }
7401
7402 if ((userNotificationEventModelImpl.getColumnBitmask() &
7403 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D.getColumnBitmask()) != 0) {
7404 Object[] args = new Object[] {
7405 userNotificationEventModelImpl.getOriginalUserId(),
7406 userNotificationEventModelImpl.getOriginalDeliveryType(),
7407 userNotificationEventModelImpl.getOriginalDelivered()
7408 };
7409
7410 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_D, args);
7411 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D,
7412 args);
7413
7414 args = new Object[] {
7415 userNotificationEventModelImpl.getUserId(),
7416 userNotificationEventModelImpl.getDeliveryType(),
7417 userNotificationEventModelImpl.getDelivered()
7418 };
7419
7420 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_D, args);
7421 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D,
7422 args);
7423 }
7424
7425 if ((userNotificationEventModelImpl.getColumnBitmask() &
7426 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A.getColumnBitmask()) != 0) {
7427 Object[] args = new Object[] {
7428 userNotificationEventModelImpl.getOriginalUserId(),
7429 userNotificationEventModelImpl.getOriginalDeliveryType(),
7430 userNotificationEventModelImpl.getOriginalArchived()
7431 };
7432
7433 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_A, args);
7434 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A,
7435 args);
7436
7437 args = new Object[] {
7438 userNotificationEventModelImpl.getUserId(),
7439 userNotificationEventModelImpl.getDeliveryType(),
7440 userNotificationEventModelImpl.getArchived()
7441 };
7442
7443 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_A, args);
7444 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A,
7445 args);
7446 }
7447
7448 if ((userNotificationEventModelImpl.getColumnBitmask() &
7449 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A.getColumnBitmask()) != 0) {
7450 Object[] args = new Object[] {
7451 userNotificationEventModelImpl.getOriginalUserId(),
7452 userNotificationEventModelImpl.getOriginalDelivered(),
7453 userNotificationEventModelImpl.getOriginalActionRequired()
7454 };
7455
7456 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_D_A, args);
7457 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A,
7458 args);
7459
7460 args = new Object[] {
7461 userNotificationEventModelImpl.getUserId(),
7462 userNotificationEventModelImpl.getDelivered(),
7463 userNotificationEventModelImpl.getActionRequired()
7464 };
7465
7466 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_D_A, args);
7467 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A,
7468 args);
7469 }
7470
7471 if ((userNotificationEventModelImpl.getColumnBitmask() &
7472 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A.getColumnBitmask()) != 0) {
7473 Object[] args = new Object[] {
7474 userNotificationEventModelImpl.getOriginalUserId(),
7475 userNotificationEventModelImpl.getOriginalActionRequired(),
7476 userNotificationEventModelImpl.getOriginalArchived()
7477 };
7478
7479 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_A_A, args);
7480 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A,
7481 args);
7482
7483 args = new Object[] {
7484 userNotificationEventModelImpl.getUserId(),
7485 userNotificationEventModelImpl.getActionRequired(),
7486 userNotificationEventModelImpl.getArchived()
7487 };
7488
7489 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_A_A, args);
7490 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A,
7491 args);
7492 }
7493
7494 if ((userNotificationEventModelImpl.getColumnBitmask() &
7495 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A.getColumnBitmask()) != 0) {
7496 Object[] args = new Object[] {
7497 userNotificationEventModelImpl.getOriginalUserId(),
7498 userNotificationEventModelImpl.getOriginalDeliveryType(),
7499 userNotificationEventModelImpl.getOriginalDelivered(),
7500 userNotificationEventModelImpl.getOriginalActionRequired()
7501 };
7502
7503 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_D_A, args);
7504 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A,
7505 args);
7506
7507 args = new Object[] {
7508 userNotificationEventModelImpl.getUserId(),
7509 userNotificationEventModelImpl.getDeliveryType(),
7510 userNotificationEventModelImpl.getDelivered(),
7511 userNotificationEventModelImpl.getActionRequired()
7512 };
7513
7514 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_D_A, args);
7515 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A,
7516 args);
7517 }
7518
7519 if ((userNotificationEventModelImpl.getColumnBitmask() &
7520 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A.getColumnBitmask()) != 0) {
7521 Object[] args = new Object[] {
7522 userNotificationEventModelImpl.getOriginalUserId(),
7523 userNotificationEventModelImpl.getOriginalDeliveryType(),
7524 userNotificationEventModelImpl.getOriginalActionRequired(),
7525 userNotificationEventModelImpl.getOriginalArchived()
7526 };
7527
7528 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_A_A, args);
7529 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A,
7530 args);
7531
7532 args = new Object[] {
7533 userNotificationEventModelImpl.getUserId(),
7534 userNotificationEventModelImpl.getDeliveryType(),
7535 userNotificationEventModelImpl.getActionRequired(),
7536 userNotificationEventModelImpl.getArchived()
7537 };
7538
7539 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_A_A, args);
7540 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A,
7541 args);
7542 }
7543 }
7544
7545 entityCache.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7546 UserNotificationEventImpl.class,
7547 userNotificationEvent.getPrimaryKey(), userNotificationEvent, false);
7548
7549 userNotificationEvent.resetOriginalValues();
7550
7551 return userNotificationEvent;
7552 }
7553
7554 protected UserNotificationEvent toUnwrappedModel(
7555 UserNotificationEvent userNotificationEvent) {
7556 if (userNotificationEvent instanceof UserNotificationEventImpl) {
7557 return userNotificationEvent;
7558 }
7559
7560 UserNotificationEventImpl userNotificationEventImpl = new UserNotificationEventImpl();
7561
7562 userNotificationEventImpl.setNew(userNotificationEvent.isNew());
7563 userNotificationEventImpl.setPrimaryKey(userNotificationEvent.getPrimaryKey());
7564
7565 userNotificationEventImpl.setMvccVersion(userNotificationEvent.getMvccVersion());
7566 userNotificationEventImpl.setUuid(userNotificationEvent.getUuid());
7567 userNotificationEventImpl.setUserNotificationEventId(userNotificationEvent.getUserNotificationEventId());
7568 userNotificationEventImpl.setCompanyId(userNotificationEvent.getCompanyId());
7569 userNotificationEventImpl.setUserId(userNotificationEvent.getUserId());
7570 userNotificationEventImpl.setType(userNotificationEvent.getType());
7571 userNotificationEventImpl.setTimestamp(userNotificationEvent.getTimestamp());
7572 userNotificationEventImpl.setDeliveryType(userNotificationEvent.getDeliveryType());
7573 userNotificationEventImpl.setDeliverBy(userNotificationEvent.getDeliverBy());
7574 userNotificationEventImpl.setDelivered(userNotificationEvent.isDelivered());
7575 userNotificationEventImpl.setPayload(userNotificationEvent.getPayload());
7576 userNotificationEventImpl.setActionRequired(userNotificationEvent.isActionRequired());
7577 userNotificationEventImpl.setArchived(userNotificationEvent.isArchived());
7578
7579 return userNotificationEventImpl;
7580 }
7581
7582
7589 @Override
7590 public UserNotificationEvent findByPrimaryKey(Serializable primaryKey)
7591 throws NoSuchUserNotificationEventException {
7592 UserNotificationEvent userNotificationEvent = fetchByPrimaryKey(primaryKey);
7593
7594 if (userNotificationEvent == null) {
7595 if (_log.isWarnEnabled()) {
7596 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
7597 }
7598
7599 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
7600 primaryKey);
7601 }
7602
7603 return userNotificationEvent;
7604 }
7605
7606
7613 @Override
7614 public UserNotificationEvent findByPrimaryKey(long userNotificationEventId)
7615 throws NoSuchUserNotificationEventException {
7616 return findByPrimaryKey((Serializable)userNotificationEventId);
7617 }
7618
7619
7625 @Override
7626 public UserNotificationEvent fetchByPrimaryKey(Serializable primaryKey) {
7627 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)entityCache.getResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7628 UserNotificationEventImpl.class, primaryKey);
7629
7630 if (userNotificationEvent == _nullUserNotificationEvent) {
7631 return null;
7632 }
7633
7634 if (userNotificationEvent == null) {
7635 Session session = null;
7636
7637 try {
7638 session = openSession();
7639
7640 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
7641 primaryKey);
7642
7643 if (userNotificationEvent != null) {
7644 cacheResult(userNotificationEvent);
7645 }
7646 else {
7647 entityCache.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7648 UserNotificationEventImpl.class, primaryKey,
7649 _nullUserNotificationEvent);
7650 }
7651 }
7652 catch (Exception e) {
7653 entityCache.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7654 UserNotificationEventImpl.class, primaryKey);
7655
7656 throw processException(e);
7657 }
7658 finally {
7659 closeSession(session);
7660 }
7661 }
7662
7663 return userNotificationEvent;
7664 }
7665
7666
7672 @Override
7673 public UserNotificationEvent fetchByPrimaryKey(long userNotificationEventId) {
7674 return fetchByPrimaryKey((Serializable)userNotificationEventId);
7675 }
7676
7677 @Override
7678 public Map<Serializable, UserNotificationEvent> fetchByPrimaryKeys(
7679 Set<Serializable> primaryKeys) {
7680 if (primaryKeys.isEmpty()) {
7681 return Collections.emptyMap();
7682 }
7683
7684 Map<Serializable, UserNotificationEvent> map = new HashMap<Serializable, UserNotificationEvent>();
7685
7686 if (primaryKeys.size() == 1) {
7687 Iterator<Serializable> iterator = primaryKeys.iterator();
7688
7689 Serializable primaryKey = iterator.next();
7690
7691 UserNotificationEvent userNotificationEvent = fetchByPrimaryKey(primaryKey);
7692
7693 if (userNotificationEvent != null) {
7694 map.put(primaryKey, userNotificationEvent);
7695 }
7696
7697 return map;
7698 }
7699
7700 Set<Serializable> uncachedPrimaryKeys = null;
7701
7702 for (Serializable primaryKey : primaryKeys) {
7703 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)entityCache.getResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7704 UserNotificationEventImpl.class, primaryKey);
7705
7706 if (userNotificationEvent == null) {
7707 if (uncachedPrimaryKeys == null) {
7708 uncachedPrimaryKeys = new HashSet<Serializable>();
7709 }
7710
7711 uncachedPrimaryKeys.add(primaryKey);
7712 }
7713 else {
7714 map.put(primaryKey, userNotificationEvent);
7715 }
7716 }
7717
7718 if (uncachedPrimaryKeys == null) {
7719 return map;
7720 }
7721
7722 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
7723 1);
7724
7725 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE_PKS_IN);
7726
7727 for (Serializable primaryKey : uncachedPrimaryKeys) {
7728 query.append(String.valueOf(primaryKey));
7729
7730 query.append(StringPool.COMMA);
7731 }
7732
7733 query.setIndex(query.index() - 1);
7734
7735 query.append(StringPool.CLOSE_PARENTHESIS);
7736
7737 String sql = query.toString();
7738
7739 Session session = null;
7740
7741 try {
7742 session = openSession();
7743
7744 Query q = session.createQuery(sql);
7745
7746 for (UserNotificationEvent userNotificationEvent : (List<UserNotificationEvent>)q.list()) {
7747 map.put(userNotificationEvent.getPrimaryKeyObj(),
7748 userNotificationEvent);
7749
7750 cacheResult(userNotificationEvent);
7751
7752 uncachedPrimaryKeys.remove(userNotificationEvent.getPrimaryKeyObj());
7753 }
7754
7755 for (Serializable primaryKey : uncachedPrimaryKeys) {
7756 entityCache.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7757 UserNotificationEventImpl.class, primaryKey,
7758 _nullUserNotificationEvent);
7759 }
7760 }
7761 catch (Exception e) {
7762 throw processException(e);
7763 }
7764 finally {
7765 closeSession(session);
7766 }
7767
7768 return map;
7769 }
7770
7771
7776 @Override
7777 public List<UserNotificationEvent> findAll() {
7778 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7779 }
7780
7781
7792 @Override
7793 public List<UserNotificationEvent> findAll(int start, int end) {
7794 return findAll(start, end, null);
7795 }
7796
7797
7809 @Override
7810 public List<UserNotificationEvent> findAll(int start, int end,
7811 OrderByComparator<UserNotificationEvent> orderByComparator) {
7812 return findAll(start, end, orderByComparator, true);
7813 }
7814
7815
7828 @Override
7829 public List<UserNotificationEvent> findAll(int start, int end,
7830 OrderByComparator<UserNotificationEvent> orderByComparator,
7831 boolean retrieveFromCache) {
7832 boolean pagination = true;
7833 FinderPath finderPath = null;
7834 Object[] finderArgs = null;
7835
7836 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7837 (orderByComparator == null)) {
7838 pagination = false;
7839 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
7840 finderArgs = FINDER_ARGS_EMPTY;
7841 }
7842 else {
7843 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
7844 finderArgs = new Object[] { start, end, orderByComparator };
7845 }
7846
7847 List<UserNotificationEvent> list = null;
7848
7849 if (retrieveFromCache) {
7850 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
7851 finderArgs, this);
7852 }
7853
7854 if (list == null) {
7855 StringBundler query = null;
7856 String sql = null;
7857
7858 if (orderByComparator != null) {
7859 query = new StringBundler(2 +
7860 (orderByComparator.getOrderByFields().length * 3));
7861
7862 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT);
7863
7864 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7865 orderByComparator);
7866
7867 sql = query.toString();
7868 }
7869 else {
7870 sql = _SQL_SELECT_USERNOTIFICATIONEVENT;
7871
7872 if (pagination) {
7873 sql = sql.concat(UserNotificationEventModelImpl.ORDER_BY_JPQL);
7874 }
7875 }
7876
7877 Session session = null;
7878
7879 try {
7880 session = openSession();
7881
7882 Query q = session.createQuery(sql);
7883
7884 if (!pagination) {
7885 list = (List<UserNotificationEvent>)QueryUtil.list(q,
7886 getDialect(), start, end, false);
7887
7888 Collections.sort(list);
7889
7890 list = Collections.unmodifiableList(list);
7891 }
7892 else {
7893 list = (List<UserNotificationEvent>)QueryUtil.list(q,
7894 getDialect(), start, end);
7895 }
7896
7897 cacheResult(list);
7898
7899 finderCache.putResult(finderPath, finderArgs, list);
7900 }
7901 catch (Exception e) {
7902 finderCache.removeResult(finderPath, finderArgs);
7903
7904 throw processException(e);
7905 }
7906 finally {
7907 closeSession(session);
7908 }
7909 }
7910
7911 return list;
7912 }
7913
7914
7918 @Override
7919 public void removeAll() {
7920 for (UserNotificationEvent userNotificationEvent : findAll()) {
7921 remove(userNotificationEvent);
7922 }
7923 }
7924
7925
7930 @Override
7931 public int countAll() {
7932 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
7933 FINDER_ARGS_EMPTY, this);
7934
7935 if (count == null) {
7936 Session session = null;
7937
7938 try {
7939 session = openSession();
7940
7941 Query q = session.createQuery(_SQL_COUNT_USERNOTIFICATIONEVENT);
7942
7943 count = (Long)q.uniqueResult();
7944
7945 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
7946 count);
7947 }
7948 catch (Exception e) {
7949 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
7950 FINDER_ARGS_EMPTY);
7951
7952 throw processException(e);
7953 }
7954 finally {
7955 closeSession(session);
7956 }
7957 }
7958
7959 return count.intValue();
7960 }
7961
7962 @Override
7963 public Set<String> getBadColumnNames() {
7964 return _badColumnNames;
7965 }
7966
7967 @Override
7968 protected Map<String, Integer> getTableColumnsMap() {
7969 return UserNotificationEventModelImpl.TABLE_COLUMNS_MAP;
7970 }
7971
7972
7975 public void afterPropertiesSet() {
7976 }
7977
7978 public void destroy() {
7979 entityCache.removeCache(UserNotificationEventImpl.class.getName());
7980 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
7981 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
7982 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7983 }
7984
7985 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
7986 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
7987 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent";
7988 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT_WHERE_PKS_IN = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent WHERE userNotificationEventId IN (";
7989 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT_WHERE = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent WHERE ";
7990 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent";
7991 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT_WHERE = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent WHERE ";
7992 private static final String _ORDER_BY_ENTITY_ALIAS = "userNotificationEvent.";
7993 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserNotificationEvent exists with the primary key ";
7994 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserNotificationEvent exists with the key {";
7995 private static final Log _log = LogFactoryUtil.getLog(UserNotificationEventPersistenceImpl.class);
7996 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
7997 "uuid", "type"
7998 });
7999 private static final UserNotificationEvent _nullUserNotificationEvent = new UserNotificationEventImpl() {
8000 @Override
8001 public Object clone() {
8002 return this;
8003 }
8004
8005 @Override
8006 public CacheModel<UserNotificationEvent> toCacheModel() {
8007 return _nullUserNotificationEventCacheModel;
8008 }
8009 };
8010
8011 private static final CacheModel<UserNotificationEvent> _nullUserNotificationEventCacheModel =
8012 new NullCacheModel();
8013
8014 private static class NullCacheModel implements CacheModel<UserNotificationEvent>,
8015 MVCCModel {
8016 @Override
8017 public long getMvccVersion() {
8018 return -1;
8019 }
8020
8021 @Override
8022 public void setMvccVersion(long mvccVersion) {
8023 }
8024
8025 @Override
8026 public UserNotificationEvent toEntityModel() {
8027 return _nullUserNotificationEvent;
8028 }
8029 }
8030 }