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.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.OrderByComparator;
030 import com.liferay.portal.kernel.util.SetUtil;
031 import com.liferay.portal.kernel.util.StringBundler;
032 import com.liferay.portal.kernel.util.StringPool;
033 import com.liferay.portal.kernel.util.Validator;
034 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
035 import com.liferay.portal.model.CacheModel;
036 import com.liferay.portal.model.MVCCModel;
037 import com.liferay.portal.model.UserNotificationEvent;
038 import com.liferay.portal.model.impl.UserNotificationEventImpl;
039 import com.liferay.portal.model.impl.UserNotificationEventModelImpl;
040 import com.liferay.portal.service.persistence.UserNotificationEventPersistence;
041
042 import java.io.Serializable;
043
044 import java.util.Collections;
045 import java.util.HashMap;
046 import java.util.HashSet;
047 import java.util.Iterator;
048 import java.util.List;
049 import java.util.Map;
050 import java.util.Set;
051
052
064 @ProviderType
065 public class UserNotificationEventPersistenceImpl extends BasePersistenceImpl<UserNotificationEvent>
066 implements UserNotificationEventPersistence {
067
072 public static final String FINDER_CLASS_NAME_ENTITY = UserNotificationEventImpl.class.getName();
073 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List1";
075 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List2";
077 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
078 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
079 UserNotificationEventImpl.class,
080 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
081 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
082 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
083 UserNotificationEventImpl.class,
084 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
086 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
089 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
090 UserNotificationEventImpl.class,
091 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
092 new String[] {
093 String.class.getName(),
094
095 Integer.class.getName(), Integer.class.getName(),
096 OrderByComparator.class.getName()
097 });
098 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
099 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
100 UserNotificationEventImpl.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
102 new String[] { String.class.getName() },
103 UserNotificationEventModelImpl.UUID_COLUMN_BITMASK |
104 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
106 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
108 new String[] { String.class.getName() });
109
110
116 @Override
117 public List<UserNotificationEvent> findByUuid(String uuid) {
118 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
119 }
120
121
133 @Override
134 public List<UserNotificationEvent> findByUuid(String uuid, int start,
135 int end) {
136 return findByUuid(uuid, start, end, null);
137 }
138
139
152 @Override
153 public List<UserNotificationEvent> findByUuid(String uuid, int start,
154 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
155 boolean pagination = true;
156 FinderPath finderPath = null;
157 Object[] finderArgs = null;
158
159 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
160 (orderByComparator == null)) {
161 pagination = false;
162 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
163 finderArgs = new Object[] { uuid };
164 }
165 else {
166 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
167 finderArgs = new Object[] { uuid, start, end, orderByComparator };
168 }
169
170 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
171 finderArgs, this);
172
173 if ((list != null) && !list.isEmpty()) {
174 for (UserNotificationEvent userNotificationEvent : list) {
175 if (!Validator.equals(uuid, userNotificationEvent.getUuid())) {
176 list = null;
177
178 break;
179 }
180 }
181 }
182
183 if (list == null) {
184 StringBundler query = null;
185
186 if (orderByComparator != null) {
187 query = new StringBundler(3 +
188 (orderByComparator.getOrderByFields().length * 3));
189 }
190 else {
191 query = new StringBundler(3);
192 }
193
194 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
195
196 boolean bindUuid = false;
197
198 if (uuid == null) {
199 query.append(_FINDER_COLUMN_UUID_UUID_1);
200 }
201 else if (uuid.equals(StringPool.BLANK)) {
202 query.append(_FINDER_COLUMN_UUID_UUID_3);
203 }
204 else {
205 bindUuid = true;
206
207 query.append(_FINDER_COLUMN_UUID_UUID_2);
208 }
209
210 if (orderByComparator != null) {
211 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
212 orderByComparator);
213 }
214 else
215 if (pagination) {
216 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
217 }
218
219 String sql = query.toString();
220
221 Session session = null;
222
223 try {
224 session = openSession();
225
226 Query q = session.createQuery(sql);
227
228 QueryPos qPos = QueryPos.getInstance(q);
229
230 if (bindUuid) {
231 qPos.add(uuid);
232 }
233
234 if (!pagination) {
235 list = (List<UserNotificationEvent>)QueryUtil.list(q,
236 getDialect(), start, end, false);
237
238 Collections.sort(list);
239
240 list = Collections.unmodifiableList(list);
241 }
242 else {
243 list = (List<UserNotificationEvent>)QueryUtil.list(q,
244 getDialect(), start, end);
245 }
246
247 cacheResult(list);
248
249 FinderCacheUtil.putResult(finderPath, finderArgs, list);
250 }
251 catch (Exception e) {
252 FinderCacheUtil.removeResult(finderPath, finderArgs);
253
254 throw processException(e);
255 }
256 finally {
257 closeSession(session);
258 }
259 }
260
261 return list;
262 }
263
264
272 @Override
273 public UserNotificationEvent findByUuid_First(String uuid,
274 OrderByComparator<UserNotificationEvent> orderByComparator)
275 throws NoSuchUserNotificationEventException {
276 UserNotificationEvent userNotificationEvent = fetchByUuid_First(uuid,
277 orderByComparator);
278
279 if (userNotificationEvent != null) {
280 return userNotificationEvent;
281 }
282
283 StringBundler msg = new StringBundler(4);
284
285 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
286
287 msg.append("uuid=");
288 msg.append(uuid);
289
290 msg.append(StringPool.CLOSE_CURLY_BRACE);
291
292 throw new NoSuchUserNotificationEventException(msg.toString());
293 }
294
295
302 @Override
303 public UserNotificationEvent fetchByUuid_First(String uuid,
304 OrderByComparator<UserNotificationEvent> orderByComparator) {
305 List<UserNotificationEvent> list = findByUuid(uuid, 0, 1,
306 orderByComparator);
307
308 if (!list.isEmpty()) {
309 return list.get(0);
310 }
311
312 return null;
313 }
314
315
323 @Override
324 public UserNotificationEvent findByUuid_Last(String uuid,
325 OrderByComparator<UserNotificationEvent> orderByComparator)
326 throws NoSuchUserNotificationEventException {
327 UserNotificationEvent userNotificationEvent = fetchByUuid_Last(uuid,
328 orderByComparator);
329
330 if (userNotificationEvent != null) {
331 return userNotificationEvent;
332 }
333
334 StringBundler msg = new StringBundler(4);
335
336 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
337
338 msg.append("uuid=");
339 msg.append(uuid);
340
341 msg.append(StringPool.CLOSE_CURLY_BRACE);
342
343 throw new NoSuchUserNotificationEventException(msg.toString());
344 }
345
346
353 @Override
354 public UserNotificationEvent fetchByUuid_Last(String uuid,
355 OrderByComparator<UserNotificationEvent> orderByComparator) {
356 int count = countByUuid(uuid);
357
358 if (count == 0) {
359 return null;
360 }
361
362 List<UserNotificationEvent> list = findByUuid(uuid, count - 1, count,
363 orderByComparator);
364
365 if (!list.isEmpty()) {
366 return list.get(0);
367 }
368
369 return null;
370 }
371
372
381 @Override
382 public UserNotificationEvent[] findByUuid_PrevAndNext(
383 long userNotificationEventId, String uuid,
384 OrderByComparator<UserNotificationEvent> orderByComparator)
385 throws NoSuchUserNotificationEventException {
386 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
387
388 Session session = null;
389
390 try {
391 session = openSession();
392
393 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
394
395 array[0] = getByUuid_PrevAndNext(session, userNotificationEvent,
396 uuid, orderByComparator, true);
397
398 array[1] = userNotificationEvent;
399
400 array[2] = getByUuid_PrevAndNext(session, userNotificationEvent,
401 uuid, orderByComparator, false);
402
403 return array;
404 }
405 catch (Exception e) {
406 throw processException(e);
407 }
408 finally {
409 closeSession(session);
410 }
411 }
412
413 protected UserNotificationEvent getByUuid_PrevAndNext(Session session,
414 UserNotificationEvent userNotificationEvent, String uuid,
415 OrderByComparator<UserNotificationEvent> orderByComparator,
416 boolean previous) {
417 StringBundler query = null;
418
419 if (orderByComparator != null) {
420 query = new StringBundler(6 +
421 (orderByComparator.getOrderByFields().length * 6));
422 }
423 else {
424 query = new StringBundler(3);
425 }
426
427 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
428
429 boolean bindUuid = false;
430
431 if (uuid == null) {
432 query.append(_FINDER_COLUMN_UUID_UUID_1);
433 }
434 else if (uuid.equals(StringPool.BLANK)) {
435 query.append(_FINDER_COLUMN_UUID_UUID_3);
436 }
437 else {
438 bindUuid = true;
439
440 query.append(_FINDER_COLUMN_UUID_UUID_2);
441 }
442
443 if (orderByComparator != null) {
444 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
445
446 if (orderByConditionFields.length > 0) {
447 query.append(WHERE_AND);
448 }
449
450 for (int i = 0; i < orderByConditionFields.length; i++) {
451 query.append(_ORDER_BY_ENTITY_ALIAS);
452 query.append(orderByConditionFields[i]);
453
454 if ((i + 1) < orderByConditionFields.length) {
455 if (orderByComparator.isAscending() ^ previous) {
456 query.append(WHERE_GREATER_THAN_HAS_NEXT);
457 }
458 else {
459 query.append(WHERE_LESSER_THAN_HAS_NEXT);
460 }
461 }
462 else {
463 if (orderByComparator.isAscending() ^ previous) {
464 query.append(WHERE_GREATER_THAN);
465 }
466 else {
467 query.append(WHERE_LESSER_THAN);
468 }
469 }
470 }
471
472 query.append(ORDER_BY_CLAUSE);
473
474 String[] orderByFields = orderByComparator.getOrderByFields();
475
476 for (int i = 0; i < orderByFields.length; i++) {
477 query.append(_ORDER_BY_ENTITY_ALIAS);
478 query.append(orderByFields[i]);
479
480 if ((i + 1) < orderByFields.length) {
481 if (orderByComparator.isAscending() ^ previous) {
482 query.append(ORDER_BY_ASC_HAS_NEXT);
483 }
484 else {
485 query.append(ORDER_BY_DESC_HAS_NEXT);
486 }
487 }
488 else {
489 if (orderByComparator.isAscending() ^ previous) {
490 query.append(ORDER_BY_ASC);
491 }
492 else {
493 query.append(ORDER_BY_DESC);
494 }
495 }
496 }
497 }
498 else {
499 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
500 }
501
502 String sql = query.toString();
503
504 Query q = session.createQuery(sql);
505
506 q.setFirstResult(0);
507 q.setMaxResults(2);
508
509 QueryPos qPos = QueryPos.getInstance(q);
510
511 if (bindUuid) {
512 qPos.add(uuid);
513 }
514
515 if (orderByComparator != null) {
516 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
517
518 for (Object value : values) {
519 qPos.add(value);
520 }
521 }
522
523 List<UserNotificationEvent> list = q.list();
524
525 if (list.size() == 2) {
526 return list.get(1);
527 }
528 else {
529 return null;
530 }
531 }
532
533
538 @Override
539 public void removeByUuid(String uuid) {
540 for (UserNotificationEvent userNotificationEvent : findByUuid(uuid,
541 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
542 remove(userNotificationEvent);
543 }
544 }
545
546
552 @Override
553 public int countByUuid(String uuid) {
554 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
555
556 Object[] finderArgs = new Object[] { uuid };
557
558 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
559 this);
560
561 if (count == null) {
562 StringBundler query = new StringBundler(2);
563
564 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
565
566 boolean bindUuid = false;
567
568 if (uuid == null) {
569 query.append(_FINDER_COLUMN_UUID_UUID_1);
570 }
571 else if (uuid.equals(StringPool.BLANK)) {
572 query.append(_FINDER_COLUMN_UUID_UUID_3);
573 }
574 else {
575 bindUuid = true;
576
577 query.append(_FINDER_COLUMN_UUID_UUID_2);
578 }
579
580 String sql = query.toString();
581
582 Session session = null;
583
584 try {
585 session = openSession();
586
587 Query q = session.createQuery(sql);
588
589 QueryPos qPos = QueryPos.getInstance(q);
590
591 if (bindUuid) {
592 qPos.add(uuid);
593 }
594
595 count = (Long)q.uniqueResult();
596
597 FinderCacheUtil.putResult(finderPath, finderArgs, count);
598 }
599 catch (Exception e) {
600 FinderCacheUtil.removeResult(finderPath, finderArgs);
601
602 throw processException(e);
603 }
604 finally {
605 closeSession(session);
606 }
607 }
608
609 return count.intValue();
610 }
611
612 private static final String _FINDER_COLUMN_UUID_UUID_1 = "userNotificationEvent.uuid IS NULL";
613 private static final String _FINDER_COLUMN_UUID_UUID_2 = "userNotificationEvent.uuid = ?";
614 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = '')";
615 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
616 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
617 UserNotificationEventImpl.class,
618 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
619 new String[] {
620 String.class.getName(), Long.class.getName(),
621
622 Integer.class.getName(), Integer.class.getName(),
623 OrderByComparator.class.getName()
624 });
625 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
626 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
627 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
628 UserNotificationEventImpl.class,
629 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
630 new String[] { String.class.getName(), Long.class.getName() },
631 UserNotificationEventModelImpl.UUID_COLUMN_BITMASK |
632 UserNotificationEventModelImpl.COMPANYID_COLUMN_BITMASK |
633 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
634 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
635 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
636 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
637 new String[] { String.class.getName(), Long.class.getName() });
638
639
646 @Override
647 public List<UserNotificationEvent> findByUuid_C(String uuid, long companyId) {
648 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
649 QueryUtil.ALL_POS, null);
650 }
651
652
665 @Override
666 public List<UserNotificationEvent> findByUuid_C(String uuid,
667 long companyId, int start, int end) {
668 return findByUuid_C(uuid, companyId, start, end, null);
669 }
670
671
685 @Override
686 public List<UserNotificationEvent> findByUuid_C(String uuid,
687 long companyId, int start, int end,
688 OrderByComparator<UserNotificationEvent> orderByComparator) {
689 boolean pagination = true;
690 FinderPath finderPath = null;
691 Object[] finderArgs = null;
692
693 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
694 (orderByComparator == null)) {
695 pagination = false;
696 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
697 finderArgs = new Object[] { uuid, companyId };
698 }
699 else {
700 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
701 finderArgs = new Object[] {
702 uuid, companyId,
703
704 start, end, orderByComparator
705 };
706 }
707
708 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
709 finderArgs, this);
710
711 if ((list != null) && !list.isEmpty()) {
712 for (UserNotificationEvent userNotificationEvent : list) {
713 if (!Validator.equals(uuid, userNotificationEvent.getUuid()) ||
714 (companyId != userNotificationEvent.getCompanyId())) {
715 list = null;
716
717 break;
718 }
719 }
720 }
721
722 if (list == null) {
723 StringBundler query = null;
724
725 if (orderByComparator != null) {
726 query = new StringBundler(4 +
727 (orderByComparator.getOrderByFields().length * 3));
728 }
729 else {
730 query = new StringBundler(4);
731 }
732
733 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
734
735 boolean bindUuid = false;
736
737 if (uuid == null) {
738 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
739 }
740 else if (uuid.equals(StringPool.BLANK)) {
741 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
742 }
743 else {
744 bindUuid = true;
745
746 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
747 }
748
749 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
750
751 if (orderByComparator != null) {
752 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
753 orderByComparator);
754 }
755 else
756 if (pagination) {
757 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
758 }
759
760 String sql = query.toString();
761
762 Session session = null;
763
764 try {
765 session = openSession();
766
767 Query q = session.createQuery(sql);
768
769 QueryPos qPos = QueryPos.getInstance(q);
770
771 if (bindUuid) {
772 qPos.add(uuid);
773 }
774
775 qPos.add(companyId);
776
777 if (!pagination) {
778 list = (List<UserNotificationEvent>)QueryUtil.list(q,
779 getDialect(), start, end, false);
780
781 Collections.sort(list);
782
783 list = Collections.unmodifiableList(list);
784 }
785 else {
786 list = (List<UserNotificationEvent>)QueryUtil.list(q,
787 getDialect(), start, end);
788 }
789
790 cacheResult(list);
791
792 FinderCacheUtil.putResult(finderPath, finderArgs, list);
793 }
794 catch (Exception e) {
795 FinderCacheUtil.removeResult(finderPath, finderArgs);
796
797 throw processException(e);
798 }
799 finally {
800 closeSession(session);
801 }
802 }
803
804 return list;
805 }
806
807
816 @Override
817 public UserNotificationEvent findByUuid_C_First(String uuid,
818 long companyId,
819 OrderByComparator<UserNotificationEvent> orderByComparator)
820 throws NoSuchUserNotificationEventException {
821 UserNotificationEvent userNotificationEvent = fetchByUuid_C_First(uuid,
822 companyId, orderByComparator);
823
824 if (userNotificationEvent != null) {
825 return userNotificationEvent;
826 }
827
828 StringBundler msg = new StringBundler(6);
829
830 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
831
832 msg.append("uuid=");
833 msg.append(uuid);
834
835 msg.append(", companyId=");
836 msg.append(companyId);
837
838 msg.append(StringPool.CLOSE_CURLY_BRACE);
839
840 throw new NoSuchUserNotificationEventException(msg.toString());
841 }
842
843
851 @Override
852 public UserNotificationEvent fetchByUuid_C_First(String uuid,
853 long companyId,
854 OrderByComparator<UserNotificationEvent> orderByComparator) {
855 List<UserNotificationEvent> list = findByUuid_C(uuid, companyId, 0, 1,
856 orderByComparator);
857
858 if (!list.isEmpty()) {
859 return list.get(0);
860 }
861
862 return null;
863 }
864
865
874 @Override
875 public UserNotificationEvent findByUuid_C_Last(String uuid, long companyId,
876 OrderByComparator<UserNotificationEvent> orderByComparator)
877 throws NoSuchUserNotificationEventException {
878 UserNotificationEvent userNotificationEvent = fetchByUuid_C_Last(uuid,
879 companyId, orderByComparator);
880
881 if (userNotificationEvent != null) {
882 return userNotificationEvent;
883 }
884
885 StringBundler msg = new StringBundler(6);
886
887 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
888
889 msg.append("uuid=");
890 msg.append(uuid);
891
892 msg.append(", companyId=");
893 msg.append(companyId);
894
895 msg.append(StringPool.CLOSE_CURLY_BRACE);
896
897 throw new NoSuchUserNotificationEventException(msg.toString());
898 }
899
900
908 @Override
909 public UserNotificationEvent fetchByUuid_C_Last(String uuid,
910 long companyId,
911 OrderByComparator<UserNotificationEvent> orderByComparator) {
912 int count = countByUuid_C(uuid, companyId);
913
914 if (count == 0) {
915 return null;
916 }
917
918 List<UserNotificationEvent> list = findByUuid_C(uuid, companyId,
919 count - 1, count, orderByComparator);
920
921 if (!list.isEmpty()) {
922 return list.get(0);
923 }
924
925 return null;
926 }
927
928
938 @Override
939 public UserNotificationEvent[] findByUuid_C_PrevAndNext(
940 long userNotificationEventId, String uuid, long companyId,
941 OrderByComparator<UserNotificationEvent> orderByComparator)
942 throws NoSuchUserNotificationEventException {
943 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
944
945 Session session = null;
946
947 try {
948 session = openSession();
949
950 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
951
952 array[0] = getByUuid_C_PrevAndNext(session, userNotificationEvent,
953 uuid, companyId, orderByComparator, true);
954
955 array[1] = userNotificationEvent;
956
957 array[2] = getByUuid_C_PrevAndNext(session, userNotificationEvent,
958 uuid, companyId, orderByComparator, false);
959
960 return array;
961 }
962 catch (Exception e) {
963 throw processException(e);
964 }
965 finally {
966 closeSession(session);
967 }
968 }
969
970 protected UserNotificationEvent getByUuid_C_PrevAndNext(Session session,
971 UserNotificationEvent userNotificationEvent, String uuid,
972 long companyId,
973 OrderByComparator<UserNotificationEvent> orderByComparator,
974 boolean previous) {
975 StringBundler query = null;
976
977 if (orderByComparator != null) {
978 query = new StringBundler(6 +
979 (orderByComparator.getOrderByFields().length * 6));
980 }
981 else {
982 query = new StringBundler(3);
983 }
984
985 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
986
987 boolean bindUuid = false;
988
989 if (uuid == null) {
990 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
991 }
992 else if (uuid.equals(StringPool.BLANK)) {
993 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
994 }
995 else {
996 bindUuid = true;
997
998 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
999 }
1000
1001 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1002
1003 if (orderByComparator != null) {
1004 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1005
1006 if (orderByConditionFields.length > 0) {
1007 query.append(WHERE_AND);
1008 }
1009
1010 for (int i = 0; i < orderByConditionFields.length; i++) {
1011 query.append(_ORDER_BY_ENTITY_ALIAS);
1012 query.append(orderByConditionFields[i]);
1013
1014 if ((i + 1) < orderByConditionFields.length) {
1015 if (orderByComparator.isAscending() ^ previous) {
1016 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1017 }
1018 else {
1019 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1020 }
1021 }
1022 else {
1023 if (orderByComparator.isAscending() ^ previous) {
1024 query.append(WHERE_GREATER_THAN);
1025 }
1026 else {
1027 query.append(WHERE_LESSER_THAN);
1028 }
1029 }
1030 }
1031
1032 query.append(ORDER_BY_CLAUSE);
1033
1034 String[] orderByFields = orderByComparator.getOrderByFields();
1035
1036 for (int i = 0; i < orderByFields.length; i++) {
1037 query.append(_ORDER_BY_ENTITY_ALIAS);
1038 query.append(orderByFields[i]);
1039
1040 if ((i + 1) < orderByFields.length) {
1041 if (orderByComparator.isAscending() ^ previous) {
1042 query.append(ORDER_BY_ASC_HAS_NEXT);
1043 }
1044 else {
1045 query.append(ORDER_BY_DESC_HAS_NEXT);
1046 }
1047 }
1048 else {
1049 if (orderByComparator.isAscending() ^ previous) {
1050 query.append(ORDER_BY_ASC);
1051 }
1052 else {
1053 query.append(ORDER_BY_DESC);
1054 }
1055 }
1056 }
1057 }
1058 else {
1059 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1060 }
1061
1062 String sql = query.toString();
1063
1064 Query q = session.createQuery(sql);
1065
1066 q.setFirstResult(0);
1067 q.setMaxResults(2);
1068
1069 QueryPos qPos = QueryPos.getInstance(q);
1070
1071 if (bindUuid) {
1072 qPos.add(uuid);
1073 }
1074
1075 qPos.add(companyId);
1076
1077 if (orderByComparator != null) {
1078 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1079
1080 for (Object value : values) {
1081 qPos.add(value);
1082 }
1083 }
1084
1085 List<UserNotificationEvent> list = q.list();
1086
1087 if (list.size() == 2) {
1088 return list.get(1);
1089 }
1090 else {
1091 return null;
1092 }
1093 }
1094
1095
1101 @Override
1102 public void removeByUuid_C(String uuid, long companyId) {
1103 for (UserNotificationEvent userNotificationEvent : findByUuid_C(uuid,
1104 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1105 remove(userNotificationEvent);
1106 }
1107 }
1108
1109
1116 @Override
1117 public int countByUuid_C(String uuid, long companyId) {
1118 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1119
1120 Object[] finderArgs = new Object[] { uuid, companyId };
1121
1122 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1123 this);
1124
1125 if (count == null) {
1126 StringBundler query = new StringBundler(3);
1127
1128 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1129
1130 boolean bindUuid = false;
1131
1132 if (uuid == null) {
1133 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1134 }
1135 else if (uuid.equals(StringPool.BLANK)) {
1136 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1137 }
1138 else {
1139 bindUuid = true;
1140
1141 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1142 }
1143
1144 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1145
1146 String sql = query.toString();
1147
1148 Session session = null;
1149
1150 try {
1151 session = openSession();
1152
1153 Query q = session.createQuery(sql);
1154
1155 QueryPos qPos = QueryPos.getInstance(q);
1156
1157 if (bindUuid) {
1158 qPos.add(uuid);
1159 }
1160
1161 qPos.add(companyId);
1162
1163 count = (Long)q.uniqueResult();
1164
1165 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1166 }
1167 catch (Exception e) {
1168 FinderCacheUtil.removeResult(finderPath, finderArgs);
1169
1170 throw processException(e);
1171 }
1172 finally {
1173 closeSession(session);
1174 }
1175 }
1176
1177 return count.intValue();
1178 }
1179
1180 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "userNotificationEvent.uuid IS NULL AND ";
1181 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "userNotificationEvent.uuid = ? AND ";
1182 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = '') AND ";
1183 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "userNotificationEvent.companyId = ?";
1184 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1185 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1186 UserNotificationEventImpl.class,
1187 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
1188 new String[] {
1189 Long.class.getName(),
1190
1191 Integer.class.getName(), Integer.class.getName(),
1192 OrderByComparator.class.getName()
1193 });
1194 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
1195 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1196 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1197 UserNotificationEventImpl.class,
1198 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
1199 new String[] { Long.class.getName() },
1200 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
1201 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
1202 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1203 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
1204 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
1205 new String[] { Long.class.getName() });
1206
1207
1213 @Override
1214 public List<UserNotificationEvent> findByUserId(long userId) {
1215 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1216 }
1217
1218
1230 @Override
1231 public List<UserNotificationEvent> findByUserId(long userId, int start,
1232 int end) {
1233 return findByUserId(userId, start, end, null);
1234 }
1235
1236
1249 @Override
1250 public List<UserNotificationEvent> findByUserId(long userId, int start,
1251 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
1252 boolean pagination = true;
1253 FinderPath finderPath = null;
1254 Object[] finderArgs = null;
1255
1256 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1257 (orderByComparator == null)) {
1258 pagination = false;
1259 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1260 finderArgs = new Object[] { userId };
1261 }
1262 else {
1263 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1264 finderArgs = new Object[] { userId, start, end, orderByComparator };
1265 }
1266
1267 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
1268 finderArgs, this);
1269
1270 if ((list != null) && !list.isEmpty()) {
1271 for (UserNotificationEvent userNotificationEvent : list) {
1272 if ((userId != userNotificationEvent.getUserId())) {
1273 list = null;
1274
1275 break;
1276 }
1277 }
1278 }
1279
1280 if (list == null) {
1281 StringBundler query = null;
1282
1283 if (orderByComparator != null) {
1284 query = new StringBundler(3 +
1285 (orderByComparator.getOrderByFields().length * 3));
1286 }
1287 else {
1288 query = new StringBundler(3);
1289 }
1290
1291 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1292
1293 query.append(_FINDER_COLUMN_USERID_USERID_2);
1294
1295 if (orderByComparator != null) {
1296 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1297 orderByComparator);
1298 }
1299 else
1300 if (pagination) {
1301 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1302 }
1303
1304 String sql = query.toString();
1305
1306 Session session = null;
1307
1308 try {
1309 session = openSession();
1310
1311 Query q = session.createQuery(sql);
1312
1313 QueryPos qPos = QueryPos.getInstance(q);
1314
1315 qPos.add(userId);
1316
1317 if (!pagination) {
1318 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1319 getDialect(), start, end, false);
1320
1321 Collections.sort(list);
1322
1323 list = Collections.unmodifiableList(list);
1324 }
1325 else {
1326 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1327 getDialect(), start, end);
1328 }
1329
1330 cacheResult(list);
1331
1332 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1333 }
1334 catch (Exception e) {
1335 FinderCacheUtil.removeResult(finderPath, finderArgs);
1336
1337 throw processException(e);
1338 }
1339 finally {
1340 closeSession(session);
1341 }
1342 }
1343
1344 return list;
1345 }
1346
1347
1355 @Override
1356 public UserNotificationEvent findByUserId_First(long userId,
1357 OrderByComparator<UserNotificationEvent> orderByComparator)
1358 throws NoSuchUserNotificationEventException {
1359 UserNotificationEvent userNotificationEvent = fetchByUserId_First(userId,
1360 orderByComparator);
1361
1362 if (userNotificationEvent != null) {
1363 return userNotificationEvent;
1364 }
1365
1366 StringBundler msg = new StringBundler(4);
1367
1368 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1369
1370 msg.append("userId=");
1371 msg.append(userId);
1372
1373 msg.append(StringPool.CLOSE_CURLY_BRACE);
1374
1375 throw new NoSuchUserNotificationEventException(msg.toString());
1376 }
1377
1378
1385 @Override
1386 public UserNotificationEvent fetchByUserId_First(long userId,
1387 OrderByComparator<UserNotificationEvent> orderByComparator) {
1388 List<UserNotificationEvent> list = findByUserId(userId, 0, 1,
1389 orderByComparator);
1390
1391 if (!list.isEmpty()) {
1392 return list.get(0);
1393 }
1394
1395 return null;
1396 }
1397
1398
1406 @Override
1407 public UserNotificationEvent findByUserId_Last(long userId,
1408 OrderByComparator<UserNotificationEvent> orderByComparator)
1409 throws NoSuchUserNotificationEventException {
1410 UserNotificationEvent userNotificationEvent = fetchByUserId_Last(userId,
1411 orderByComparator);
1412
1413 if (userNotificationEvent != null) {
1414 return userNotificationEvent;
1415 }
1416
1417 StringBundler msg = new StringBundler(4);
1418
1419 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1420
1421 msg.append("userId=");
1422 msg.append(userId);
1423
1424 msg.append(StringPool.CLOSE_CURLY_BRACE);
1425
1426 throw new NoSuchUserNotificationEventException(msg.toString());
1427 }
1428
1429
1436 @Override
1437 public UserNotificationEvent fetchByUserId_Last(long userId,
1438 OrderByComparator<UserNotificationEvent> orderByComparator) {
1439 int count = countByUserId(userId);
1440
1441 if (count == 0) {
1442 return null;
1443 }
1444
1445 List<UserNotificationEvent> list = findByUserId(userId, count - 1,
1446 count, orderByComparator);
1447
1448 if (!list.isEmpty()) {
1449 return list.get(0);
1450 }
1451
1452 return null;
1453 }
1454
1455
1464 @Override
1465 public UserNotificationEvent[] findByUserId_PrevAndNext(
1466 long userNotificationEventId, long userId,
1467 OrderByComparator<UserNotificationEvent> orderByComparator)
1468 throws NoSuchUserNotificationEventException {
1469 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
1470
1471 Session session = null;
1472
1473 try {
1474 session = openSession();
1475
1476 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1477
1478 array[0] = getByUserId_PrevAndNext(session, userNotificationEvent,
1479 userId, orderByComparator, true);
1480
1481 array[1] = userNotificationEvent;
1482
1483 array[2] = getByUserId_PrevAndNext(session, userNotificationEvent,
1484 userId, orderByComparator, false);
1485
1486 return array;
1487 }
1488 catch (Exception e) {
1489 throw processException(e);
1490 }
1491 finally {
1492 closeSession(session);
1493 }
1494 }
1495
1496 protected UserNotificationEvent getByUserId_PrevAndNext(Session session,
1497 UserNotificationEvent userNotificationEvent, long userId,
1498 OrderByComparator<UserNotificationEvent> orderByComparator,
1499 boolean previous) {
1500 StringBundler query = null;
1501
1502 if (orderByComparator != null) {
1503 query = new StringBundler(6 +
1504 (orderByComparator.getOrderByFields().length * 6));
1505 }
1506 else {
1507 query = new StringBundler(3);
1508 }
1509
1510 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1511
1512 query.append(_FINDER_COLUMN_USERID_USERID_2);
1513
1514 if (orderByComparator != null) {
1515 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1516
1517 if (orderByConditionFields.length > 0) {
1518 query.append(WHERE_AND);
1519 }
1520
1521 for (int i = 0; i < orderByConditionFields.length; i++) {
1522 query.append(_ORDER_BY_ENTITY_ALIAS);
1523 query.append(orderByConditionFields[i]);
1524
1525 if ((i + 1) < orderByConditionFields.length) {
1526 if (orderByComparator.isAscending() ^ previous) {
1527 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1528 }
1529 else {
1530 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1531 }
1532 }
1533 else {
1534 if (orderByComparator.isAscending() ^ previous) {
1535 query.append(WHERE_GREATER_THAN);
1536 }
1537 else {
1538 query.append(WHERE_LESSER_THAN);
1539 }
1540 }
1541 }
1542
1543 query.append(ORDER_BY_CLAUSE);
1544
1545 String[] orderByFields = orderByComparator.getOrderByFields();
1546
1547 for (int i = 0; i < orderByFields.length; i++) {
1548 query.append(_ORDER_BY_ENTITY_ALIAS);
1549 query.append(orderByFields[i]);
1550
1551 if ((i + 1) < orderByFields.length) {
1552 if (orderByComparator.isAscending() ^ previous) {
1553 query.append(ORDER_BY_ASC_HAS_NEXT);
1554 }
1555 else {
1556 query.append(ORDER_BY_DESC_HAS_NEXT);
1557 }
1558 }
1559 else {
1560 if (orderByComparator.isAscending() ^ previous) {
1561 query.append(ORDER_BY_ASC);
1562 }
1563 else {
1564 query.append(ORDER_BY_DESC);
1565 }
1566 }
1567 }
1568 }
1569 else {
1570 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1571 }
1572
1573 String sql = query.toString();
1574
1575 Query q = session.createQuery(sql);
1576
1577 q.setFirstResult(0);
1578 q.setMaxResults(2);
1579
1580 QueryPos qPos = QueryPos.getInstance(q);
1581
1582 qPos.add(userId);
1583
1584 if (orderByComparator != null) {
1585 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1586
1587 for (Object value : values) {
1588 qPos.add(value);
1589 }
1590 }
1591
1592 List<UserNotificationEvent> list = q.list();
1593
1594 if (list.size() == 2) {
1595 return list.get(1);
1596 }
1597 else {
1598 return null;
1599 }
1600 }
1601
1602
1607 @Override
1608 public void removeByUserId(long userId) {
1609 for (UserNotificationEvent userNotificationEvent : findByUserId(
1610 userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1611 remove(userNotificationEvent);
1612 }
1613 }
1614
1615
1621 @Override
1622 public int countByUserId(long userId) {
1623 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
1624
1625 Object[] finderArgs = new Object[] { userId };
1626
1627 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1628 this);
1629
1630 if (count == null) {
1631 StringBundler query = new StringBundler(2);
1632
1633 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1634
1635 query.append(_FINDER_COLUMN_USERID_USERID_2);
1636
1637 String sql = query.toString();
1638
1639 Session session = null;
1640
1641 try {
1642 session = openSession();
1643
1644 Query q = session.createQuery(sql);
1645
1646 QueryPos qPos = QueryPos.getInstance(q);
1647
1648 qPos.add(userId);
1649
1650 count = (Long)q.uniqueResult();
1651
1652 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1653 }
1654 catch (Exception e) {
1655 FinderCacheUtil.removeResult(finderPath, finderArgs);
1656
1657 throw processException(e);
1658 }
1659 finally {
1660 closeSession(session);
1661 }
1662 }
1663
1664 return count.intValue();
1665 }
1666
1667 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userNotificationEvent.userId = ?";
1668 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1669 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1670 UserNotificationEventImpl.class,
1671 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT",
1672 new String[] {
1673 Long.class.getName(), Integer.class.getName(),
1674
1675 Integer.class.getName(), Integer.class.getName(),
1676 OrderByComparator.class.getName()
1677 });
1678 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1679 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1680 UserNotificationEventImpl.class,
1681 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT",
1682 new String[] { Long.class.getName(), Integer.class.getName() },
1683 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
1684 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
1685 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
1686 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1687 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
1688 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT",
1689 new String[] { Long.class.getName(), Integer.class.getName() });
1690
1691
1698 @Override
1699 public List<UserNotificationEvent> findByU_DT(long userId, int deliveryType) {
1700 return findByU_DT(userId, deliveryType, QueryUtil.ALL_POS,
1701 QueryUtil.ALL_POS, null);
1702 }
1703
1704
1717 @Override
1718 public List<UserNotificationEvent> findByU_DT(long userId,
1719 int deliveryType, int start, int end) {
1720 return findByU_DT(userId, deliveryType, start, end, null);
1721 }
1722
1723
1737 @Override
1738 public List<UserNotificationEvent> findByU_DT(long userId,
1739 int deliveryType, int start, int end,
1740 OrderByComparator<UserNotificationEvent> orderByComparator) {
1741 boolean pagination = true;
1742 FinderPath finderPath = null;
1743 Object[] finderArgs = null;
1744
1745 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1746 (orderByComparator == null)) {
1747 pagination = false;
1748 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT;
1749 finderArgs = new Object[] { userId, deliveryType };
1750 }
1751 else {
1752 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT;
1753 finderArgs = new Object[] {
1754 userId, deliveryType,
1755
1756 start, end, orderByComparator
1757 };
1758 }
1759
1760 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
1761 finderArgs, this);
1762
1763 if ((list != null) && !list.isEmpty()) {
1764 for (UserNotificationEvent userNotificationEvent : list) {
1765 if ((userId != userNotificationEvent.getUserId()) ||
1766 (deliveryType != userNotificationEvent.getDeliveryType())) {
1767 list = null;
1768
1769 break;
1770 }
1771 }
1772 }
1773
1774 if (list == null) {
1775 StringBundler query = null;
1776
1777 if (orderByComparator != null) {
1778 query = new StringBundler(4 +
1779 (orderByComparator.getOrderByFields().length * 3));
1780 }
1781 else {
1782 query = new StringBundler(4);
1783 }
1784
1785 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1786
1787 query.append(_FINDER_COLUMN_U_DT_USERID_2);
1788
1789 query.append(_FINDER_COLUMN_U_DT_DELIVERYTYPE_2);
1790
1791 if (orderByComparator != null) {
1792 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1793 orderByComparator);
1794 }
1795 else
1796 if (pagination) {
1797 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1798 }
1799
1800 String sql = query.toString();
1801
1802 Session session = null;
1803
1804 try {
1805 session = openSession();
1806
1807 Query q = session.createQuery(sql);
1808
1809 QueryPos qPos = QueryPos.getInstance(q);
1810
1811 qPos.add(userId);
1812
1813 qPos.add(deliveryType);
1814
1815 if (!pagination) {
1816 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1817 getDialect(), start, end, false);
1818
1819 Collections.sort(list);
1820
1821 list = Collections.unmodifiableList(list);
1822 }
1823 else {
1824 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1825 getDialect(), start, end);
1826 }
1827
1828 cacheResult(list);
1829
1830 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1831 }
1832 catch (Exception e) {
1833 FinderCacheUtil.removeResult(finderPath, finderArgs);
1834
1835 throw processException(e);
1836 }
1837 finally {
1838 closeSession(session);
1839 }
1840 }
1841
1842 return list;
1843 }
1844
1845
1854 @Override
1855 public UserNotificationEvent findByU_DT_First(long userId,
1856 int deliveryType,
1857 OrderByComparator<UserNotificationEvent> orderByComparator)
1858 throws NoSuchUserNotificationEventException {
1859 UserNotificationEvent userNotificationEvent = fetchByU_DT_First(userId,
1860 deliveryType, orderByComparator);
1861
1862 if (userNotificationEvent != null) {
1863 return userNotificationEvent;
1864 }
1865
1866 StringBundler msg = new StringBundler(6);
1867
1868 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1869
1870 msg.append("userId=");
1871 msg.append(userId);
1872
1873 msg.append(", deliveryType=");
1874 msg.append(deliveryType);
1875
1876 msg.append(StringPool.CLOSE_CURLY_BRACE);
1877
1878 throw new NoSuchUserNotificationEventException(msg.toString());
1879 }
1880
1881
1889 @Override
1890 public UserNotificationEvent fetchByU_DT_First(long userId,
1891 int deliveryType,
1892 OrderByComparator<UserNotificationEvent> orderByComparator) {
1893 List<UserNotificationEvent> list = findByU_DT(userId, deliveryType, 0,
1894 1, orderByComparator);
1895
1896 if (!list.isEmpty()) {
1897 return list.get(0);
1898 }
1899
1900 return null;
1901 }
1902
1903
1912 @Override
1913 public UserNotificationEvent findByU_DT_Last(long userId, int deliveryType,
1914 OrderByComparator<UserNotificationEvent> orderByComparator)
1915 throws NoSuchUserNotificationEventException {
1916 UserNotificationEvent userNotificationEvent = fetchByU_DT_Last(userId,
1917 deliveryType, orderByComparator);
1918
1919 if (userNotificationEvent != null) {
1920 return userNotificationEvent;
1921 }
1922
1923 StringBundler msg = new StringBundler(6);
1924
1925 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1926
1927 msg.append("userId=");
1928 msg.append(userId);
1929
1930 msg.append(", deliveryType=");
1931 msg.append(deliveryType);
1932
1933 msg.append(StringPool.CLOSE_CURLY_BRACE);
1934
1935 throw new NoSuchUserNotificationEventException(msg.toString());
1936 }
1937
1938
1946 @Override
1947 public UserNotificationEvent fetchByU_DT_Last(long userId,
1948 int deliveryType,
1949 OrderByComparator<UserNotificationEvent> orderByComparator) {
1950 int count = countByU_DT(userId, deliveryType);
1951
1952 if (count == 0) {
1953 return null;
1954 }
1955
1956 List<UserNotificationEvent> list = findByU_DT(userId, deliveryType,
1957 count - 1, count, orderByComparator);
1958
1959 if (!list.isEmpty()) {
1960 return list.get(0);
1961 }
1962
1963 return null;
1964 }
1965
1966
1976 @Override
1977 public UserNotificationEvent[] findByU_DT_PrevAndNext(
1978 long userNotificationEventId, long userId, int deliveryType,
1979 OrderByComparator<UserNotificationEvent> orderByComparator)
1980 throws NoSuchUserNotificationEventException {
1981 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
1982
1983 Session session = null;
1984
1985 try {
1986 session = openSession();
1987
1988 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1989
1990 array[0] = getByU_DT_PrevAndNext(session, userNotificationEvent,
1991 userId, deliveryType, orderByComparator, true);
1992
1993 array[1] = userNotificationEvent;
1994
1995 array[2] = getByU_DT_PrevAndNext(session, userNotificationEvent,
1996 userId, deliveryType, orderByComparator, false);
1997
1998 return array;
1999 }
2000 catch (Exception e) {
2001 throw processException(e);
2002 }
2003 finally {
2004 closeSession(session);
2005 }
2006 }
2007
2008 protected UserNotificationEvent getByU_DT_PrevAndNext(Session session,
2009 UserNotificationEvent userNotificationEvent, long userId,
2010 int deliveryType,
2011 OrderByComparator<UserNotificationEvent> orderByComparator,
2012 boolean previous) {
2013 StringBundler query = null;
2014
2015 if (orderByComparator != null) {
2016 query = new StringBundler(6 +
2017 (orderByComparator.getOrderByFields().length * 6));
2018 }
2019 else {
2020 query = new StringBundler(3);
2021 }
2022
2023 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2024
2025 query.append(_FINDER_COLUMN_U_DT_USERID_2);
2026
2027 query.append(_FINDER_COLUMN_U_DT_DELIVERYTYPE_2);
2028
2029 if (orderByComparator != null) {
2030 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2031
2032 if (orderByConditionFields.length > 0) {
2033 query.append(WHERE_AND);
2034 }
2035
2036 for (int i = 0; i < orderByConditionFields.length; i++) {
2037 query.append(_ORDER_BY_ENTITY_ALIAS);
2038 query.append(orderByConditionFields[i]);
2039
2040 if ((i + 1) < orderByConditionFields.length) {
2041 if (orderByComparator.isAscending() ^ previous) {
2042 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2043 }
2044 else {
2045 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2046 }
2047 }
2048 else {
2049 if (orderByComparator.isAscending() ^ previous) {
2050 query.append(WHERE_GREATER_THAN);
2051 }
2052 else {
2053 query.append(WHERE_LESSER_THAN);
2054 }
2055 }
2056 }
2057
2058 query.append(ORDER_BY_CLAUSE);
2059
2060 String[] orderByFields = orderByComparator.getOrderByFields();
2061
2062 for (int i = 0; i < orderByFields.length; i++) {
2063 query.append(_ORDER_BY_ENTITY_ALIAS);
2064 query.append(orderByFields[i]);
2065
2066 if ((i + 1) < orderByFields.length) {
2067 if (orderByComparator.isAscending() ^ previous) {
2068 query.append(ORDER_BY_ASC_HAS_NEXT);
2069 }
2070 else {
2071 query.append(ORDER_BY_DESC_HAS_NEXT);
2072 }
2073 }
2074 else {
2075 if (orderByComparator.isAscending() ^ previous) {
2076 query.append(ORDER_BY_ASC);
2077 }
2078 else {
2079 query.append(ORDER_BY_DESC);
2080 }
2081 }
2082 }
2083 }
2084 else {
2085 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2086 }
2087
2088 String sql = query.toString();
2089
2090 Query q = session.createQuery(sql);
2091
2092 q.setFirstResult(0);
2093 q.setMaxResults(2);
2094
2095 QueryPos qPos = QueryPos.getInstance(q);
2096
2097 qPos.add(userId);
2098
2099 qPos.add(deliveryType);
2100
2101 if (orderByComparator != null) {
2102 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
2103
2104 for (Object value : values) {
2105 qPos.add(value);
2106 }
2107 }
2108
2109 List<UserNotificationEvent> list = q.list();
2110
2111 if (list.size() == 2) {
2112 return list.get(1);
2113 }
2114 else {
2115 return null;
2116 }
2117 }
2118
2119
2125 @Override
2126 public void removeByU_DT(long userId, int deliveryType) {
2127 for (UserNotificationEvent userNotificationEvent : findByU_DT(userId,
2128 deliveryType, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2129 remove(userNotificationEvent);
2130 }
2131 }
2132
2133
2140 @Override
2141 public int countByU_DT(long userId, int deliveryType) {
2142 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT;
2143
2144 Object[] finderArgs = new Object[] { userId, deliveryType };
2145
2146 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2147 this);
2148
2149 if (count == null) {
2150 StringBundler query = new StringBundler(3);
2151
2152 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2153
2154 query.append(_FINDER_COLUMN_U_DT_USERID_2);
2155
2156 query.append(_FINDER_COLUMN_U_DT_DELIVERYTYPE_2);
2157
2158 String sql = query.toString();
2159
2160 Session session = null;
2161
2162 try {
2163 session = openSession();
2164
2165 Query q = session.createQuery(sql);
2166
2167 QueryPos qPos = QueryPos.getInstance(q);
2168
2169 qPos.add(userId);
2170
2171 qPos.add(deliveryType);
2172
2173 count = (Long)q.uniqueResult();
2174
2175 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2176 }
2177 catch (Exception e) {
2178 FinderCacheUtil.removeResult(finderPath, finderArgs);
2179
2180 throw processException(e);
2181 }
2182 finally {
2183 closeSession(session);
2184 }
2185 }
2186
2187 return count.intValue();
2188 }
2189
2190 private static final String _FINDER_COLUMN_U_DT_USERID_2 = "userNotificationEvent.userId = ? AND ";
2191 private static final String _FINDER_COLUMN_U_DT_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ?";
2192 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2193 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2194 UserNotificationEventImpl.class,
2195 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_D",
2196 new String[] {
2197 Long.class.getName(), Boolean.class.getName(),
2198
2199 Integer.class.getName(), Integer.class.getName(),
2200 OrderByComparator.class.getName()
2201 });
2202 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2203 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2204 UserNotificationEventImpl.class,
2205 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_D",
2206 new String[] { Long.class.getName(), Boolean.class.getName() },
2207 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
2208 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
2209 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
2210 public static final FinderPath FINDER_PATH_COUNT_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2211 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
2212 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_D",
2213 new String[] { Long.class.getName(), Boolean.class.getName() });
2214
2215
2222 @Override
2223 public List<UserNotificationEvent> findByU_D(long userId, boolean delivered) {
2224 return findByU_D(userId, delivered, QueryUtil.ALL_POS,
2225 QueryUtil.ALL_POS, null);
2226 }
2227
2228
2241 @Override
2242 public List<UserNotificationEvent> findByU_D(long userId,
2243 boolean delivered, int start, int end) {
2244 return findByU_D(userId, delivered, start, end, null);
2245 }
2246
2247
2261 @Override
2262 public List<UserNotificationEvent> findByU_D(long userId,
2263 boolean delivered, int start, int end,
2264 OrderByComparator<UserNotificationEvent> orderByComparator) {
2265 boolean pagination = true;
2266 FinderPath finderPath = null;
2267 Object[] finderArgs = null;
2268
2269 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2270 (orderByComparator == null)) {
2271 pagination = false;
2272 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D;
2273 finderArgs = new Object[] { userId, delivered };
2274 }
2275 else {
2276 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D;
2277 finderArgs = new Object[] {
2278 userId, delivered,
2279
2280 start, end, orderByComparator
2281 };
2282 }
2283
2284 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
2285 finderArgs, this);
2286
2287 if ((list != null) && !list.isEmpty()) {
2288 for (UserNotificationEvent userNotificationEvent : list) {
2289 if ((userId != userNotificationEvent.getUserId()) ||
2290 (delivered != userNotificationEvent.getDelivered())) {
2291 list = null;
2292
2293 break;
2294 }
2295 }
2296 }
2297
2298 if (list == null) {
2299 StringBundler query = null;
2300
2301 if (orderByComparator != null) {
2302 query = new StringBundler(4 +
2303 (orderByComparator.getOrderByFields().length * 3));
2304 }
2305 else {
2306 query = new StringBundler(4);
2307 }
2308
2309 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2310
2311 query.append(_FINDER_COLUMN_U_D_USERID_2);
2312
2313 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
2314
2315 if (orderByComparator != null) {
2316 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2317 orderByComparator);
2318 }
2319 else
2320 if (pagination) {
2321 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2322 }
2323
2324 String sql = query.toString();
2325
2326 Session session = null;
2327
2328 try {
2329 session = openSession();
2330
2331 Query q = session.createQuery(sql);
2332
2333 QueryPos qPos = QueryPos.getInstance(q);
2334
2335 qPos.add(userId);
2336
2337 qPos.add(delivered);
2338
2339 if (!pagination) {
2340 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2341 getDialect(), start, end, false);
2342
2343 Collections.sort(list);
2344
2345 list = Collections.unmodifiableList(list);
2346 }
2347 else {
2348 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2349 getDialect(), start, end);
2350 }
2351
2352 cacheResult(list);
2353
2354 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2355 }
2356 catch (Exception e) {
2357 FinderCacheUtil.removeResult(finderPath, finderArgs);
2358
2359 throw processException(e);
2360 }
2361 finally {
2362 closeSession(session);
2363 }
2364 }
2365
2366 return list;
2367 }
2368
2369
2378 @Override
2379 public UserNotificationEvent findByU_D_First(long userId,
2380 boolean delivered,
2381 OrderByComparator<UserNotificationEvent> orderByComparator)
2382 throws NoSuchUserNotificationEventException {
2383 UserNotificationEvent userNotificationEvent = fetchByU_D_First(userId,
2384 delivered, orderByComparator);
2385
2386 if (userNotificationEvent != null) {
2387 return userNotificationEvent;
2388 }
2389
2390 StringBundler msg = new StringBundler(6);
2391
2392 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2393
2394 msg.append("userId=");
2395 msg.append(userId);
2396
2397 msg.append(", delivered=");
2398 msg.append(delivered);
2399
2400 msg.append(StringPool.CLOSE_CURLY_BRACE);
2401
2402 throw new NoSuchUserNotificationEventException(msg.toString());
2403 }
2404
2405
2413 @Override
2414 public UserNotificationEvent fetchByU_D_First(long userId,
2415 boolean delivered,
2416 OrderByComparator<UserNotificationEvent> orderByComparator) {
2417 List<UserNotificationEvent> list = findByU_D(userId, delivered, 0, 1,
2418 orderByComparator);
2419
2420 if (!list.isEmpty()) {
2421 return list.get(0);
2422 }
2423
2424 return null;
2425 }
2426
2427
2436 @Override
2437 public UserNotificationEvent findByU_D_Last(long userId, boolean delivered,
2438 OrderByComparator<UserNotificationEvent> orderByComparator)
2439 throws NoSuchUserNotificationEventException {
2440 UserNotificationEvent userNotificationEvent = fetchByU_D_Last(userId,
2441 delivered, orderByComparator);
2442
2443 if (userNotificationEvent != null) {
2444 return userNotificationEvent;
2445 }
2446
2447 StringBundler msg = new StringBundler(6);
2448
2449 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2450
2451 msg.append("userId=");
2452 msg.append(userId);
2453
2454 msg.append(", delivered=");
2455 msg.append(delivered);
2456
2457 msg.append(StringPool.CLOSE_CURLY_BRACE);
2458
2459 throw new NoSuchUserNotificationEventException(msg.toString());
2460 }
2461
2462
2470 @Override
2471 public UserNotificationEvent fetchByU_D_Last(long userId,
2472 boolean delivered,
2473 OrderByComparator<UserNotificationEvent> orderByComparator) {
2474 int count = countByU_D(userId, delivered);
2475
2476 if (count == 0) {
2477 return null;
2478 }
2479
2480 List<UserNotificationEvent> list = findByU_D(userId, delivered,
2481 count - 1, count, orderByComparator);
2482
2483 if (!list.isEmpty()) {
2484 return list.get(0);
2485 }
2486
2487 return null;
2488 }
2489
2490
2500 @Override
2501 public UserNotificationEvent[] findByU_D_PrevAndNext(
2502 long userNotificationEventId, long userId, boolean delivered,
2503 OrderByComparator<UserNotificationEvent> orderByComparator)
2504 throws NoSuchUserNotificationEventException {
2505 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
2506
2507 Session session = null;
2508
2509 try {
2510 session = openSession();
2511
2512 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
2513
2514 array[0] = getByU_D_PrevAndNext(session, userNotificationEvent,
2515 userId, delivered, orderByComparator, true);
2516
2517 array[1] = userNotificationEvent;
2518
2519 array[2] = getByU_D_PrevAndNext(session, userNotificationEvent,
2520 userId, delivered, orderByComparator, false);
2521
2522 return array;
2523 }
2524 catch (Exception e) {
2525 throw processException(e);
2526 }
2527 finally {
2528 closeSession(session);
2529 }
2530 }
2531
2532 protected UserNotificationEvent getByU_D_PrevAndNext(Session session,
2533 UserNotificationEvent userNotificationEvent, long userId,
2534 boolean delivered,
2535 OrderByComparator<UserNotificationEvent> orderByComparator,
2536 boolean previous) {
2537 StringBundler query = null;
2538
2539 if (orderByComparator != null) {
2540 query = new StringBundler(6 +
2541 (orderByComparator.getOrderByFields().length * 6));
2542 }
2543 else {
2544 query = new StringBundler(3);
2545 }
2546
2547 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2548
2549 query.append(_FINDER_COLUMN_U_D_USERID_2);
2550
2551 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
2552
2553 if (orderByComparator != null) {
2554 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2555
2556 if (orderByConditionFields.length > 0) {
2557 query.append(WHERE_AND);
2558 }
2559
2560 for (int i = 0; i < orderByConditionFields.length; i++) {
2561 query.append(_ORDER_BY_ENTITY_ALIAS);
2562 query.append(orderByConditionFields[i]);
2563
2564 if ((i + 1) < orderByConditionFields.length) {
2565 if (orderByComparator.isAscending() ^ previous) {
2566 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2567 }
2568 else {
2569 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2570 }
2571 }
2572 else {
2573 if (orderByComparator.isAscending() ^ previous) {
2574 query.append(WHERE_GREATER_THAN);
2575 }
2576 else {
2577 query.append(WHERE_LESSER_THAN);
2578 }
2579 }
2580 }
2581
2582 query.append(ORDER_BY_CLAUSE);
2583
2584 String[] orderByFields = orderByComparator.getOrderByFields();
2585
2586 for (int i = 0; i < orderByFields.length; i++) {
2587 query.append(_ORDER_BY_ENTITY_ALIAS);
2588 query.append(orderByFields[i]);
2589
2590 if ((i + 1) < orderByFields.length) {
2591 if (orderByComparator.isAscending() ^ previous) {
2592 query.append(ORDER_BY_ASC_HAS_NEXT);
2593 }
2594 else {
2595 query.append(ORDER_BY_DESC_HAS_NEXT);
2596 }
2597 }
2598 else {
2599 if (orderByComparator.isAscending() ^ previous) {
2600 query.append(ORDER_BY_ASC);
2601 }
2602 else {
2603 query.append(ORDER_BY_DESC);
2604 }
2605 }
2606 }
2607 }
2608 else {
2609 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2610 }
2611
2612 String sql = query.toString();
2613
2614 Query q = session.createQuery(sql);
2615
2616 q.setFirstResult(0);
2617 q.setMaxResults(2);
2618
2619 QueryPos qPos = QueryPos.getInstance(q);
2620
2621 qPos.add(userId);
2622
2623 qPos.add(delivered);
2624
2625 if (orderByComparator != null) {
2626 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
2627
2628 for (Object value : values) {
2629 qPos.add(value);
2630 }
2631 }
2632
2633 List<UserNotificationEvent> list = q.list();
2634
2635 if (list.size() == 2) {
2636 return list.get(1);
2637 }
2638 else {
2639 return null;
2640 }
2641 }
2642
2643
2649 @Override
2650 public void removeByU_D(long userId, boolean delivered) {
2651 for (UserNotificationEvent userNotificationEvent : findByU_D(userId,
2652 delivered, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2653 remove(userNotificationEvent);
2654 }
2655 }
2656
2657
2664 @Override
2665 public int countByU_D(long userId, boolean delivered) {
2666 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_D;
2667
2668 Object[] finderArgs = new Object[] { userId, delivered };
2669
2670 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2671 this);
2672
2673 if (count == null) {
2674 StringBundler query = new StringBundler(3);
2675
2676 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2677
2678 query.append(_FINDER_COLUMN_U_D_USERID_2);
2679
2680 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
2681
2682 String sql = query.toString();
2683
2684 Session session = null;
2685
2686 try {
2687 session = openSession();
2688
2689 Query q = session.createQuery(sql);
2690
2691 QueryPos qPos = QueryPos.getInstance(q);
2692
2693 qPos.add(userId);
2694
2695 qPos.add(delivered);
2696
2697 count = (Long)q.uniqueResult();
2698
2699 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2700 }
2701 catch (Exception e) {
2702 FinderCacheUtil.removeResult(finderPath, finderArgs);
2703
2704 throw processException(e);
2705 }
2706 finally {
2707 closeSession(session);
2708 }
2709 }
2710
2711 return count.intValue();
2712 }
2713
2714 private static final String _FINDER_COLUMN_U_D_USERID_2 = "userNotificationEvent.userId = ? AND ";
2715 private static final String _FINDER_COLUMN_U_D_DELIVERED_2 = "userNotificationEvent.delivered = ?";
2716 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2717 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2718 UserNotificationEventImpl.class,
2719 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_A",
2720 new String[] {
2721 Long.class.getName(), Boolean.class.getName(),
2722
2723 Integer.class.getName(), Integer.class.getName(),
2724 OrderByComparator.class.getName()
2725 });
2726 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2727 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2728 UserNotificationEventImpl.class,
2729 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_A",
2730 new String[] { Long.class.getName(), Boolean.class.getName() },
2731 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
2732 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
2733 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
2734 public static final FinderPath FINDER_PATH_COUNT_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2735 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
2736 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_A",
2737 new String[] { Long.class.getName(), Boolean.class.getName() });
2738
2739
2746 @Override
2747 public List<UserNotificationEvent> findByU_A(long userId, boolean archived) {
2748 return findByU_A(userId, archived, QueryUtil.ALL_POS,
2749 QueryUtil.ALL_POS, null);
2750 }
2751
2752
2765 @Override
2766 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
2767 int start, int end) {
2768 return findByU_A(userId, archived, start, end, null);
2769 }
2770
2771
2785 @Override
2786 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
2787 int start, int end,
2788 OrderByComparator<UserNotificationEvent> orderByComparator) {
2789 boolean pagination = true;
2790 FinderPath finderPath = null;
2791 Object[] finderArgs = null;
2792
2793 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2794 (orderByComparator == null)) {
2795 pagination = false;
2796 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A;
2797 finderArgs = new Object[] { userId, archived };
2798 }
2799 else {
2800 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A;
2801 finderArgs = new Object[] {
2802 userId, archived,
2803
2804 start, end, orderByComparator
2805 };
2806 }
2807
2808 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
2809 finderArgs, this);
2810
2811 if ((list != null) && !list.isEmpty()) {
2812 for (UserNotificationEvent userNotificationEvent : list) {
2813 if ((userId != userNotificationEvent.getUserId()) ||
2814 (archived != userNotificationEvent.getArchived())) {
2815 list = null;
2816
2817 break;
2818 }
2819 }
2820 }
2821
2822 if (list == null) {
2823 StringBundler query = null;
2824
2825 if (orderByComparator != null) {
2826 query = new StringBundler(4 +
2827 (orderByComparator.getOrderByFields().length * 3));
2828 }
2829 else {
2830 query = new StringBundler(4);
2831 }
2832
2833 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2834
2835 query.append(_FINDER_COLUMN_U_A_USERID_2);
2836
2837 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
2838
2839 if (orderByComparator != null) {
2840 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2841 orderByComparator);
2842 }
2843 else
2844 if (pagination) {
2845 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2846 }
2847
2848 String sql = query.toString();
2849
2850 Session session = null;
2851
2852 try {
2853 session = openSession();
2854
2855 Query q = session.createQuery(sql);
2856
2857 QueryPos qPos = QueryPos.getInstance(q);
2858
2859 qPos.add(userId);
2860
2861 qPos.add(archived);
2862
2863 if (!pagination) {
2864 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2865 getDialect(), start, end, false);
2866
2867 Collections.sort(list);
2868
2869 list = Collections.unmodifiableList(list);
2870 }
2871 else {
2872 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2873 getDialect(), start, end);
2874 }
2875
2876 cacheResult(list);
2877
2878 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2879 }
2880 catch (Exception e) {
2881 FinderCacheUtil.removeResult(finderPath, finderArgs);
2882
2883 throw processException(e);
2884 }
2885 finally {
2886 closeSession(session);
2887 }
2888 }
2889
2890 return list;
2891 }
2892
2893
2902 @Override
2903 public UserNotificationEvent findByU_A_First(long userId, boolean archived,
2904 OrderByComparator<UserNotificationEvent> orderByComparator)
2905 throws NoSuchUserNotificationEventException {
2906 UserNotificationEvent userNotificationEvent = fetchByU_A_First(userId,
2907 archived, orderByComparator);
2908
2909 if (userNotificationEvent != null) {
2910 return userNotificationEvent;
2911 }
2912
2913 StringBundler msg = new StringBundler(6);
2914
2915 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2916
2917 msg.append("userId=");
2918 msg.append(userId);
2919
2920 msg.append(", archived=");
2921 msg.append(archived);
2922
2923 msg.append(StringPool.CLOSE_CURLY_BRACE);
2924
2925 throw new NoSuchUserNotificationEventException(msg.toString());
2926 }
2927
2928
2936 @Override
2937 public UserNotificationEvent fetchByU_A_First(long userId,
2938 boolean archived,
2939 OrderByComparator<UserNotificationEvent> orderByComparator) {
2940 List<UserNotificationEvent> list = findByU_A(userId, archived, 0, 1,
2941 orderByComparator);
2942
2943 if (!list.isEmpty()) {
2944 return list.get(0);
2945 }
2946
2947 return null;
2948 }
2949
2950
2959 @Override
2960 public UserNotificationEvent findByU_A_Last(long userId, boolean archived,
2961 OrderByComparator<UserNotificationEvent> orderByComparator)
2962 throws NoSuchUserNotificationEventException {
2963 UserNotificationEvent userNotificationEvent = fetchByU_A_Last(userId,
2964 archived, orderByComparator);
2965
2966 if (userNotificationEvent != null) {
2967 return userNotificationEvent;
2968 }
2969
2970 StringBundler msg = new StringBundler(6);
2971
2972 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2973
2974 msg.append("userId=");
2975 msg.append(userId);
2976
2977 msg.append(", archived=");
2978 msg.append(archived);
2979
2980 msg.append(StringPool.CLOSE_CURLY_BRACE);
2981
2982 throw new NoSuchUserNotificationEventException(msg.toString());
2983 }
2984
2985
2993 @Override
2994 public UserNotificationEvent fetchByU_A_Last(long userId, boolean archived,
2995 OrderByComparator<UserNotificationEvent> orderByComparator) {
2996 int count = countByU_A(userId, archived);
2997
2998 if (count == 0) {
2999 return null;
3000 }
3001
3002 List<UserNotificationEvent> list = findByU_A(userId, archived,
3003 count - 1, count, orderByComparator);
3004
3005 if (!list.isEmpty()) {
3006 return list.get(0);
3007 }
3008
3009 return null;
3010 }
3011
3012
3022 @Override
3023 public UserNotificationEvent[] findByU_A_PrevAndNext(
3024 long userNotificationEventId, long userId, boolean archived,
3025 OrderByComparator<UserNotificationEvent> orderByComparator)
3026 throws NoSuchUserNotificationEventException {
3027 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
3028
3029 Session session = null;
3030
3031 try {
3032 session = openSession();
3033
3034 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
3035
3036 array[0] = getByU_A_PrevAndNext(session, userNotificationEvent,
3037 userId, archived, orderByComparator, true);
3038
3039 array[1] = userNotificationEvent;
3040
3041 array[2] = getByU_A_PrevAndNext(session, userNotificationEvent,
3042 userId, archived, orderByComparator, false);
3043
3044 return array;
3045 }
3046 catch (Exception e) {
3047 throw processException(e);
3048 }
3049 finally {
3050 closeSession(session);
3051 }
3052 }
3053
3054 protected UserNotificationEvent getByU_A_PrevAndNext(Session session,
3055 UserNotificationEvent userNotificationEvent, long userId,
3056 boolean archived,
3057 OrderByComparator<UserNotificationEvent> orderByComparator,
3058 boolean previous) {
3059 StringBundler query = null;
3060
3061 if (orderByComparator != null) {
3062 query = new StringBundler(6 +
3063 (orderByComparator.getOrderByFields().length * 6));
3064 }
3065 else {
3066 query = new StringBundler(3);
3067 }
3068
3069 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3070
3071 query.append(_FINDER_COLUMN_U_A_USERID_2);
3072
3073 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
3074
3075 if (orderByComparator != null) {
3076 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3077
3078 if (orderByConditionFields.length > 0) {
3079 query.append(WHERE_AND);
3080 }
3081
3082 for (int i = 0; i < orderByConditionFields.length; i++) {
3083 query.append(_ORDER_BY_ENTITY_ALIAS);
3084 query.append(orderByConditionFields[i]);
3085
3086 if ((i + 1) < orderByConditionFields.length) {
3087 if (orderByComparator.isAscending() ^ previous) {
3088 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3089 }
3090 else {
3091 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3092 }
3093 }
3094 else {
3095 if (orderByComparator.isAscending() ^ previous) {
3096 query.append(WHERE_GREATER_THAN);
3097 }
3098 else {
3099 query.append(WHERE_LESSER_THAN);
3100 }
3101 }
3102 }
3103
3104 query.append(ORDER_BY_CLAUSE);
3105
3106 String[] orderByFields = orderByComparator.getOrderByFields();
3107
3108 for (int i = 0; i < orderByFields.length; i++) {
3109 query.append(_ORDER_BY_ENTITY_ALIAS);
3110 query.append(orderByFields[i]);
3111
3112 if ((i + 1) < orderByFields.length) {
3113 if (orderByComparator.isAscending() ^ previous) {
3114 query.append(ORDER_BY_ASC_HAS_NEXT);
3115 }
3116 else {
3117 query.append(ORDER_BY_DESC_HAS_NEXT);
3118 }
3119 }
3120 else {
3121 if (orderByComparator.isAscending() ^ previous) {
3122 query.append(ORDER_BY_ASC);
3123 }
3124 else {
3125 query.append(ORDER_BY_DESC);
3126 }
3127 }
3128 }
3129 }
3130 else {
3131 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3132 }
3133
3134 String sql = query.toString();
3135
3136 Query q = session.createQuery(sql);
3137
3138 q.setFirstResult(0);
3139 q.setMaxResults(2);
3140
3141 QueryPos qPos = QueryPos.getInstance(q);
3142
3143 qPos.add(userId);
3144
3145 qPos.add(archived);
3146
3147 if (orderByComparator != null) {
3148 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
3149
3150 for (Object value : values) {
3151 qPos.add(value);
3152 }
3153 }
3154
3155 List<UserNotificationEvent> list = q.list();
3156
3157 if (list.size() == 2) {
3158 return list.get(1);
3159 }
3160 else {
3161 return null;
3162 }
3163 }
3164
3165
3171 @Override
3172 public void removeByU_A(long userId, boolean archived) {
3173 for (UserNotificationEvent userNotificationEvent : findByU_A(userId,
3174 archived, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3175 remove(userNotificationEvent);
3176 }
3177 }
3178
3179
3186 @Override
3187 public int countByU_A(long userId, boolean archived) {
3188 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_A;
3189
3190 Object[] finderArgs = new Object[] { userId, archived };
3191
3192 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3193 this);
3194
3195 if (count == null) {
3196 StringBundler query = new StringBundler(3);
3197
3198 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
3199
3200 query.append(_FINDER_COLUMN_U_A_USERID_2);
3201
3202 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
3203
3204 String sql = query.toString();
3205
3206 Session session = null;
3207
3208 try {
3209 session = openSession();
3210
3211 Query q = session.createQuery(sql);
3212
3213 QueryPos qPos = QueryPos.getInstance(q);
3214
3215 qPos.add(userId);
3216
3217 qPos.add(archived);
3218
3219 count = (Long)q.uniqueResult();
3220
3221 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3222 }
3223 catch (Exception e) {
3224 FinderCacheUtil.removeResult(finderPath, finderArgs);
3225
3226 throw processException(e);
3227 }
3228 finally {
3229 closeSession(session);
3230 }
3231 }
3232
3233 return count.intValue();
3234 }
3235
3236 private static final String _FINDER_COLUMN_U_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
3237 private static final String _FINDER_COLUMN_U_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
3238 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3239 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3240 UserNotificationEventImpl.class,
3241 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_D",
3242 new String[] {
3243 Long.class.getName(), Integer.class.getName(),
3244 Boolean.class.getName(),
3245
3246 Integer.class.getName(), Integer.class.getName(),
3247 OrderByComparator.class.getName()
3248 });
3249 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D =
3250 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3251 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3252 UserNotificationEventImpl.class,
3253 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_D",
3254 new String[] {
3255 Long.class.getName(), Integer.class.getName(),
3256 Boolean.class.getName()
3257 },
3258 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
3259 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
3260 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
3261 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
3262 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3263 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
3264 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_D",
3265 new String[] {
3266 Long.class.getName(), Integer.class.getName(),
3267 Boolean.class.getName()
3268 });
3269
3270
3278 @Override
3279 public List<UserNotificationEvent> findByU_DT_D(long userId,
3280 int deliveryType, boolean delivered) {
3281 return findByU_DT_D(userId, deliveryType, delivered, QueryUtil.ALL_POS,
3282 QueryUtil.ALL_POS, null);
3283 }
3284
3285
3299 @Override
3300 public List<UserNotificationEvent> findByU_DT_D(long userId,
3301 int deliveryType, boolean delivered, int start, int end) {
3302 return findByU_DT_D(userId, deliveryType, delivered, start, end, null);
3303 }
3304
3305
3320 @Override
3321 public List<UserNotificationEvent> findByU_DT_D(long userId,
3322 int deliveryType, boolean delivered, int start, int end,
3323 OrderByComparator<UserNotificationEvent> orderByComparator) {
3324 boolean pagination = true;
3325 FinderPath finderPath = null;
3326 Object[] finderArgs = null;
3327
3328 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3329 (orderByComparator == null)) {
3330 pagination = false;
3331 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D;
3332 finderArgs = new Object[] { userId, deliveryType, delivered };
3333 }
3334 else {
3335 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D;
3336 finderArgs = new Object[] {
3337 userId, deliveryType, delivered,
3338
3339 start, end, orderByComparator
3340 };
3341 }
3342
3343 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
3344 finderArgs, this);
3345
3346 if ((list != null) && !list.isEmpty()) {
3347 for (UserNotificationEvent userNotificationEvent : list) {
3348 if ((userId != userNotificationEvent.getUserId()) ||
3349 (deliveryType != userNotificationEvent.getDeliveryType()) ||
3350 (delivered != userNotificationEvent.getDelivered())) {
3351 list = null;
3352
3353 break;
3354 }
3355 }
3356 }
3357
3358 if (list == null) {
3359 StringBundler query = null;
3360
3361 if (orderByComparator != null) {
3362 query = new StringBundler(5 +
3363 (orderByComparator.getOrderByFields().length * 3));
3364 }
3365 else {
3366 query = new StringBundler(5);
3367 }
3368
3369 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3370
3371 query.append(_FINDER_COLUMN_U_DT_D_USERID_2);
3372
3373 query.append(_FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2);
3374
3375 query.append(_FINDER_COLUMN_U_DT_D_DELIVERED_2);
3376
3377 if (orderByComparator != null) {
3378 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3379 orderByComparator);
3380 }
3381 else
3382 if (pagination) {
3383 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3384 }
3385
3386 String sql = query.toString();
3387
3388 Session session = null;
3389
3390 try {
3391 session = openSession();
3392
3393 Query q = session.createQuery(sql);
3394
3395 QueryPos qPos = QueryPos.getInstance(q);
3396
3397 qPos.add(userId);
3398
3399 qPos.add(deliveryType);
3400
3401 qPos.add(delivered);
3402
3403 if (!pagination) {
3404 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3405 getDialect(), start, end, false);
3406
3407 Collections.sort(list);
3408
3409 list = Collections.unmodifiableList(list);
3410 }
3411 else {
3412 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3413 getDialect(), start, end);
3414 }
3415
3416 cacheResult(list);
3417
3418 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3419 }
3420 catch (Exception e) {
3421 FinderCacheUtil.removeResult(finderPath, finderArgs);
3422
3423 throw processException(e);
3424 }
3425 finally {
3426 closeSession(session);
3427 }
3428 }
3429
3430 return list;
3431 }
3432
3433
3443 @Override
3444 public UserNotificationEvent findByU_DT_D_First(long userId,
3445 int deliveryType, boolean delivered,
3446 OrderByComparator<UserNotificationEvent> orderByComparator)
3447 throws NoSuchUserNotificationEventException {
3448 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_First(userId,
3449 deliveryType, delivered, orderByComparator);
3450
3451 if (userNotificationEvent != null) {
3452 return userNotificationEvent;
3453 }
3454
3455 StringBundler msg = new StringBundler(8);
3456
3457 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3458
3459 msg.append("userId=");
3460 msg.append(userId);
3461
3462 msg.append(", deliveryType=");
3463 msg.append(deliveryType);
3464
3465 msg.append(", delivered=");
3466 msg.append(delivered);
3467
3468 msg.append(StringPool.CLOSE_CURLY_BRACE);
3469
3470 throw new NoSuchUserNotificationEventException(msg.toString());
3471 }
3472
3473
3482 @Override
3483 public UserNotificationEvent fetchByU_DT_D_First(long userId,
3484 int deliveryType, boolean delivered,
3485 OrderByComparator<UserNotificationEvent> orderByComparator) {
3486 List<UserNotificationEvent> list = findByU_DT_D(userId, deliveryType,
3487 delivered, 0, 1, orderByComparator);
3488
3489 if (!list.isEmpty()) {
3490 return list.get(0);
3491 }
3492
3493 return null;
3494 }
3495
3496
3506 @Override
3507 public UserNotificationEvent findByU_DT_D_Last(long userId,
3508 int deliveryType, boolean delivered,
3509 OrderByComparator<UserNotificationEvent> orderByComparator)
3510 throws NoSuchUserNotificationEventException {
3511 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_Last(userId,
3512 deliveryType, delivered, orderByComparator);
3513
3514 if (userNotificationEvent != null) {
3515 return userNotificationEvent;
3516 }
3517
3518 StringBundler msg = new StringBundler(8);
3519
3520 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3521
3522 msg.append("userId=");
3523 msg.append(userId);
3524
3525 msg.append(", deliveryType=");
3526 msg.append(deliveryType);
3527
3528 msg.append(", delivered=");
3529 msg.append(delivered);
3530
3531 msg.append(StringPool.CLOSE_CURLY_BRACE);
3532
3533 throw new NoSuchUserNotificationEventException(msg.toString());
3534 }
3535
3536
3545 @Override
3546 public UserNotificationEvent fetchByU_DT_D_Last(long userId,
3547 int deliveryType, boolean delivered,
3548 OrderByComparator<UserNotificationEvent> orderByComparator) {
3549 int count = countByU_DT_D(userId, deliveryType, delivered);
3550
3551 if (count == 0) {
3552 return null;
3553 }
3554
3555 List<UserNotificationEvent> list = findByU_DT_D(userId, deliveryType,
3556 delivered, count - 1, count, orderByComparator);
3557
3558 if (!list.isEmpty()) {
3559 return list.get(0);
3560 }
3561
3562 return null;
3563 }
3564
3565
3576 @Override
3577 public UserNotificationEvent[] findByU_DT_D_PrevAndNext(
3578 long userNotificationEventId, long userId, int deliveryType,
3579 boolean delivered,
3580 OrderByComparator<UserNotificationEvent> orderByComparator)
3581 throws NoSuchUserNotificationEventException {
3582 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
3583
3584 Session session = null;
3585
3586 try {
3587 session = openSession();
3588
3589 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
3590
3591 array[0] = getByU_DT_D_PrevAndNext(session, userNotificationEvent,
3592 userId, deliveryType, delivered, orderByComparator, true);
3593
3594 array[1] = userNotificationEvent;
3595
3596 array[2] = getByU_DT_D_PrevAndNext(session, userNotificationEvent,
3597 userId, deliveryType, delivered, orderByComparator, false);
3598
3599 return array;
3600 }
3601 catch (Exception e) {
3602 throw processException(e);
3603 }
3604 finally {
3605 closeSession(session);
3606 }
3607 }
3608
3609 protected UserNotificationEvent getByU_DT_D_PrevAndNext(Session session,
3610 UserNotificationEvent userNotificationEvent, long userId,
3611 int deliveryType, boolean delivered,
3612 OrderByComparator<UserNotificationEvent> orderByComparator,
3613 boolean previous) {
3614 StringBundler query = null;
3615
3616 if (orderByComparator != null) {
3617 query = new StringBundler(6 +
3618 (orderByComparator.getOrderByFields().length * 6));
3619 }
3620 else {
3621 query = new StringBundler(3);
3622 }
3623
3624 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3625
3626 query.append(_FINDER_COLUMN_U_DT_D_USERID_2);
3627
3628 query.append(_FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2);
3629
3630 query.append(_FINDER_COLUMN_U_DT_D_DELIVERED_2);
3631
3632 if (orderByComparator != null) {
3633 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3634
3635 if (orderByConditionFields.length > 0) {
3636 query.append(WHERE_AND);
3637 }
3638
3639 for (int i = 0; i < orderByConditionFields.length; i++) {
3640 query.append(_ORDER_BY_ENTITY_ALIAS);
3641 query.append(orderByConditionFields[i]);
3642
3643 if ((i + 1) < orderByConditionFields.length) {
3644 if (orderByComparator.isAscending() ^ previous) {
3645 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3646 }
3647 else {
3648 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3649 }
3650 }
3651 else {
3652 if (orderByComparator.isAscending() ^ previous) {
3653 query.append(WHERE_GREATER_THAN);
3654 }
3655 else {
3656 query.append(WHERE_LESSER_THAN);
3657 }
3658 }
3659 }
3660
3661 query.append(ORDER_BY_CLAUSE);
3662
3663 String[] orderByFields = orderByComparator.getOrderByFields();
3664
3665 for (int i = 0; i < orderByFields.length; i++) {
3666 query.append(_ORDER_BY_ENTITY_ALIAS);
3667 query.append(orderByFields[i]);
3668
3669 if ((i + 1) < orderByFields.length) {
3670 if (orderByComparator.isAscending() ^ previous) {
3671 query.append(ORDER_BY_ASC_HAS_NEXT);
3672 }
3673 else {
3674 query.append(ORDER_BY_DESC_HAS_NEXT);
3675 }
3676 }
3677 else {
3678 if (orderByComparator.isAscending() ^ previous) {
3679 query.append(ORDER_BY_ASC);
3680 }
3681 else {
3682 query.append(ORDER_BY_DESC);
3683 }
3684 }
3685 }
3686 }
3687 else {
3688 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3689 }
3690
3691 String sql = query.toString();
3692
3693 Query q = session.createQuery(sql);
3694
3695 q.setFirstResult(0);
3696 q.setMaxResults(2);
3697
3698 QueryPos qPos = QueryPos.getInstance(q);
3699
3700 qPos.add(userId);
3701
3702 qPos.add(deliveryType);
3703
3704 qPos.add(delivered);
3705
3706 if (orderByComparator != null) {
3707 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
3708
3709 for (Object value : values) {
3710 qPos.add(value);
3711 }
3712 }
3713
3714 List<UserNotificationEvent> list = q.list();
3715
3716 if (list.size() == 2) {
3717 return list.get(1);
3718 }
3719 else {
3720 return null;
3721 }
3722 }
3723
3724
3731 @Override
3732 public void removeByU_DT_D(long userId, int deliveryType, boolean delivered) {
3733 for (UserNotificationEvent userNotificationEvent : findByU_DT_D(
3734 userId, deliveryType, delivered, QueryUtil.ALL_POS,
3735 QueryUtil.ALL_POS, null)) {
3736 remove(userNotificationEvent);
3737 }
3738 }
3739
3740
3748 @Override
3749 public int countByU_DT_D(long userId, int deliveryType, boolean delivered) {
3750 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_D;
3751
3752 Object[] finderArgs = new Object[] { userId, deliveryType, delivered };
3753
3754 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3755 this);
3756
3757 if (count == null) {
3758 StringBundler query = new StringBundler(4);
3759
3760 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
3761
3762 query.append(_FINDER_COLUMN_U_DT_D_USERID_2);
3763
3764 query.append(_FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2);
3765
3766 query.append(_FINDER_COLUMN_U_DT_D_DELIVERED_2);
3767
3768 String sql = query.toString();
3769
3770 Session session = null;
3771
3772 try {
3773 session = openSession();
3774
3775 Query q = session.createQuery(sql);
3776
3777 QueryPos qPos = QueryPos.getInstance(q);
3778
3779 qPos.add(userId);
3780
3781 qPos.add(deliveryType);
3782
3783 qPos.add(delivered);
3784
3785 count = (Long)q.uniqueResult();
3786
3787 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3788 }
3789 catch (Exception e) {
3790 FinderCacheUtil.removeResult(finderPath, finderArgs);
3791
3792 throw processException(e);
3793 }
3794 finally {
3795 closeSession(session);
3796 }
3797 }
3798
3799 return count.intValue();
3800 }
3801
3802 private static final String _FINDER_COLUMN_U_DT_D_USERID_2 = "userNotificationEvent.userId = ? AND ";
3803 private static final String _FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
3804 private static final String _FINDER_COLUMN_U_DT_D_DELIVERED_2 = "userNotificationEvent.delivered = ?";
3805 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3806 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3807 UserNotificationEventImpl.class,
3808 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_A",
3809 new String[] {
3810 Long.class.getName(), Integer.class.getName(),
3811 Boolean.class.getName(),
3812
3813 Integer.class.getName(), Integer.class.getName(),
3814 OrderByComparator.class.getName()
3815 });
3816 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A =
3817 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3818 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3819 UserNotificationEventImpl.class,
3820 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_A",
3821 new String[] {
3822 Long.class.getName(), Integer.class.getName(),
3823 Boolean.class.getName()
3824 },
3825 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
3826 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
3827 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
3828 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
3829 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3830 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
3831 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_A",
3832 new String[] {
3833 Long.class.getName(), Integer.class.getName(),
3834 Boolean.class.getName()
3835 });
3836
3837
3845 @Override
3846 public List<UserNotificationEvent> findByU_DT_A(long userId,
3847 int deliveryType, boolean archived) {
3848 return findByU_DT_A(userId, deliveryType, archived, QueryUtil.ALL_POS,
3849 QueryUtil.ALL_POS, null);
3850 }
3851
3852
3866 @Override
3867 public List<UserNotificationEvent> findByU_DT_A(long userId,
3868 int deliveryType, boolean archived, int start, int end) {
3869 return findByU_DT_A(userId, deliveryType, archived, start, end, null);
3870 }
3871
3872
3887 @Override
3888 public List<UserNotificationEvent> findByU_DT_A(long userId,
3889 int deliveryType, boolean archived, int start, int end,
3890 OrderByComparator<UserNotificationEvent> orderByComparator) {
3891 boolean pagination = true;
3892 FinderPath finderPath = null;
3893 Object[] finderArgs = null;
3894
3895 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3896 (orderByComparator == null)) {
3897 pagination = false;
3898 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A;
3899 finderArgs = new Object[] { userId, deliveryType, archived };
3900 }
3901 else {
3902 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A;
3903 finderArgs = new Object[] {
3904 userId, deliveryType, archived,
3905
3906 start, end, orderByComparator
3907 };
3908 }
3909
3910 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
3911 finderArgs, this);
3912
3913 if ((list != null) && !list.isEmpty()) {
3914 for (UserNotificationEvent userNotificationEvent : list) {
3915 if ((userId != userNotificationEvent.getUserId()) ||
3916 (deliveryType != userNotificationEvent.getDeliveryType()) ||
3917 (archived != userNotificationEvent.getArchived())) {
3918 list = null;
3919
3920 break;
3921 }
3922 }
3923 }
3924
3925 if (list == null) {
3926 StringBundler query = null;
3927
3928 if (orderByComparator != null) {
3929 query = new StringBundler(5 +
3930 (orderByComparator.getOrderByFields().length * 3));
3931 }
3932 else {
3933 query = new StringBundler(5);
3934 }
3935
3936 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3937
3938 query.append(_FINDER_COLUMN_U_DT_A_USERID_2);
3939
3940 query.append(_FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2);
3941
3942 query.append(_FINDER_COLUMN_U_DT_A_ARCHIVED_2);
3943
3944 if (orderByComparator != null) {
3945 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3946 orderByComparator);
3947 }
3948 else
3949 if (pagination) {
3950 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3951 }
3952
3953 String sql = query.toString();
3954
3955 Session session = null;
3956
3957 try {
3958 session = openSession();
3959
3960 Query q = session.createQuery(sql);
3961
3962 QueryPos qPos = QueryPos.getInstance(q);
3963
3964 qPos.add(userId);
3965
3966 qPos.add(deliveryType);
3967
3968 qPos.add(archived);
3969
3970 if (!pagination) {
3971 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3972 getDialect(), start, end, false);
3973
3974 Collections.sort(list);
3975
3976 list = Collections.unmodifiableList(list);
3977 }
3978 else {
3979 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3980 getDialect(), start, end);
3981 }
3982
3983 cacheResult(list);
3984
3985 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3986 }
3987 catch (Exception e) {
3988 FinderCacheUtil.removeResult(finderPath, finderArgs);
3989
3990 throw processException(e);
3991 }
3992 finally {
3993 closeSession(session);
3994 }
3995 }
3996
3997 return list;
3998 }
3999
4000
4010 @Override
4011 public UserNotificationEvent findByU_DT_A_First(long userId,
4012 int deliveryType, boolean archived,
4013 OrderByComparator<UserNotificationEvent> orderByComparator)
4014 throws NoSuchUserNotificationEventException {
4015 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_First(userId,
4016 deliveryType, archived, orderByComparator);
4017
4018 if (userNotificationEvent != null) {
4019 return userNotificationEvent;
4020 }
4021
4022 StringBundler msg = new StringBundler(8);
4023
4024 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4025
4026 msg.append("userId=");
4027 msg.append(userId);
4028
4029 msg.append(", deliveryType=");
4030 msg.append(deliveryType);
4031
4032 msg.append(", archived=");
4033 msg.append(archived);
4034
4035 msg.append(StringPool.CLOSE_CURLY_BRACE);
4036
4037 throw new NoSuchUserNotificationEventException(msg.toString());
4038 }
4039
4040
4049 @Override
4050 public UserNotificationEvent fetchByU_DT_A_First(long userId,
4051 int deliveryType, boolean archived,
4052 OrderByComparator<UserNotificationEvent> orderByComparator) {
4053 List<UserNotificationEvent> list = findByU_DT_A(userId, deliveryType,
4054 archived, 0, 1, orderByComparator);
4055
4056 if (!list.isEmpty()) {
4057 return list.get(0);
4058 }
4059
4060 return null;
4061 }
4062
4063
4073 @Override
4074 public UserNotificationEvent findByU_DT_A_Last(long userId,
4075 int deliveryType, boolean archived,
4076 OrderByComparator<UserNotificationEvent> orderByComparator)
4077 throws NoSuchUserNotificationEventException {
4078 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_Last(userId,
4079 deliveryType, archived, orderByComparator);
4080
4081 if (userNotificationEvent != null) {
4082 return userNotificationEvent;
4083 }
4084
4085 StringBundler msg = new StringBundler(8);
4086
4087 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4088
4089 msg.append("userId=");
4090 msg.append(userId);
4091
4092 msg.append(", deliveryType=");
4093 msg.append(deliveryType);
4094
4095 msg.append(", archived=");
4096 msg.append(archived);
4097
4098 msg.append(StringPool.CLOSE_CURLY_BRACE);
4099
4100 throw new NoSuchUserNotificationEventException(msg.toString());
4101 }
4102
4103
4112 @Override
4113 public UserNotificationEvent fetchByU_DT_A_Last(long userId,
4114 int deliveryType, boolean archived,
4115 OrderByComparator<UserNotificationEvent> orderByComparator) {
4116 int count = countByU_DT_A(userId, deliveryType, archived);
4117
4118 if (count == 0) {
4119 return null;
4120 }
4121
4122 List<UserNotificationEvent> list = findByU_DT_A(userId, deliveryType,
4123 archived, count - 1, count, orderByComparator);
4124
4125 if (!list.isEmpty()) {
4126 return list.get(0);
4127 }
4128
4129 return null;
4130 }
4131
4132
4143 @Override
4144 public UserNotificationEvent[] findByU_DT_A_PrevAndNext(
4145 long userNotificationEventId, long userId, int deliveryType,
4146 boolean archived,
4147 OrderByComparator<UserNotificationEvent> orderByComparator)
4148 throws NoSuchUserNotificationEventException {
4149 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
4150
4151 Session session = null;
4152
4153 try {
4154 session = openSession();
4155
4156 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
4157
4158 array[0] = getByU_DT_A_PrevAndNext(session, userNotificationEvent,
4159 userId, deliveryType, archived, orderByComparator, true);
4160
4161 array[1] = userNotificationEvent;
4162
4163 array[2] = getByU_DT_A_PrevAndNext(session, userNotificationEvent,
4164 userId, deliveryType, archived, orderByComparator, false);
4165
4166 return array;
4167 }
4168 catch (Exception e) {
4169 throw processException(e);
4170 }
4171 finally {
4172 closeSession(session);
4173 }
4174 }
4175
4176 protected UserNotificationEvent getByU_DT_A_PrevAndNext(Session session,
4177 UserNotificationEvent userNotificationEvent, long userId,
4178 int deliveryType, boolean archived,
4179 OrderByComparator<UserNotificationEvent> orderByComparator,
4180 boolean previous) {
4181 StringBundler query = null;
4182
4183 if (orderByComparator != null) {
4184 query = new StringBundler(6 +
4185 (orderByComparator.getOrderByFields().length * 6));
4186 }
4187 else {
4188 query = new StringBundler(3);
4189 }
4190
4191 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4192
4193 query.append(_FINDER_COLUMN_U_DT_A_USERID_2);
4194
4195 query.append(_FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2);
4196
4197 query.append(_FINDER_COLUMN_U_DT_A_ARCHIVED_2);
4198
4199 if (orderByComparator != null) {
4200 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4201
4202 if (orderByConditionFields.length > 0) {
4203 query.append(WHERE_AND);
4204 }
4205
4206 for (int i = 0; i < orderByConditionFields.length; i++) {
4207 query.append(_ORDER_BY_ENTITY_ALIAS);
4208 query.append(orderByConditionFields[i]);
4209
4210 if ((i + 1) < orderByConditionFields.length) {
4211 if (orderByComparator.isAscending() ^ previous) {
4212 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4213 }
4214 else {
4215 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4216 }
4217 }
4218 else {
4219 if (orderByComparator.isAscending() ^ previous) {
4220 query.append(WHERE_GREATER_THAN);
4221 }
4222 else {
4223 query.append(WHERE_LESSER_THAN);
4224 }
4225 }
4226 }
4227
4228 query.append(ORDER_BY_CLAUSE);
4229
4230 String[] orderByFields = orderByComparator.getOrderByFields();
4231
4232 for (int i = 0; i < orderByFields.length; i++) {
4233 query.append(_ORDER_BY_ENTITY_ALIAS);
4234 query.append(orderByFields[i]);
4235
4236 if ((i + 1) < orderByFields.length) {
4237 if (orderByComparator.isAscending() ^ previous) {
4238 query.append(ORDER_BY_ASC_HAS_NEXT);
4239 }
4240 else {
4241 query.append(ORDER_BY_DESC_HAS_NEXT);
4242 }
4243 }
4244 else {
4245 if (orderByComparator.isAscending() ^ previous) {
4246 query.append(ORDER_BY_ASC);
4247 }
4248 else {
4249 query.append(ORDER_BY_DESC);
4250 }
4251 }
4252 }
4253 }
4254 else {
4255 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
4256 }
4257
4258 String sql = query.toString();
4259
4260 Query q = session.createQuery(sql);
4261
4262 q.setFirstResult(0);
4263 q.setMaxResults(2);
4264
4265 QueryPos qPos = QueryPos.getInstance(q);
4266
4267 qPos.add(userId);
4268
4269 qPos.add(deliveryType);
4270
4271 qPos.add(archived);
4272
4273 if (orderByComparator != null) {
4274 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
4275
4276 for (Object value : values) {
4277 qPos.add(value);
4278 }
4279 }
4280
4281 List<UserNotificationEvent> list = q.list();
4282
4283 if (list.size() == 2) {
4284 return list.get(1);
4285 }
4286 else {
4287 return null;
4288 }
4289 }
4290
4291
4298 @Override
4299 public void removeByU_DT_A(long userId, int deliveryType, boolean archived) {
4300 for (UserNotificationEvent userNotificationEvent : findByU_DT_A(
4301 userId, deliveryType, archived, QueryUtil.ALL_POS,
4302 QueryUtil.ALL_POS, null)) {
4303 remove(userNotificationEvent);
4304 }
4305 }
4306
4307
4315 @Override
4316 public int countByU_DT_A(long userId, int deliveryType, boolean archived) {
4317 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_A;
4318
4319 Object[] finderArgs = new Object[] { userId, deliveryType, archived };
4320
4321 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4322 this);
4323
4324 if (count == null) {
4325 StringBundler query = new StringBundler(4);
4326
4327 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
4328
4329 query.append(_FINDER_COLUMN_U_DT_A_USERID_2);
4330
4331 query.append(_FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2);
4332
4333 query.append(_FINDER_COLUMN_U_DT_A_ARCHIVED_2);
4334
4335 String sql = query.toString();
4336
4337 Session session = null;
4338
4339 try {
4340 session = openSession();
4341
4342 Query q = session.createQuery(sql);
4343
4344 QueryPos qPos = QueryPos.getInstance(q);
4345
4346 qPos.add(userId);
4347
4348 qPos.add(deliveryType);
4349
4350 qPos.add(archived);
4351
4352 count = (Long)q.uniqueResult();
4353
4354 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4355 }
4356 catch (Exception e) {
4357 FinderCacheUtil.removeResult(finderPath, finderArgs);
4358
4359 throw processException(e);
4360 }
4361 finally {
4362 closeSession(session);
4363 }
4364 }
4365
4366 return count.intValue();
4367 }
4368
4369 private static final String _FINDER_COLUMN_U_DT_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
4370 private static final String _FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
4371 private static final String _FINDER_COLUMN_U_DT_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
4372 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4373 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
4374 UserNotificationEventImpl.class,
4375 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_D_A",
4376 new String[] {
4377 Long.class.getName(), Boolean.class.getName(),
4378 Boolean.class.getName(),
4379
4380 Integer.class.getName(), Integer.class.getName(),
4381 OrderByComparator.class.getName()
4382 });
4383 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4384 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
4385 UserNotificationEventImpl.class,
4386 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_D_A",
4387 new String[] {
4388 Long.class.getName(), Boolean.class.getName(),
4389 Boolean.class.getName()
4390 },
4391 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
4392 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
4393 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
4394 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
4395 public static final FinderPath FINDER_PATH_COUNT_BY_U_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4396 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
4397 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_D_A",
4398 new String[] {
4399 Long.class.getName(), Boolean.class.getName(),
4400 Boolean.class.getName()
4401 });
4402
4403
4411 @Override
4412 public List<UserNotificationEvent> findByU_D_A(long userId,
4413 boolean delivered, boolean actionRequired) {
4414 return findByU_D_A(userId, delivered, actionRequired,
4415 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4416 }
4417
4418
4432 @Override
4433 public List<UserNotificationEvent> findByU_D_A(long userId,
4434 boolean delivered, boolean actionRequired, int start, int end) {
4435 return findByU_D_A(userId, delivered, actionRequired, start, end, null);
4436 }
4437
4438
4453 @Override
4454 public List<UserNotificationEvent> findByU_D_A(long userId,
4455 boolean delivered, boolean actionRequired, int start, int end,
4456 OrderByComparator<UserNotificationEvent> orderByComparator) {
4457 boolean pagination = true;
4458 FinderPath finderPath = null;
4459 Object[] finderArgs = null;
4460
4461 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4462 (orderByComparator == null)) {
4463 pagination = false;
4464 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A;
4465 finderArgs = new Object[] { userId, delivered, actionRequired };
4466 }
4467 else {
4468 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D_A;
4469 finderArgs = new Object[] {
4470 userId, delivered, actionRequired,
4471
4472 start, end, orderByComparator
4473 };
4474 }
4475
4476 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
4477 finderArgs, this);
4478
4479 if ((list != null) && !list.isEmpty()) {
4480 for (UserNotificationEvent userNotificationEvent : list) {
4481 if ((userId != userNotificationEvent.getUserId()) ||
4482 (delivered != userNotificationEvent.getDelivered()) ||
4483 (actionRequired != userNotificationEvent.getActionRequired())) {
4484 list = null;
4485
4486 break;
4487 }
4488 }
4489 }
4490
4491 if (list == null) {
4492 StringBundler query = null;
4493
4494 if (orderByComparator != null) {
4495 query = new StringBundler(5 +
4496 (orderByComparator.getOrderByFields().length * 3));
4497 }
4498 else {
4499 query = new StringBundler(5);
4500 }
4501
4502 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4503
4504 query.append(_FINDER_COLUMN_U_D_A_USERID_2);
4505
4506 query.append(_FINDER_COLUMN_U_D_A_DELIVERED_2);
4507
4508 query.append(_FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2);
4509
4510 if (orderByComparator != null) {
4511 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4512 orderByComparator);
4513 }
4514 else
4515 if (pagination) {
4516 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
4517 }
4518
4519 String sql = query.toString();
4520
4521 Session session = null;
4522
4523 try {
4524 session = openSession();
4525
4526 Query q = session.createQuery(sql);
4527
4528 QueryPos qPos = QueryPos.getInstance(q);
4529
4530 qPos.add(userId);
4531
4532 qPos.add(delivered);
4533
4534 qPos.add(actionRequired);
4535
4536 if (!pagination) {
4537 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4538 getDialect(), start, end, false);
4539
4540 Collections.sort(list);
4541
4542 list = Collections.unmodifiableList(list);
4543 }
4544 else {
4545 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4546 getDialect(), start, end);
4547 }
4548
4549 cacheResult(list);
4550
4551 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4552 }
4553 catch (Exception e) {
4554 FinderCacheUtil.removeResult(finderPath, finderArgs);
4555
4556 throw processException(e);
4557 }
4558 finally {
4559 closeSession(session);
4560 }
4561 }
4562
4563 return list;
4564 }
4565
4566
4576 @Override
4577 public UserNotificationEvent findByU_D_A_First(long userId,
4578 boolean delivered, boolean actionRequired,
4579 OrderByComparator<UserNotificationEvent> orderByComparator)
4580 throws NoSuchUserNotificationEventException {
4581 UserNotificationEvent userNotificationEvent = fetchByU_D_A_First(userId,
4582 delivered, actionRequired, orderByComparator);
4583
4584 if (userNotificationEvent != null) {
4585 return userNotificationEvent;
4586 }
4587
4588 StringBundler msg = new StringBundler(8);
4589
4590 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4591
4592 msg.append("userId=");
4593 msg.append(userId);
4594
4595 msg.append(", delivered=");
4596 msg.append(delivered);
4597
4598 msg.append(", actionRequired=");
4599 msg.append(actionRequired);
4600
4601 msg.append(StringPool.CLOSE_CURLY_BRACE);
4602
4603 throw new NoSuchUserNotificationEventException(msg.toString());
4604 }
4605
4606
4615 @Override
4616 public UserNotificationEvent fetchByU_D_A_First(long userId,
4617 boolean delivered, boolean actionRequired,
4618 OrderByComparator<UserNotificationEvent> orderByComparator) {
4619 List<UserNotificationEvent> list = findByU_D_A(userId, delivered,
4620 actionRequired, 0, 1, orderByComparator);
4621
4622 if (!list.isEmpty()) {
4623 return list.get(0);
4624 }
4625
4626 return null;
4627 }
4628
4629
4639 @Override
4640 public UserNotificationEvent findByU_D_A_Last(long userId,
4641 boolean delivered, boolean actionRequired,
4642 OrderByComparator<UserNotificationEvent> orderByComparator)
4643 throws NoSuchUserNotificationEventException {
4644 UserNotificationEvent userNotificationEvent = fetchByU_D_A_Last(userId,
4645 delivered, actionRequired, orderByComparator);
4646
4647 if (userNotificationEvent != null) {
4648 return userNotificationEvent;
4649 }
4650
4651 StringBundler msg = new StringBundler(8);
4652
4653 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4654
4655 msg.append("userId=");
4656 msg.append(userId);
4657
4658 msg.append(", delivered=");
4659 msg.append(delivered);
4660
4661 msg.append(", actionRequired=");
4662 msg.append(actionRequired);
4663
4664 msg.append(StringPool.CLOSE_CURLY_BRACE);
4665
4666 throw new NoSuchUserNotificationEventException(msg.toString());
4667 }
4668
4669
4678 @Override
4679 public UserNotificationEvent fetchByU_D_A_Last(long userId,
4680 boolean delivered, boolean actionRequired,
4681 OrderByComparator<UserNotificationEvent> orderByComparator) {
4682 int count = countByU_D_A(userId, delivered, actionRequired);
4683
4684 if (count == 0) {
4685 return null;
4686 }
4687
4688 List<UserNotificationEvent> list = findByU_D_A(userId, delivered,
4689 actionRequired, count - 1, count, orderByComparator);
4690
4691 if (!list.isEmpty()) {
4692 return list.get(0);
4693 }
4694
4695 return null;
4696 }
4697
4698
4709 @Override
4710 public UserNotificationEvent[] findByU_D_A_PrevAndNext(
4711 long userNotificationEventId, long userId, boolean delivered,
4712 boolean actionRequired,
4713 OrderByComparator<UserNotificationEvent> orderByComparator)
4714 throws NoSuchUserNotificationEventException {
4715 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
4716
4717 Session session = null;
4718
4719 try {
4720 session = openSession();
4721
4722 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
4723
4724 array[0] = getByU_D_A_PrevAndNext(session, userNotificationEvent,
4725 userId, delivered, actionRequired, orderByComparator, true);
4726
4727 array[1] = userNotificationEvent;
4728
4729 array[2] = getByU_D_A_PrevAndNext(session, userNotificationEvent,
4730 userId, delivered, actionRequired, orderByComparator, false);
4731
4732 return array;
4733 }
4734 catch (Exception e) {
4735 throw processException(e);
4736 }
4737 finally {
4738 closeSession(session);
4739 }
4740 }
4741
4742 protected UserNotificationEvent getByU_D_A_PrevAndNext(Session session,
4743 UserNotificationEvent userNotificationEvent, long userId,
4744 boolean delivered, boolean actionRequired,
4745 OrderByComparator<UserNotificationEvent> orderByComparator,
4746 boolean previous) {
4747 StringBundler query = null;
4748
4749 if (orderByComparator != null) {
4750 query = new StringBundler(6 +
4751 (orderByComparator.getOrderByFields().length * 6));
4752 }
4753 else {
4754 query = new StringBundler(3);
4755 }
4756
4757 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4758
4759 query.append(_FINDER_COLUMN_U_D_A_USERID_2);
4760
4761 query.append(_FINDER_COLUMN_U_D_A_DELIVERED_2);
4762
4763 query.append(_FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2);
4764
4765 if (orderByComparator != null) {
4766 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4767
4768 if (orderByConditionFields.length > 0) {
4769 query.append(WHERE_AND);
4770 }
4771
4772 for (int i = 0; i < orderByConditionFields.length; i++) {
4773 query.append(_ORDER_BY_ENTITY_ALIAS);
4774 query.append(orderByConditionFields[i]);
4775
4776 if ((i + 1) < orderByConditionFields.length) {
4777 if (orderByComparator.isAscending() ^ previous) {
4778 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4779 }
4780 else {
4781 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4782 }
4783 }
4784 else {
4785 if (orderByComparator.isAscending() ^ previous) {
4786 query.append(WHERE_GREATER_THAN);
4787 }
4788 else {
4789 query.append(WHERE_LESSER_THAN);
4790 }
4791 }
4792 }
4793
4794 query.append(ORDER_BY_CLAUSE);
4795
4796 String[] orderByFields = orderByComparator.getOrderByFields();
4797
4798 for (int i = 0; i < orderByFields.length; i++) {
4799 query.append(_ORDER_BY_ENTITY_ALIAS);
4800 query.append(orderByFields[i]);
4801
4802 if ((i + 1) < orderByFields.length) {
4803 if (orderByComparator.isAscending() ^ previous) {
4804 query.append(ORDER_BY_ASC_HAS_NEXT);
4805 }
4806 else {
4807 query.append(ORDER_BY_DESC_HAS_NEXT);
4808 }
4809 }
4810 else {
4811 if (orderByComparator.isAscending() ^ previous) {
4812 query.append(ORDER_BY_ASC);
4813 }
4814 else {
4815 query.append(ORDER_BY_DESC);
4816 }
4817 }
4818 }
4819 }
4820 else {
4821 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
4822 }
4823
4824 String sql = query.toString();
4825
4826 Query q = session.createQuery(sql);
4827
4828 q.setFirstResult(0);
4829 q.setMaxResults(2);
4830
4831 QueryPos qPos = QueryPos.getInstance(q);
4832
4833 qPos.add(userId);
4834
4835 qPos.add(delivered);
4836
4837 qPos.add(actionRequired);
4838
4839 if (orderByComparator != null) {
4840 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
4841
4842 for (Object value : values) {
4843 qPos.add(value);
4844 }
4845 }
4846
4847 List<UserNotificationEvent> list = q.list();
4848
4849 if (list.size() == 2) {
4850 return list.get(1);
4851 }
4852 else {
4853 return null;
4854 }
4855 }
4856
4857
4864 @Override
4865 public void removeByU_D_A(long userId, boolean delivered,
4866 boolean actionRequired) {
4867 for (UserNotificationEvent userNotificationEvent : findByU_D_A(userId,
4868 delivered, actionRequired, QueryUtil.ALL_POS,
4869 QueryUtil.ALL_POS, null)) {
4870 remove(userNotificationEvent);
4871 }
4872 }
4873
4874
4882 @Override
4883 public int countByU_D_A(long userId, boolean delivered,
4884 boolean actionRequired) {
4885 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_D_A;
4886
4887 Object[] finderArgs = new Object[] { userId, delivered, actionRequired };
4888
4889 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4890 this);
4891
4892 if (count == null) {
4893 StringBundler query = new StringBundler(4);
4894
4895 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
4896
4897 query.append(_FINDER_COLUMN_U_D_A_USERID_2);
4898
4899 query.append(_FINDER_COLUMN_U_D_A_DELIVERED_2);
4900
4901 query.append(_FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2);
4902
4903 String sql = query.toString();
4904
4905 Session session = null;
4906
4907 try {
4908 session = openSession();
4909
4910 Query q = session.createQuery(sql);
4911
4912 QueryPos qPos = QueryPos.getInstance(q);
4913
4914 qPos.add(userId);
4915
4916 qPos.add(delivered);
4917
4918 qPos.add(actionRequired);
4919
4920 count = (Long)q.uniqueResult();
4921
4922 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4923 }
4924 catch (Exception e) {
4925 FinderCacheUtil.removeResult(finderPath, finderArgs);
4926
4927 throw processException(e);
4928 }
4929 finally {
4930 closeSession(session);
4931 }
4932 }
4933
4934 return count.intValue();
4935 }
4936
4937 private static final String _FINDER_COLUMN_U_D_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
4938 private static final String _FINDER_COLUMN_U_D_A_DELIVERED_2 = "userNotificationEvent.delivered = ? AND ";
4939 private static final String _FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ?";
4940 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4941 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
4942 UserNotificationEventImpl.class,
4943 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_A_A",
4944 new String[] {
4945 Long.class.getName(), Boolean.class.getName(),
4946 Boolean.class.getName(),
4947
4948 Integer.class.getName(), Integer.class.getName(),
4949 OrderByComparator.class.getName()
4950 });
4951 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4952 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
4953 UserNotificationEventImpl.class,
4954 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_A_A",
4955 new String[] {
4956 Long.class.getName(), Boolean.class.getName(),
4957 Boolean.class.getName()
4958 },
4959 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
4960 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
4961 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
4962 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
4963 public static final FinderPath FINDER_PATH_COUNT_BY_U_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4964 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
4965 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_A_A",
4966 new String[] {
4967 Long.class.getName(), Boolean.class.getName(),
4968 Boolean.class.getName()
4969 });
4970
4971
4979 @Override
4980 public List<UserNotificationEvent> findByU_A_A(long userId,
4981 boolean actionRequired, boolean archived) {
4982 return findByU_A_A(userId, actionRequired, archived, QueryUtil.ALL_POS,
4983 QueryUtil.ALL_POS, null);
4984 }
4985
4986
5000 @Override
5001 public List<UserNotificationEvent> findByU_A_A(long userId,
5002 boolean actionRequired, boolean archived, int start, int end) {
5003 return findByU_A_A(userId, actionRequired, archived, start, end, null);
5004 }
5005
5006
5021 @Override
5022 public List<UserNotificationEvent> findByU_A_A(long userId,
5023 boolean actionRequired, boolean archived, int start, int end,
5024 OrderByComparator<UserNotificationEvent> orderByComparator) {
5025 boolean pagination = true;
5026 FinderPath finderPath = null;
5027 Object[] finderArgs = null;
5028
5029 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5030 (orderByComparator == null)) {
5031 pagination = false;
5032 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A;
5033 finderArgs = new Object[] { userId, actionRequired, archived };
5034 }
5035 else {
5036 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A_A;
5037 finderArgs = new Object[] {
5038 userId, actionRequired, archived,
5039
5040 start, end, orderByComparator
5041 };
5042 }
5043
5044 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
5045 finderArgs, this);
5046
5047 if ((list != null) && !list.isEmpty()) {
5048 for (UserNotificationEvent userNotificationEvent : list) {
5049 if ((userId != userNotificationEvent.getUserId()) ||
5050 (actionRequired != userNotificationEvent.getActionRequired()) ||
5051 (archived != userNotificationEvent.getArchived())) {
5052 list = null;
5053
5054 break;
5055 }
5056 }
5057 }
5058
5059 if (list == null) {
5060 StringBundler query = null;
5061
5062 if (orderByComparator != null) {
5063 query = new StringBundler(5 +
5064 (orderByComparator.getOrderByFields().length * 3));
5065 }
5066 else {
5067 query = new StringBundler(5);
5068 }
5069
5070 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5071
5072 query.append(_FINDER_COLUMN_U_A_A_USERID_2);
5073
5074 query.append(_FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2);
5075
5076 query.append(_FINDER_COLUMN_U_A_A_ARCHIVED_2);
5077
5078 if (orderByComparator != null) {
5079 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5080 orderByComparator);
5081 }
5082 else
5083 if (pagination) {
5084 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5085 }
5086
5087 String sql = query.toString();
5088
5089 Session session = null;
5090
5091 try {
5092 session = openSession();
5093
5094 Query q = session.createQuery(sql);
5095
5096 QueryPos qPos = QueryPos.getInstance(q);
5097
5098 qPos.add(userId);
5099
5100 qPos.add(actionRequired);
5101
5102 qPos.add(archived);
5103
5104 if (!pagination) {
5105 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5106 getDialect(), start, end, false);
5107
5108 Collections.sort(list);
5109
5110 list = Collections.unmodifiableList(list);
5111 }
5112 else {
5113 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5114 getDialect(), start, end);
5115 }
5116
5117 cacheResult(list);
5118
5119 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5120 }
5121 catch (Exception e) {
5122 FinderCacheUtil.removeResult(finderPath, finderArgs);
5123
5124 throw processException(e);
5125 }
5126 finally {
5127 closeSession(session);
5128 }
5129 }
5130
5131 return list;
5132 }
5133
5134
5144 @Override
5145 public UserNotificationEvent findByU_A_A_First(long userId,
5146 boolean actionRequired, boolean archived,
5147 OrderByComparator<UserNotificationEvent> orderByComparator)
5148 throws NoSuchUserNotificationEventException {
5149 UserNotificationEvent userNotificationEvent = fetchByU_A_A_First(userId,
5150 actionRequired, archived, orderByComparator);
5151
5152 if (userNotificationEvent != null) {
5153 return userNotificationEvent;
5154 }
5155
5156 StringBundler msg = new StringBundler(8);
5157
5158 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5159
5160 msg.append("userId=");
5161 msg.append(userId);
5162
5163 msg.append(", actionRequired=");
5164 msg.append(actionRequired);
5165
5166 msg.append(", archived=");
5167 msg.append(archived);
5168
5169 msg.append(StringPool.CLOSE_CURLY_BRACE);
5170
5171 throw new NoSuchUserNotificationEventException(msg.toString());
5172 }
5173
5174
5183 @Override
5184 public UserNotificationEvent fetchByU_A_A_First(long userId,
5185 boolean actionRequired, boolean archived,
5186 OrderByComparator<UserNotificationEvent> orderByComparator) {
5187 List<UserNotificationEvent> list = findByU_A_A(userId, actionRequired,
5188 archived, 0, 1, orderByComparator);
5189
5190 if (!list.isEmpty()) {
5191 return list.get(0);
5192 }
5193
5194 return null;
5195 }
5196
5197
5207 @Override
5208 public UserNotificationEvent findByU_A_A_Last(long userId,
5209 boolean actionRequired, boolean archived,
5210 OrderByComparator<UserNotificationEvent> orderByComparator)
5211 throws NoSuchUserNotificationEventException {
5212 UserNotificationEvent userNotificationEvent = fetchByU_A_A_Last(userId,
5213 actionRequired, archived, orderByComparator);
5214
5215 if (userNotificationEvent != null) {
5216 return userNotificationEvent;
5217 }
5218
5219 StringBundler msg = new StringBundler(8);
5220
5221 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5222
5223 msg.append("userId=");
5224 msg.append(userId);
5225
5226 msg.append(", actionRequired=");
5227 msg.append(actionRequired);
5228
5229 msg.append(", archived=");
5230 msg.append(archived);
5231
5232 msg.append(StringPool.CLOSE_CURLY_BRACE);
5233
5234 throw new NoSuchUserNotificationEventException(msg.toString());
5235 }
5236
5237
5246 @Override
5247 public UserNotificationEvent fetchByU_A_A_Last(long userId,
5248 boolean actionRequired, boolean archived,
5249 OrderByComparator<UserNotificationEvent> orderByComparator) {
5250 int count = countByU_A_A(userId, actionRequired, archived);
5251
5252 if (count == 0) {
5253 return null;
5254 }
5255
5256 List<UserNotificationEvent> list = findByU_A_A(userId, actionRequired,
5257 archived, count - 1, count, orderByComparator);
5258
5259 if (!list.isEmpty()) {
5260 return list.get(0);
5261 }
5262
5263 return null;
5264 }
5265
5266
5277 @Override
5278 public UserNotificationEvent[] findByU_A_A_PrevAndNext(
5279 long userNotificationEventId, long userId, boolean actionRequired,
5280 boolean archived,
5281 OrderByComparator<UserNotificationEvent> orderByComparator)
5282 throws NoSuchUserNotificationEventException {
5283 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
5284
5285 Session session = null;
5286
5287 try {
5288 session = openSession();
5289
5290 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
5291
5292 array[0] = getByU_A_A_PrevAndNext(session, userNotificationEvent,
5293 userId, actionRequired, archived, orderByComparator, true);
5294
5295 array[1] = userNotificationEvent;
5296
5297 array[2] = getByU_A_A_PrevAndNext(session, userNotificationEvent,
5298 userId, actionRequired, archived, orderByComparator, false);
5299
5300 return array;
5301 }
5302 catch (Exception e) {
5303 throw processException(e);
5304 }
5305 finally {
5306 closeSession(session);
5307 }
5308 }
5309
5310 protected UserNotificationEvent getByU_A_A_PrevAndNext(Session session,
5311 UserNotificationEvent userNotificationEvent, long userId,
5312 boolean actionRequired, boolean archived,
5313 OrderByComparator<UserNotificationEvent> orderByComparator,
5314 boolean previous) {
5315 StringBundler query = null;
5316
5317 if (orderByComparator != null) {
5318 query = new StringBundler(6 +
5319 (orderByComparator.getOrderByFields().length * 6));
5320 }
5321 else {
5322 query = new StringBundler(3);
5323 }
5324
5325 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5326
5327 query.append(_FINDER_COLUMN_U_A_A_USERID_2);
5328
5329 query.append(_FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2);
5330
5331 query.append(_FINDER_COLUMN_U_A_A_ARCHIVED_2);
5332
5333 if (orderByComparator != null) {
5334 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5335
5336 if (orderByConditionFields.length > 0) {
5337 query.append(WHERE_AND);
5338 }
5339
5340 for (int i = 0; i < orderByConditionFields.length; i++) {
5341 query.append(_ORDER_BY_ENTITY_ALIAS);
5342 query.append(orderByConditionFields[i]);
5343
5344 if ((i + 1) < orderByConditionFields.length) {
5345 if (orderByComparator.isAscending() ^ previous) {
5346 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5347 }
5348 else {
5349 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5350 }
5351 }
5352 else {
5353 if (orderByComparator.isAscending() ^ previous) {
5354 query.append(WHERE_GREATER_THAN);
5355 }
5356 else {
5357 query.append(WHERE_LESSER_THAN);
5358 }
5359 }
5360 }
5361
5362 query.append(ORDER_BY_CLAUSE);
5363
5364 String[] orderByFields = orderByComparator.getOrderByFields();
5365
5366 for (int i = 0; i < orderByFields.length; i++) {
5367 query.append(_ORDER_BY_ENTITY_ALIAS);
5368 query.append(orderByFields[i]);
5369
5370 if ((i + 1) < orderByFields.length) {
5371 if (orderByComparator.isAscending() ^ previous) {
5372 query.append(ORDER_BY_ASC_HAS_NEXT);
5373 }
5374 else {
5375 query.append(ORDER_BY_DESC_HAS_NEXT);
5376 }
5377 }
5378 else {
5379 if (orderByComparator.isAscending() ^ previous) {
5380 query.append(ORDER_BY_ASC);
5381 }
5382 else {
5383 query.append(ORDER_BY_DESC);
5384 }
5385 }
5386 }
5387 }
5388 else {
5389 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5390 }
5391
5392 String sql = query.toString();
5393
5394 Query q = session.createQuery(sql);
5395
5396 q.setFirstResult(0);
5397 q.setMaxResults(2);
5398
5399 QueryPos qPos = QueryPos.getInstance(q);
5400
5401 qPos.add(userId);
5402
5403 qPos.add(actionRequired);
5404
5405 qPos.add(archived);
5406
5407 if (orderByComparator != null) {
5408 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
5409
5410 for (Object value : values) {
5411 qPos.add(value);
5412 }
5413 }
5414
5415 List<UserNotificationEvent> list = q.list();
5416
5417 if (list.size() == 2) {
5418 return list.get(1);
5419 }
5420 else {
5421 return null;
5422 }
5423 }
5424
5425
5432 @Override
5433 public void removeByU_A_A(long userId, boolean actionRequired,
5434 boolean archived) {
5435 for (UserNotificationEvent userNotificationEvent : findByU_A_A(userId,
5436 actionRequired, archived, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
5437 null)) {
5438 remove(userNotificationEvent);
5439 }
5440 }
5441
5442
5450 @Override
5451 public int countByU_A_A(long userId, boolean actionRequired,
5452 boolean archived) {
5453 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_A_A;
5454
5455 Object[] finderArgs = new Object[] { userId, actionRequired, archived };
5456
5457 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5458 this);
5459
5460 if (count == null) {
5461 StringBundler query = new StringBundler(4);
5462
5463 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
5464
5465 query.append(_FINDER_COLUMN_U_A_A_USERID_2);
5466
5467 query.append(_FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2);
5468
5469 query.append(_FINDER_COLUMN_U_A_A_ARCHIVED_2);
5470
5471 String sql = query.toString();
5472
5473 Session session = null;
5474
5475 try {
5476 session = openSession();
5477
5478 Query q = session.createQuery(sql);
5479
5480 QueryPos qPos = QueryPos.getInstance(q);
5481
5482 qPos.add(userId);
5483
5484 qPos.add(actionRequired);
5485
5486 qPos.add(archived);
5487
5488 count = (Long)q.uniqueResult();
5489
5490 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5491 }
5492 catch (Exception e) {
5493 FinderCacheUtil.removeResult(finderPath, finderArgs);
5494
5495 throw processException(e);
5496 }
5497 finally {
5498 closeSession(session);
5499 }
5500 }
5501
5502 return count.intValue();
5503 }
5504
5505 private static final String _FINDER_COLUMN_U_A_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
5506 private static final String _FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ? AND ";
5507 private static final String _FINDER_COLUMN_U_A_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
5508 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5509 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5510 UserNotificationEventImpl.class,
5511 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_D_A",
5512 new String[] {
5513 Long.class.getName(), Integer.class.getName(),
5514 Boolean.class.getName(), Boolean.class.getName(),
5515
5516 Integer.class.getName(), Integer.class.getName(),
5517 OrderByComparator.class.getName()
5518 });
5519 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A =
5520 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5521 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5522 UserNotificationEventImpl.class,
5523 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_D_A",
5524 new String[] {
5525 Long.class.getName(), Integer.class.getName(),
5526 Boolean.class.getName(), Boolean.class.getName()
5527 },
5528 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
5529 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
5530 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
5531 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
5532 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
5533 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5534 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
5535 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_D_A",
5536 new String[] {
5537 Long.class.getName(), Integer.class.getName(),
5538 Boolean.class.getName(), Boolean.class.getName()
5539 });
5540
5541
5550 @Override
5551 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
5552 int deliveryType, boolean delivered, boolean actionRequired) {
5553 return findByU_DT_D_A(userId, deliveryType, delivered, actionRequired,
5554 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5555 }
5556
5557
5572 @Override
5573 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
5574 int deliveryType, boolean delivered, boolean actionRequired, int start,
5575 int end) {
5576 return findByU_DT_D_A(userId, deliveryType, delivered, actionRequired,
5577 start, end, null);
5578 }
5579
5580
5596 @Override
5597 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
5598 int deliveryType, boolean delivered, boolean actionRequired, int start,
5599 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
5600 boolean pagination = true;
5601 FinderPath finderPath = null;
5602 Object[] finderArgs = null;
5603
5604 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5605 (orderByComparator == null)) {
5606 pagination = false;
5607 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A;
5608 finderArgs = new Object[] {
5609 userId, deliveryType, delivered, actionRequired
5610 };
5611 }
5612 else {
5613 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D_A;
5614 finderArgs = new Object[] {
5615 userId, deliveryType, delivered, actionRequired,
5616
5617 start, end, orderByComparator
5618 };
5619 }
5620
5621 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
5622 finderArgs, this);
5623
5624 if ((list != null) && !list.isEmpty()) {
5625 for (UserNotificationEvent userNotificationEvent : list) {
5626 if ((userId != userNotificationEvent.getUserId()) ||
5627 (deliveryType != userNotificationEvent.getDeliveryType()) ||
5628 (delivered != userNotificationEvent.getDelivered()) ||
5629 (actionRequired != userNotificationEvent.getActionRequired())) {
5630 list = null;
5631
5632 break;
5633 }
5634 }
5635 }
5636
5637 if (list == null) {
5638 StringBundler query = null;
5639
5640 if (orderByComparator != null) {
5641 query = new StringBundler(6 +
5642 (orderByComparator.getOrderByFields().length * 3));
5643 }
5644 else {
5645 query = new StringBundler(6);
5646 }
5647
5648 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5649
5650 query.append(_FINDER_COLUMN_U_DT_D_A_USERID_2);
5651
5652 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2);
5653
5654 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERED_2);
5655
5656 query.append(_FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2);
5657
5658 if (orderByComparator != null) {
5659 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5660 orderByComparator);
5661 }
5662 else
5663 if (pagination) {
5664 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5665 }
5666
5667 String sql = query.toString();
5668
5669 Session session = null;
5670
5671 try {
5672 session = openSession();
5673
5674 Query q = session.createQuery(sql);
5675
5676 QueryPos qPos = QueryPos.getInstance(q);
5677
5678 qPos.add(userId);
5679
5680 qPos.add(deliveryType);
5681
5682 qPos.add(delivered);
5683
5684 qPos.add(actionRequired);
5685
5686 if (!pagination) {
5687 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5688 getDialect(), start, end, false);
5689
5690 Collections.sort(list);
5691
5692 list = Collections.unmodifiableList(list);
5693 }
5694 else {
5695 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5696 getDialect(), start, end);
5697 }
5698
5699 cacheResult(list);
5700
5701 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5702 }
5703 catch (Exception e) {
5704 FinderCacheUtil.removeResult(finderPath, finderArgs);
5705
5706 throw processException(e);
5707 }
5708 finally {
5709 closeSession(session);
5710 }
5711 }
5712
5713 return list;
5714 }
5715
5716
5727 @Override
5728 public UserNotificationEvent findByU_DT_D_A_First(long userId,
5729 int deliveryType, boolean delivered, boolean actionRequired,
5730 OrderByComparator<UserNotificationEvent> orderByComparator)
5731 throws NoSuchUserNotificationEventException {
5732 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_A_First(userId,
5733 deliveryType, delivered, actionRequired, orderByComparator);
5734
5735 if (userNotificationEvent != null) {
5736 return userNotificationEvent;
5737 }
5738
5739 StringBundler msg = new StringBundler(10);
5740
5741 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5742
5743 msg.append("userId=");
5744 msg.append(userId);
5745
5746 msg.append(", deliveryType=");
5747 msg.append(deliveryType);
5748
5749 msg.append(", delivered=");
5750 msg.append(delivered);
5751
5752 msg.append(", actionRequired=");
5753 msg.append(actionRequired);
5754
5755 msg.append(StringPool.CLOSE_CURLY_BRACE);
5756
5757 throw new NoSuchUserNotificationEventException(msg.toString());
5758 }
5759
5760
5770 @Override
5771 public UserNotificationEvent fetchByU_DT_D_A_First(long userId,
5772 int deliveryType, boolean delivered, boolean actionRequired,
5773 OrderByComparator<UserNotificationEvent> orderByComparator) {
5774 List<UserNotificationEvent> list = findByU_DT_D_A(userId, deliveryType,
5775 delivered, actionRequired, 0, 1, orderByComparator);
5776
5777 if (!list.isEmpty()) {
5778 return list.get(0);
5779 }
5780
5781 return null;
5782 }
5783
5784
5795 @Override
5796 public UserNotificationEvent findByU_DT_D_A_Last(long userId,
5797 int deliveryType, boolean delivered, boolean actionRequired,
5798 OrderByComparator<UserNotificationEvent> orderByComparator)
5799 throws NoSuchUserNotificationEventException {
5800 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_A_Last(userId,
5801 deliveryType, delivered, actionRequired, orderByComparator);
5802
5803 if (userNotificationEvent != null) {
5804 return userNotificationEvent;
5805 }
5806
5807 StringBundler msg = new StringBundler(10);
5808
5809 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5810
5811 msg.append("userId=");
5812 msg.append(userId);
5813
5814 msg.append(", deliveryType=");
5815 msg.append(deliveryType);
5816
5817 msg.append(", delivered=");
5818 msg.append(delivered);
5819
5820 msg.append(", actionRequired=");
5821 msg.append(actionRequired);
5822
5823 msg.append(StringPool.CLOSE_CURLY_BRACE);
5824
5825 throw new NoSuchUserNotificationEventException(msg.toString());
5826 }
5827
5828
5838 @Override
5839 public UserNotificationEvent fetchByU_DT_D_A_Last(long userId,
5840 int deliveryType, boolean delivered, boolean actionRequired,
5841 OrderByComparator<UserNotificationEvent> orderByComparator) {
5842 int count = countByU_DT_D_A(userId, deliveryType, delivered,
5843 actionRequired);
5844
5845 if (count == 0) {
5846 return null;
5847 }
5848
5849 List<UserNotificationEvent> list = findByU_DT_D_A(userId, deliveryType,
5850 delivered, actionRequired, count - 1, count, orderByComparator);
5851
5852 if (!list.isEmpty()) {
5853 return list.get(0);
5854 }
5855
5856 return null;
5857 }
5858
5859
5871 @Override
5872 public UserNotificationEvent[] findByU_DT_D_A_PrevAndNext(
5873 long userNotificationEventId, long userId, int deliveryType,
5874 boolean delivered, boolean actionRequired,
5875 OrderByComparator<UserNotificationEvent> orderByComparator)
5876 throws NoSuchUserNotificationEventException {
5877 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
5878
5879 Session session = null;
5880
5881 try {
5882 session = openSession();
5883
5884 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
5885
5886 array[0] = getByU_DT_D_A_PrevAndNext(session,
5887 userNotificationEvent, userId, deliveryType, delivered,
5888 actionRequired, orderByComparator, true);
5889
5890 array[1] = userNotificationEvent;
5891
5892 array[2] = getByU_DT_D_A_PrevAndNext(session,
5893 userNotificationEvent, userId, deliveryType, delivered,
5894 actionRequired, orderByComparator, false);
5895
5896 return array;
5897 }
5898 catch (Exception e) {
5899 throw processException(e);
5900 }
5901 finally {
5902 closeSession(session);
5903 }
5904 }
5905
5906 protected UserNotificationEvent getByU_DT_D_A_PrevAndNext(Session session,
5907 UserNotificationEvent userNotificationEvent, long userId,
5908 int deliveryType, boolean delivered, boolean actionRequired,
5909 OrderByComparator<UserNotificationEvent> orderByComparator,
5910 boolean previous) {
5911 StringBundler query = null;
5912
5913 if (orderByComparator != null) {
5914 query = new StringBundler(6 +
5915 (orderByComparator.getOrderByFields().length * 6));
5916 }
5917 else {
5918 query = new StringBundler(3);
5919 }
5920
5921 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5922
5923 query.append(_FINDER_COLUMN_U_DT_D_A_USERID_2);
5924
5925 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2);
5926
5927 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERED_2);
5928
5929 query.append(_FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2);
5930
5931 if (orderByComparator != null) {
5932 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5933
5934 if (orderByConditionFields.length > 0) {
5935 query.append(WHERE_AND);
5936 }
5937
5938 for (int i = 0; i < orderByConditionFields.length; i++) {
5939 query.append(_ORDER_BY_ENTITY_ALIAS);
5940 query.append(orderByConditionFields[i]);
5941
5942 if ((i + 1) < orderByConditionFields.length) {
5943 if (orderByComparator.isAscending() ^ previous) {
5944 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5945 }
5946 else {
5947 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5948 }
5949 }
5950 else {
5951 if (orderByComparator.isAscending() ^ previous) {
5952 query.append(WHERE_GREATER_THAN);
5953 }
5954 else {
5955 query.append(WHERE_LESSER_THAN);
5956 }
5957 }
5958 }
5959
5960 query.append(ORDER_BY_CLAUSE);
5961
5962 String[] orderByFields = orderByComparator.getOrderByFields();
5963
5964 for (int i = 0; i < orderByFields.length; i++) {
5965 query.append(_ORDER_BY_ENTITY_ALIAS);
5966 query.append(orderByFields[i]);
5967
5968 if ((i + 1) < orderByFields.length) {
5969 if (orderByComparator.isAscending() ^ previous) {
5970 query.append(ORDER_BY_ASC_HAS_NEXT);
5971 }
5972 else {
5973 query.append(ORDER_BY_DESC_HAS_NEXT);
5974 }
5975 }
5976 else {
5977 if (orderByComparator.isAscending() ^ previous) {
5978 query.append(ORDER_BY_ASC);
5979 }
5980 else {
5981 query.append(ORDER_BY_DESC);
5982 }
5983 }
5984 }
5985 }
5986 else {
5987 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5988 }
5989
5990 String sql = query.toString();
5991
5992 Query q = session.createQuery(sql);
5993
5994 q.setFirstResult(0);
5995 q.setMaxResults(2);
5996
5997 QueryPos qPos = QueryPos.getInstance(q);
5998
5999 qPos.add(userId);
6000
6001 qPos.add(deliveryType);
6002
6003 qPos.add(delivered);
6004
6005 qPos.add(actionRequired);
6006
6007 if (orderByComparator != null) {
6008 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
6009
6010 for (Object value : values) {
6011 qPos.add(value);
6012 }
6013 }
6014
6015 List<UserNotificationEvent> list = q.list();
6016
6017 if (list.size() == 2) {
6018 return list.get(1);
6019 }
6020 else {
6021 return null;
6022 }
6023 }
6024
6025
6033 @Override
6034 public void removeByU_DT_D_A(long userId, int deliveryType,
6035 boolean delivered, boolean actionRequired) {
6036 for (UserNotificationEvent userNotificationEvent : findByU_DT_D_A(
6037 userId, deliveryType, delivered, actionRequired,
6038 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6039 remove(userNotificationEvent);
6040 }
6041 }
6042
6043
6052 @Override
6053 public int countByU_DT_D_A(long userId, int deliveryType,
6054 boolean delivered, boolean actionRequired) {
6055 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_D_A;
6056
6057 Object[] finderArgs = new Object[] {
6058 userId, deliveryType, delivered, actionRequired
6059 };
6060
6061 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6062 this);
6063
6064 if (count == null) {
6065 StringBundler query = new StringBundler(5);
6066
6067 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
6068
6069 query.append(_FINDER_COLUMN_U_DT_D_A_USERID_2);
6070
6071 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2);
6072
6073 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERED_2);
6074
6075 query.append(_FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2);
6076
6077 String sql = query.toString();
6078
6079 Session session = null;
6080
6081 try {
6082 session = openSession();
6083
6084 Query q = session.createQuery(sql);
6085
6086 QueryPos qPos = QueryPos.getInstance(q);
6087
6088 qPos.add(userId);
6089
6090 qPos.add(deliveryType);
6091
6092 qPos.add(delivered);
6093
6094 qPos.add(actionRequired);
6095
6096 count = (Long)q.uniqueResult();
6097
6098 FinderCacheUtil.putResult(finderPath, finderArgs, count);
6099 }
6100 catch (Exception e) {
6101 FinderCacheUtil.removeResult(finderPath, finderArgs);
6102
6103 throw processException(e);
6104 }
6105 finally {
6106 closeSession(session);
6107 }
6108 }
6109
6110 return count.intValue();
6111 }
6112
6113 private static final String _FINDER_COLUMN_U_DT_D_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
6114 private static final String _FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
6115 private static final String _FINDER_COLUMN_U_DT_D_A_DELIVERED_2 = "userNotificationEvent.delivered = ? AND ";
6116 private static final String _FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ?";
6117 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6118 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
6119 UserNotificationEventImpl.class,
6120 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_A_A",
6121 new String[] {
6122 Long.class.getName(), Integer.class.getName(),
6123 Boolean.class.getName(), Boolean.class.getName(),
6124
6125 Integer.class.getName(), Integer.class.getName(),
6126 OrderByComparator.class.getName()
6127 });
6128 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A =
6129 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6130 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
6131 UserNotificationEventImpl.class,
6132 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_A_A",
6133 new String[] {
6134 Long.class.getName(), Integer.class.getName(),
6135 Boolean.class.getName(), Boolean.class.getName()
6136 },
6137 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
6138 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
6139 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
6140 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
6141 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
6142 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6143 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
6144 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_A_A",
6145 new String[] {
6146 Long.class.getName(), Integer.class.getName(),
6147 Boolean.class.getName(), Boolean.class.getName()
6148 });
6149
6150
6159 @Override
6160 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
6161 int deliveryType, boolean actionRequired, boolean archived) {
6162 return findByU_DT_A_A(userId, deliveryType, actionRequired, archived,
6163 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6164 }
6165
6166
6181 @Override
6182 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
6183 int deliveryType, boolean actionRequired, boolean archived, int start,
6184 int end) {
6185 return findByU_DT_A_A(userId, deliveryType, actionRequired, archived,
6186 start, end, null);
6187 }
6188
6189
6205 @Override
6206 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
6207 int deliveryType, boolean actionRequired, boolean archived, int start,
6208 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
6209 boolean pagination = true;
6210 FinderPath finderPath = null;
6211 Object[] finderArgs = null;
6212
6213 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6214 (orderByComparator == null)) {
6215 pagination = false;
6216 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A;
6217 finderArgs = new Object[] {
6218 userId, deliveryType, actionRequired, archived
6219 };
6220 }
6221 else {
6222 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A_A;
6223 finderArgs = new Object[] {
6224 userId, deliveryType, actionRequired, archived,
6225
6226 start, end, orderByComparator
6227 };
6228 }
6229
6230 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
6231 finderArgs, this);
6232
6233 if ((list != null) && !list.isEmpty()) {
6234 for (UserNotificationEvent userNotificationEvent : list) {
6235 if ((userId != userNotificationEvent.getUserId()) ||
6236 (deliveryType != userNotificationEvent.getDeliveryType()) ||
6237 (actionRequired != userNotificationEvent.getActionRequired()) ||
6238 (archived != userNotificationEvent.getArchived())) {
6239 list = null;
6240
6241 break;
6242 }
6243 }
6244 }
6245
6246 if (list == null) {
6247 StringBundler query = null;
6248
6249 if (orderByComparator != null) {
6250 query = new StringBundler(6 +
6251 (orderByComparator.getOrderByFields().length * 3));
6252 }
6253 else {
6254 query = new StringBundler(6);
6255 }
6256
6257 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
6258
6259 query.append(_FINDER_COLUMN_U_DT_A_A_USERID_2);
6260
6261 query.append(_FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2);
6262
6263 query.append(_FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2);
6264
6265 query.append(_FINDER_COLUMN_U_DT_A_A_ARCHIVED_2);
6266
6267 if (orderByComparator != null) {
6268 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6269 orderByComparator);
6270 }
6271 else
6272 if (pagination) {
6273 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
6274 }
6275
6276 String sql = query.toString();
6277
6278 Session session = null;
6279
6280 try {
6281 session = openSession();
6282
6283 Query q = session.createQuery(sql);
6284
6285 QueryPos qPos = QueryPos.getInstance(q);
6286
6287 qPos.add(userId);
6288
6289 qPos.add(deliveryType);
6290
6291 qPos.add(actionRequired);
6292
6293 qPos.add(archived);
6294
6295 if (!pagination) {
6296 list = (List<UserNotificationEvent>)QueryUtil.list(q,
6297 getDialect(), start, end, false);
6298
6299 Collections.sort(list);
6300
6301 list = Collections.unmodifiableList(list);
6302 }
6303 else {
6304 list = (List<UserNotificationEvent>)QueryUtil.list(q,
6305 getDialect(), start, end);
6306 }
6307
6308 cacheResult(list);
6309
6310 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6311 }
6312 catch (Exception e) {
6313 FinderCacheUtil.removeResult(finderPath, finderArgs);
6314
6315 throw processException(e);
6316 }
6317 finally {
6318 closeSession(session);
6319 }
6320 }
6321
6322 return list;
6323 }
6324
6325
6336 @Override
6337 public UserNotificationEvent findByU_DT_A_A_First(long userId,
6338 int deliveryType, boolean actionRequired, boolean archived,
6339 OrderByComparator<UserNotificationEvent> orderByComparator)
6340 throws NoSuchUserNotificationEventException {
6341 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_A_First(userId,
6342 deliveryType, actionRequired, archived, orderByComparator);
6343
6344 if (userNotificationEvent != null) {
6345 return userNotificationEvent;
6346 }
6347
6348 StringBundler msg = new StringBundler(10);
6349
6350 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6351
6352 msg.append("userId=");
6353 msg.append(userId);
6354
6355 msg.append(", deliveryType=");
6356 msg.append(deliveryType);
6357
6358 msg.append(", actionRequired=");
6359 msg.append(actionRequired);
6360
6361 msg.append(", archived=");
6362 msg.append(archived);
6363
6364 msg.append(StringPool.CLOSE_CURLY_BRACE);
6365
6366 throw new NoSuchUserNotificationEventException(msg.toString());
6367 }
6368
6369
6379 @Override
6380 public UserNotificationEvent fetchByU_DT_A_A_First(long userId,
6381 int deliveryType, boolean actionRequired, boolean archived,
6382 OrderByComparator<UserNotificationEvent> orderByComparator) {
6383 List<UserNotificationEvent> list = findByU_DT_A_A(userId, deliveryType,
6384 actionRequired, archived, 0, 1, orderByComparator);
6385
6386 if (!list.isEmpty()) {
6387 return list.get(0);
6388 }
6389
6390 return null;
6391 }
6392
6393
6404 @Override
6405 public UserNotificationEvent findByU_DT_A_A_Last(long userId,
6406 int deliveryType, boolean actionRequired, boolean archived,
6407 OrderByComparator<UserNotificationEvent> orderByComparator)
6408 throws NoSuchUserNotificationEventException {
6409 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_A_Last(userId,
6410 deliveryType, actionRequired, archived, orderByComparator);
6411
6412 if (userNotificationEvent != null) {
6413 return userNotificationEvent;
6414 }
6415
6416 StringBundler msg = new StringBundler(10);
6417
6418 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6419
6420 msg.append("userId=");
6421 msg.append(userId);
6422
6423 msg.append(", deliveryType=");
6424 msg.append(deliveryType);
6425
6426 msg.append(", actionRequired=");
6427 msg.append(actionRequired);
6428
6429 msg.append(", archived=");
6430 msg.append(archived);
6431
6432 msg.append(StringPool.CLOSE_CURLY_BRACE);
6433
6434 throw new NoSuchUserNotificationEventException(msg.toString());
6435 }
6436
6437
6447 @Override
6448 public UserNotificationEvent fetchByU_DT_A_A_Last(long userId,
6449 int deliveryType, boolean actionRequired, boolean archived,
6450 OrderByComparator<UserNotificationEvent> orderByComparator) {
6451 int count = countByU_DT_A_A(userId, deliveryType, actionRequired,
6452 archived);
6453
6454 if (count == 0) {
6455 return null;
6456 }
6457
6458 List<UserNotificationEvent> list = findByU_DT_A_A(userId, deliveryType,
6459 actionRequired, archived, count - 1, count, orderByComparator);
6460
6461 if (!list.isEmpty()) {
6462 return list.get(0);
6463 }
6464
6465 return null;
6466 }
6467
6468
6480 @Override
6481 public UserNotificationEvent[] findByU_DT_A_A_PrevAndNext(
6482 long userNotificationEventId, long userId, int deliveryType,
6483 boolean actionRequired, boolean archived,
6484 OrderByComparator<UserNotificationEvent> orderByComparator)
6485 throws NoSuchUserNotificationEventException {
6486 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
6487
6488 Session session = null;
6489
6490 try {
6491 session = openSession();
6492
6493 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
6494
6495 array[0] = getByU_DT_A_A_PrevAndNext(session,
6496 userNotificationEvent, userId, deliveryType,
6497 actionRequired, archived, orderByComparator, true);
6498
6499 array[1] = userNotificationEvent;
6500
6501 array[2] = getByU_DT_A_A_PrevAndNext(session,
6502 userNotificationEvent, userId, deliveryType,
6503 actionRequired, archived, orderByComparator, false);
6504
6505 return array;
6506 }
6507 catch (Exception e) {
6508 throw processException(e);
6509 }
6510 finally {
6511 closeSession(session);
6512 }
6513 }
6514
6515 protected UserNotificationEvent getByU_DT_A_A_PrevAndNext(Session session,
6516 UserNotificationEvent userNotificationEvent, long userId,
6517 int deliveryType, boolean actionRequired, boolean archived,
6518 OrderByComparator<UserNotificationEvent> orderByComparator,
6519 boolean previous) {
6520 StringBundler query = null;
6521
6522 if (orderByComparator != null) {
6523 query = new StringBundler(6 +
6524 (orderByComparator.getOrderByFields().length * 6));
6525 }
6526 else {
6527 query = new StringBundler(3);
6528 }
6529
6530 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
6531
6532 query.append(_FINDER_COLUMN_U_DT_A_A_USERID_2);
6533
6534 query.append(_FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2);
6535
6536 query.append(_FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2);
6537
6538 query.append(_FINDER_COLUMN_U_DT_A_A_ARCHIVED_2);
6539
6540 if (orderByComparator != null) {
6541 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6542
6543 if (orderByConditionFields.length > 0) {
6544 query.append(WHERE_AND);
6545 }
6546
6547 for (int i = 0; i < orderByConditionFields.length; i++) {
6548 query.append(_ORDER_BY_ENTITY_ALIAS);
6549 query.append(orderByConditionFields[i]);
6550
6551 if ((i + 1) < orderByConditionFields.length) {
6552 if (orderByComparator.isAscending() ^ previous) {
6553 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6554 }
6555 else {
6556 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6557 }
6558 }
6559 else {
6560 if (orderByComparator.isAscending() ^ previous) {
6561 query.append(WHERE_GREATER_THAN);
6562 }
6563 else {
6564 query.append(WHERE_LESSER_THAN);
6565 }
6566 }
6567 }
6568
6569 query.append(ORDER_BY_CLAUSE);
6570
6571 String[] orderByFields = orderByComparator.getOrderByFields();
6572
6573 for (int i = 0; i < orderByFields.length; i++) {
6574 query.append(_ORDER_BY_ENTITY_ALIAS);
6575 query.append(orderByFields[i]);
6576
6577 if ((i + 1) < orderByFields.length) {
6578 if (orderByComparator.isAscending() ^ previous) {
6579 query.append(ORDER_BY_ASC_HAS_NEXT);
6580 }
6581 else {
6582 query.append(ORDER_BY_DESC_HAS_NEXT);
6583 }
6584 }
6585 else {
6586 if (orderByComparator.isAscending() ^ previous) {
6587 query.append(ORDER_BY_ASC);
6588 }
6589 else {
6590 query.append(ORDER_BY_DESC);
6591 }
6592 }
6593 }
6594 }
6595 else {
6596 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
6597 }
6598
6599 String sql = query.toString();
6600
6601 Query q = session.createQuery(sql);
6602
6603 q.setFirstResult(0);
6604 q.setMaxResults(2);
6605
6606 QueryPos qPos = QueryPos.getInstance(q);
6607
6608 qPos.add(userId);
6609
6610 qPos.add(deliveryType);
6611
6612 qPos.add(actionRequired);
6613
6614 qPos.add(archived);
6615
6616 if (orderByComparator != null) {
6617 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
6618
6619 for (Object value : values) {
6620 qPos.add(value);
6621 }
6622 }
6623
6624 List<UserNotificationEvent> list = q.list();
6625
6626 if (list.size() == 2) {
6627 return list.get(1);
6628 }
6629 else {
6630 return null;
6631 }
6632 }
6633
6634
6642 @Override
6643 public void removeByU_DT_A_A(long userId, int deliveryType,
6644 boolean actionRequired, boolean archived) {
6645 for (UserNotificationEvent userNotificationEvent : findByU_DT_A_A(
6646 userId, deliveryType, actionRequired, archived,
6647 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6648 remove(userNotificationEvent);
6649 }
6650 }
6651
6652
6661 @Override
6662 public int countByU_DT_A_A(long userId, int deliveryType,
6663 boolean actionRequired, boolean archived) {
6664 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_A_A;
6665
6666 Object[] finderArgs = new Object[] {
6667 userId, deliveryType, actionRequired, archived
6668 };
6669
6670 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6671 this);
6672
6673 if (count == null) {
6674 StringBundler query = new StringBundler(5);
6675
6676 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
6677
6678 query.append(_FINDER_COLUMN_U_DT_A_A_USERID_2);
6679
6680 query.append(_FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2);
6681
6682 query.append(_FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2);
6683
6684 query.append(_FINDER_COLUMN_U_DT_A_A_ARCHIVED_2);
6685
6686 String sql = query.toString();
6687
6688 Session session = null;
6689
6690 try {
6691 session = openSession();
6692
6693 Query q = session.createQuery(sql);
6694
6695 QueryPos qPos = QueryPos.getInstance(q);
6696
6697 qPos.add(userId);
6698
6699 qPos.add(deliveryType);
6700
6701 qPos.add(actionRequired);
6702
6703 qPos.add(archived);
6704
6705 count = (Long)q.uniqueResult();
6706
6707 FinderCacheUtil.putResult(finderPath, finderArgs, count);
6708 }
6709 catch (Exception e) {
6710 FinderCacheUtil.removeResult(finderPath, finderArgs);
6711
6712 throw processException(e);
6713 }
6714 finally {
6715 closeSession(session);
6716 }
6717 }
6718
6719 return count.intValue();
6720 }
6721
6722 private static final String _FINDER_COLUMN_U_DT_A_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
6723 private static final String _FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
6724 private static final String _FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ? AND ";
6725 private static final String _FINDER_COLUMN_U_DT_A_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
6726
6727 public UserNotificationEventPersistenceImpl() {
6728 setModelClass(UserNotificationEvent.class);
6729 }
6730
6731
6736 @Override
6737 public void cacheResult(UserNotificationEvent userNotificationEvent) {
6738 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6739 UserNotificationEventImpl.class,
6740 userNotificationEvent.getPrimaryKey(), userNotificationEvent);
6741
6742 userNotificationEvent.resetOriginalValues();
6743 }
6744
6745
6750 @Override
6751 public void cacheResult(List<UserNotificationEvent> userNotificationEvents) {
6752 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
6753 if (EntityCacheUtil.getResult(
6754 UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6755 UserNotificationEventImpl.class,
6756 userNotificationEvent.getPrimaryKey()) == null) {
6757 cacheResult(userNotificationEvent);
6758 }
6759 else {
6760 userNotificationEvent.resetOriginalValues();
6761 }
6762 }
6763 }
6764
6765
6772 @Override
6773 public void clearCache() {
6774 EntityCacheUtil.clearCache(UserNotificationEventImpl.class);
6775
6776 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
6777 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6778 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6779 }
6780
6781
6788 @Override
6789 public void clearCache(UserNotificationEvent userNotificationEvent) {
6790 EntityCacheUtil.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6791 UserNotificationEventImpl.class,
6792 userNotificationEvent.getPrimaryKey());
6793
6794 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6795 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6796 }
6797
6798 @Override
6799 public void clearCache(List<UserNotificationEvent> userNotificationEvents) {
6800 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6801 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6802
6803 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
6804 EntityCacheUtil.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6805 UserNotificationEventImpl.class,
6806 userNotificationEvent.getPrimaryKey());
6807 }
6808 }
6809
6810
6816 @Override
6817 public UserNotificationEvent create(long userNotificationEventId) {
6818 UserNotificationEvent userNotificationEvent = new UserNotificationEventImpl();
6819
6820 userNotificationEvent.setNew(true);
6821 userNotificationEvent.setPrimaryKey(userNotificationEventId);
6822
6823 String uuid = PortalUUIDUtil.generate();
6824
6825 userNotificationEvent.setUuid(uuid);
6826
6827 return userNotificationEvent;
6828 }
6829
6830
6837 @Override
6838 public UserNotificationEvent remove(long userNotificationEventId)
6839 throws NoSuchUserNotificationEventException {
6840 return remove((Serializable)userNotificationEventId);
6841 }
6842
6843
6850 @Override
6851 public UserNotificationEvent remove(Serializable primaryKey)
6852 throws NoSuchUserNotificationEventException {
6853 Session session = null;
6854
6855 try {
6856 session = openSession();
6857
6858 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
6859 primaryKey);
6860
6861 if (userNotificationEvent == null) {
6862 if (_log.isWarnEnabled()) {
6863 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
6864 }
6865
6866 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
6867 primaryKey);
6868 }
6869
6870 return remove(userNotificationEvent);
6871 }
6872 catch (NoSuchUserNotificationEventException nsee) {
6873 throw nsee;
6874 }
6875 catch (Exception e) {
6876 throw processException(e);
6877 }
6878 finally {
6879 closeSession(session);
6880 }
6881 }
6882
6883 @Override
6884 protected UserNotificationEvent removeImpl(
6885 UserNotificationEvent userNotificationEvent) {
6886 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
6887
6888 Session session = null;
6889
6890 try {
6891 session = openSession();
6892
6893 if (!session.contains(userNotificationEvent)) {
6894 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
6895 userNotificationEvent.getPrimaryKeyObj());
6896 }
6897
6898 if (userNotificationEvent != null) {
6899 session.delete(userNotificationEvent);
6900 }
6901 }
6902 catch (Exception e) {
6903 throw processException(e);
6904 }
6905 finally {
6906 closeSession(session);
6907 }
6908
6909 if (userNotificationEvent != null) {
6910 clearCache(userNotificationEvent);
6911 }
6912
6913 return userNotificationEvent;
6914 }
6915
6916 @Override
6917 public UserNotificationEvent updateImpl(
6918 UserNotificationEvent userNotificationEvent) {
6919 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
6920
6921 boolean isNew = userNotificationEvent.isNew();
6922
6923 UserNotificationEventModelImpl userNotificationEventModelImpl = (UserNotificationEventModelImpl)userNotificationEvent;
6924
6925 if (Validator.isNull(userNotificationEvent.getUuid())) {
6926 String uuid = PortalUUIDUtil.generate();
6927
6928 userNotificationEvent.setUuid(uuid);
6929 }
6930
6931 Session session = null;
6932
6933 try {
6934 session = openSession();
6935
6936 if (userNotificationEvent.isNew()) {
6937 session.save(userNotificationEvent);
6938
6939 userNotificationEvent.setNew(false);
6940 }
6941 else {
6942 session.merge(userNotificationEvent);
6943 }
6944 }
6945 catch (Exception e) {
6946 throw processException(e);
6947 }
6948 finally {
6949 closeSession(session);
6950 }
6951
6952 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6953
6954 if (isNew || !UserNotificationEventModelImpl.COLUMN_BITMASK_ENABLED) {
6955 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6956 }
6957
6958 else {
6959 if ((userNotificationEventModelImpl.getColumnBitmask() &
6960 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
6961 Object[] args = new Object[] {
6962 userNotificationEventModelImpl.getOriginalUuid()
6963 };
6964
6965 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
6966 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
6967 args);
6968
6969 args = new Object[] { userNotificationEventModelImpl.getUuid() };
6970
6971 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
6972 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
6973 args);
6974 }
6975
6976 if ((userNotificationEventModelImpl.getColumnBitmask() &
6977 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
6978 Object[] args = new Object[] {
6979 userNotificationEventModelImpl.getOriginalUuid(),
6980 userNotificationEventModelImpl.getOriginalCompanyId()
6981 };
6982
6983 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
6984 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
6985 args);
6986
6987 args = new Object[] {
6988 userNotificationEventModelImpl.getUuid(),
6989 userNotificationEventModelImpl.getCompanyId()
6990 };
6991
6992 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
6993 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
6994 args);
6995 }
6996
6997 if ((userNotificationEventModelImpl.getColumnBitmask() &
6998 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
6999 Object[] args = new Object[] {
7000 userNotificationEventModelImpl.getOriginalUserId()
7001 };
7002
7003 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
7004 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
7005 args);
7006
7007 args = new Object[] { userNotificationEventModelImpl.getUserId() };
7008
7009 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
7010 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
7011 args);
7012 }
7013
7014 if ((userNotificationEventModelImpl.getColumnBitmask() &
7015 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT.getColumnBitmask()) != 0) {
7016 Object[] args = new Object[] {
7017 userNotificationEventModelImpl.getOriginalUserId(),
7018 userNotificationEventModelImpl.getOriginalDeliveryType()
7019 };
7020
7021 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_DT, args);
7022 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT,
7023 args);
7024
7025 args = new Object[] {
7026 userNotificationEventModelImpl.getUserId(),
7027 userNotificationEventModelImpl.getDeliveryType()
7028 };
7029
7030 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_DT, args);
7031 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT,
7032 args);
7033 }
7034
7035 if ((userNotificationEventModelImpl.getColumnBitmask() &
7036 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D.getColumnBitmask()) != 0) {
7037 Object[] args = new Object[] {
7038 userNotificationEventModelImpl.getOriginalUserId(),
7039 userNotificationEventModelImpl.getOriginalDelivered()
7040 };
7041
7042 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_D, args);
7043 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D,
7044 args);
7045
7046 args = new Object[] {
7047 userNotificationEventModelImpl.getUserId(),
7048 userNotificationEventModelImpl.getDelivered()
7049 };
7050
7051 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_D, args);
7052 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D,
7053 args);
7054 }
7055
7056 if ((userNotificationEventModelImpl.getColumnBitmask() &
7057 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A.getColumnBitmask()) != 0) {
7058 Object[] args = new Object[] {
7059 userNotificationEventModelImpl.getOriginalUserId(),
7060 userNotificationEventModelImpl.getOriginalArchived()
7061 };
7062
7063 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
7064 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
7065 args);
7066
7067 args = new Object[] {
7068 userNotificationEventModelImpl.getUserId(),
7069 userNotificationEventModelImpl.getArchived()
7070 };
7071
7072 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
7073 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
7074 args);
7075 }
7076
7077 if ((userNotificationEventModelImpl.getColumnBitmask() &
7078 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D.getColumnBitmask()) != 0) {
7079 Object[] args = new Object[] {
7080 userNotificationEventModelImpl.getOriginalUserId(),
7081 userNotificationEventModelImpl.getOriginalDeliveryType(),
7082 userNotificationEventModelImpl.getOriginalDelivered()
7083 };
7084
7085 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_DT_D, args);
7086 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D,
7087 args);
7088
7089 args = new Object[] {
7090 userNotificationEventModelImpl.getUserId(),
7091 userNotificationEventModelImpl.getDeliveryType(),
7092 userNotificationEventModelImpl.getDelivered()
7093 };
7094
7095 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_DT_D, args);
7096 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D,
7097 args);
7098 }
7099
7100 if ((userNotificationEventModelImpl.getColumnBitmask() &
7101 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A.getColumnBitmask()) != 0) {
7102 Object[] args = new Object[] {
7103 userNotificationEventModelImpl.getOriginalUserId(),
7104 userNotificationEventModelImpl.getOriginalDeliveryType(),
7105 userNotificationEventModelImpl.getOriginalArchived()
7106 };
7107
7108 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_DT_A, args);
7109 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A,
7110 args);
7111
7112 args = new Object[] {
7113 userNotificationEventModelImpl.getUserId(),
7114 userNotificationEventModelImpl.getDeliveryType(),
7115 userNotificationEventModelImpl.getArchived()
7116 };
7117
7118 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_DT_A, args);
7119 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A,
7120 args);
7121 }
7122
7123 if ((userNotificationEventModelImpl.getColumnBitmask() &
7124 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A.getColumnBitmask()) != 0) {
7125 Object[] args = new Object[] {
7126 userNotificationEventModelImpl.getOriginalUserId(),
7127 userNotificationEventModelImpl.getOriginalDelivered(),
7128 userNotificationEventModelImpl.getOriginalActionRequired()
7129 };
7130
7131 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_D_A, args);
7132 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A,
7133 args);
7134
7135 args = new Object[] {
7136 userNotificationEventModelImpl.getUserId(),
7137 userNotificationEventModelImpl.getDelivered(),
7138 userNotificationEventModelImpl.getActionRequired()
7139 };
7140
7141 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_D_A, args);
7142 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A,
7143 args);
7144 }
7145
7146 if ((userNotificationEventModelImpl.getColumnBitmask() &
7147 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A.getColumnBitmask()) != 0) {
7148 Object[] args = new Object[] {
7149 userNotificationEventModelImpl.getOriginalUserId(),
7150 userNotificationEventModelImpl.getOriginalActionRequired(),
7151 userNotificationEventModelImpl.getOriginalArchived()
7152 };
7153
7154 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_A_A, args);
7155 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A,
7156 args);
7157
7158 args = new Object[] {
7159 userNotificationEventModelImpl.getUserId(),
7160 userNotificationEventModelImpl.getActionRequired(),
7161 userNotificationEventModelImpl.getArchived()
7162 };
7163
7164 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_A_A, args);
7165 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A,
7166 args);
7167 }
7168
7169 if ((userNotificationEventModelImpl.getColumnBitmask() &
7170 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A.getColumnBitmask()) != 0) {
7171 Object[] args = new Object[] {
7172 userNotificationEventModelImpl.getOriginalUserId(),
7173 userNotificationEventModelImpl.getOriginalDeliveryType(),
7174 userNotificationEventModelImpl.getOriginalDelivered(),
7175 userNotificationEventModelImpl.getOriginalActionRequired()
7176 };
7177
7178 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_DT_D_A, args);
7179 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A,
7180 args);
7181
7182 args = new Object[] {
7183 userNotificationEventModelImpl.getUserId(),
7184 userNotificationEventModelImpl.getDeliveryType(),
7185 userNotificationEventModelImpl.getDelivered(),
7186 userNotificationEventModelImpl.getActionRequired()
7187 };
7188
7189 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_DT_D_A, args);
7190 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A,
7191 args);
7192 }
7193
7194 if ((userNotificationEventModelImpl.getColumnBitmask() &
7195 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A.getColumnBitmask()) != 0) {
7196 Object[] args = new Object[] {
7197 userNotificationEventModelImpl.getOriginalUserId(),
7198 userNotificationEventModelImpl.getOriginalDeliveryType(),
7199 userNotificationEventModelImpl.getOriginalActionRequired(),
7200 userNotificationEventModelImpl.getOriginalArchived()
7201 };
7202
7203 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_DT_A_A, args);
7204 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A,
7205 args);
7206
7207 args = new Object[] {
7208 userNotificationEventModelImpl.getUserId(),
7209 userNotificationEventModelImpl.getDeliveryType(),
7210 userNotificationEventModelImpl.getActionRequired(),
7211 userNotificationEventModelImpl.getArchived()
7212 };
7213
7214 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_DT_A_A, args);
7215 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A,
7216 args);
7217 }
7218 }
7219
7220 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7221 UserNotificationEventImpl.class,
7222 userNotificationEvent.getPrimaryKey(), userNotificationEvent, false);
7223
7224 userNotificationEvent.resetOriginalValues();
7225
7226 return userNotificationEvent;
7227 }
7228
7229 protected UserNotificationEvent toUnwrappedModel(
7230 UserNotificationEvent userNotificationEvent) {
7231 if (userNotificationEvent instanceof UserNotificationEventImpl) {
7232 return userNotificationEvent;
7233 }
7234
7235 UserNotificationEventImpl userNotificationEventImpl = new UserNotificationEventImpl();
7236
7237 userNotificationEventImpl.setNew(userNotificationEvent.isNew());
7238 userNotificationEventImpl.setPrimaryKey(userNotificationEvent.getPrimaryKey());
7239
7240 userNotificationEventImpl.setMvccVersion(userNotificationEvent.getMvccVersion());
7241 userNotificationEventImpl.setUuid(userNotificationEvent.getUuid());
7242 userNotificationEventImpl.setUserNotificationEventId(userNotificationEvent.getUserNotificationEventId());
7243 userNotificationEventImpl.setCompanyId(userNotificationEvent.getCompanyId());
7244 userNotificationEventImpl.setUserId(userNotificationEvent.getUserId());
7245 userNotificationEventImpl.setType(userNotificationEvent.getType());
7246 userNotificationEventImpl.setTimestamp(userNotificationEvent.getTimestamp());
7247 userNotificationEventImpl.setDeliveryType(userNotificationEvent.getDeliveryType());
7248 userNotificationEventImpl.setDeliverBy(userNotificationEvent.getDeliverBy());
7249 userNotificationEventImpl.setDelivered(userNotificationEvent.isDelivered());
7250 userNotificationEventImpl.setPayload(userNotificationEvent.getPayload());
7251 userNotificationEventImpl.setActionRequired(userNotificationEvent.isActionRequired());
7252 userNotificationEventImpl.setArchived(userNotificationEvent.isArchived());
7253
7254 return userNotificationEventImpl;
7255 }
7256
7257
7264 @Override
7265 public UserNotificationEvent findByPrimaryKey(Serializable primaryKey)
7266 throws NoSuchUserNotificationEventException {
7267 UserNotificationEvent userNotificationEvent = fetchByPrimaryKey(primaryKey);
7268
7269 if (userNotificationEvent == null) {
7270 if (_log.isWarnEnabled()) {
7271 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
7272 }
7273
7274 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
7275 primaryKey);
7276 }
7277
7278 return userNotificationEvent;
7279 }
7280
7281
7288 @Override
7289 public UserNotificationEvent findByPrimaryKey(long userNotificationEventId)
7290 throws NoSuchUserNotificationEventException {
7291 return findByPrimaryKey((Serializable)userNotificationEventId);
7292 }
7293
7294
7300 @Override
7301 public UserNotificationEvent fetchByPrimaryKey(Serializable primaryKey) {
7302 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)EntityCacheUtil.getResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7303 UserNotificationEventImpl.class, primaryKey);
7304
7305 if (userNotificationEvent == _nullUserNotificationEvent) {
7306 return null;
7307 }
7308
7309 if (userNotificationEvent == null) {
7310 Session session = null;
7311
7312 try {
7313 session = openSession();
7314
7315 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
7316 primaryKey);
7317
7318 if (userNotificationEvent != null) {
7319 cacheResult(userNotificationEvent);
7320 }
7321 else {
7322 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7323 UserNotificationEventImpl.class, primaryKey,
7324 _nullUserNotificationEvent);
7325 }
7326 }
7327 catch (Exception e) {
7328 EntityCacheUtil.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7329 UserNotificationEventImpl.class, primaryKey);
7330
7331 throw processException(e);
7332 }
7333 finally {
7334 closeSession(session);
7335 }
7336 }
7337
7338 return userNotificationEvent;
7339 }
7340
7341
7347 @Override
7348 public UserNotificationEvent fetchByPrimaryKey(long userNotificationEventId) {
7349 return fetchByPrimaryKey((Serializable)userNotificationEventId);
7350 }
7351
7352 @Override
7353 public Map<Serializable, UserNotificationEvent> fetchByPrimaryKeys(
7354 Set<Serializable> primaryKeys) {
7355 if (primaryKeys.isEmpty()) {
7356 return Collections.emptyMap();
7357 }
7358
7359 Map<Serializable, UserNotificationEvent> map = new HashMap<Serializable, UserNotificationEvent>();
7360
7361 if (primaryKeys.size() == 1) {
7362 Iterator<Serializable> iterator = primaryKeys.iterator();
7363
7364 Serializable primaryKey = iterator.next();
7365
7366 UserNotificationEvent userNotificationEvent = fetchByPrimaryKey(primaryKey);
7367
7368 if (userNotificationEvent != null) {
7369 map.put(primaryKey, userNotificationEvent);
7370 }
7371
7372 return map;
7373 }
7374
7375 Set<Serializable> uncachedPrimaryKeys = null;
7376
7377 for (Serializable primaryKey : primaryKeys) {
7378 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)EntityCacheUtil.getResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7379 UserNotificationEventImpl.class, primaryKey);
7380
7381 if (userNotificationEvent == null) {
7382 if (uncachedPrimaryKeys == null) {
7383 uncachedPrimaryKeys = new HashSet<Serializable>();
7384 }
7385
7386 uncachedPrimaryKeys.add(primaryKey);
7387 }
7388 else {
7389 map.put(primaryKey, userNotificationEvent);
7390 }
7391 }
7392
7393 if (uncachedPrimaryKeys == null) {
7394 return map;
7395 }
7396
7397 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
7398 1);
7399
7400 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE_PKS_IN);
7401
7402 for (Serializable primaryKey : uncachedPrimaryKeys) {
7403 query.append(String.valueOf(primaryKey));
7404
7405 query.append(StringPool.COMMA);
7406 }
7407
7408 query.setIndex(query.index() - 1);
7409
7410 query.append(StringPool.CLOSE_PARENTHESIS);
7411
7412 String sql = query.toString();
7413
7414 Session session = null;
7415
7416 try {
7417 session = openSession();
7418
7419 Query q = session.createQuery(sql);
7420
7421 for (UserNotificationEvent userNotificationEvent : (List<UserNotificationEvent>)q.list()) {
7422 map.put(userNotificationEvent.getPrimaryKeyObj(),
7423 userNotificationEvent);
7424
7425 cacheResult(userNotificationEvent);
7426
7427 uncachedPrimaryKeys.remove(userNotificationEvent.getPrimaryKeyObj());
7428 }
7429
7430 for (Serializable primaryKey : uncachedPrimaryKeys) {
7431 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7432 UserNotificationEventImpl.class, primaryKey,
7433 _nullUserNotificationEvent);
7434 }
7435 }
7436 catch (Exception e) {
7437 throw processException(e);
7438 }
7439 finally {
7440 closeSession(session);
7441 }
7442
7443 return map;
7444 }
7445
7446
7451 @Override
7452 public List<UserNotificationEvent> findAll() {
7453 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7454 }
7455
7456
7467 @Override
7468 public List<UserNotificationEvent> findAll(int start, int end) {
7469 return findAll(start, end, null);
7470 }
7471
7472
7484 @Override
7485 public List<UserNotificationEvent> findAll(int start, int end,
7486 OrderByComparator<UserNotificationEvent> orderByComparator) {
7487 boolean pagination = true;
7488 FinderPath finderPath = null;
7489 Object[] finderArgs = null;
7490
7491 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7492 (orderByComparator == null)) {
7493 pagination = false;
7494 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
7495 finderArgs = FINDER_ARGS_EMPTY;
7496 }
7497 else {
7498 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
7499 finderArgs = new Object[] { start, end, orderByComparator };
7500 }
7501
7502 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
7503 finderArgs, this);
7504
7505 if (list == null) {
7506 StringBundler query = null;
7507 String sql = null;
7508
7509 if (orderByComparator != null) {
7510 query = new StringBundler(2 +
7511 (orderByComparator.getOrderByFields().length * 3));
7512
7513 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT);
7514
7515 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7516 orderByComparator);
7517
7518 sql = query.toString();
7519 }
7520 else {
7521 sql = _SQL_SELECT_USERNOTIFICATIONEVENT;
7522
7523 if (pagination) {
7524 sql = sql.concat(UserNotificationEventModelImpl.ORDER_BY_JPQL);
7525 }
7526 }
7527
7528 Session session = null;
7529
7530 try {
7531 session = openSession();
7532
7533 Query q = session.createQuery(sql);
7534
7535 if (!pagination) {
7536 list = (List<UserNotificationEvent>)QueryUtil.list(q,
7537 getDialect(), start, end, false);
7538
7539 Collections.sort(list);
7540
7541 list = Collections.unmodifiableList(list);
7542 }
7543 else {
7544 list = (List<UserNotificationEvent>)QueryUtil.list(q,
7545 getDialect(), start, end);
7546 }
7547
7548 cacheResult(list);
7549
7550 FinderCacheUtil.putResult(finderPath, finderArgs, list);
7551 }
7552 catch (Exception e) {
7553 FinderCacheUtil.removeResult(finderPath, finderArgs);
7554
7555 throw processException(e);
7556 }
7557 finally {
7558 closeSession(session);
7559 }
7560 }
7561
7562 return list;
7563 }
7564
7565
7569 @Override
7570 public void removeAll() {
7571 for (UserNotificationEvent userNotificationEvent : findAll()) {
7572 remove(userNotificationEvent);
7573 }
7574 }
7575
7576
7581 @Override
7582 public int countAll() {
7583 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
7584 FINDER_ARGS_EMPTY, this);
7585
7586 if (count == null) {
7587 Session session = null;
7588
7589 try {
7590 session = openSession();
7591
7592 Query q = session.createQuery(_SQL_COUNT_USERNOTIFICATIONEVENT);
7593
7594 count = (Long)q.uniqueResult();
7595
7596 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
7597 FINDER_ARGS_EMPTY, count);
7598 }
7599 catch (Exception e) {
7600 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
7601 FINDER_ARGS_EMPTY);
7602
7603 throw processException(e);
7604 }
7605 finally {
7606 closeSession(session);
7607 }
7608 }
7609
7610 return count.intValue();
7611 }
7612
7613 @Override
7614 protected Set<String> getBadColumnNames() {
7615 return _badColumnNames;
7616 }
7617
7618
7621 public void afterPropertiesSet() {
7622 }
7623
7624 public void destroy() {
7625 EntityCacheUtil.removeCache(UserNotificationEventImpl.class.getName());
7626 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
7627 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
7628 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7629 }
7630
7631 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent";
7632 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT_WHERE_PKS_IN = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent WHERE userNotificationEventId IN (";
7633 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT_WHERE = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent WHERE ";
7634 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent";
7635 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT_WHERE = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent WHERE ";
7636 private static final String _ORDER_BY_ENTITY_ALIAS = "userNotificationEvent.";
7637 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserNotificationEvent exists with the primary key ";
7638 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserNotificationEvent exists with the key {";
7639 private static final Log _log = LogFactoryUtil.getLog(UserNotificationEventPersistenceImpl.class);
7640 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
7641 "uuid", "type"
7642 });
7643 private static final UserNotificationEvent _nullUserNotificationEvent = new UserNotificationEventImpl() {
7644 @Override
7645 public Object clone() {
7646 return this;
7647 }
7648
7649 @Override
7650 public CacheModel<UserNotificationEvent> toCacheModel() {
7651 return _nullUserNotificationEventCacheModel;
7652 }
7653 };
7654
7655 private static final CacheModel<UserNotificationEvent> _nullUserNotificationEventCacheModel =
7656 new NullCacheModel();
7657
7658 private static class NullCacheModel implements CacheModel<UserNotificationEvent>,
7659 MVCCModel {
7660 @Override
7661 public long getMvccVersion() {
7662 return -1;
7663 }
7664
7665 @Override
7666 public void setMvccVersion(long mvccVersion) {
7667 }
7668
7669 @Override
7670 public UserNotificationEvent toEntityModel() {
7671 return _nullUserNotificationEvent;
7672 }
7673 }
7674 }