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