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