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 * 3));
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(6 +
451 (orderByComparator.getOrderByFields().length * 6));
452 }
453 else {
454 query = new StringBundler(3);
455 }
456
457 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
458
459 boolean bindUuid = false;
460
461 if (uuid == null) {
462 query.append(_FINDER_COLUMN_UUID_UUID_1);
463 }
464 else if (uuid.equals(StringPool.BLANK)) {
465 query.append(_FINDER_COLUMN_UUID_UUID_3);
466 }
467 else {
468 bindUuid = true;
469
470 query.append(_FINDER_COLUMN_UUID_UUID_2);
471 }
472
473 if (orderByComparator != null) {
474 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
475
476 if (orderByConditionFields.length > 0) {
477 query.append(WHERE_AND);
478 }
479
480 for (int i = 0; i < orderByConditionFields.length; i++) {
481 query.append(_ORDER_BY_ENTITY_ALIAS);
482 query.append(orderByConditionFields[i]);
483
484 if ((i + 1) < orderByConditionFields.length) {
485 if (orderByComparator.isAscending() ^ previous) {
486 query.append(WHERE_GREATER_THAN_HAS_NEXT);
487 }
488 else {
489 query.append(WHERE_LESSER_THAN_HAS_NEXT);
490 }
491 }
492 else {
493 if (orderByComparator.isAscending() ^ previous) {
494 query.append(WHERE_GREATER_THAN);
495 }
496 else {
497 query.append(WHERE_LESSER_THAN);
498 }
499 }
500 }
501
502 query.append(ORDER_BY_CLAUSE);
503
504 String[] orderByFields = orderByComparator.getOrderByFields();
505
506 for (int i = 0; i < orderByFields.length; i++) {
507 query.append(_ORDER_BY_ENTITY_ALIAS);
508 query.append(orderByFields[i]);
509
510 if ((i + 1) < orderByFields.length) {
511 if (orderByComparator.isAscending() ^ previous) {
512 query.append(ORDER_BY_ASC_HAS_NEXT);
513 }
514 else {
515 query.append(ORDER_BY_DESC_HAS_NEXT);
516 }
517 }
518 else {
519 if (orderByComparator.isAscending() ^ previous) {
520 query.append(ORDER_BY_ASC);
521 }
522 else {
523 query.append(ORDER_BY_DESC);
524 }
525 }
526 }
527 }
528 else {
529 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
530 }
531
532 String sql = query.toString();
533
534 Query q = session.createQuery(sql);
535
536 q.setFirstResult(0);
537 q.setMaxResults(2);
538
539 QueryPos qPos = QueryPos.getInstance(q);
540
541 if (bindUuid) {
542 qPos.add(uuid);
543 }
544
545 if (orderByComparator != null) {
546 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
547
548 for (Object value : values) {
549 qPos.add(value);
550 }
551 }
552
553 List<UserNotificationEvent> list = q.list();
554
555 if (list.size() == 2) {
556 return list.get(1);
557 }
558 else {
559 return null;
560 }
561 }
562
563
568 @Override
569 public void removeByUuid(String uuid) {
570 for (UserNotificationEvent userNotificationEvent : findByUuid(uuid,
571 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
572 remove(userNotificationEvent);
573 }
574 }
575
576
582 @Override
583 public int countByUuid(String uuid) {
584 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
585
586 Object[] finderArgs = new Object[] { uuid };
587
588 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
589
590 if (count == null) {
591 StringBundler query = new StringBundler(2);
592
593 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
594
595 boolean bindUuid = false;
596
597 if (uuid == null) {
598 query.append(_FINDER_COLUMN_UUID_UUID_1);
599 }
600 else if (uuid.equals(StringPool.BLANK)) {
601 query.append(_FINDER_COLUMN_UUID_UUID_3);
602 }
603 else {
604 bindUuid = true;
605
606 query.append(_FINDER_COLUMN_UUID_UUID_2);
607 }
608
609 String sql = query.toString();
610
611 Session session = null;
612
613 try {
614 session = openSession();
615
616 Query q = session.createQuery(sql);
617
618 QueryPos qPos = QueryPos.getInstance(q);
619
620 if (bindUuid) {
621 qPos.add(uuid);
622 }
623
624 count = (Long)q.uniqueResult();
625
626 finderCache.putResult(finderPath, finderArgs, count);
627 }
628 catch (Exception e) {
629 finderCache.removeResult(finderPath, finderArgs);
630
631 throw processException(e);
632 }
633 finally {
634 closeSession(session);
635 }
636 }
637
638 return count.intValue();
639 }
640
641 private static final String _FINDER_COLUMN_UUID_UUID_1 = "userNotificationEvent.uuid IS NULL";
642 private static final String _FINDER_COLUMN_UUID_UUID_2 = "userNotificationEvent.uuid = ?";
643 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = '')";
644 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
645 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
646 UserNotificationEventImpl.class,
647 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
648 new String[] {
649 String.class.getName(), Long.class.getName(),
650
651 Integer.class.getName(), Integer.class.getName(),
652 OrderByComparator.class.getName()
653 });
654 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
655 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
656 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
657 UserNotificationEventImpl.class,
658 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
659 new String[] { String.class.getName(), Long.class.getName() },
660 UserNotificationEventModelImpl.UUID_COLUMN_BITMASK |
661 UserNotificationEventModelImpl.COMPANYID_COLUMN_BITMASK |
662 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
663 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
664 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
665 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
666 new String[] { String.class.getName(), Long.class.getName() });
667
668
675 @Override
676 public List<UserNotificationEvent> findByUuid_C(String uuid, long companyId) {
677 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
678 QueryUtil.ALL_POS, null);
679 }
680
681
694 @Override
695 public List<UserNotificationEvent> findByUuid_C(String uuid,
696 long companyId, int start, int end) {
697 return findByUuid_C(uuid, companyId, start, end, null);
698 }
699
700
714 @Override
715 public List<UserNotificationEvent> findByUuid_C(String uuid,
716 long companyId, int start, int end,
717 OrderByComparator<UserNotificationEvent> orderByComparator) {
718 return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
719 }
720
721
736 @Override
737 public List<UserNotificationEvent> findByUuid_C(String uuid,
738 long companyId, int start, int end,
739 OrderByComparator<UserNotificationEvent> orderByComparator,
740 boolean retrieveFromCache) {
741 boolean pagination = true;
742 FinderPath finderPath = null;
743 Object[] finderArgs = null;
744
745 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
746 (orderByComparator == null)) {
747 pagination = false;
748 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
749 finderArgs = new Object[] { uuid, companyId };
750 }
751 else {
752 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
753 finderArgs = new Object[] {
754 uuid, companyId,
755
756 start, end, orderByComparator
757 };
758 }
759
760 List<UserNotificationEvent> list = null;
761
762 if (retrieveFromCache) {
763 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
764 finderArgs, this);
765
766 if ((list != null) && !list.isEmpty()) {
767 for (UserNotificationEvent userNotificationEvent : list) {
768 if (!Validator.equals(uuid, userNotificationEvent.getUuid()) ||
769 (companyId != userNotificationEvent.getCompanyId())) {
770 list = null;
771
772 break;
773 }
774 }
775 }
776 }
777
778 if (list == null) {
779 StringBundler query = null;
780
781 if (orderByComparator != null) {
782 query = new StringBundler(4 +
783 (orderByComparator.getOrderByFields().length * 3));
784 }
785 else {
786 query = new StringBundler(4);
787 }
788
789 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
790
791 boolean bindUuid = false;
792
793 if (uuid == null) {
794 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
795 }
796 else if (uuid.equals(StringPool.BLANK)) {
797 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
798 }
799 else {
800 bindUuid = true;
801
802 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
803 }
804
805 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
806
807 if (orderByComparator != null) {
808 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
809 orderByComparator);
810 }
811 else
812 if (pagination) {
813 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
814 }
815
816 String sql = query.toString();
817
818 Session session = null;
819
820 try {
821 session = openSession();
822
823 Query q = session.createQuery(sql);
824
825 QueryPos qPos = QueryPos.getInstance(q);
826
827 if (bindUuid) {
828 qPos.add(uuid);
829 }
830
831 qPos.add(companyId);
832
833 if (!pagination) {
834 list = (List<UserNotificationEvent>)QueryUtil.list(q,
835 getDialect(), start, end, false);
836
837 Collections.sort(list);
838
839 list = Collections.unmodifiableList(list);
840 }
841 else {
842 list = (List<UserNotificationEvent>)QueryUtil.list(q,
843 getDialect(), start, end);
844 }
845
846 cacheResult(list);
847
848 finderCache.putResult(finderPath, finderArgs, list);
849 }
850 catch (Exception e) {
851 finderCache.removeResult(finderPath, finderArgs);
852
853 throw processException(e);
854 }
855 finally {
856 closeSession(session);
857 }
858 }
859
860 return list;
861 }
862
863
872 @Override
873 public UserNotificationEvent findByUuid_C_First(String uuid,
874 long companyId,
875 OrderByComparator<UserNotificationEvent> orderByComparator)
876 throws NoSuchUserNotificationEventException {
877 UserNotificationEvent userNotificationEvent = fetchByUuid_C_First(uuid,
878 companyId, orderByComparator);
879
880 if (userNotificationEvent != null) {
881 return userNotificationEvent;
882 }
883
884 StringBundler msg = new StringBundler(6);
885
886 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
887
888 msg.append("uuid=");
889 msg.append(uuid);
890
891 msg.append(", companyId=");
892 msg.append(companyId);
893
894 msg.append(StringPool.CLOSE_CURLY_BRACE);
895
896 throw new NoSuchUserNotificationEventException(msg.toString());
897 }
898
899
907 @Override
908 public UserNotificationEvent fetchByUuid_C_First(String uuid,
909 long companyId,
910 OrderByComparator<UserNotificationEvent> orderByComparator) {
911 List<UserNotificationEvent> list = findByUuid_C(uuid, companyId, 0, 1,
912 orderByComparator);
913
914 if (!list.isEmpty()) {
915 return list.get(0);
916 }
917
918 return null;
919 }
920
921
930 @Override
931 public UserNotificationEvent findByUuid_C_Last(String uuid, long companyId,
932 OrderByComparator<UserNotificationEvent> orderByComparator)
933 throws NoSuchUserNotificationEventException {
934 UserNotificationEvent userNotificationEvent = fetchByUuid_C_Last(uuid,
935 companyId, orderByComparator);
936
937 if (userNotificationEvent != null) {
938 return userNotificationEvent;
939 }
940
941 StringBundler msg = new StringBundler(6);
942
943 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
944
945 msg.append("uuid=");
946 msg.append(uuid);
947
948 msg.append(", companyId=");
949 msg.append(companyId);
950
951 msg.append(StringPool.CLOSE_CURLY_BRACE);
952
953 throw new NoSuchUserNotificationEventException(msg.toString());
954 }
955
956
964 @Override
965 public UserNotificationEvent fetchByUuid_C_Last(String uuid,
966 long companyId,
967 OrderByComparator<UserNotificationEvent> orderByComparator) {
968 int count = countByUuid_C(uuid, companyId);
969
970 if (count == 0) {
971 return null;
972 }
973
974 List<UserNotificationEvent> list = findByUuid_C(uuid, companyId,
975 count - 1, count, orderByComparator);
976
977 if (!list.isEmpty()) {
978 return list.get(0);
979 }
980
981 return null;
982 }
983
984
994 @Override
995 public UserNotificationEvent[] findByUuid_C_PrevAndNext(
996 long userNotificationEventId, String uuid, long companyId,
997 OrderByComparator<UserNotificationEvent> orderByComparator)
998 throws NoSuchUserNotificationEventException {
999 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
1000
1001 Session session = null;
1002
1003 try {
1004 session = openSession();
1005
1006 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1007
1008 array[0] = getByUuid_C_PrevAndNext(session, userNotificationEvent,
1009 uuid, companyId, orderByComparator, true);
1010
1011 array[1] = userNotificationEvent;
1012
1013 array[2] = getByUuid_C_PrevAndNext(session, userNotificationEvent,
1014 uuid, companyId, orderByComparator, false);
1015
1016 return array;
1017 }
1018 catch (Exception e) {
1019 throw processException(e);
1020 }
1021 finally {
1022 closeSession(session);
1023 }
1024 }
1025
1026 protected UserNotificationEvent getByUuid_C_PrevAndNext(Session session,
1027 UserNotificationEvent userNotificationEvent, String uuid,
1028 long companyId,
1029 OrderByComparator<UserNotificationEvent> orderByComparator,
1030 boolean previous) {
1031 StringBundler query = null;
1032
1033 if (orderByComparator != null) {
1034 query = new StringBundler(6 +
1035 (orderByComparator.getOrderByFields().length * 6));
1036 }
1037 else {
1038 query = new StringBundler(3);
1039 }
1040
1041 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1042
1043 boolean bindUuid = false;
1044
1045 if (uuid == null) {
1046 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1047 }
1048 else if (uuid.equals(StringPool.BLANK)) {
1049 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1050 }
1051 else {
1052 bindUuid = true;
1053
1054 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1055 }
1056
1057 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1058
1059 if (orderByComparator != null) {
1060 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1061
1062 if (orderByConditionFields.length > 0) {
1063 query.append(WHERE_AND);
1064 }
1065
1066 for (int i = 0; i < orderByConditionFields.length; i++) {
1067 query.append(_ORDER_BY_ENTITY_ALIAS);
1068 query.append(orderByConditionFields[i]);
1069
1070 if ((i + 1) < orderByConditionFields.length) {
1071 if (orderByComparator.isAscending() ^ previous) {
1072 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1073 }
1074 else {
1075 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1076 }
1077 }
1078 else {
1079 if (orderByComparator.isAscending() ^ previous) {
1080 query.append(WHERE_GREATER_THAN);
1081 }
1082 else {
1083 query.append(WHERE_LESSER_THAN);
1084 }
1085 }
1086 }
1087
1088 query.append(ORDER_BY_CLAUSE);
1089
1090 String[] orderByFields = orderByComparator.getOrderByFields();
1091
1092 for (int i = 0; i < orderByFields.length; i++) {
1093 query.append(_ORDER_BY_ENTITY_ALIAS);
1094 query.append(orderByFields[i]);
1095
1096 if ((i + 1) < orderByFields.length) {
1097 if (orderByComparator.isAscending() ^ previous) {
1098 query.append(ORDER_BY_ASC_HAS_NEXT);
1099 }
1100 else {
1101 query.append(ORDER_BY_DESC_HAS_NEXT);
1102 }
1103 }
1104 else {
1105 if (orderByComparator.isAscending() ^ previous) {
1106 query.append(ORDER_BY_ASC);
1107 }
1108 else {
1109 query.append(ORDER_BY_DESC);
1110 }
1111 }
1112 }
1113 }
1114 else {
1115 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1116 }
1117
1118 String sql = query.toString();
1119
1120 Query q = session.createQuery(sql);
1121
1122 q.setFirstResult(0);
1123 q.setMaxResults(2);
1124
1125 QueryPos qPos = QueryPos.getInstance(q);
1126
1127 if (bindUuid) {
1128 qPos.add(uuid);
1129 }
1130
1131 qPos.add(companyId);
1132
1133 if (orderByComparator != null) {
1134 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1135
1136 for (Object value : values) {
1137 qPos.add(value);
1138 }
1139 }
1140
1141 List<UserNotificationEvent> list = q.list();
1142
1143 if (list.size() == 2) {
1144 return list.get(1);
1145 }
1146 else {
1147 return null;
1148 }
1149 }
1150
1151
1157 @Override
1158 public void removeByUuid_C(String uuid, long companyId) {
1159 for (UserNotificationEvent userNotificationEvent : findByUuid_C(uuid,
1160 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1161 remove(userNotificationEvent);
1162 }
1163 }
1164
1165
1172 @Override
1173 public int countByUuid_C(String uuid, long companyId) {
1174 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1175
1176 Object[] finderArgs = new Object[] { uuid, companyId };
1177
1178 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1179
1180 if (count == null) {
1181 StringBundler query = new StringBundler(3);
1182
1183 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1184
1185 boolean bindUuid = false;
1186
1187 if (uuid == null) {
1188 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1189 }
1190 else if (uuid.equals(StringPool.BLANK)) {
1191 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1192 }
1193 else {
1194 bindUuid = true;
1195
1196 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1197 }
1198
1199 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1200
1201 String sql = query.toString();
1202
1203 Session session = null;
1204
1205 try {
1206 session = openSession();
1207
1208 Query q = session.createQuery(sql);
1209
1210 QueryPos qPos = QueryPos.getInstance(q);
1211
1212 if (bindUuid) {
1213 qPos.add(uuid);
1214 }
1215
1216 qPos.add(companyId);
1217
1218 count = (Long)q.uniqueResult();
1219
1220 finderCache.putResult(finderPath, finderArgs, count);
1221 }
1222 catch (Exception e) {
1223 finderCache.removeResult(finderPath, finderArgs);
1224
1225 throw processException(e);
1226 }
1227 finally {
1228 closeSession(session);
1229 }
1230 }
1231
1232 return count.intValue();
1233 }
1234
1235 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "userNotificationEvent.uuid IS NULL AND ";
1236 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "userNotificationEvent.uuid = ? AND ";
1237 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = '') AND ";
1238 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "userNotificationEvent.companyId = ?";
1239 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1240 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1241 UserNotificationEventImpl.class,
1242 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
1243 new String[] {
1244 Long.class.getName(),
1245
1246 Integer.class.getName(), Integer.class.getName(),
1247 OrderByComparator.class.getName()
1248 });
1249 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
1250 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1251 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1252 UserNotificationEventImpl.class,
1253 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
1254 new String[] { Long.class.getName() },
1255 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
1256 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
1257 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1258 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
1259 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
1260 new String[] { Long.class.getName() });
1261
1262
1268 @Override
1269 public List<UserNotificationEvent> findByUserId(long userId) {
1270 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1271 }
1272
1273
1285 @Override
1286 public List<UserNotificationEvent> findByUserId(long userId, int start,
1287 int end) {
1288 return findByUserId(userId, start, end, null);
1289 }
1290
1291
1304 @Override
1305 public List<UserNotificationEvent> findByUserId(long userId, int start,
1306 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
1307 return findByUserId(userId, start, end, orderByComparator, true);
1308 }
1309
1310
1324 @Override
1325 public List<UserNotificationEvent> findByUserId(long userId, int start,
1326 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
1327 boolean retrieveFromCache) {
1328 boolean pagination = true;
1329 FinderPath finderPath = null;
1330 Object[] finderArgs = null;
1331
1332 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1333 (orderByComparator == null)) {
1334 pagination = false;
1335 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1336 finderArgs = new Object[] { userId };
1337 }
1338 else {
1339 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1340 finderArgs = new Object[] { userId, start, end, orderByComparator };
1341 }
1342
1343 List<UserNotificationEvent> list = null;
1344
1345 if (retrieveFromCache) {
1346 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
1347 finderArgs, this);
1348
1349 if ((list != null) && !list.isEmpty()) {
1350 for (UserNotificationEvent userNotificationEvent : list) {
1351 if ((userId != userNotificationEvent.getUserId())) {
1352 list = null;
1353
1354 break;
1355 }
1356 }
1357 }
1358 }
1359
1360 if (list == null) {
1361 StringBundler query = null;
1362
1363 if (orderByComparator != null) {
1364 query = new StringBundler(3 +
1365 (orderByComparator.getOrderByFields().length * 3));
1366 }
1367 else {
1368 query = new StringBundler(3);
1369 }
1370
1371 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1372
1373 query.append(_FINDER_COLUMN_USERID_USERID_2);
1374
1375 if (orderByComparator != null) {
1376 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1377 orderByComparator);
1378 }
1379 else
1380 if (pagination) {
1381 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1382 }
1383
1384 String sql = query.toString();
1385
1386 Session session = null;
1387
1388 try {
1389 session = openSession();
1390
1391 Query q = session.createQuery(sql);
1392
1393 QueryPos qPos = QueryPos.getInstance(q);
1394
1395 qPos.add(userId);
1396
1397 if (!pagination) {
1398 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1399 getDialect(), start, end, false);
1400
1401 Collections.sort(list);
1402
1403 list = Collections.unmodifiableList(list);
1404 }
1405 else {
1406 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1407 getDialect(), start, end);
1408 }
1409
1410 cacheResult(list);
1411
1412 finderCache.putResult(finderPath, finderArgs, list);
1413 }
1414 catch (Exception e) {
1415 finderCache.removeResult(finderPath, finderArgs);
1416
1417 throw processException(e);
1418 }
1419 finally {
1420 closeSession(session);
1421 }
1422 }
1423
1424 return list;
1425 }
1426
1427
1435 @Override
1436 public UserNotificationEvent findByUserId_First(long userId,
1437 OrderByComparator<UserNotificationEvent> orderByComparator)
1438 throws NoSuchUserNotificationEventException {
1439 UserNotificationEvent userNotificationEvent = fetchByUserId_First(userId,
1440 orderByComparator);
1441
1442 if (userNotificationEvent != null) {
1443 return userNotificationEvent;
1444 }
1445
1446 StringBundler msg = new StringBundler(4);
1447
1448 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1449
1450 msg.append("userId=");
1451 msg.append(userId);
1452
1453 msg.append(StringPool.CLOSE_CURLY_BRACE);
1454
1455 throw new NoSuchUserNotificationEventException(msg.toString());
1456 }
1457
1458
1465 @Override
1466 public UserNotificationEvent fetchByUserId_First(long userId,
1467 OrderByComparator<UserNotificationEvent> orderByComparator) {
1468 List<UserNotificationEvent> list = findByUserId(userId, 0, 1,
1469 orderByComparator);
1470
1471 if (!list.isEmpty()) {
1472 return list.get(0);
1473 }
1474
1475 return null;
1476 }
1477
1478
1486 @Override
1487 public UserNotificationEvent findByUserId_Last(long userId,
1488 OrderByComparator<UserNotificationEvent> orderByComparator)
1489 throws NoSuchUserNotificationEventException {
1490 UserNotificationEvent userNotificationEvent = fetchByUserId_Last(userId,
1491 orderByComparator);
1492
1493 if (userNotificationEvent != null) {
1494 return userNotificationEvent;
1495 }
1496
1497 StringBundler msg = new StringBundler(4);
1498
1499 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1500
1501 msg.append("userId=");
1502 msg.append(userId);
1503
1504 msg.append(StringPool.CLOSE_CURLY_BRACE);
1505
1506 throw new NoSuchUserNotificationEventException(msg.toString());
1507 }
1508
1509
1516 @Override
1517 public UserNotificationEvent fetchByUserId_Last(long userId,
1518 OrderByComparator<UserNotificationEvent> orderByComparator) {
1519 int count = countByUserId(userId);
1520
1521 if (count == 0) {
1522 return null;
1523 }
1524
1525 List<UserNotificationEvent> list = findByUserId(userId, count - 1,
1526 count, orderByComparator);
1527
1528 if (!list.isEmpty()) {
1529 return list.get(0);
1530 }
1531
1532 return null;
1533 }
1534
1535
1544 @Override
1545 public UserNotificationEvent[] findByUserId_PrevAndNext(
1546 long userNotificationEventId, long userId,
1547 OrderByComparator<UserNotificationEvent> orderByComparator)
1548 throws NoSuchUserNotificationEventException {
1549 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
1550
1551 Session session = null;
1552
1553 try {
1554 session = openSession();
1555
1556 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1557
1558 array[0] = getByUserId_PrevAndNext(session, userNotificationEvent,
1559 userId, orderByComparator, true);
1560
1561 array[1] = userNotificationEvent;
1562
1563 array[2] = getByUserId_PrevAndNext(session, userNotificationEvent,
1564 userId, orderByComparator, false);
1565
1566 return array;
1567 }
1568 catch (Exception e) {
1569 throw processException(e);
1570 }
1571 finally {
1572 closeSession(session);
1573 }
1574 }
1575
1576 protected UserNotificationEvent getByUserId_PrevAndNext(Session session,
1577 UserNotificationEvent userNotificationEvent, long userId,
1578 OrderByComparator<UserNotificationEvent> orderByComparator,
1579 boolean previous) {
1580 StringBundler query = null;
1581
1582 if (orderByComparator != null) {
1583 query = new StringBundler(6 +
1584 (orderByComparator.getOrderByFields().length * 6));
1585 }
1586 else {
1587 query = new StringBundler(3);
1588 }
1589
1590 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1591
1592 query.append(_FINDER_COLUMN_USERID_USERID_2);
1593
1594 if (orderByComparator != null) {
1595 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1596
1597 if (orderByConditionFields.length > 0) {
1598 query.append(WHERE_AND);
1599 }
1600
1601 for (int i = 0; i < orderByConditionFields.length; i++) {
1602 query.append(_ORDER_BY_ENTITY_ALIAS);
1603 query.append(orderByConditionFields[i]);
1604
1605 if ((i + 1) < orderByConditionFields.length) {
1606 if (orderByComparator.isAscending() ^ previous) {
1607 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1608 }
1609 else {
1610 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1611 }
1612 }
1613 else {
1614 if (orderByComparator.isAscending() ^ previous) {
1615 query.append(WHERE_GREATER_THAN);
1616 }
1617 else {
1618 query.append(WHERE_LESSER_THAN);
1619 }
1620 }
1621 }
1622
1623 query.append(ORDER_BY_CLAUSE);
1624
1625 String[] orderByFields = orderByComparator.getOrderByFields();
1626
1627 for (int i = 0; i < orderByFields.length; i++) {
1628 query.append(_ORDER_BY_ENTITY_ALIAS);
1629 query.append(orderByFields[i]);
1630
1631 if ((i + 1) < orderByFields.length) {
1632 if (orderByComparator.isAscending() ^ previous) {
1633 query.append(ORDER_BY_ASC_HAS_NEXT);
1634 }
1635 else {
1636 query.append(ORDER_BY_DESC_HAS_NEXT);
1637 }
1638 }
1639 else {
1640 if (orderByComparator.isAscending() ^ previous) {
1641 query.append(ORDER_BY_ASC);
1642 }
1643 else {
1644 query.append(ORDER_BY_DESC);
1645 }
1646 }
1647 }
1648 }
1649 else {
1650 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1651 }
1652
1653 String sql = query.toString();
1654
1655 Query q = session.createQuery(sql);
1656
1657 q.setFirstResult(0);
1658 q.setMaxResults(2);
1659
1660 QueryPos qPos = QueryPos.getInstance(q);
1661
1662 qPos.add(userId);
1663
1664 if (orderByComparator != null) {
1665 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1666
1667 for (Object value : values) {
1668 qPos.add(value);
1669 }
1670 }
1671
1672 List<UserNotificationEvent> list = q.list();
1673
1674 if (list.size() == 2) {
1675 return list.get(1);
1676 }
1677 else {
1678 return null;
1679 }
1680 }
1681
1682
1687 @Override
1688 public void removeByUserId(long userId) {
1689 for (UserNotificationEvent userNotificationEvent : findByUserId(
1690 userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1691 remove(userNotificationEvent);
1692 }
1693 }
1694
1695
1701 @Override
1702 public int countByUserId(long userId) {
1703 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
1704
1705 Object[] finderArgs = new Object[] { userId };
1706
1707 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1708
1709 if (count == null) {
1710 StringBundler query = new StringBundler(2);
1711
1712 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1713
1714 query.append(_FINDER_COLUMN_USERID_USERID_2);
1715
1716 String sql = query.toString();
1717
1718 Session session = null;
1719
1720 try {
1721 session = openSession();
1722
1723 Query q = session.createQuery(sql);
1724
1725 QueryPos qPos = QueryPos.getInstance(q);
1726
1727 qPos.add(userId);
1728
1729 count = (Long)q.uniqueResult();
1730
1731 finderCache.putResult(finderPath, finderArgs, count);
1732 }
1733 catch (Exception e) {
1734 finderCache.removeResult(finderPath, finderArgs);
1735
1736 throw processException(e);
1737 }
1738 finally {
1739 closeSession(session);
1740 }
1741 }
1742
1743 return count.intValue();
1744 }
1745
1746 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userNotificationEvent.userId = ?";
1747 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TYPE = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1748 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1749 UserNotificationEventImpl.class,
1750 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByType",
1751 new String[] {
1752 String.class.getName(),
1753
1754 Integer.class.getName(), Integer.class.getName(),
1755 OrderByComparator.class.getName()
1756 });
1757 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1758 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1759 UserNotificationEventImpl.class,
1760 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByType",
1761 new String[] { String.class.getName() },
1762 UserNotificationEventModelImpl.TYPE_COLUMN_BITMASK |
1763 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
1764 public static final FinderPath FINDER_PATH_COUNT_BY_TYPE = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1765 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
1766 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByType",
1767 new String[] { String.class.getName() });
1768
1769
1775 @Override
1776 public List<UserNotificationEvent> findByType(String type) {
1777 return findByType(type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1778 }
1779
1780
1792 @Override
1793 public List<UserNotificationEvent> findByType(String type, int start,
1794 int end) {
1795 return findByType(type, start, end, null);
1796 }
1797
1798
1811 @Override
1812 public List<UserNotificationEvent> findByType(String type, int start,
1813 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
1814 return findByType(type, start, end, orderByComparator, true);
1815 }
1816
1817
1831 @Override
1832 public List<UserNotificationEvent> findByType(String type, int start,
1833 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
1834 boolean retrieveFromCache) {
1835 boolean pagination = true;
1836 FinderPath finderPath = null;
1837 Object[] finderArgs = null;
1838
1839 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1840 (orderByComparator == null)) {
1841 pagination = false;
1842 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE;
1843 finderArgs = new Object[] { type };
1844 }
1845 else {
1846 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TYPE;
1847 finderArgs = new Object[] { type, start, end, orderByComparator };
1848 }
1849
1850 List<UserNotificationEvent> list = null;
1851
1852 if (retrieveFromCache) {
1853 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
1854 finderArgs, this);
1855
1856 if ((list != null) && !list.isEmpty()) {
1857 for (UserNotificationEvent userNotificationEvent : list) {
1858 if (!Validator.equals(type, userNotificationEvent.getType())) {
1859 list = null;
1860
1861 break;
1862 }
1863 }
1864 }
1865 }
1866
1867 if (list == null) {
1868 StringBundler query = null;
1869
1870 if (orderByComparator != null) {
1871 query = new StringBundler(3 +
1872 (orderByComparator.getOrderByFields().length * 3));
1873 }
1874 else {
1875 query = new StringBundler(3);
1876 }
1877
1878 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1879
1880 boolean bindType = false;
1881
1882 if (type == null) {
1883 query.append(_FINDER_COLUMN_TYPE_TYPE_1);
1884 }
1885 else if (type.equals(StringPool.BLANK)) {
1886 query.append(_FINDER_COLUMN_TYPE_TYPE_3);
1887 }
1888 else {
1889 bindType = true;
1890
1891 query.append(_FINDER_COLUMN_TYPE_TYPE_2);
1892 }
1893
1894 if (orderByComparator != null) {
1895 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1896 orderByComparator);
1897 }
1898 else
1899 if (pagination) {
1900 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1901 }
1902
1903 String sql = query.toString();
1904
1905 Session session = null;
1906
1907 try {
1908 session = openSession();
1909
1910 Query q = session.createQuery(sql);
1911
1912 QueryPos qPos = QueryPos.getInstance(q);
1913
1914 if (bindType) {
1915 qPos.add(type);
1916 }
1917
1918 if (!pagination) {
1919 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1920 getDialect(), start, end, false);
1921
1922 Collections.sort(list);
1923
1924 list = Collections.unmodifiableList(list);
1925 }
1926 else {
1927 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1928 getDialect(), start, end);
1929 }
1930
1931 cacheResult(list);
1932
1933 finderCache.putResult(finderPath, finderArgs, list);
1934 }
1935 catch (Exception e) {
1936 finderCache.removeResult(finderPath, finderArgs);
1937
1938 throw processException(e);
1939 }
1940 finally {
1941 closeSession(session);
1942 }
1943 }
1944
1945 return list;
1946 }
1947
1948
1956 @Override
1957 public UserNotificationEvent findByType_First(String type,
1958 OrderByComparator<UserNotificationEvent> orderByComparator)
1959 throws NoSuchUserNotificationEventException {
1960 UserNotificationEvent userNotificationEvent = fetchByType_First(type,
1961 orderByComparator);
1962
1963 if (userNotificationEvent != null) {
1964 return userNotificationEvent;
1965 }
1966
1967 StringBundler msg = new StringBundler(4);
1968
1969 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1970
1971 msg.append("type=");
1972 msg.append(type);
1973
1974 msg.append(StringPool.CLOSE_CURLY_BRACE);
1975
1976 throw new NoSuchUserNotificationEventException(msg.toString());
1977 }
1978
1979
1986 @Override
1987 public UserNotificationEvent fetchByType_First(String type,
1988 OrderByComparator<UserNotificationEvent> orderByComparator) {
1989 List<UserNotificationEvent> list = findByType(type, 0, 1,
1990 orderByComparator);
1991
1992 if (!list.isEmpty()) {
1993 return list.get(0);
1994 }
1995
1996 return null;
1997 }
1998
1999
2007 @Override
2008 public UserNotificationEvent findByType_Last(String type,
2009 OrderByComparator<UserNotificationEvent> orderByComparator)
2010 throws NoSuchUserNotificationEventException {
2011 UserNotificationEvent userNotificationEvent = fetchByType_Last(type,
2012 orderByComparator);
2013
2014 if (userNotificationEvent != null) {
2015 return userNotificationEvent;
2016 }
2017
2018 StringBundler msg = new StringBundler(4);
2019
2020 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2021
2022 msg.append("type=");
2023 msg.append(type);
2024
2025 msg.append(StringPool.CLOSE_CURLY_BRACE);
2026
2027 throw new NoSuchUserNotificationEventException(msg.toString());
2028 }
2029
2030
2037 @Override
2038 public UserNotificationEvent fetchByType_Last(String type,
2039 OrderByComparator<UserNotificationEvent> orderByComparator) {
2040 int count = countByType(type);
2041
2042 if (count == 0) {
2043 return null;
2044 }
2045
2046 List<UserNotificationEvent> list = findByType(type, count - 1, count,
2047 orderByComparator);
2048
2049 if (!list.isEmpty()) {
2050 return list.get(0);
2051 }
2052
2053 return null;
2054 }
2055
2056
2065 @Override
2066 public UserNotificationEvent[] findByType_PrevAndNext(
2067 long userNotificationEventId, String type,
2068 OrderByComparator<UserNotificationEvent> orderByComparator)
2069 throws NoSuchUserNotificationEventException {
2070 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
2071
2072 Session session = null;
2073
2074 try {
2075 session = openSession();
2076
2077 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
2078
2079 array[0] = getByType_PrevAndNext(session, userNotificationEvent,
2080 type, orderByComparator, true);
2081
2082 array[1] = userNotificationEvent;
2083
2084 array[2] = getByType_PrevAndNext(session, userNotificationEvent,
2085 type, orderByComparator, false);
2086
2087 return array;
2088 }
2089 catch (Exception e) {
2090 throw processException(e);
2091 }
2092 finally {
2093 closeSession(session);
2094 }
2095 }
2096
2097 protected UserNotificationEvent getByType_PrevAndNext(Session session,
2098 UserNotificationEvent userNotificationEvent, String type,
2099 OrderByComparator<UserNotificationEvent> orderByComparator,
2100 boolean previous) {
2101 StringBundler query = null;
2102
2103 if (orderByComparator != null) {
2104 query = new StringBundler(6 +
2105 (orderByComparator.getOrderByFields().length * 6));
2106 }
2107 else {
2108 query = new StringBundler(3);
2109 }
2110
2111 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2112
2113 boolean bindType = false;
2114
2115 if (type == null) {
2116 query.append(_FINDER_COLUMN_TYPE_TYPE_1);
2117 }
2118 else if (type.equals(StringPool.BLANK)) {
2119 query.append(_FINDER_COLUMN_TYPE_TYPE_3);
2120 }
2121 else {
2122 bindType = true;
2123
2124 query.append(_FINDER_COLUMN_TYPE_TYPE_2);
2125 }
2126
2127 if (orderByComparator != null) {
2128 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2129
2130 if (orderByConditionFields.length > 0) {
2131 query.append(WHERE_AND);
2132 }
2133
2134 for (int i = 0; i < orderByConditionFields.length; i++) {
2135 query.append(_ORDER_BY_ENTITY_ALIAS);
2136 query.append(orderByConditionFields[i]);
2137
2138 if ((i + 1) < orderByConditionFields.length) {
2139 if (orderByComparator.isAscending() ^ previous) {
2140 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2141 }
2142 else {
2143 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2144 }
2145 }
2146 else {
2147 if (orderByComparator.isAscending() ^ previous) {
2148 query.append(WHERE_GREATER_THAN);
2149 }
2150 else {
2151 query.append(WHERE_LESSER_THAN);
2152 }
2153 }
2154 }
2155
2156 query.append(ORDER_BY_CLAUSE);
2157
2158 String[] orderByFields = orderByComparator.getOrderByFields();
2159
2160 for (int i = 0; i < orderByFields.length; i++) {
2161 query.append(_ORDER_BY_ENTITY_ALIAS);
2162 query.append(orderByFields[i]);
2163
2164 if ((i + 1) < orderByFields.length) {
2165 if (orderByComparator.isAscending() ^ previous) {
2166 query.append(ORDER_BY_ASC_HAS_NEXT);
2167 }
2168 else {
2169 query.append(ORDER_BY_DESC_HAS_NEXT);
2170 }
2171 }
2172 else {
2173 if (orderByComparator.isAscending() ^ previous) {
2174 query.append(ORDER_BY_ASC);
2175 }
2176 else {
2177 query.append(ORDER_BY_DESC);
2178 }
2179 }
2180 }
2181 }
2182 else {
2183 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2184 }
2185
2186 String sql = query.toString();
2187
2188 Query q = session.createQuery(sql);
2189
2190 q.setFirstResult(0);
2191 q.setMaxResults(2);
2192
2193 QueryPos qPos = QueryPos.getInstance(q);
2194
2195 if (bindType) {
2196 qPos.add(type);
2197 }
2198
2199 if (orderByComparator != null) {
2200 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
2201
2202 for (Object value : values) {
2203 qPos.add(value);
2204 }
2205 }
2206
2207 List<UserNotificationEvent> list = q.list();
2208
2209 if (list.size() == 2) {
2210 return list.get(1);
2211 }
2212 else {
2213 return null;
2214 }
2215 }
2216
2217
2222 @Override
2223 public void removeByType(String type) {
2224 for (UserNotificationEvent userNotificationEvent : findByType(type,
2225 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2226 remove(userNotificationEvent);
2227 }
2228 }
2229
2230
2236 @Override
2237 public int countByType(String type) {
2238 FinderPath finderPath = FINDER_PATH_COUNT_BY_TYPE;
2239
2240 Object[] finderArgs = new Object[] { type };
2241
2242 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2243
2244 if (count == null) {
2245 StringBundler query = new StringBundler(2);
2246
2247 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2248
2249 boolean bindType = false;
2250
2251 if (type == null) {
2252 query.append(_FINDER_COLUMN_TYPE_TYPE_1);
2253 }
2254 else if (type.equals(StringPool.BLANK)) {
2255 query.append(_FINDER_COLUMN_TYPE_TYPE_3);
2256 }
2257 else {
2258 bindType = true;
2259
2260 query.append(_FINDER_COLUMN_TYPE_TYPE_2);
2261 }
2262
2263 String sql = query.toString();
2264
2265 Session session = null;
2266
2267 try {
2268 session = openSession();
2269
2270 Query q = session.createQuery(sql);
2271
2272 QueryPos qPos = QueryPos.getInstance(q);
2273
2274 if (bindType) {
2275 qPos.add(type);
2276 }
2277
2278 count = (Long)q.uniqueResult();
2279
2280 finderCache.putResult(finderPath, finderArgs, count);
2281 }
2282 catch (Exception e) {
2283 finderCache.removeResult(finderPath, finderArgs);
2284
2285 throw processException(e);
2286 }
2287 finally {
2288 closeSession(session);
2289 }
2290 }
2291
2292 return count.intValue();
2293 }
2294
2295 private static final String _FINDER_COLUMN_TYPE_TYPE_1 = "userNotificationEvent.type IS NULL";
2296 private static final String _FINDER_COLUMN_TYPE_TYPE_2 = "userNotificationEvent.type = ?";
2297 private static final String _FINDER_COLUMN_TYPE_TYPE_3 = "(userNotificationEvent.type IS NULL OR userNotificationEvent.type = '')";
2298 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2299 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2300 UserNotificationEventImpl.class,
2301 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT",
2302 new String[] {
2303 Long.class.getName(), Integer.class.getName(),
2304
2305 Integer.class.getName(), Integer.class.getName(),
2306 OrderByComparator.class.getName()
2307 });
2308 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2309 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2310 UserNotificationEventImpl.class,
2311 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT",
2312 new String[] { Long.class.getName(), Integer.class.getName() },
2313 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
2314 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
2315 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
2316 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2317 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
2318 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT",
2319 new String[] { Long.class.getName(), Integer.class.getName() });
2320
2321
2328 @Override
2329 public List<UserNotificationEvent> findByU_DT(long userId, int deliveryType) {
2330 return findByU_DT(userId, deliveryType, QueryUtil.ALL_POS,
2331 QueryUtil.ALL_POS, null);
2332 }
2333
2334
2347 @Override
2348 public List<UserNotificationEvent> findByU_DT(long userId,
2349 int deliveryType, int start, int end) {
2350 return findByU_DT(userId, deliveryType, start, end, null);
2351 }
2352
2353
2367 @Override
2368 public List<UserNotificationEvent> findByU_DT(long userId,
2369 int deliveryType, int start, int end,
2370 OrderByComparator<UserNotificationEvent> orderByComparator) {
2371 return findByU_DT(userId, deliveryType, start, end, orderByComparator,
2372 true);
2373 }
2374
2375
2390 @Override
2391 public List<UserNotificationEvent> findByU_DT(long userId,
2392 int deliveryType, int start, int end,
2393 OrderByComparator<UserNotificationEvent> orderByComparator,
2394 boolean retrieveFromCache) {
2395 boolean pagination = true;
2396 FinderPath finderPath = null;
2397 Object[] finderArgs = null;
2398
2399 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2400 (orderByComparator == null)) {
2401 pagination = false;
2402 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT;
2403 finderArgs = new Object[] { userId, deliveryType };
2404 }
2405 else {
2406 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT;
2407 finderArgs = new Object[] {
2408 userId, deliveryType,
2409
2410 start, end, orderByComparator
2411 };
2412 }
2413
2414 List<UserNotificationEvent> list = null;
2415
2416 if (retrieveFromCache) {
2417 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
2418 finderArgs, this);
2419
2420 if ((list != null) && !list.isEmpty()) {
2421 for (UserNotificationEvent userNotificationEvent : list) {
2422 if ((userId != userNotificationEvent.getUserId()) ||
2423 (deliveryType != userNotificationEvent.getDeliveryType())) {
2424 list = null;
2425
2426 break;
2427 }
2428 }
2429 }
2430 }
2431
2432 if (list == null) {
2433 StringBundler query = null;
2434
2435 if (orderByComparator != null) {
2436 query = new StringBundler(4 +
2437 (orderByComparator.getOrderByFields().length * 3));
2438 }
2439 else {
2440 query = new StringBundler(4);
2441 }
2442
2443 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2444
2445 query.append(_FINDER_COLUMN_U_DT_USERID_2);
2446
2447 query.append(_FINDER_COLUMN_U_DT_DELIVERYTYPE_2);
2448
2449 if (orderByComparator != null) {
2450 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2451 orderByComparator);
2452 }
2453 else
2454 if (pagination) {
2455 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2456 }
2457
2458 String sql = query.toString();
2459
2460 Session session = null;
2461
2462 try {
2463 session = openSession();
2464
2465 Query q = session.createQuery(sql);
2466
2467 QueryPos qPos = QueryPos.getInstance(q);
2468
2469 qPos.add(userId);
2470
2471 qPos.add(deliveryType);
2472
2473 if (!pagination) {
2474 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2475 getDialect(), start, end, false);
2476
2477 Collections.sort(list);
2478
2479 list = Collections.unmodifiableList(list);
2480 }
2481 else {
2482 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2483 getDialect(), start, end);
2484 }
2485
2486 cacheResult(list);
2487
2488 finderCache.putResult(finderPath, finderArgs, list);
2489 }
2490 catch (Exception e) {
2491 finderCache.removeResult(finderPath, finderArgs);
2492
2493 throw processException(e);
2494 }
2495 finally {
2496 closeSession(session);
2497 }
2498 }
2499
2500 return list;
2501 }
2502
2503
2512 @Override
2513 public UserNotificationEvent findByU_DT_First(long userId,
2514 int deliveryType,
2515 OrderByComparator<UserNotificationEvent> orderByComparator)
2516 throws NoSuchUserNotificationEventException {
2517 UserNotificationEvent userNotificationEvent = fetchByU_DT_First(userId,
2518 deliveryType, orderByComparator);
2519
2520 if (userNotificationEvent != null) {
2521 return userNotificationEvent;
2522 }
2523
2524 StringBundler msg = new StringBundler(6);
2525
2526 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2527
2528 msg.append("userId=");
2529 msg.append(userId);
2530
2531 msg.append(", deliveryType=");
2532 msg.append(deliveryType);
2533
2534 msg.append(StringPool.CLOSE_CURLY_BRACE);
2535
2536 throw new NoSuchUserNotificationEventException(msg.toString());
2537 }
2538
2539
2547 @Override
2548 public UserNotificationEvent fetchByU_DT_First(long userId,
2549 int deliveryType,
2550 OrderByComparator<UserNotificationEvent> orderByComparator) {
2551 List<UserNotificationEvent> list = findByU_DT(userId, deliveryType, 0,
2552 1, orderByComparator);
2553
2554 if (!list.isEmpty()) {
2555 return list.get(0);
2556 }
2557
2558 return null;
2559 }
2560
2561
2570 @Override
2571 public UserNotificationEvent findByU_DT_Last(long userId, int deliveryType,
2572 OrderByComparator<UserNotificationEvent> orderByComparator)
2573 throws NoSuchUserNotificationEventException {
2574 UserNotificationEvent userNotificationEvent = fetchByU_DT_Last(userId,
2575 deliveryType, orderByComparator);
2576
2577 if (userNotificationEvent != null) {
2578 return userNotificationEvent;
2579 }
2580
2581 StringBundler msg = new StringBundler(6);
2582
2583 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2584
2585 msg.append("userId=");
2586 msg.append(userId);
2587
2588 msg.append(", deliveryType=");
2589 msg.append(deliveryType);
2590
2591 msg.append(StringPool.CLOSE_CURLY_BRACE);
2592
2593 throw new NoSuchUserNotificationEventException(msg.toString());
2594 }
2595
2596
2604 @Override
2605 public UserNotificationEvent fetchByU_DT_Last(long userId,
2606 int deliveryType,
2607 OrderByComparator<UserNotificationEvent> orderByComparator) {
2608 int count = countByU_DT(userId, deliveryType);
2609
2610 if (count == 0) {
2611 return null;
2612 }
2613
2614 List<UserNotificationEvent> list = findByU_DT(userId, deliveryType,
2615 count - 1, count, orderByComparator);
2616
2617 if (!list.isEmpty()) {
2618 return list.get(0);
2619 }
2620
2621 return null;
2622 }
2623
2624
2634 @Override
2635 public UserNotificationEvent[] findByU_DT_PrevAndNext(
2636 long userNotificationEventId, long userId, int deliveryType,
2637 OrderByComparator<UserNotificationEvent> orderByComparator)
2638 throws NoSuchUserNotificationEventException {
2639 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
2640
2641 Session session = null;
2642
2643 try {
2644 session = openSession();
2645
2646 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
2647
2648 array[0] = getByU_DT_PrevAndNext(session, userNotificationEvent,
2649 userId, deliveryType, orderByComparator, true);
2650
2651 array[1] = userNotificationEvent;
2652
2653 array[2] = getByU_DT_PrevAndNext(session, userNotificationEvent,
2654 userId, deliveryType, orderByComparator, false);
2655
2656 return array;
2657 }
2658 catch (Exception e) {
2659 throw processException(e);
2660 }
2661 finally {
2662 closeSession(session);
2663 }
2664 }
2665
2666 protected UserNotificationEvent getByU_DT_PrevAndNext(Session session,
2667 UserNotificationEvent userNotificationEvent, long userId,
2668 int deliveryType,
2669 OrderByComparator<UserNotificationEvent> orderByComparator,
2670 boolean previous) {
2671 StringBundler query = null;
2672
2673 if (orderByComparator != null) {
2674 query = new StringBundler(6 +
2675 (orderByComparator.getOrderByFields().length * 6));
2676 }
2677 else {
2678 query = new StringBundler(3);
2679 }
2680
2681 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2682
2683 query.append(_FINDER_COLUMN_U_DT_USERID_2);
2684
2685 query.append(_FINDER_COLUMN_U_DT_DELIVERYTYPE_2);
2686
2687 if (orderByComparator != null) {
2688 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2689
2690 if (orderByConditionFields.length > 0) {
2691 query.append(WHERE_AND);
2692 }
2693
2694 for (int i = 0; i < orderByConditionFields.length; i++) {
2695 query.append(_ORDER_BY_ENTITY_ALIAS);
2696 query.append(orderByConditionFields[i]);
2697
2698 if ((i + 1) < orderByConditionFields.length) {
2699 if (orderByComparator.isAscending() ^ previous) {
2700 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2701 }
2702 else {
2703 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2704 }
2705 }
2706 else {
2707 if (orderByComparator.isAscending() ^ previous) {
2708 query.append(WHERE_GREATER_THAN);
2709 }
2710 else {
2711 query.append(WHERE_LESSER_THAN);
2712 }
2713 }
2714 }
2715
2716 query.append(ORDER_BY_CLAUSE);
2717
2718 String[] orderByFields = orderByComparator.getOrderByFields();
2719
2720 for (int i = 0; i < orderByFields.length; i++) {
2721 query.append(_ORDER_BY_ENTITY_ALIAS);
2722 query.append(orderByFields[i]);
2723
2724 if ((i + 1) < orderByFields.length) {
2725 if (orderByComparator.isAscending() ^ previous) {
2726 query.append(ORDER_BY_ASC_HAS_NEXT);
2727 }
2728 else {
2729 query.append(ORDER_BY_DESC_HAS_NEXT);
2730 }
2731 }
2732 else {
2733 if (orderByComparator.isAscending() ^ previous) {
2734 query.append(ORDER_BY_ASC);
2735 }
2736 else {
2737 query.append(ORDER_BY_DESC);
2738 }
2739 }
2740 }
2741 }
2742 else {
2743 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2744 }
2745
2746 String sql = query.toString();
2747
2748 Query q = session.createQuery(sql);
2749
2750 q.setFirstResult(0);
2751 q.setMaxResults(2);
2752
2753 QueryPos qPos = QueryPos.getInstance(q);
2754
2755 qPos.add(userId);
2756
2757 qPos.add(deliveryType);
2758
2759 if (orderByComparator != null) {
2760 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
2761
2762 for (Object value : values) {
2763 qPos.add(value);
2764 }
2765 }
2766
2767 List<UserNotificationEvent> list = q.list();
2768
2769 if (list.size() == 2) {
2770 return list.get(1);
2771 }
2772 else {
2773 return null;
2774 }
2775 }
2776
2777
2783 @Override
2784 public void removeByU_DT(long userId, int deliveryType) {
2785 for (UserNotificationEvent userNotificationEvent : findByU_DT(userId,
2786 deliveryType, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2787 remove(userNotificationEvent);
2788 }
2789 }
2790
2791
2798 @Override
2799 public int countByU_DT(long userId, int deliveryType) {
2800 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT;
2801
2802 Object[] finderArgs = new Object[] { userId, deliveryType };
2803
2804 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2805
2806 if (count == null) {
2807 StringBundler query = new StringBundler(3);
2808
2809 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2810
2811 query.append(_FINDER_COLUMN_U_DT_USERID_2);
2812
2813 query.append(_FINDER_COLUMN_U_DT_DELIVERYTYPE_2);
2814
2815 String sql = query.toString();
2816
2817 Session session = null;
2818
2819 try {
2820 session = openSession();
2821
2822 Query q = session.createQuery(sql);
2823
2824 QueryPos qPos = QueryPos.getInstance(q);
2825
2826 qPos.add(userId);
2827
2828 qPos.add(deliveryType);
2829
2830 count = (Long)q.uniqueResult();
2831
2832 finderCache.putResult(finderPath, finderArgs, count);
2833 }
2834 catch (Exception e) {
2835 finderCache.removeResult(finderPath, finderArgs);
2836
2837 throw processException(e);
2838 }
2839 finally {
2840 closeSession(session);
2841 }
2842 }
2843
2844 return count.intValue();
2845 }
2846
2847 private static final String _FINDER_COLUMN_U_DT_USERID_2 = "userNotificationEvent.userId = ? AND ";
2848 private static final String _FINDER_COLUMN_U_DT_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ?";
2849 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2850 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2851 UserNotificationEventImpl.class,
2852 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_D",
2853 new String[] {
2854 Long.class.getName(), Boolean.class.getName(),
2855
2856 Integer.class.getName(), Integer.class.getName(),
2857 OrderByComparator.class.getName()
2858 });
2859 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2860 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2861 UserNotificationEventImpl.class,
2862 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_D",
2863 new String[] { Long.class.getName(), Boolean.class.getName() },
2864 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
2865 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
2866 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
2867 public static final FinderPath FINDER_PATH_COUNT_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2868 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
2869 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_D",
2870 new String[] { Long.class.getName(), Boolean.class.getName() });
2871
2872
2879 @Override
2880 public List<UserNotificationEvent> findByU_D(long userId, boolean delivered) {
2881 return findByU_D(userId, delivered, QueryUtil.ALL_POS,
2882 QueryUtil.ALL_POS, null);
2883 }
2884
2885
2898 @Override
2899 public List<UserNotificationEvent> findByU_D(long userId,
2900 boolean delivered, int start, int end) {
2901 return findByU_D(userId, delivered, start, end, null);
2902 }
2903
2904
2918 @Override
2919 public List<UserNotificationEvent> findByU_D(long userId,
2920 boolean delivered, int start, int end,
2921 OrderByComparator<UserNotificationEvent> orderByComparator) {
2922 return findByU_D(userId, delivered, start, end, orderByComparator, true);
2923 }
2924
2925
2940 @Override
2941 public List<UserNotificationEvent> findByU_D(long userId,
2942 boolean delivered, int start, int end,
2943 OrderByComparator<UserNotificationEvent> orderByComparator,
2944 boolean retrieveFromCache) {
2945 boolean pagination = true;
2946 FinderPath finderPath = null;
2947 Object[] finderArgs = null;
2948
2949 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2950 (orderByComparator == null)) {
2951 pagination = false;
2952 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D;
2953 finderArgs = new Object[] { userId, delivered };
2954 }
2955 else {
2956 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D;
2957 finderArgs = new Object[] {
2958 userId, delivered,
2959
2960 start, end, orderByComparator
2961 };
2962 }
2963
2964 List<UserNotificationEvent> list = null;
2965
2966 if (retrieveFromCache) {
2967 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
2968 finderArgs, this);
2969
2970 if ((list != null) && !list.isEmpty()) {
2971 for (UserNotificationEvent userNotificationEvent : list) {
2972 if ((userId != userNotificationEvent.getUserId()) ||
2973 (delivered != userNotificationEvent.getDelivered())) {
2974 list = null;
2975
2976 break;
2977 }
2978 }
2979 }
2980 }
2981
2982 if (list == null) {
2983 StringBundler query = null;
2984
2985 if (orderByComparator != null) {
2986 query = new StringBundler(4 +
2987 (orderByComparator.getOrderByFields().length * 3));
2988 }
2989 else {
2990 query = new StringBundler(4);
2991 }
2992
2993 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2994
2995 query.append(_FINDER_COLUMN_U_D_USERID_2);
2996
2997 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
2998
2999 if (orderByComparator != null) {
3000 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3001 orderByComparator);
3002 }
3003 else
3004 if (pagination) {
3005 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3006 }
3007
3008 String sql = query.toString();
3009
3010 Session session = null;
3011
3012 try {
3013 session = openSession();
3014
3015 Query q = session.createQuery(sql);
3016
3017 QueryPos qPos = QueryPos.getInstance(q);
3018
3019 qPos.add(userId);
3020
3021 qPos.add(delivered);
3022
3023 if (!pagination) {
3024 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3025 getDialect(), start, end, false);
3026
3027 Collections.sort(list);
3028
3029 list = Collections.unmodifiableList(list);
3030 }
3031 else {
3032 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3033 getDialect(), start, end);
3034 }
3035
3036 cacheResult(list);
3037
3038 finderCache.putResult(finderPath, finderArgs, list);
3039 }
3040 catch (Exception e) {
3041 finderCache.removeResult(finderPath, finderArgs);
3042
3043 throw processException(e);
3044 }
3045 finally {
3046 closeSession(session);
3047 }
3048 }
3049
3050 return list;
3051 }
3052
3053
3062 @Override
3063 public UserNotificationEvent findByU_D_First(long userId,
3064 boolean delivered,
3065 OrderByComparator<UserNotificationEvent> orderByComparator)
3066 throws NoSuchUserNotificationEventException {
3067 UserNotificationEvent userNotificationEvent = fetchByU_D_First(userId,
3068 delivered, orderByComparator);
3069
3070 if (userNotificationEvent != null) {
3071 return userNotificationEvent;
3072 }
3073
3074 StringBundler msg = new StringBundler(6);
3075
3076 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3077
3078 msg.append("userId=");
3079 msg.append(userId);
3080
3081 msg.append(", delivered=");
3082 msg.append(delivered);
3083
3084 msg.append(StringPool.CLOSE_CURLY_BRACE);
3085
3086 throw new NoSuchUserNotificationEventException(msg.toString());
3087 }
3088
3089
3097 @Override
3098 public UserNotificationEvent fetchByU_D_First(long userId,
3099 boolean delivered,
3100 OrderByComparator<UserNotificationEvent> orderByComparator) {
3101 List<UserNotificationEvent> list = findByU_D(userId, delivered, 0, 1,
3102 orderByComparator);
3103
3104 if (!list.isEmpty()) {
3105 return list.get(0);
3106 }
3107
3108 return null;
3109 }
3110
3111
3120 @Override
3121 public UserNotificationEvent findByU_D_Last(long userId, boolean delivered,
3122 OrderByComparator<UserNotificationEvent> orderByComparator)
3123 throws NoSuchUserNotificationEventException {
3124 UserNotificationEvent userNotificationEvent = fetchByU_D_Last(userId,
3125 delivered, orderByComparator);
3126
3127 if (userNotificationEvent != null) {
3128 return userNotificationEvent;
3129 }
3130
3131 StringBundler msg = new StringBundler(6);
3132
3133 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3134
3135 msg.append("userId=");
3136 msg.append(userId);
3137
3138 msg.append(", delivered=");
3139 msg.append(delivered);
3140
3141 msg.append(StringPool.CLOSE_CURLY_BRACE);
3142
3143 throw new NoSuchUserNotificationEventException(msg.toString());
3144 }
3145
3146
3154 @Override
3155 public UserNotificationEvent fetchByU_D_Last(long userId,
3156 boolean delivered,
3157 OrderByComparator<UserNotificationEvent> orderByComparator) {
3158 int count = countByU_D(userId, delivered);
3159
3160 if (count == 0) {
3161 return null;
3162 }
3163
3164 List<UserNotificationEvent> list = findByU_D(userId, delivered,
3165 count - 1, count, orderByComparator);
3166
3167 if (!list.isEmpty()) {
3168 return list.get(0);
3169 }
3170
3171 return null;
3172 }
3173
3174
3184 @Override
3185 public UserNotificationEvent[] findByU_D_PrevAndNext(
3186 long userNotificationEventId, long userId, boolean delivered,
3187 OrderByComparator<UserNotificationEvent> orderByComparator)
3188 throws NoSuchUserNotificationEventException {
3189 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
3190
3191 Session session = null;
3192
3193 try {
3194 session = openSession();
3195
3196 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
3197
3198 array[0] = getByU_D_PrevAndNext(session, userNotificationEvent,
3199 userId, delivered, orderByComparator, true);
3200
3201 array[1] = userNotificationEvent;
3202
3203 array[2] = getByU_D_PrevAndNext(session, userNotificationEvent,
3204 userId, delivered, orderByComparator, false);
3205
3206 return array;
3207 }
3208 catch (Exception e) {
3209 throw processException(e);
3210 }
3211 finally {
3212 closeSession(session);
3213 }
3214 }
3215
3216 protected UserNotificationEvent getByU_D_PrevAndNext(Session session,
3217 UserNotificationEvent userNotificationEvent, long userId,
3218 boolean delivered,
3219 OrderByComparator<UserNotificationEvent> orderByComparator,
3220 boolean previous) {
3221 StringBundler query = null;
3222
3223 if (orderByComparator != null) {
3224 query = new StringBundler(6 +
3225 (orderByComparator.getOrderByFields().length * 6));
3226 }
3227 else {
3228 query = new StringBundler(3);
3229 }
3230
3231 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3232
3233 query.append(_FINDER_COLUMN_U_D_USERID_2);
3234
3235 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
3236
3237 if (orderByComparator != null) {
3238 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3239
3240 if (orderByConditionFields.length > 0) {
3241 query.append(WHERE_AND);
3242 }
3243
3244 for (int i = 0; i < orderByConditionFields.length; i++) {
3245 query.append(_ORDER_BY_ENTITY_ALIAS);
3246 query.append(orderByConditionFields[i]);
3247
3248 if ((i + 1) < orderByConditionFields.length) {
3249 if (orderByComparator.isAscending() ^ previous) {
3250 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3251 }
3252 else {
3253 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3254 }
3255 }
3256 else {
3257 if (orderByComparator.isAscending() ^ previous) {
3258 query.append(WHERE_GREATER_THAN);
3259 }
3260 else {
3261 query.append(WHERE_LESSER_THAN);
3262 }
3263 }
3264 }
3265
3266 query.append(ORDER_BY_CLAUSE);
3267
3268 String[] orderByFields = orderByComparator.getOrderByFields();
3269
3270 for (int i = 0; i < orderByFields.length; i++) {
3271 query.append(_ORDER_BY_ENTITY_ALIAS);
3272 query.append(orderByFields[i]);
3273
3274 if ((i + 1) < orderByFields.length) {
3275 if (orderByComparator.isAscending() ^ previous) {
3276 query.append(ORDER_BY_ASC_HAS_NEXT);
3277 }
3278 else {
3279 query.append(ORDER_BY_DESC_HAS_NEXT);
3280 }
3281 }
3282 else {
3283 if (orderByComparator.isAscending() ^ previous) {
3284 query.append(ORDER_BY_ASC);
3285 }
3286 else {
3287 query.append(ORDER_BY_DESC);
3288 }
3289 }
3290 }
3291 }
3292 else {
3293 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3294 }
3295
3296 String sql = query.toString();
3297
3298 Query q = session.createQuery(sql);
3299
3300 q.setFirstResult(0);
3301 q.setMaxResults(2);
3302
3303 QueryPos qPos = QueryPos.getInstance(q);
3304
3305 qPos.add(userId);
3306
3307 qPos.add(delivered);
3308
3309 if (orderByComparator != null) {
3310 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
3311
3312 for (Object value : values) {
3313 qPos.add(value);
3314 }
3315 }
3316
3317 List<UserNotificationEvent> list = q.list();
3318
3319 if (list.size() == 2) {
3320 return list.get(1);
3321 }
3322 else {
3323 return null;
3324 }
3325 }
3326
3327
3333 @Override
3334 public void removeByU_D(long userId, boolean delivered) {
3335 for (UserNotificationEvent userNotificationEvent : findByU_D(userId,
3336 delivered, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3337 remove(userNotificationEvent);
3338 }
3339 }
3340
3341
3348 @Override
3349 public int countByU_D(long userId, boolean delivered) {
3350 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_D;
3351
3352 Object[] finderArgs = new Object[] { userId, delivered };
3353
3354 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3355
3356 if (count == null) {
3357 StringBundler query = new StringBundler(3);
3358
3359 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
3360
3361 query.append(_FINDER_COLUMN_U_D_USERID_2);
3362
3363 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
3364
3365 String sql = query.toString();
3366
3367 Session session = null;
3368
3369 try {
3370 session = openSession();
3371
3372 Query q = session.createQuery(sql);
3373
3374 QueryPos qPos = QueryPos.getInstance(q);
3375
3376 qPos.add(userId);
3377
3378 qPos.add(delivered);
3379
3380 count = (Long)q.uniqueResult();
3381
3382 finderCache.putResult(finderPath, finderArgs, count);
3383 }
3384 catch (Exception e) {
3385 finderCache.removeResult(finderPath, finderArgs);
3386
3387 throw processException(e);
3388 }
3389 finally {
3390 closeSession(session);
3391 }
3392 }
3393
3394 return count.intValue();
3395 }
3396
3397 private static final String _FINDER_COLUMN_U_D_USERID_2 = "userNotificationEvent.userId = ? AND ";
3398 private static final String _FINDER_COLUMN_U_D_DELIVERED_2 = "userNotificationEvent.delivered = ?";
3399 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3400 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3401 UserNotificationEventImpl.class,
3402 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_A",
3403 new String[] {
3404 Long.class.getName(), Boolean.class.getName(),
3405
3406 Integer.class.getName(), Integer.class.getName(),
3407 OrderByComparator.class.getName()
3408 });
3409 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3410 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3411 UserNotificationEventImpl.class,
3412 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_A",
3413 new String[] { Long.class.getName(), Boolean.class.getName() },
3414 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
3415 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
3416 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
3417 public static final FinderPath FINDER_PATH_COUNT_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3418 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
3419 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_A",
3420 new String[] { Long.class.getName(), Boolean.class.getName() });
3421
3422
3429 @Override
3430 public List<UserNotificationEvent> findByU_A(long userId, boolean archived) {
3431 return findByU_A(userId, archived, QueryUtil.ALL_POS,
3432 QueryUtil.ALL_POS, null);
3433 }
3434
3435
3448 @Override
3449 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
3450 int start, int end) {
3451 return findByU_A(userId, archived, start, end, null);
3452 }
3453
3454
3468 @Override
3469 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
3470 int start, int end,
3471 OrderByComparator<UserNotificationEvent> orderByComparator) {
3472 return findByU_A(userId, archived, start, end, orderByComparator, true);
3473 }
3474
3475
3490 @Override
3491 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
3492 int start, int end,
3493 OrderByComparator<UserNotificationEvent> orderByComparator,
3494 boolean retrieveFromCache) {
3495 boolean pagination = true;
3496 FinderPath finderPath = null;
3497 Object[] finderArgs = null;
3498
3499 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3500 (orderByComparator == null)) {
3501 pagination = false;
3502 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A;
3503 finderArgs = new Object[] { userId, archived };
3504 }
3505 else {
3506 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A;
3507 finderArgs = new Object[] {
3508 userId, archived,
3509
3510 start, end, orderByComparator
3511 };
3512 }
3513
3514 List<UserNotificationEvent> list = null;
3515
3516 if (retrieveFromCache) {
3517 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
3518 finderArgs, this);
3519
3520 if ((list != null) && !list.isEmpty()) {
3521 for (UserNotificationEvent userNotificationEvent : list) {
3522 if ((userId != userNotificationEvent.getUserId()) ||
3523 (archived != userNotificationEvent.getArchived())) {
3524 list = null;
3525
3526 break;
3527 }
3528 }
3529 }
3530 }
3531
3532 if (list == null) {
3533 StringBundler query = null;
3534
3535 if (orderByComparator != null) {
3536 query = new StringBundler(4 +
3537 (orderByComparator.getOrderByFields().length * 3));
3538 }
3539 else {
3540 query = new StringBundler(4);
3541 }
3542
3543 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3544
3545 query.append(_FINDER_COLUMN_U_A_USERID_2);
3546
3547 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
3548
3549 if (orderByComparator != null) {
3550 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3551 orderByComparator);
3552 }
3553 else
3554 if (pagination) {
3555 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3556 }
3557
3558 String sql = query.toString();
3559
3560 Session session = null;
3561
3562 try {
3563 session = openSession();
3564
3565 Query q = session.createQuery(sql);
3566
3567 QueryPos qPos = QueryPos.getInstance(q);
3568
3569 qPos.add(userId);
3570
3571 qPos.add(archived);
3572
3573 if (!pagination) {
3574 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3575 getDialect(), start, end, false);
3576
3577 Collections.sort(list);
3578
3579 list = Collections.unmodifiableList(list);
3580 }
3581 else {
3582 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3583 getDialect(), start, end);
3584 }
3585
3586 cacheResult(list);
3587
3588 finderCache.putResult(finderPath, finderArgs, list);
3589 }
3590 catch (Exception e) {
3591 finderCache.removeResult(finderPath, finderArgs);
3592
3593 throw processException(e);
3594 }
3595 finally {
3596 closeSession(session);
3597 }
3598 }
3599
3600 return list;
3601 }
3602
3603
3612 @Override
3613 public UserNotificationEvent findByU_A_First(long userId, boolean archived,
3614 OrderByComparator<UserNotificationEvent> orderByComparator)
3615 throws NoSuchUserNotificationEventException {
3616 UserNotificationEvent userNotificationEvent = fetchByU_A_First(userId,
3617 archived, orderByComparator);
3618
3619 if (userNotificationEvent != null) {
3620 return userNotificationEvent;
3621 }
3622
3623 StringBundler msg = new StringBundler(6);
3624
3625 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3626
3627 msg.append("userId=");
3628 msg.append(userId);
3629
3630 msg.append(", archived=");
3631 msg.append(archived);
3632
3633 msg.append(StringPool.CLOSE_CURLY_BRACE);
3634
3635 throw new NoSuchUserNotificationEventException(msg.toString());
3636 }
3637
3638
3646 @Override
3647 public UserNotificationEvent fetchByU_A_First(long userId,
3648 boolean archived,
3649 OrderByComparator<UserNotificationEvent> orderByComparator) {
3650 List<UserNotificationEvent> list = findByU_A(userId, archived, 0, 1,
3651 orderByComparator);
3652
3653 if (!list.isEmpty()) {
3654 return list.get(0);
3655 }
3656
3657 return null;
3658 }
3659
3660
3669 @Override
3670 public UserNotificationEvent findByU_A_Last(long userId, boolean archived,
3671 OrderByComparator<UserNotificationEvent> orderByComparator)
3672 throws NoSuchUserNotificationEventException {
3673 UserNotificationEvent userNotificationEvent = fetchByU_A_Last(userId,
3674 archived, orderByComparator);
3675
3676 if (userNotificationEvent != null) {
3677 return userNotificationEvent;
3678 }
3679
3680 StringBundler msg = new StringBundler(6);
3681
3682 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3683
3684 msg.append("userId=");
3685 msg.append(userId);
3686
3687 msg.append(", archived=");
3688 msg.append(archived);
3689
3690 msg.append(StringPool.CLOSE_CURLY_BRACE);
3691
3692 throw new NoSuchUserNotificationEventException(msg.toString());
3693 }
3694
3695
3703 @Override
3704 public UserNotificationEvent fetchByU_A_Last(long userId, boolean archived,
3705 OrderByComparator<UserNotificationEvent> orderByComparator) {
3706 int count = countByU_A(userId, archived);
3707
3708 if (count == 0) {
3709 return null;
3710 }
3711
3712 List<UserNotificationEvent> list = findByU_A(userId, archived,
3713 count - 1, count, orderByComparator);
3714
3715 if (!list.isEmpty()) {
3716 return list.get(0);
3717 }
3718
3719 return null;
3720 }
3721
3722
3732 @Override
3733 public UserNotificationEvent[] findByU_A_PrevAndNext(
3734 long userNotificationEventId, long userId, boolean archived,
3735 OrderByComparator<UserNotificationEvent> orderByComparator)
3736 throws NoSuchUserNotificationEventException {
3737 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
3738
3739 Session session = null;
3740
3741 try {
3742 session = openSession();
3743
3744 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
3745
3746 array[0] = getByU_A_PrevAndNext(session, userNotificationEvent,
3747 userId, archived, orderByComparator, true);
3748
3749 array[1] = userNotificationEvent;
3750
3751 array[2] = getByU_A_PrevAndNext(session, userNotificationEvent,
3752 userId, archived, orderByComparator, false);
3753
3754 return array;
3755 }
3756 catch (Exception e) {
3757 throw processException(e);
3758 }
3759 finally {
3760 closeSession(session);
3761 }
3762 }
3763
3764 protected UserNotificationEvent getByU_A_PrevAndNext(Session session,
3765 UserNotificationEvent userNotificationEvent, long userId,
3766 boolean archived,
3767 OrderByComparator<UserNotificationEvent> orderByComparator,
3768 boolean previous) {
3769 StringBundler query = null;
3770
3771 if (orderByComparator != null) {
3772 query = new StringBundler(6 +
3773 (orderByComparator.getOrderByFields().length * 6));
3774 }
3775 else {
3776 query = new StringBundler(3);
3777 }
3778
3779 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
3780
3781 query.append(_FINDER_COLUMN_U_A_USERID_2);
3782
3783 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
3784
3785 if (orderByComparator != null) {
3786 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3787
3788 if (orderByConditionFields.length > 0) {
3789 query.append(WHERE_AND);
3790 }
3791
3792 for (int i = 0; i < orderByConditionFields.length; i++) {
3793 query.append(_ORDER_BY_ENTITY_ALIAS);
3794 query.append(orderByConditionFields[i]);
3795
3796 if ((i + 1) < orderByConditionFields.length) {
3797 if (orderByComparator.isAscending() ^ previous) {
3798 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3799 }
3800 else {
3801 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3802 }
3803 }
3804 else {
3805 if (orderByComparator.isAscending() ^ previous) {
3806 query.append(WHERE_GREATER_THAN);
3807 }
3808 else {
3809 query.append(WHERE_LESSER_THAN);
3810 }
3811 }
3812 }
3813
3814 query.append(ORDER_BY_CLAUSE);
3815
3816 String[] orderByFields = orderByComparator.getOrderByFields();
3817
3818 for (int i = 0; i < orderByFields.length; i++) {
3819 query.append(_ORDER_BY_ENTITY_ALIAS);
3820 query.append(orderByFields[i]);
3821
3822 if ((i + 1) < orderByFields.length) {
3823 if (orderByComparator.isAscending() ^ previous) {
3824 query.append(ORDER_BY_ASC_HAS_NEXT);
3825 }
3826 else {
3827 query.append(ORDER_BY_DESC_HAS_NEXT);
3828 }
3829 }
3830 else {
3831 if (orderByComparator.isAscending() ^ previous) {
3832 query.append(ORDER_BY_ASC);
3833 }
3834 else {
3835 query.append(ORDER_BY_DESC);
3836 }
3837 }
3838 }
3839 }
3840 else {
3841 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3842 }
3843
3844 String sql = query.toString();
3845
3846 Query q = session.createQuery(sql);
3847
3848 q.setFirstResult(0);
3849 q.setMaxResults(2);
3850
3851 QueryPos qPos = QueryPos.getInstance(q);
3852
3853 qPos.add(userId);
3854
3855 qPos.add(archived);
3856
3857 if (orderByComparator != null) {
3858 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
3859
3860 for (Object value : values) {
3861 qPos.add(value);
3862 }
3863 }
3864
3865 List<UserNotificationEvent> list = q.list();
3866
3867 if (list.size() == 2) {
3868 return list.get(1);
3869 }
3870 else {
3871 return null;
3872 }
3873 }
3874
3875
3881 @Override
3882 public void removeByU_A(long userId, boolean archived) {
3883 for (UserNotificationEvent userNotificationEvent : findByU_A(userId,
3884 archived, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3885 remove(userNotificationEvent);
3886 }
3887 }
3888
3889
3896 @Override
3897 public int countByU_A(long userId, boolean archived) {
3898 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_A;
3899
3900 Object[] finderArgs = new Object[] { userId, archived };
3901
3902 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3903
3904 if (count == null) {
3905 StringBundler query = new StringBundler(3);
3906
3907 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
3908
3909 query.append(_FINDER_COLUMN_U_A_USERID_2);
3910
3911 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
3912
3913 String sql = query.toString();
3914
3915 Session session = null;
3916
3917 try {
3918 session = openSession();
3919
3920 Query q = session.createQuery(sql);
3921
3922 QueryPos qPos = QueryPos.getInstance(q);
3923
3924 qPos.add(userId);
3925
3926 qPos.add(archived);
3927
3928 count = (Long)q.uniqueResult();
3929
3930 finderCache.putResult(finderPath, finderArgs, count);
3931 }
3932 catch (Exception e) {
3933 finderCache.removeResult(finderPath, finderArgs);
3934
3935 throw processException(e);
3936 }
3937 finally {
3938 closeSession(session);
3939 }
3940 }
3941
3942 return count.intValue();
3943 }
3944
3945 private static final String _FINDER_COLUMN_U_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
3946 private static final String _FINDER_COLUMN_U_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
3947 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3948 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3949 UserNotificationEventImpl.class,
3950 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_D",
3951 new String[] {
3952 Long.class.getName(), Integer.class.getName(),
3953 Boolean.class.getName(),
3954
3955 Integer.class.getName(), Integer.class.getName(),
3956 OrderByComparator.class.getName()
3957 });
3958 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D =
3959 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3960 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
3961 UserNotificationEventImpl.class,
3962 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_D",
3963 new String[] {
3964 Long.class.getName(), Integer.class.getName(),
3965 Boolean.class.getName()
3966 },
3967 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
3968 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
3969 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
3970 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
3971 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3972 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
3973 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_D",
3974 new String[] {
3975 Long.class.getName(), Integer.class.getName(),
3976 Boolean.class.getName()
3977 });
3978
3979
3987 @Override
3988 public List<UserNotificationEvent> findByU_DT_D(long userId,
3989 int deliveryType, boolean delivered) {
3990 return findByU_DT_D(userId, deliveryType, delivered, QueryUtil.ALL_POS,
3991 QueryUtil.ALL_POS, null);
3992 }
3993
3994
4008 @Override
4009 public List<UserNotificationEvent> findByU_DT_D(long userId,
4010 int deliveryType, boolean delivered, int start, int end) {
4011 return findByU_DT_D(userId, deliveryType, delivered, start, end, null);
4012 }
4013
4014
4029 @Override
4030 public List<UserNotificationEvent> findByU_DT_D(long userId,
4031 int deliveryType, boolean delivered, int start, int end,
4032 OrderByComparator<UserNotificationEvent> orderByComparator) {
4033 return findByU_DT_D(userId, deliveryType, delivered, start, end,
4034 orderByComparator, true);
4035 }
4036
4037
4053 @Override
4054 public List<UserNotificationEvent> findByU_DT_D(long userId,
4055 int deliveryType, boolean delivered, int start, int end,
4056 OrderByComparator<UserNotificationEvent> orderByComparator,
4057 boolean retrieveFromCache) {
4058 boolean pagination = true;
4059 FinderPath finderPath = null;
4060 Object[] finderArgs = null;
4061
4062 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4063 (orderByComparator == null)) {
4064 pagination = false;
4065 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D;
4066 finderArgs = new Object[] { userId, deliveryType, delivered };
4067 }
4068 else {
4069 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D;
4070 finderArgs = new Object[] {
4071 userId, deliveryType, delivered,
4072
4073 start, end, orderByComparator
4074 };
4075 }
4076
4077 List<UserNotificationEvent> list = null;
4078
4079 if (retrieveFromCache) {
4080 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
4081 finderArgs, this);
4082
4083 if ((list != null) && !list.isEmpty()) {
4084 for (UserNotificationEvent userNotificationEvent : list) {
4085 if ((userId != userNotificationEvent.getUserId()) ||
4086 (deliveryType != userNotificationEvent.getDeliveryType()) ||
4087 (delivered != userNotificationEvent.getDelivered())) {
4088 list = null;
4089
4090 break;
4091 }
4092 }
4093 }
4094 }
4095
4096 if (list == null) {
4097 StringBundler query = null;
4098
4099 if (orderByComparator != null) {
4100 query = new StringBundler(5 +
4101 (orderByComparator.getOrderByFields().length * 3));
4102 }
4103 else {
4104 query = new StringBundler(5);
4105 }
4106
4107 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4108
4109 query.append(_FINDER_COLUMN_U_DT_D_USERID_2);
4110
4111 query.append(_FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2);
4112
4113 query.append(_FINDER_COLUMN_U_DT_D_DELIVERED_2);
4114
4115 if (orderByComparator != null) {
4116 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4117 orderByComparator);
4118 }
4119 else
4120 if (pagination) {
4121 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
4122 }
4123
4124 String sql = query.toString();
4125
4126 Session session = null;
4127
4128 try {
4129 session = openSession();
4130
4131 Query q = session.createQuery(sql);
4132
4133 QueryPos qPos = QueryPos.getInstance(q);
4134
4135 qPos.add(userId);
4136
4137 qPos.add(deliveryType);
4138
4139 qPos.add(delivered);
4140
4141 if (!pagination) {
4142 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4143 getDialect(), start, end, false);
4144
4145 Collections.sort(list);
4146
4147 list = Collections.unmodifiableList(list);
4148 }
4149 else {
4150 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4151 getDialect(), start, end);
4152 }
4153
4154 cacheResult(list);
4155
4156 finderCache.putResult(finderPath, finderArgs, list);
4157 }
4158 catch (Exception e) {
4159 finderCache.removeResult(finderPath, finderArgs);
4160
4161 throw processException(e);
4162 }
4163 finally {
4164 closeSession(session);
4165 }
4166 }
4167
4168 return list;
4169 }
4170
4171
4181 @Override
4182 public UserNotificationEvent findByU_DT_D_First(long userId,
4183 int deliveryType, boolean delivered,
4184 OrderByComparator<UserNotificationEvent> orderByComparator)
4185 throws NoSuchUserNotificationEventException {
4186 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_First(userId,
4187 deliveryType, delivered, orderByComparator);
4188
4189 if (userNotificationEvent != null) {
4190 return userNotificationEvent;
4191 }
4192
4193 StringBundler msg = new StringBundler(8);
4194
4195 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4196
4197 msg.append("userId=");
4198 msg.append(userId);
4199
4200 msg.append(", deliveryType=");
4201 msg.append(deliveryType);
4202
4203 msg.append(", delivered=");
4204 msg.append(delivered);
4205
4206 msg.append(StringPool.CLOSE_CURLY_BRACE);
4207
4208 throw new NoSuchUserNotificationEventException(msg.toString());
4209 }
4210
4211
4220 @Override
4221 public UserNotificationEvent fetchByU_DT_D_First(long userId,
4222 int deliveryType, boolean delivered,
4223 OrderByComparator<UserNotificationEvent> orderByComparator) {
4224 List<UserNotificationEvent> list = findByU_DT_D(userId, deliveryType,
4225 delivered, 0, 1, orderByComparator);
4226
4227 if (!list.isEmpty()) {
4228 return list.get(0);
4229 }
4230
4231 return null;
4232 }
4233
4234
4244 @Override
4245 public UserNotificationEvent findByU_DT_D_Last(long userId,
4246 int deliveryType, boolean delivered,
4247 OrderByComparator<UserNotificationEvent> orderByComparator)
4248 throws NoSuchUserNotificationEventException {
4249 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_Last(userId,
4250 deliveryType, delivered, orderByComparator);
4251
4252 if (userNotificationEvent != null) {
4253 return userNotificationEvent;
4254 }
4255
4256 StringBundler msg = new StringBundler(8);
4257
4258 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4259
4260 msg.append("userId=");
4261 msg.append(userId);
4262
4263 msg.append(", deliveryType=");
4264 msg.append(deliveryType);
4265
4266 msg.append(", delivered=");
4267 msg.append(delivered);
4268
4269 msg.append(StringPool.CLOSE_CURLY_BRACE);
4270
4271 throw new NoSuchUserNotificationEventException(msg.toString());
4272 }
4273
4274
4283 @Override
4284 public UserNotificationEvent fetchByU_DT_D_Last(long userId,
4285 int deliveryType, boolean delivered,
4286 OrderByComparator<UserNotificationEvent> orderByComparator) {
4287 int count = countByU_DT_D(userId, deliveryType, delivered);
4288
4289 if (count == 0) {
4290 return null;
4291 }
4292
4293 List<UserNotificationEvent> list = findByU_DT_D(userId, deliveryType,
4294 delivered, count - 1, count, orderByComparator);
4295
4296 if (!list.isEmpty()) {
4297 return list.get(0);
4298 }
4299
4300 return null;
4301 }
4302
4303
4314 @Override
4315 public UserNotificationEvent[] findByU_DT_D_PrevAndNext(
4316 long userNotificationEventId, long userId, int deliveryType,
4317 boolean delivered,
4318 OrderByComparator<UserNotificationEvent> orderByComparator)
4319 throws NoSuchUserNotificationEventException {
4320 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
4321
4322 Session session = null;
4323
4324 try {
4325 session = openSession();
4326
4327 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
4328
4329 array[0] = getByU_DT_D_PrevAndNext(session, userNotificationEvent,
4330 userId, deliveryType, delivered, orderByComparator, true);
4331
4332 array[1] = userNotificationEvent;
4333
4334 array[2] = getByU_DT_D_PrevAndNext(session, userNotificationEvent,
4335 userId, deliveryType, delivered, orderByComparator, false);
4336
4337 return array;
4338 }
4339 catch (Exception e) {
4340 throw processException(e);
4341 }
4342 finally {
4343 closeSession(session);
4344 }
4345 }
4346
4347 protected UserNotificationEvent getByU_DT_D_PrevAndNext(Session session,
4348 UserNotificationEvent userNotificationEvent, long userId,
4349 int deliveryType, boolean delivered,
4350 OrderByComparator<UserNotificationEvent> orderByComparator,
4351 boolean previous) {
4352 StringBundler query = null;
4353
4354 if (orderByComparator != null) {
4355 query = new StringBundler(6 +
4356 (orderByComparator.getOrderByFields().length * 6));
4357 }
4358 else {
4359 query = new StringBundler(3);
4360 }
4361
4362 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4363
4364 query.append(_FINDER_COLUMN_U_DT_D_USERID_2);
4365
4366 query.append(_FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2);
4367
4368 query.append(_FINDER_COLUMN_U_DT_D_DELIVERED_2);
4369
4370 if (orderByComparator != null) {
4371 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4372
4373 if (orderByConditionFields.length > 0) {
4374 query.append(WHERE_AND);
4375 }
4376
4377 for (int i = 0; i < orderByConditionFields.length; i++) {
4378 query.append(_ORDER_BY_ENTITY_ALIAS);
4379 query.append(orderByConditionFields[i]);
4380
4381 if ((i + 1) < orderByConditionFields.length) {
4382 if (orderByComparator.isAscending() ^ previous) {
4383 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4384 }
4385 else {
4386 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4387 }
4388 }
4389 else {
4390 if (orderByComparator.isAscending() ^ previous) {
4391 query.append(WHERE_GREATER_THAN);
4392 }
4393 else {
4394 query.append(WHERE_LESSER_THAN);
4395 }
4396 }
4397 }
4398
4399 query.append(ORDER_BY_CLAUSE);
4400
4401 String[] orderByFields = orderByComparator.getOrderByFields();
4402
4403 for (int i = 0; i < orderByFields.length; i++) {
4404 query.append(_ORDER_BY_ENTITY_ALIAS);
4405 query.append(orderByFields[i]);
4406
4407 if ((i + 1) < orderByFields.length) {
4408 if (orderByComparator.isAscending() ^ previous) {
4409 query.append(ORDER_BY_ASC_HAS_NEXT);
4410 }
4411 else {
4412 query.append(ORDER_BY_DESC_HAS_NEXT);
4413 }
4414 }
4415 else {
4416 if (orderByComparator.isAscending() ^ previous) {
4417 query.append(ORDER_BY_ASC);
4418 }
4419 else {
4420 query.append(ORDER_BY_DESC);
4421 }
4422 }
4423 }
4424 }
4425 else {
4426 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
4427 }
4428
4429 String sql = query.toString();
4430
4431 Query q = session.createQuery(sql);
4432
4433 q.setFirstResult(0);
4434 q.setMaxResults(2);
4435
4436 QueryPos qPos = QueryPos.getInstance(q);
4437
4438 qPos.add(userId);
4439
4440 qPos.add(deliveryType);
4441
4442 qPos.add(delivered);
4443
4444 if (orderByComparator != null) {
4445 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
4446
4447 for (Object value : values) {
4448 qPos.add(value);
4449 }
4450 }
4451
4452 List<UserNotificationEvent> list = q.list();
4453
4454 if (list.size() == 2) {
4455 return list.get(1);
4456 }
4457 else {
4458 return null;
4459 }
4460 }
4461
4462
4469 @Override
4470 public void removeByU_DT_D(long userId, int deliveryType, boolean delivered) {
4471 for (UserNotificationEvent userNotificationEvent : findByU_DT_D(
4472 userId, deliveryType, delivered, QueryUtil.ALL_POS,
4473 QueryUtil.ALL_POS, null)) {
4474 remove(userNotificationEvent);
4475 }
4476 }
4477
4478
4486 @Override
4487 public int countByU_DT_D(long userId, int deliveryType, boolean delivered) {
4488 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_D;
4489
4490 Object[] finderArgs = new Object[] { userId, deliveryType, delivered };
4491
4492 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4493
4494 if (count == null) {
4495 StringBundler query = new StringBundler(4);
4496
4497 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
4498
4499 query.append(_FINDER_COLUMN_U_DT_D_USERID_2);
4500
4501 query.append(_FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2);
4502
4503 query.append(_FINDER_COLUMN_U_DT_D_DELIVERED_2);
4504
4505 String sql = query.toString();
4506
4507 Session session = null;
4508
4509 try {
4510 session = openSession();
4511
4512 Query q = session.createQuery(sql);
4513
4514 QueryPos qPos = QueryPos.getInstance(q);
4515
4516 qPos.add(userId);
4517
4518 qPos.add(deliveryType);
4519
4520 qPos.add(delivered);
4521
4522 count = (Long)q.uniqueResult();
4523
4524 finderCache.putResult(finderPath, finderArgs, count);
4525 }
4526 catch (Exception e) {
4527 finderCache.removeResult(finderPath, finderArgs);
4528
4529 throw processException(e);
4530 }
4531 finally {
4532 closeSession(session);
4533 }
4534 }
4535
4536 return count.intValue();
4537 }
4538
4539 private static final String _FINDER_COLUMN_U_DT_D_USERID_2 = "userNotificationEvent.userId = ? AND ";
4540 private static final String _FINDER_COLUMN_U_DT_D_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
4541 private static final String _FINDER_COLUMN_U_DT_D_DELIVERED_2 = "userNotificationEvent.delivered = ?";
4542 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4543 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
4544 UserNotificationEventImpl.class,
4545 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_A",
4546 new String[] {
4547 Long.class.getName(), Integer.class.getName(),
4548 Boolean.class.getName(),
4549
4550 Integer.class.getName(), Integer.class.getName(),
4551 OrderByComparator.class.getName()
4552 });
4553 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A =
4554 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4555 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
4556 UserNotificationEventImpl.class,
4557 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_A",
4558 new String[] {
4559 Long.class.getName(), Integer.class.getName(),
4560 Boolean.class.getName()
4561 },
4562 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
4563 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
4564 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
4565 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
4566 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
4567 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
4568 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_A",
4569 new String[] {
4570 Long.class.getName(), Integer.class.getName(),
4571 Boolean.class.getName()
4572 });
4573
4574
4582 @Override
4583 public List<UserNotificationEvent> findByU_DT_A(long userId,
4584 int deliveryType, boolean archived) {
4585 return findByU_DT_A(userId, deliveryType, archived, QueryUtil.ALL_POS,
4586 QueryUtil.ALL_POS, null);
4587 }
4588
4589
4603 @Override
4604 public List<UserNotificationEvent> findByU_DT_A(long userId,
4605 int deliveryType, boolean archived, int start, int end) {
4606 return findByU_DT_A(userId, deliveryType, archived, start, end, null);
4607 }
4608
4609
4624 @Override
4625 public List<UserNotificationEvent> findByU_DT_A(long userId,
4626 int deliveryType, boolean archived, int start, int end,
4627 OrderByComparator<UserNotificationEvent> orderByComparator) {
4628 return findByU_DT_A(userId, deliveryType, archived, start, end,
4629 orderByComparator, true);
4630 }
4631
4632
4648 @Override
4649 public List<UserNotificationEvent> findByU_DT_A(long userId,
4650 int deliveryType, boolean archived, int start, int end,
4651 OrderByComparator<UserNotificationEvent> orderByComparator,
4652 boolean retrieveFromCache) {
4653 boolean pagination = true;
4654 FinderPath finderPath = null;
4655 Object[] finderArgs = null;
4656
4657 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4658 (orderByComparator == null)) {
4659 pagination = false;
4660 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A;
4661 finderArgs = new Object[] { userId, deliveryType, archived };
4662 }
4663 else {
4664 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A;
4665 finderArgs = new Object[] {
4666 userId, deliveryType, archived,
4667
4668 start, end, orderByComparator
4669 };
4670 }
4671
4672 List<UserNotificationEvent> list = null;
4673
4674 if (retrieveFromCache) {
4675 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
4676 finderArgs, this);
4677
4678 if ((list != null) && !list.isEmpty()) {
4679 for (UserNotificationEvent userNotificationEvent : list) {
4680 if ((userId != userNotificationEvent.getUserId()) ||
4681 (deliveryType != userNotificationEvent.getDeliveryType()) ||
4682 (archived != userNotificationEvent.getArchived())) {
4683 list = null;
4684
4685 break;
4686 }
4687 }
4688 }
4689 }
4690
4691 if (list == null) {
4692 StringBundler query = null;
4693
4694 if (orderByComparator != null) {
4695 query = new StringBundler(5 +
4696 (orderByComparator.getOrderByFields().length * 3));
4697 }
4698 else {
4699 query = new StringBundler(5);
4700 }
4701
4702 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4703
4704 query.append(_FINDER_COLUMN_U_DT_A_USERID_2);
4705
4706 query.append(_FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2);
4707
4708 query.append(_FINDER_COLUMN_U_DT_A_ARCHIVED_2);
4709
4710 if (orderByComparator != null) {
4711 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4712 orderByComparator);
4713 }
4714 else
4715 if (pagination) {
4716 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
4717 }
4718
4719 String sql = query.toString();
4720
4721 Session session = null;
4722
4723 try {
4724 session = openSession();
4725
4726 Query q = session.createQuery(sql);
4727
4728 QueryPos qPos = QueryPos.getInstance(q);
4729
4730 qPos.add(userId);
4731
4732 qPos.add(deliveryType);
4733
4734 qPos.add(archived);
4735
4736 if (!pagination) {
4737 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4738 getDialect(), start, end, false);
4739
4740 Collections.sort(list);
4741
4742 list = Collections.unmodifiableList(list);
4743 }
4744 else {
4745 list = (List<UserNotificationEvent>)QueryUtil.list(q,
4746 getDialect(), start, end);
4747 }
4748
4749 cacheResult(list);
4750
4751 finderCache.putResult(finderPath, finderArgs, list);
4752 }
4753 catch (Exception e) {
4754 finderCache.removeResult(finderPath, finderArgs);
4755
4756 throw processException(e);
4757 }
4758 finally {
4759 closeSession(session);
4760 }
4761 }
4762
4763 return list;
4764 }
4765
4766
4776 @Override
4777 public UserNotificationEvent findByU_DT_A_First(long userId,
4778 int deliveryType, boolean archived,
4779 OrderByComparator<UserNotificationEvent> orderByComparator)
4780 throws NoSuchUserNotificationEventException {
4781 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_First(userId,
4782 deliveryType, archived, orderByComparator);
4783
4784 if (userNotificationEvent != null) {
4785 return userNotificationEvent;
4786 }
4787
4788 StringBundler msg = new StringBundler(8);
4789
4790 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4791
4792 msg.append("userId=");
4793 msg.append(userId);
4794
4795 msg.append(", deliveryType=");
4796 msg.append(deliveryType);
4797
4798 msg.append(", archived=");
4799 msg.append(archived);
4800
4801 msg.append(StringPool.CLOSE_CURLY_BRACE);
4802
4803 throw new NoSuchUserNotificationEventException(msg.toString());
4804 }
4805
4806
4815 @Override
4816 public UserNotificationEvent fetchByU_DT_A_First(long userId,
4817 int deliveryType, boolean archived,
4818 OrderByComparator<UserNotificationEvent> orderByComparator) {
4819 List<UserNotificationEvent> list = findByU_DT_A(userId, deliveryType,
4820 archived, 0, 1, orderByComparator);
4821
4822 if (!list.isEmpty()) {
4823 return list.get(0);
4824 }
4825
4826 return null;
4827 }
4828
4829
4839 @Override
4840 public UserNotificationEvent findByU_DT_A_Last(long userId,
4841 int deliveryType, boolean archived,
4842 OrderByComparator<UserNotificationEvent> orderByComparator)
4843 throws NoSuchUserNotificationEventException {
4844 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_Last(userId,
4845 deliveryType, archived, orderByComparator);
4846
4847 if (userNotificationEvent != null) {
4848 return userNotificationEvent;
4849 }
4850
4851 StringBundler msg = new StringBundler(8);
4852
4853 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4854
4855 msg.append("userId=");
4856 msg.append(userId);
4857
4858 msg.append(", deliveryType=");
4859 msg.append(deliveryType);
4860
4861 msg.append(", archived=");
4862 msg.append(archived);
4863
4864 msg.append(StringPool.CLOSE_CURLY_BRACE);
4865
4866 throw new NoSuchUserNotificationEventException(msg.toString());
4867 }
4868
4869
4878 @Override
4879 public UserNotificationEvent fetchByU_DT_A_Last(long userId,
4880 int deliveryType, boolean archived,
4881 OrderByComparator<UserNotificationEvent> orderByComparator) {
4882 int count = countByU_DT_A(userId, deliveryType, archived);
4883
4884 if (count == 0) {
4885 return null;
4886 }
4887
4888 List<UserNotificationEvent> list = findByU_DT_A(userId, deliveryType,
4889 archived, count - 1, count, orderByComparator);
4890
4891 if (!list.isEmpty()) {
4892 return list.get(0);
4893 }
4894
4895 return null;
4896 }
4897
4898
4909 @Override
4910 public UserNotificationEvent[] findByU_DT_A_PrevAndNext(
4911 long userNotificationEventId, long userId, int deliveryType,
4912 boolean archived,
4913 OrderByComparator<UserNotificationEvent> orderByComparator)
4914 throws NoSuchUserNotificationEventException {
4915 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
4916
4917 Session session = null;
4918
4919 try {
4920 session = openSession();
4921
4922 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
4923
4924 array[0] = getByU_DT_A_PrevAndNext(session, userNotificationEvent,
4925 userId, deliveryType, archived, orderByComparator, true);
4926
4927 array[1] = userNotificationEvent;
4928
4929 array[2] = getByU_DT_A_PrevAndNext(session, userNotificationEvent,
4930 userId, deliveryType, archived, orderByComparator, false);
4931
4932 return array;
4933 }
4934 catch (Exception e) {
4935 throw processException(e);
4936 }
4937 finally {
4938 closeSession(session);
4939 }
4940 }
4941
4942 protected UserNotificationEvent getByU_DT_A_PrevAndNext(Session session,
4943 UserNotificationEvent userNotificationEvent, long userId,
4944 int deliveryType, boolean archived,
4945 OrderByComparator<UserNotificationEvent> orderByComparator,
4946 boolean previous) {
4947 StringBundler query = null;
4948
4949 if (orderByComparator != null) {
4950 query = new StringBundler(6 +
4951 (orderByComparator.getOrderByFields().length * 6));
4952 }
4953 else {
4954 query = new StringBundler(3);
4955 }
4956
4957 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
4958
4959 query.append(_FINDER_COLUMN_U_DT_A_USERID_2);
4960
4961 query.append(_FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2);
4962
4963 query.append(_FINDER_COLUMN_U_DT_A_ARCHIVED_2);
4964
4965 if (orderByComparator != null) {
4966 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4967
4968 if (orderByConditionFields.length > 0) {
4969 query.append(WHERE_AND);
4970 }
4971
4972 for (int i = 0; i < orderByConditionFields.length; i++) {
4973 query.append(_ORDER_BY_ENTITY_ALIAS);
4974 query.append(orderByConditionFields[i]);
4975
4976 if ((i + 1) < orderByConditionFields.length) {
4977 if (orderByComparator.isAscending() ^ previous) {
4978 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4979 }
4980 else {
4981 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4982 }
4983 }
4984 else {
4985 if (orderByComparator.isAscending() ^ previous) {
4986 query.append(WHERE_GREATER_THAN);
4987 }
4988 else {
4989 query.append(WHERE_LESSER_THAN);
4990 }
4991 }
4992 }
4993
4994 query.append(ORDER_BY_CLAUSE);
4995
4996 String[] orderByFields = orderByComparator.getOrderByFields();
4997
4998 for (int i = 0; i < orderByFields.length; i++) {
4999 query.append(_ORDER_BY_ENTITY_ALIAS);
5000 query.append(orderByFields[i]);
5001
5002 if ((i + 1) < orderByFields.length) {
5003 if (orderByComparator.isAscending() ^ previous) {
5004 query.append(ORDER_BY_ASC_HAS_NEXT);
5005 }
5006 else {
5007 query.append(ORDER_BY_DESC_HAS_NEXT);
5008 }
5009 }
5010 else {
5011 if (orderByComparator.isAscending() ^ previous) {
5012 query.append(ORDER_BY_ASC);
5013 }
5014 else {
5015 query.append(ORDER_BY_DESC);
5016 }
5017 }
5018 }
5019 }
5020 else {
5021 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5022 }
5023
5024 String sql = query.toString();
5025
5026 Query q = session.createQuery(sql);
5027
5028 q.setFirstResult(0);
5029 q.setMaxResults(2);
5030
5031 QueryPos qPos = QueryPos.getInstance(q);
5032
5033 qPos.add(userId);
5034
5035 qPos.add(deliveryType);
5036
5037 qPos.add(archived);
5038
5039 if (orderByComparator != null) {
5040 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
5041
5042 for (Object value : values) {
5043 qPos.add(value);
5044 }
5045 }
5046
5047 List<UserNotificationEvent> list = q.list();
5048
5049 if (list.size() == 2) {
5050 return list.get(1);
5051 }
5052 else {
5053 return null;
5054 }
5055 }
5056
5057
5064 @Override
5065 public void removeByU_DT_A(long userId, int deliveryType, boolean archived) {
5066 for (UserNotificationEvent userNotificationEvent : findByU_DT_A(
5067 userId, deliveryType, archived, QueryUtil.ALL_POS,
5068 QueryUtil.ALL_POS, null)) {
5069 remove(userNotificationEvent);
5070 }
5071 }
5072
5073
5081 @Override
5082 public int countByU_DT_A(long userId, int deliveryType, boolean archived) {
5083 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_A;
5084
5085 Object[] finderArgs = new Object[] { userId, deliveryType, archived };
5086
5087 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5088
5089 if (count == null) {
5090 StringBundler query = new StringBundler(4);
5091
5092 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
5093
5094 query.append(_FINDER_COLUMN_U_DT_A_USERID_2);
5095
5096 query.append(_FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2);
5097
5098 query.append(_FINDER_COLUMN_U_DT_A_ARCHIVED_2);
5099
5100 String sql = query.toString();
5101
5102 Session session = null;
5103
5104 try {
5105 session = openSession();
5106
5107 Query q = session.createQuery(sql);
5108
5109 QueryPos qPos = QueryPos.getInstance(q);
5110
5111 qPos.add(userId);
5112
5113 qPos.add(deliveryType);
5114
5115 qPos.add(archived);
5116
5117 count = (Long)q.uniqueResult();
5118
5119 finderCache.putResult(finderPath, finderArgs, count);
5120 }
5121 catch (Exception e) {
5122 finderCache.removeResult(finderPath, finderArgs);
5123
5124 throw processException(e);
5125 }
5126 finally {
5127 closeSession(session);
5128 }
5129 }
5130
5131 return count.intValue();
5132 }
5133
5134 private static final String _FINDER_COLUMN_U_DT_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
5135 private static final String _FINDER_COLUMN_U_DT_A_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
5136 private static final String _FINDER_COLUMN_U_DT_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
5137 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5138 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5139 UserNotificationEventImpl.class,
5140 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_D_A",
5141 new String[] {
5142 Long.class.getName(), Boolean.class.getName(),
5143 Boolean.class.getName(),
5144
5145 Integer.class.getName(), Integer.class.getName(),
5146 OrderByComparator.class.getName()
5147 });
5148 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5149 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5150 UserNotificationEventImpl.class,
5151 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_D_A",
5152 new String[] {
5153 Long.class.getName(), Boolean.class.getName(),
5154 Boolean.class.getName()
5155 },
5156 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
5157 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
5158 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
5159 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
5160 public static final FinderPath FINDER_PATH_COUNT_BY_U_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5161 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
5162 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_D_A",
5163 new String[] {
5164 Long.class.getName(), Boolean.class.getName(),
5165 Boolean.class.getName()
5166 });
5167
5168
5176 @Override
5177 public List<UserNotificationEvent> findByU_D_A(long userId,
5178 boolean delivered, boolean actionRequired) {
5179 return findByU_D_A(userId, delivered, actionRequired,
5180 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5181 }
5182
5183
5197 @Override
5198 public List<UserNotificationEvent> findByU_D_A(long userId,
5199 boolean delivered, boolean actionRequired, int start, int end) {
5200 return findByU_D_A(userId, delivered, actionRequired, start, end, null);
5201 }
5202
5203
5218 @Override
5219 public List<UserNotificationEvent> findByU_D_A(long userId,
5220 boolean delivered, boolean actionRequired, int start, int end,
5221 OrderByComparator<UserNotificationEvent> orderByComparator) {
5222 return findByU_D_A(userId, delivered, actionRequired, start, end,
5223 orderByComparator, true);
5224 }
5225
5226
5242 @Override
5243 public List<UserNotificationEvent> findByU_D_A(long userId,
5244 boolean delivered, boolean actionRequired, int start, int end,
5245 OrderByComparator<UserNotificationEvent> orderByComparator,
5246 boolean retrieveFromCache) {
5247 boolean pagination = true;
5248 FinderPath finderPath = null;
5249 Object[] finderArgs = null;
5250
5251 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5252 (orderByComparator == null)) {
5253 pagination = false;
5254 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A;
5255 finderArgs = new Object[] { userId, delivered, actionRequired };
5256 }
5257 else {
5258 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D_A;
5259 finderArgs = new Object[] {
5260 userId, delivered, actionRequired,
5261
5262 start, end, orderByComparator
5263 };
5264 }
5265
5266 List<UserNotificationEvent> list = null;
5267
5268 if (retrieveFromCache) {
5269 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
5270 finderArgs, this);
5271
5272 if ((list != null) && !list.isEmpty()) {
5273 for (UserNotificationEvent userNotificationEvent : list) {
5274 if ((userId != userNotificationEvent.getUserId()) ||
5275 (delivered != userNotificationEvent.getDelivered()) ||
5276 (actionRequired != userNotificationEvent.getActionRequired())) {
5277 list = null;
5278
5279 break;
5280 }
5281 }
5282 }
5283 }
5284
5285 if (list == null) {
5286 StringBundler query = null;
5287
5288 if (orderByComparator != null) {
5289 query = new StringBundler(5 +
5290 (orderByComparator.getOrderByFields().length * 3));
5291 }
5292 else {
5293 query = new StringBundler(5);
5294 }
5295
5296 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5297
5298 query.append(_FINDER_COLUMN_U_D_A_USERID_2);
5299
5300 query.append(_FINDER_COLUMN_U_D_A_DELIVERED_2);
5301
5302 query.append(_FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2);
5303
5304 if (orderByComparator != null) {
5305 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5306 orderByComparator);
5307 }
5308 else
5309 if (pagination) {
5310 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5311 }
5312
5313 String sql = query.toString();
5314
5315 Session session = null;
5316
5317 try {
5318 session = openSession();
5319
5320 Query q = session.createQuery(sql);
5321
5322 QueryPos qPos = QueryPos.getInstance(q);
5323
5324 qPos.add(userId);
5325
5326 qPos.add(delivered);
5327
5328 qPos.add(actionRequired);
5329
5330 if (!pagination) {
5331 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5332 getDialect(), start, end, false);
5333
5334 Collections.sort(list);
5335
5336 list = Collections.unmodifiableList(list);
5337 }
5338 else {
5339 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5340 getDialect(), start, end);
5341 }
5342
5343 cacheResult(list);
5344
5345 finderCache.putResult(finderPath, finderArgs, list);
5346 }
5347 catch (Exception e) {
5348 finderCache.removeResult(finderPath, finderArgs);
5349
5350 throw processException(e);
5351 }
5352 finally {
5353 closeSession(session);
5354 }
5355 }
5356
5357 return list;
5358 }
5359
5360
5370 @Override
5371 public UserNotificationEvent findByU_D_A_First(long userId,
5372 boolean delivered, boolean actionRequired,
5373 OrderByComparator<UserNotificationEvent> orderByComparator)
5374 throws NoSuchUserNotificationEventException {
5375 UserNotificationEvent userNotificationEvent = fetchByU_D_A_First(userId,
5376 delivered, actionRequired, orderByComparator);
5377
5378 if (userNotificationEvent != null) {
5379 return userNotificationEvent;
5380 }
5381
5382 StringBundler msg = new StringBundler(8);
5383
5384 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5385
5386 msg.append("userId=");
5387 msg.append(userId);
5388
5389 msg.append(", delivered=");
5390 msg.append(delivered);
5391
5392 msg.append(", actionRequired=");
5393 msg.append(actionRequired);
5394
5395 msg.append(StringPool.CLOSE_CURLY_BRACE);
5396
5397 throw new NoSuchUserNotificationEventException(msg.toString());
5398 }
5399
5400
5409 @Override
5410 public UserNotificationEvent fetchByU_D_A_First(long userId,
5411 boolean delivered, boolean actionRequired,
5412 OrderByComparator<UserNotificationEvent> orderByComparator) {
5413 List<UserNotificationEvent> list = findByU_D_A(userId, delivered,
5414 actionRequired, 0, 1, orderByComparator);
5415
5416 if (!list.isEmpty()) {
5417 return list.get(0);
5418 }
5419
5420 return null;
5421 }
5422
5423
5433 @Override
5434 public UserNotificationEvent findByU_D_A_Last(long userId,
5435 boolean delivered, boolean actionRequired,
5436 OrderByComparator<UserNotificationEvent> orderByComparator)
5437 throws NoSuchUserNotificationEventException {
5438 UserNotificationEvent userNotificationEvent = fetchByU_D_A_Last(userId,
5439 delivered, actionRequired, orderByComparator);
5440
5441 if (userNotificationEvent != null) {
5442 return userNotificationEvent;
5443 }
5444
5445 StringBundler msg = new StringBundler(8);
5446
5447 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5448
5449 msg.append("userId=");
5450 msg.append(userId);
5451
5452 msg.append(", delivered=");
5453 msg.append(delivered);
5454
5455 msg.append(", actionRequired=");
5456 msg.append(actionRequired);
5457
5458 msg.append(StringPool.CLOSE_CURLY_BRACE);
5459
5460 throw new NoSuchUserNotificationEventException(msg.toString());
5461 }
5462
5463
5472 @Override
5473 public UserNotificationEvent fetchByU_D_A_Last(long userId,
5474 boolean delivered, boolean actionRequired,
5475 OrderByComparator<UserNotificationEvent> orderByComparator) {
5476 int count = countByU_D_A(userId, delivered, actionRequired);
5477
5478 if (count == 0) {
5479 return null;
5480 }
5481
5482 List<UserNotificationEvent> list = findByU_D_A(userId, delivered,
5483 actionRequired, count - 1, count, orderByComparator);
5484
5485 if (!list.isEmpty()) {
5486 return list.get(0);
5487 }
5488
5489 return null;
5490 }
5491
5492
5503 @Override
5504 public UserNotificationEvent[] findByU_D_A_PrevAndNext(
5505 long userNotificationEventId, long userId, boolean delivered,
5506 boolean actionRequired,
5507 OrderByComparator<UserNotificationEvent> orderByComparator)
5508 throws NoSuchUserNotificationEventException {
5509 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
5510
5511 Session session = null;
5512
5513 try {
5514 session = openSession();
5515
5516 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
5517
5518 array[0] = getByU_D_A_PrevAndNext(session, userNotificationEvent,
5519 userId, delivered, actionRequired, orderByComparator, true);
5520
5521 array[1] = userNotificationEvent;
5522
5523 array[2] = getByU_D_A_PrevAndNext(session, userNotificationEvent,
5524 userId, delivered, actionRequired, orderByComparator, false);
5525
5526 return array;
5527 }
5528 catch (Exception e) {
5529 throw processException(e);
5530 }
5531 finally {
5532 closeSession(session);
5533 }
5534 }
5535
5536 protected UserNotificationEvent getByU_D_A_PrevAndNext(Session session,
5537 UserNotificationEvent userNotificationEvent, long userId,
5538 boolean delivered, boolean actionRequired,
5539 OrderByComparator<UserNotificationEvent> orderByComparator,
5540 boolean previous) {
5541 StringBundler query = null;
5542
5543 if (orderByComparator != null) {
5544 query = new StringBundler(6 +
5545 (orderByComparator.getOrderByFields().length * 6));
5546 }
5547 else {
5548 query = new StringBundler(3);
5549 }
5550
5551 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5552
5553 query.append(_FINDER_COLUMN_U_D_A_USERID_2);
5554
5555 query.append(_FINDER_COLUMN_U_D_A_DELIVERED_2);
5556
5557 query.append(_FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2);
5558
5559 if (orderByComparator != null) {
5560 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5561
5562 if (orderByConditionFields.length > 0) {
5563 query.append(WHERE_AND);
5564 }
5565
5566 for (int i = 0; i < orderByConditionFields.length; i++) {
5567 query.append(_ORDER_BY_ENTITY_ALIAS);
5568 query.append(orderByConditionFields[i]);
5569
5570 if ((i + 1) < orderByConditionFields.length) {
5571 if (orderByComparator.isAscending() ^ previous) {
5572 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5573 }
5574 else {
5575 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5576 }
5577 }
5578 else {
5579 if (orderByComparator.isAscending() ^ previous) {
5580 query.append(WHERE_GREATER_THAN);
5581 }
5582 else {
5583 query.append(WHERE_LESSER_THAN);
5584 }
5585 }
5586 }
5587
5588 query.append(ORDER_BY_CLAUSE);
5589
5590 String[] orderByFields = orderByComparator.getOrderByFields();
5591
5592 for (int i = 0; i < orderByFields.length; i++) {
5593 query.append(_ORDER_BY_ENTITY_ALIAS);
5594 query.append(orderByFields[i]);
5595
5596 if ((i + 1) < orderByFields.length) {
5597 if (orderByComparator.isAscending() ^ previous) {
5598 query.append(ORDER_BY_ASC_HAS_NEXT);
5599 }
5600 else {
5601 query.append(ORDER_BY_DESC_HAS_NEXT);
5602 }
5603 }
5604 else {
5605 if (orderByComparator.isAscending() ^ previous) {
5606 query.append(ORDER_BY_ASC);
5607 }
5608 else {
5609 query.append(ORDER_BY_DESC);
5610 }
5611 }
5612 }
5613 }
5614 else {
5615 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5616 }
5617
5618 String sql = query.toString();
5619
5620 Query q = session.createQuery(sql);
5621
5622 q.setFirstResult(0);
5623 q.setMaxResults(2);
5624
5625 QueryPos qPos = QueryPos.getInstance(q);
5626
5627 qPos.add(userId);
5628
5629 qPos.add(delivered);
5630
5631 qPos.add(actionRequired);
5632
5633 if (orderByComparator != null) {
5634 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
5635
5636 for (Object value : values) {
5637 qPos.add(value);
5638 }
5639 }
5640
5641 List<UserNotificationEvent> list = q.list();
5642
5643 if (list.size() == 2) {
5644 return list.get(1);
5645 }
5646 else {
5647 return null;
5648 }
5649 }
5650
5651
5658 @Override
5659 public void removeByU_D_A(long userId, boolean delivered,
5660 boolean actionRequired) {
5661 for (UserNotificationEvent userNotificationEvent : findByU_D_A(userId,
5662 delivered, actionRequired, QueryUtil.ALL_POS,
5663 QueryUtil.ALL_POS, null)) {
5664 remove(userNotificationEvent);
5665 }
5666 }
5667
5668
5676 @Override
5677 public int countByU_D_A(long userId, boolean delivered,
5678 boolean actionRequired) {
5679 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_D_A;
5680
5681 Object[] finderArgs = new Object[] { userId, delivered, actionRequired };
5682
5683 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5684
5685 if (count == null) {
5686 StringBundler query = new StringBundler(4);
5687
5688 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
5689
5690 query.append(_FINDER_COLUMN_U_D_A_USERID_2);
5691
5692 query.append(_FINDER_COLUMN_U_D_A_DELIVERED_2);
5693
5694 query.append(_FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2);
5695
5696 String sql = query.toString();
5697
5698 Session session = null;
5699
5700 try {
5701 session = openSession();
5702
5703 Query q = session.createQuery(sql);
5704
5705 QueryPos qPos = QueryPos.getInstance(q);
5706
5707 qPos.add(userId);
5708
5709 qPos.add(delivered);
5710
5711 qPos.add(actionRequired);
5712
5713 count = (Long)q.uniqueResult();
5714
5715 finderCache.putResult(finderPath, finderArgs, count);
5716 }
5717 catch (Exception e) {
5718 finderCache.removeResult(finderPath, finderArgs);
5719
5720 throw processException(e);
5721 }
5722 finally {
5723 closeSession(session);
5724 }
5725 }
5726
5727 return count.intValue();
5728 }
5729
5730 private static final String _FINDER_COLUMN_U_D_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
5731 private static final String _FINDER_COLUMN_U_D_A_DELIVERED_2 = "userNotificationEvent.delivered = ? AND ";
5732 private static final String _FINDER_COLUMN_U_D_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ?";
5733 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5734 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5735 UserNotificationEventImpl.class,
5736 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_A_A",
5737 new String[] {
5738 Long.class.getName(), Boolean.class.getName(),
5739 Boolean.class.getName(),
5740
5741 Integer.class.getName(), Integer.class.getName(),
5742 OrderByComparator.class.getName()
5743 });
5744 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5745 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
5746 UserNotificationEventImpl.class,
5747 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_A_A",
5748 new String[] {
5749 Long.class.getName(), Boolean.class.getName(),
5750 Boolean.class.getName()
5751 },
5752 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
5753 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
5754 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
5755 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
5756 public static final FinderPath FINDER_PATH_COUNT_BY_U_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
5757 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
5758 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_A_A",
5759 new String[] {
5760 Long.class.getName(), Boolean.class.getName(),
5761 Boolean.class.getName()
5762 });
5763
5764
5772 @Override
5773 public List<UserNotificationEvent> findByU_A_A(long userId,
5774 boolean actionRequired, boolean archived) {
5775 return findByU_A_A(userId, actionRequired, archived, QueryUtil.ALL_POS,
5776 QueryUtil.ALL_POS, null);
5777 }
5778
5779
5793 @Override
5794 public List<UserNotificationEvent> findByU_A_A(long userId,
5795 boolean actionRequired, boolean archived, int start, int end) {
5796 return findByU_A_A(userId, actionRequired, archived, start, end, null);
5797 }
5798
5799
5814 @Override
5815 public List<UserNotificationEvent> findByU_A_A(long userId,
5816 boolean actionRequired, boolean archived, int start, int end,
5817 OrderByComparator<UserNotificationEvent> orderByComparator) {
5818 return findByU_A_A(userId, actionRequired, archived, start, end,
5819 orderByComparator, true);
5820 }
5821
5822
5838 @Override
5839 public List<UserNotificationEvent> findByU_A_A(long userId,
5840 boolean actionRequired, boolean archived, int start, int end,
5841 OrderByComparator<UserNotificationEvent> orderByComparator,
5842 boolean retrieveFromCache) {
5843 boolean pagination = true;
5844 FinderPath finderPath = null;
5845 Object[] finderArgs = null;
5846
5847 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5848 (orderByComparator == null)) {
5849 pagination = false;
5850 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A;
5851 finderArgs = new Object[] { userId, actionRequired, archived };
5852 }
5853 else {
5854 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A_A;
5855 finderArgs = new Object[] {
5856 userId, actionRequired, archived,
5857
5858 start, end, orderByComparator
5859 };
5860 }
5861
5862 List<UserNotificationEvent> list = null;
5863
5864 if (retrieveFromCache) {
5865 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
5866 finderArgs, this);
5867
5868 if ((list != null) && !list.isEmpty()) {
5869 for (UserNotificationEvent userNotificationEvent : list) {
5870 if ((userId != userNotificationEvent.getUserId()) ||
5871 (actionRequired != userNotificationEvent.getActionRequired()) ||
5872 (archived != userNotificationEvent.getArchived())) {
5873 list = null;
5874
5875 break;
5876 }
5877 }
5878 }
5879 }
5880
5881 if (list == null) {
5882 StringBundler query = null;
5883
5884 if (orderByComparator != null) {
5885 query = new StringBundler(5 +
5886 (orderByComparator.getOrderByFields().length * 3));
5887 }
5888 else {
5889 query = new StringBundler(5);
5890 }
5891
5892 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
5893
5894 query.append(_FINDER_COLUMN_U_A_A_USERID_2);
5895
5896 query.append(_FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2);
5897
5898 query.append(_FINDER_COLUMN_U_A_A_ARCHIVED_2);
5899
5900 if (orderByComparator != null) {
5901 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5902 orderByComparator);
5903 }
5904 else
5905 if (pagination) {
5906 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
5907 }
5908
5909 String sql = query.toString();
5910
5911 Session session = null;
5912
5913 try {
5914 session = openSession();
5915
5916 Query q = session.createQuery(sql);
5917
5918 QueryPos qPos = QueryPos.getInstance(q);
5919
5920 qPos.add(userId);
5921
5922 qPos.add(actionRequired);
5923
5924 qPos.add(archived);
5925
5926 if (!pagination) {
5927 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5928 getDialect(), start, end, false);
5929
5930 Collections.sort(list);
5931
5932 list = Collections.unmodifiableList(list);
5933 }
5934 else {
5935 list = (List<UserNotificationEvent>)QueryUtil.list(q,
5936 getDialect(), start, end);
5937 }
5938
5939 cacheResult(list);
5940
5941 finderCache.putResult(finderPath, finderArgs, list);
5942 }
5943 catch (Exception e) {
5944 finderCache.removeResult(finderPath, finderArgs);
5945
5946 throw processException(e);
5947 }
5948 finally {
5949 closeSession(session);
5950 }
5951 }
5952
5953 return list;
5954 }
5955
5956
5966 @Override
5967 public UserNotificationEvent findByU_A_A_First(long userId,
5968 boolean actionRequired, boolean archived,
5969 OrderByComparator<UserNotificationEvent> orderByComparator)
5970 throws NoSuchUserNotificationEventException {
5971 UserNotificationEvent userNotificationEvent = fetchByU_A_A_First(userId,
5972 actionRequired, archived, orderByComparator);
5973
5974 if (userNotificationEvent != null) {
5975 return userNotificationEvent;
5976 }
5977
5978 StringBundler msg = new StringBundler(8);
5979
5980 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5981
5982 msg.append("userId=");
5983 msg.append(userId);
5984
5985 msg.append(", actionRequired=");
5986 msg.append(actionRequired);
5987
5988 msg.append(", archived=");
5989 msg.append(archived);
5990
5991 msg.append(StringPool.CLOSE_CURLY_BRACE);
5992
5993 throw new NoSuchUserNotificationEventException(msg.toString());
5994 }
5995
5996
6005 @Override
6006 public UserNotificationEvent fetchByU_A_A_First(long userId,
6007 boolean actionRequired, boolean archived,
6008 OrderByComparator<UserNotificationEvent> orderByComparator) {
6009 List<UserNotificationEvent> list = findByU_A_A(userId, actionRequired,
6010 archived, 0, 1, orderByComparator);
6011
6012 if (!list.isEmpty()) {
6013 return list.get(0);
6014 }
6015
6016 return null;
6017 }
6018
6019
6029 @Override
6030 public UserNotificationEvent findByU_A_A_Last(long userId,
6031 boolean actionRequired, boolean archived,
6032 OrderByComparator<UserNotificationEvent> orderByComparator)
6033 throws NoSuchUserNotificationEventException {
6034 UserNotificationEvent userNotificationEvent = fetchByU_A_A_Last(userId,
6035 actionRequired, archived, orderByComparator);
6036
6037 if (userNotificationEvent != null) {
6038 return userNotificationEvent;
6039 }
6040
6041 StringBundler msg = new StringBundler(8);
6042
6043 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6044
6045 msg.append("userId=");
6046 msg.append(userId);
6047
6048 msg.append(", actionRequired=");
6049 msg.append(actionRequired);
6050
6051 msg.append(", archived=");
6052 msg.append(archived);
6053
6054 msg.append(StringPool.CLOSE_CURLY_BRACE);
6055
6056 throw new NoSuchUserNotificationEventException(msg.toString());
6057 }
6058
6059
6068 @Override
6069 public UserNotificationEvent fetchByU_A_A_Last(long userId,
6070 boolean actionRequired, boolean archived,
6071 OrderByComparator<UserNotificationEvent> orderByComparator) {
6072 int count = countByU_A_A(userId, actionRequired, archived);
6073
6074 if (count == 0) {
6075 return null;
6076 }
6077
6078 List<UserNotificationEvent> list = findByU_A_A(userId, actionRequired,
6079 archived, count - 1, count, orderByComparator);
6080
6081 if (!list.isEmpty()) {
6082 return list.get(0);
6083 }
6084
6085 return null;
6086 }
6087
6088
6099 @Override
6100 public UserNotificationEvent[] findByU_A_A_PrevAndNext(
6101 long userNotificationEventId, long userId, boolean actionRequired,
6102 boolean archived,
6103 OrderByComparator<UserNotificationEvent> orderByComparator)
6104 throws NoSuchUserNotificationEventException {
6105 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
6106
6107 Session session = null;
6108
6109 try {
6110 session = openSession();
6111
6112 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
6113
6114 array[0] = getByU_A_A_PrevAndNext(session, userNotificationEvent,
6115 userId, actionRequired, archived, orderByComparator, true);
6116
6117 array[1] = userNotificationEvent;
6118
6119 array[2] = getByU_A_A_PrevAndNext(session, userNotificationEvent,
6120 userId, actionRequired, archived, orderByComparator, false);
6121
6122 return array;
6123 }
6124 catch (Exception e) {
6125 throw processException(e);
6126 }
6127 finally {
6128 closeSession(session);
6129 }
6130 }
6131
6132 protected UserNotificationEvent getByU_A_A_PrevAndNext(Session session,
6133 UserNotificationEvent userNotificationEvent, long userId,
6134 boolean actionRequired, boolean archived,
6135 OrderByComparator<UserNotificationEvent> orderByComparator,
6136 boolean previous) {
6137 StringBundler query = null;
6138
6139 if (orderByComparator != null) {
6140 query = new StringBundler(6 +
6141 (orderByComparator.getOrderByFields().length * 6));
6142 }
6143 else {
6144 query = new StringBundler(3);
6145 }
6146
6147 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
6148
6149 query.append(_FINDER_COLUMN_U_A_A_USERID_2);
6150
6151 query.append(_FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2);
6152
6153 query.append(_FINDER_COLUMN_U_A_A_ARCHIVED_2);
6154
6155 if (orderByComparator != null) {
6156 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6157
6158 if (orderByConditionFields.length > 0) {
6159 query.append(WHERE_AND);
6160 }
6161
6162 for (int i = 0; i < orderByConditionFields.length; i++) {
6163 query.append(_ORDER_BY_ENTITY_ALIAS);
6164 query.append(orderByConditionFields[i]);
6165
6166 if ((i + 1) < orderByConditionFields.length) {
6167 if (orderByComparator.isAscending() ^ previous) {
6168 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6169 }
6170 else {
6171 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6172 }
6173 }
6174 else {
6175 if (orderByComparator.isAscending() ^ previous) {
6176 query.append(WHERE_GREATER_THAN);
6177 }
6178 else {
6179 query.append(WHERE_LESSER_THAN);
6180 }
6181 }
6182 }
6183
6184 query.append(ORDER_BY_CLAUSE);
6185
6186 String[] orderByFields = orderByComparator.getOrderByFields();
6187
6188 for (int i = 0; i < orderByFields.length; i++) {
6189 query.append(_ORDER_BY_ENTITY_ALIAS);
6190 query.append(orderByFields[i]);
6191
6192 if ((i + 1) < orderByFields.length) {
6193 if (orderByComparator.isAscending() ^ previous) {
6194 query.append(ORDER_BY_ASC_HAS_NEXT);
6195 }
6196 else {
6197 query.append(ORDER_BY_DESC_HAS_NEXT);
6198 }
6199 }
6200 else {
6201 if (orderByComparator.isAscending() ^ previous) {
6202 query.append(ORDER_BY_ASC);
6203 }
6204 else {
6205 query.append(ORDER_BY_DESC);
6206 }
6207 }
6208 }
6209 }
6210 else {
6211 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
6212 }
6213
6214 String sql = query.toString();
6215
6216 Query q = session.createQuery(sql);
6217
6218 q.setFirstResult(0);
6219 q.setMaxResults(2);
6220
6221 QueryPos qPos = QueryPos.getInstance(q);
6222
6223 qPos.add(userId);
6224
6225 qPos.add(actionRequired);
6226
6227 qPos.add(archived);
6228
6229 if (orderByComparator != null) {
6230 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
6231
6232 for (Object value : values) {
6233 qPos.add(value);
6234 }
6235 }
6236
6237 List<UserNotificationEvent> list = q.list();
6238
6239 if (list.size() == 2) {
6240 return list.get(1);
6241 }
6242 else {
6243 return null;
6244 }
6245 }
6246
6247
6254 @Override
6255 public void removeByU_A_A(long userId, boolean actionRequired,
6256 boolean archived) {
6257 for (UserNotificationEvent userNotificationEvent : findByU_A_A(userId,
6258 actionRequired, archived, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
6259 null)) {
6260 remove(userNotificationEvent);
6261 }
6262 }
6263
6264
6272 @Override
6273 public int countByU_A_A(long userId, boolean actionRequired,
6274 boolean archived) {
6275 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_A_A;
6276
6277 Object[] finderArgs = new Object[] { userId, actionRequired, archived };
6278
6279 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6280
6281 if (count == null) {
6282 StringBundler query = new StringBundler(4);
6283
6284 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
6285
6286 query.append(_FINDER_COLUMN_U_A_A_USERID_2);
6287
6288 query.append(_FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2);
6289
6290 query.append(_FINDER_COLUMN_U_A_A_ARCHIVED_2);
6291
6292 String sql = query.toString();
6293
6294 Session session = null;
6295
6296 try {
6297 session = openSession();
6298
6299 Query q = session.createQuery(sql);
6300
6301 QueryPos qPos = QueryPos.getInstance(q);
6302
6303 qPos.add(userId);
6304
6305 qPos.add(actionRequired);
6306
6307 qPos.add(archived);
6308
6309 count = (Long)q.uniqueResult();
6310
6311 finderCache.putResult(finderPath, finderArgs, count);
6312 }
6313 catch (Exception e) {
6314 finderCache.removeResult(finderPath, finderArgs);
6315
6316 throw processException(e);
6317 }
6318 finally {
6319 closeSession(session);
6320 }
6321 }
6322
6323 return count.intValue();
6324 }
6325
6326 private static final String _FINDER_COLUMN_U_A_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
6327 private static final String _FINDER_COLUMN_U_A_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ? AND ";
6328 private static final String _FINDER_COLUMN_U_A_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
6329 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_T_DT_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6330 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
6331 UserNotificationEventImpl.class,
6332 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_T_DT_D",
6333 new String[] {
6334 Long.class.getName(), String.class.getName(),
6335 Integer.class.getName(), Boolean.class.getName(),
6336
6337 Integer.class.getName(), Integer.class.getName(),
6338 OrderByComparator.class.getName()
6339 });
6340 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_T_DT_D =
6341 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6342 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
6343 UserNotificationEventImpl.class,
6344 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_T_DT_D",
6345 new String[] {
6346 Long.class.getName(), String.class.getName(),
6347 Integer.class.getName(), Boolean.class.getName()
6348 },
6349 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
6350 UserNotificationEventModelImpl.TYPE_COLUMN_BITMASK |
6351 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
6352 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
6353 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
6354 public static final FinderPath FINDER_PATH_COUNT_BY_U_T_DT_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
6355 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
6356 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_T_DT_D",
6357 new String[] {
6358 Long.class.getName(), String.class.getName(),
6359 Integer.class.getName(), Boolean.class.getName()
6360 });
6361
6362
6371 @Override
6372 public List<UserNotificationEvent> findByU_T_DT_D(long userId, String type,
6373 int deliveryType, boolean delivered) {
6374 return findByU_T_DT_D(userId, type, deliveryType, delivered,
6375 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6376 }
6377
6378
6393 @Override
6394 public List<UserNotificationEvent> findByU_T_DT_D(long userId, String type,
6395 int deliveryType, boolean delivered, int start, int end) {
6396 return findByU_T_DT_D(userId, type, deliveryType, delivered, start,
6397 end, null);
6398 }
6399
6400
6416 @Override
6417 public List<UserNotificationEvent> findByU_T_DT_D(long userId, String type,
6418 int deliveryType, boolean delivered, int start, int end,
6419 OrderByComparator<UserNotificationEvent> orderByComparator) {
6420 return findByU_T_DT_D(userId, type, deliveryType, delivered, start,
6421 end, orderByComparator, true);
6422 }
6423
6424
6441 @Override
6442 public List<UserNotificationEvent> findByU_T_DT_D(long userId, String type,
6443 int deliveryType, boolean delivered, int start, int end,
6444 OrderByComparator<UserNotificationEvent> orderByComparator,
6445 boolean retrieveFromCache) {
6446 boolean pagination = true;
6447 FinderPath finderPath = null;
6448 Object[] finderArgs = null;
6449
6450 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6451 (orderByComparator == null)) {
6452 pagination = false;
6453 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_T_DT_D;
6454 finderArgs = new Object[] { userId, type, deliveryType, delivered };
6455 }
6456 else {
6457 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_T_DT_D;
6458 finderArgs = new Object[] {
6459 userId, type, deliveryType, delivered,
6460
6461 start, end, orderByComparator
6462 };
6463 }
6464
6465 List<UserNotificationEvent> list = null;
6466
6467 if (retrieveFromCache) {
6468 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
6469 finderArgs, this);
6470
6471 if ((list != null) && !list.isEmpty()) {
6472 for (UserNotificationEvent userNotificationEvent : list) {
6473 if ((userId != userNotificationEvent.getUserId()) ||
6474 !Validator.equals(type,
6475 userNotificationEvent.getType()) ||
6476 (deliveryType != userNotificationEvent.getDeliveryType()) ||
6477 (delivered != userNotificationEvent.getDelivered())) {
6478 list = null;
6479
6480 break;
6481 }
6482 }
6483 }
6484 }
6485
6486 if (list == null) {
6487 StringBundler query = null;
6488
6489 if (orderByComparator != null) {
6490 query = new StringBundler(6 +
6491 (orderByComparator.getOrderByFields().length * 3));
6492 }
6493 else {
6494 query = new StringBundler(6);
6495 }
6496
6497 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
6498
6499 query.append(_FINDER_COLUMN_U_T_DT_D_USERID_2);
6500
6501 boolean bindType = false;
6502
6503 if (type == null) {
6504 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_1);
6505 }
6506 else if (type.equals(StringPool.BLANK)) {
6507 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_3);
6508 }
6509 else {
6510 bindType = true;
6511
6512 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_2);
6513 }
6514
6515 query.append(_FINDER_COLUMN_U_T_DT_D_DELIVERYTYPE_2);
6516
6517 query.append(_FINDER_COLUMN_U_T_DT_D_DELIVERED_2);
6518
6519 if (orderByComparator != null) {
6520 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6521 orderByComparator);
6522 }
6523 else
6524 if (pagination) {
6525 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
6526 }
6527
6528 String sql = query.toString();
6529
6530 Session session = null;
6531
6532 try {
6533 session = openSession();
6534
6535 Query q = session.createQuery(sql);
6536
6537 QueryPos qPos = QueryPos.getInstance(q);
6538
6539 qPos.add(userId);
6540
6541 if (bindType) {
6542 qPos.add(type);
6543 }
6544
6545 qPos.add(deliveryType);
6546
6547 qPos.add(delivered);
6548
6549 if (!pagination) {
6550 list = (List<UserNotificationEvent>)QueryUtil.list(q,
6551 getDialect(), start, end, false);
6552
6553 Collections.sort(list);
6554
6555 list = Collections.unmodifiableList(list);
6556 }
6557 else {
6558 list = (List<UserNotificationEvent>)QueryUtil.list(q,
6559 getDialect(), start, end);
6560 }
6561
6562 cacheResult(list);
6563
6564 finderCache.putResult(finderPath, finderArgs, list);
6565 }
6566 catch (Exception e) {
6567 finderCache.removeResult(finderPath, finderArgs);
6568
6569 throw processException(e);
6570 }
6571 finally {
6572 closeSession(session);
6573 }
6574 }
6575
6576 return list;
6577 }
6578
6579
6590 @Override
6591 public UserNotificationEvent findByU_T_DT_D_First(long userId, String type,
6592 int deliveryType, boolean delivered,
6593 OrderByComparator<UserNotificationEvent> orderByComparator)
6594 throws NoSuchUserNotificationEventException {
6595 UserNotificationEvent userNotificationEvent = fetchByU_T_DT_D_First(userId,
6596 type, deliveryType, delivered, orderByComparator);
6597
6598 if (userNotificationEvent != null) {
6599 return userNotificationEvent;
6600 }
6601
6602 StringBundler msg = new StringBundler(10);
6603
6604 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6605
6606 msg.append("userId=");
6607 msg.append(userId);
6608
6609 msg.append(", type=");
6610 msg.append(type);
6611
6612 msg.append(", deliveryType=");
6613 msg.append(deliveryType);
6614
6615 msg.append(", delivered=");
6616 msg.append(delivered);
6617
6618 msg.append(StringPool.CLOSE_CURLY_BRACE);
6619
6620 throw new NoSuchUserNotificationEventException(msg.toString());
6621 }
6622
6623
6633 @Override
6634 public UserNotificationEvent fetchByU_T_DT_D_First(long userId,
6635 String type, int deliveryType, boolean delivered,
6636 OrderByComparator<UserNotificationEvent> orderByComparator) {
6637 List<UserNotificationEvent> list = findByU_T_DT_D(userId, type,
6638 deliveryType, delivered, 0, 1, orderByComparator);
6639
6640 if (!list.isEmpty()) {
6641 return list.get(0);
6642 }
6643
6644 return null;
6645 }
6646
6647
6658 @Override
6659 public UserNotificationEvent findByU_T_DT_D_Last(long userId, String type,
6660 int deliveryType, boolean delivered,
6661 OrderByComparator<UserNotificationEvent> orderByComparator)
6662 throws NoSuchUserNotificationEventException {
6663 UserNotificationEvent userNotificationEvent = fetchByU_T_DT_D_Last(userId,
6664 type, deliveryType, delivered, orderByComparator);
6665
6666 if (userNotificationEvent != null) {
6667 return userNotificationEvent;
6668 }
6669
6670 StringBundler msg = new StringBundler(10);
6671
6672 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6673
6674 msg.append("userId=");
6675 msg.append(userId);
6676
6677 msg.append(", type=");
6678 msg.append(type);
6679
6680 msg.append(", deliveryType=");
6681 msg.append(deliveryType);
6682
6683 msg.append(", delivered=");
6684 msg.append(delivered);
6685
6686 msg.append(StringPool.CLOSE_CURLY_BRACE);
6687
6688 throw new NoSuchUserNotificationEventException(msg.toString());
6689 }
6690
6691
6701 @Override
6702 public UserNotificationEvent fetchByU_T_DT_D_Last(long userId, String type,
6703 int deliveryType, boolean delivered,
6704 OrderByComparator<UserNotificationEvent> orderByComparator) {
6705 int count = countByU_T_DT_D(userId, type, deliveryType, delivered);
6706
6707 if (count == 0) {
6708 return null;
6709 }
6710
6711 List<UserNotificationEvent> list = findByU_T_DT_D(userId, type,
6712 deliveryType, delivered, count - 1, count, orderByComparator);
6713
6714 if (!list.isEmpty()) {
6715 return list.get(0);
6716 }
6717
6718 return null;
6719 }
6720
6721
6733 @Override
6734 public UserNotificationEvent[] findByU_T_DT_D_PrevAndNext(
6735 long userNotificationEventId, long userId, String type,
6736 int deliveryType, boolean delivered,
6737 OrderByComparator<UserNotificationEvent> orderByComparator)
6738 throws NoSuchUserNotificationEventException {
6739 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
6740
6741 Session session = null;
6742
6743 try {
6744 session = openSession();
6745
6746 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
6747
6748 array[0] = getByU_T_DT_D_PrevAndNext(session,
6749 userNotificationEvent, userId, type, deliveryType,
6750 delivered, orderByComparator, true);
6751
6752 array[1] = userNotificationEvent;
6753
6754 array[2] = getByU_T_DT_D_PrevAndNext(session,
6755 userNotificationEvent, userId, type, deliveryType,
6756 delivered, orderByComparator, false);
6757
6758 return array;
6759 }
6760 catch (Exception e) {
6761 throw processException(e);
6762 }
6763 finally {
6764 closeSession(session);
6765 }
6766 }
6767
6768 protected UserNotificationEvent getByU_T_DT_D_PrevAndNext(Session session,
6769 UserNotificationEvent userNotificationEvent, long userId, String type,
6770 int deliveryType, boolean delivered,
6771 OrderByComparator<UserNotificationEvent> orderByComparator,
6772 boolean previous) {
6773 StringBundler query = null;
6774
6775 if (orderByComparator != null) {
6776 query = new StringBundler(6 +
6777 (orderByComparator.getOrderByFields().length * 6));
6778 }
6779 else {
6780 query = new StringBundler(3);
6781 }
6782
6783 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
6784
6785 query.append(_FINDER_COLUMN_U_T_DT_D_USERID_2);
6786
6787 boolean bindType = false;
6788
6789 if (type == null) {
6790 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_1);
6791 }
6792 else if (type.equals(StringPool.BLANK)) {
6793 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_3);
6794 }
6795 else {
6796 bindType = true;
6797
6798 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_2);
6799 }
6800
6801 query.append(_FINDER_COLUMN_U_T_DT_D_DELIVERYTYPE_2);
6802
6803 query.append(_FINDER_COLUMN_U_T_DT_D_DELIVERED_2);
6804
6805 if (orderByComparator != null) {
6806 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6807
6808 if (orderByConditionFields.length > 0) {
6809 query.append(WHERE_AND);
6810 }
6811
6812 for (int i = 0; i < orderByConditionFields.length; i++) {
6813 query.append(_ORDER_BY_ENTITY_ALIAS);
6814 query.append(orderByConditionFields[i]);
6815
6816 if ((i + 1) < orderByConditionFields.length) {
6817 if (orderByComparator.isAscending() ^ previous) {
6818 query.append(WHERE_GREATER_THAN_HAS_NEXT);
6819 }
6820 else {
6821 query.append(WHERE_LESSER_THAN_HAS_NEXT);
6822 }
6823 }
6824 else {
6825 if (orderByComparator.isAscending() ^ previous) {
6826 query.append(WHERE_GREATER_THAN);
6827 }
6828 else {
6829 query.append(WHERE_LESSER_THAN);
6830 }
6831 }
6832 }
6833
6834 query.append(ORDER_BY_CLAUSE);
6835
6836 String[] orderByFields = orderByComparator.getOrderByFields();
6837
6838 for (int i = 0; i < orderByFields.length; i++) {
6839 query.append(_ORDER_BY_ENTITY_ALIAS);
6840 query.append(orderByFields[i]);
6841
6842 if ((i + 1) < orderByFields.length) {
6843 if (orderByComparator.isAscending() ^ previous) {
6844 query.append(ORDER_BY_ASC_HAS_NEXT);
6845 }
6846 else {
6847 query.append(ORDER_BY_DESC_HAS_NEXT);
6848 }
6849 }
6850 else {
6851 if (orderByComparator.isAscending() ^ previous) {
6852 query.append(ORDER_BY_ASC);
6853 }
6854 else {
6855 query.append(ORDER_BY_DESC);
6856 }
6857 }
6858 }
6859 }
6860 else {
6861 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
6862 }
6863
6864 String sql = query.toString();
6865
6866 Query q = session.createQuery(sql);
6867
6868 q.setFirstResult(0);
6869 q.setMaxResults(2);
6870
6871 QueryPos qPos = QueryPos.getInstance(q);
6872
6873 qPos.add(userId);
6874
6875 if (bindType) {
6876 qPos.add(type);
6877 }
6878
6879 qPos.add(deliveryType);
6880
6881 qPos.add(delivered);
6882
6883 if (orderByComparator != null) {
6884 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
6885
6886 for (Object value : values) {
6887 qPos.add(value);
6888 }
6889 }
6890
6891 List<UserNotificationEvent> list = q.list();
6892
6893 if (list.size() == 2) {
6894 return list.get(1);
6895 }
6896 else {
6897 return null;
6898 }
6899 }
6900
6901
6909 @Override
6910 public void removeByU_T_DT_D(long userId, String type, int deliveryType,
6911 boolean delivered) {
6912 for (UserNotificationEvent userNotificationEvent : findByU_T_DT_D(
6913 userId, type, deliveryType, delivered, QueryUtil.ALL_POS,
6914 QueryUtil.ALL_POS, null)) {
6915 remove(userNotificationEvent);
6916 }
6917 }
6918
6919
6928 @Override
6929 public int countByU_T_DT_D(long userId, String type, int deliveryType,
6930 boolean delivered) {
6931 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_T_DT_D;
6932
6933 Object[] finderArgs = new Object[] { userId, type, deliveryType, delivered };
6934
6935 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6936
6937 if (count == null) {
6938 StringBundler query = new StringBundler(5);
6939
6940 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
6941
6942 query.append(_FINDER_COLUMN_U_T_DT_D_USERID_2);
6943
6944 boolean bindType = false;
6945
6946 if (type == null) {
6947 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_1);
6948 }
6949 else if (type.equals(StringPool.BLANK)) {
6950 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_3);
6951 }
6952 else {
6953 bindType = true;
6954
6955 query.append(_FINDER_COLUMN_U_T_DT_D_TYPE_2);
6956 }
6957
6958 query.append(_FINDER_COLUMN_U_T_DT_D_DELIVERYTYPE_2);
6959
6960 query.append(_FINDER_COLUMN_U_T_DT_D_DELIVERED_2);
6961
6962 String sql = query.toString();
6963
6964 Session session = null;
6965
6966 try {
6967 session = openSession();
6968
6969 Query q = session.createQuery(sql);
6970
6971 QueryPos qPos = QueryPos.getInstance(q);
6972
6973 qPos.add(userId);
6974
6975 if (bindType) {
6976 qPos.add(type);
6977 }
6978
6979 qPos.add(deliveryType);
6980
6981 qPos.add(delivered);
6982
6983 count = (Long)q.uniqueResult();
6984
6985 finderCache.putResult(finderPath, finderArgs, count);
6986 }
6987 catch (Exception e) {
6988 finderCache.removeResult(finderPath, finderArgs);
6989
6990 throw processException(e);
6991 }
6992 finally {
6993 closeSession(session);
6994 }
6995 }
6996
6997 return count.intValue();
6998 }
6999
7000 private static final String _FINDER_COLUMN_U_T_DT_D_USERID_2 = "userNotificationEvent.userId = ? AND ";
7001 private static final String _FINDER_COLUMN_U_T_DT_D_TYPE_1 = "userNotificationEvent.type IS NULL AND ";
7002 private static final String _FINDER_COLUMN_U_T_DT_D_TYPE_2 = "userNotificationEvent.type = ? AND ";
7003 private static final String _FINDER_COLUMN_U_T_DT_D_TYPE_3 = "(userNotificationEvent.type IS NULL OR userNotificationEvent.type = '') AND ";
7004 private static final String _FINDER_COLUMN_U_T_DT_D_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
7005 private static final String _FINDER_COLUMN_U_T_DT_D_DELIVERED_2 = "userNotificationEvent.delivered = ?";
7006 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7007 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
7008 UserNotificationEventImpl.class,
7009 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_D_A",
7010 new String[] {
7011 Long.class.getName(), Integer.class.getName(),
7012 Boolean.class.getName(), Boolean.class.getName(),
7013
7014 Integer.class.getName(), Integer.class.getName(),
7015 OrderByComparator.class.getName()
7016 });
7017 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A =
7018 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7019 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
7020 UserNotificationEventImpl.class,
7021 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_D_A",
7022 new String[] {
7023 Long.class.getName(), Integer.class.getName(),
7024 Boolean.class.getName(), Boolean.class.getName()
7025 },
7026 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
7027 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
7028 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
7029 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
7030 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
7031 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_D_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7032 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
7033 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_D_A",
7034 new String[] {
7035 Long.class.getName(), Integer.class.getName(),
7036 Boolean.class.getName(), Boolean.class.getName()
7037 });
7038
7039
7048 @Override
7049 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
7050 int deliveryType, boolean delivered, boolean actionRequired) {
7051 return findByU_DT_D_A(userId, deliveryType, delivered, actionRequired,
7052 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7053 }
7054
7055
7070 @Override
7071 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
7072 int deliveryType, boolean delivered, boolean actionRequired, int start,
7073 int end) {
7074 return findByU_DT_D_A(userId, deliveryType, delivered, actionRequired,
7075 start, end, null);
7076 }
7077
7078
7094 @Override
7095 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
7096 int deliveryType, boolean delivered, boolean actionRequired, int start,
7097 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
7098 return findByU_DT_D_A(userId, deliveryType, delivered, actionRequired,
7099 start, end, orderByComparator, true);
7100 }
7101
7102
7119 @Override
7120 public List<UserNotificationEvent> findByU_DT_D_A(long userId,
7121 int deliveryType, boolean delivered, boolean actionRequired, int start,
7122 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
7123 boolean retrieveFromCache) {
7124 boolean pagination = true;
7125 FinderPath finderPath = null;
7126 Object[] finderArgs = null;
7127
7128 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7129 (orderByComparator == null)) {
7130 pagination = false;
7131 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A;
7132 finderArgs = new Object[] {
7133 userId, deliveryType, delivered, actionRequired
7134 };
7135 }
7136 else {
7137 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_D_A;
7138 finderArgs = new Object[] {
7139 userId, deliveryType, delivered, actionRequired,
7140
7141 start, end, orderByComparator
7142 };
7143 }
7144
7145 List<UserNotificationEvent> list = null;
7146
7147 if (retrieveFromCache) {
7148 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
7149 finderArgs, this);
7150
7151 if ((list != null) && !list.isEmpty()) {
7152 for (UserNotificationEvent userNotificationEvent : list) {
7153 if ((userId != userNotificationEvent.getUserId()) ||
7154 (deliveryType != userNotificationEvent.getDeliveryType()) ||
7155 (delivered != userNotificationEvent.getDelivered()) ||
7156 (actionRequired != userNotificationEvent.getActionRequired())) {
7157 list = null;
7158
7159 break;
7160 }
7161 }
7162 }
7163 }
7164
7165 if (list == null) {
7166 StringBundler query = null;
7167
7168 if (orderByComparator != null) {
7169 query = new StringBundler(6 +
7170 (orderByComparator.getOrderByFields().length * 3));
7171 }
7172 else {
7173 query = new StringBundler(6);
7174 }
7175
7176 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
7177
7178 query.append(_FINDER_COLUMN_U_DT_D_A_USERID_2);
7179
7180 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2);
7181
7182 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERED_2);
7183
7184 query.append(_FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2);
7185
7186 if (orderByComparator != null) {
7187 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7188 orderByComparator);
7189 }
7190 else
7191 if (pagination) {
7192 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
7193 }
7194
7195 String sql = query.toString();
7196
7197 Session session = null;
7198
7199 try {
7200 session = openSession();
7201
7202 Query q = session.createQuery(sql);
7203
7204 QueryPos qPos = QueryPos.getInstance(q);
7205
7206 qPos.add(userId);
7207
7208 qPos.add(deliveryType);
7209
7210 qPos.add(delivered);
7211
7212 qPos.add(actionRequired);
7213
7214 if (!pagination) {
7215 list = (List<UserNotificationEvent>)QueryUtil.list(q,
7216 getDialect(), start, end, false);
7217
7218 Collections.sort(list);
7219
7220 list = Collections.unmodifiableList(list);
7221 }
7222 else {
7223 list = (List<UserNotificationEvent>)QueryUtil.list(q,
7224 getDialect(), start, end);
7225 }
7226
7227 cacheResult(list);
7228
7229 finderCache.putResult(finderPath, finderArgs, list);
7230 }
7231 catch (Exception e) {
7232 finderCache.removeResult(finderPath, finderArgs);
7233
7234 throw processException(e);
7235 }
7236 finally {
7237 closeSession(session);
7238 }
7239 }
7240
7241 return list;
7242 }
7243
7244
7255 @Override
7256 public UserNotificationEvent findByU_DT_D_A_First(long userId,
7257 int deliveryType, boolean delivered, boolean actionRequired,
7258 OrderByComparator<UserNotificationEvent> orderByComparator)
7259 throws NoSuchUserNotificationEventException {
7260 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_A_First(userId,
7261 deliveryType, delivered, actionRequired, orderByComparator);
7262
7263 if (userNotificationEvent != null) {
7264 return userNotificationEvent;
7265 }
7266
7267 StringBundler msg = new StringBundler(10);
7268
7269 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7270
7271 msg.append("userId=");
7272 msg.append(userId);
7273
7274 msg.append(", deliveryType=");
7275 msg.append(deliveryType);
7276
7277 msg.append(", delivered=");
7278 msg.append(delivered);
7279
7280 msg.append(", actionRequired=");
7281 msg.append(actionRequired);
7282
7283 msg.append(StringPool.CLOSE_CURLY_BRACE);
7284
7285 throw new NoSuchUserNotificationEventException(msg.toString());
7286 }
7287
7288
7298 @Override
7299 public UserNotificationEvent fetchByU_DT_D_A_First(long userId,
7300 int deliveryType, boolean delivered, boolean actionRequired,
7301 OrderByComparator<UserNotificationEvent> orderByComparator) {
7302 List<UserNotificationEvent> list = findByU_DT_D_A(userId, deliveryType,
7303 delivered, actionRequired, 0, 1, orderByComparator);
7304
7305 if (!list.isEmpty()) {
7306 return list.get(0);
7307 }
7308
7309 return null;
7310 }
7311
7312
7323 @Override
7324 public UserNotificationEvent findByU_DT_D_A_Last(long userId,
7325 int deliveryType, boolean delivered, boolean actionRequired,
7326 OrderByComparator<UserNotificationEvent> orderByComparator)
7327 throws NoSuchUserNotificationEventException {
7328 UserNotificationEvent userNotificationEvent = fetchByU_DT_D_A_Last(userId,
7329 deliveryType, delivered, actionRequired, orderByComparator);
7330
7331 if (userNotificationEvent != null) {
7332 return userNotificationEvent;
7333 }
7334
7335 StringBundler msg = new StringBundler(10);
7336
7337 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7338
7339 msg.append("userId=");
7340 msg.append(userId);
7341
7342 msg.append(", deliveryType=");
7343 msg.append(deliveryType);
7344
7345 msg.append(", delivered=");
7346 msg.append(delivered);
7347
7348 msg.append(", actionRequired=");
7349 msg.append(actionRequired);
7350
7351 msg.append(StringPool.CLOSE_CURLY_BRACE);
7352
7353 throw new NoSuchUserNotificationEventException(msg.toString());
7354 }
7355
7356
7366 @Override
7367 public UserNotificationEvent fetchByU_DT_D_A_Last(long userId,
7368 int deliveryType, boolean delivered, boolean actionRequired,
7369 OrderByComparator<UserNotificationEvent> orderByComparator) {
7370 int count = countByU_DT_D_A(userId, deliveryType, delivered,
7371 actionRequired);
7372
7373 if (count == 0) {
7374 return null;
7375 }
7376
7377 List<UserNotificationEvent> list = findByU_DT_D_A(userId, deliveryType,
7378 delivered, actionRequired, count - 1, count, orderByComparator);
7379
7380 if (!list.isEmpty()) {
7381 return list.get(0);
7382 }
7383
7384 return null;
7385 }
7386
7387
7399 @Override
7400 public UserNotificationEvent[] findByU_DT_D_A_PrevAndNext(
7401 long userNotificationEventId, long userId, int deliveryType,
7402 boolean delivered, boolean actionRequired,
7403 OrderByComparator<UserNotificationEvent> orderByComparator)
7404 throws NoSuchUserNotificationEventException {
7405 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
7406
7407 Session session = null;
7408
7409 try {
7410 session = openSession();
7411
7412 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
7413
7414 array[0] = getByU_DT_D_A_PrevAndNext(session,
7415 userNotificationEvent, userId, deliveryType, delivered,
7416 actionRequired, orderByComparator, true);
7417
7418 array[1] = userNotificationEvent;
7419
7420 array[2] = getByU_DT_D_A_PrevAndNext(session,
7421 userNotificationEvent, userId, deliveryType, delivered,
7422 actionRequired, orderByComparator, false);
7423
7424 return array;
7425 }
7426 catch (Exception e) {
7427 throw processException(e);
7428 }
7429 finally {
7430 closeSession(session);
7431 }
7432 }
7433
7434 protected UserNotificationEvent getByU_DT_D_A_PrevAndNext(Session session,
7435 UserNotificationEvent userNotificationEvent, long userId,
7436 int deliveryType, boolean delivered, boolean actionRequired,
7437 OrderByComparator<UserNotificationEvent> orderByComparator,
7438 boolean previous) {
7439 StringBundler query = null;
7440
7441 if (orderByComparator != null) {
7442 query = new StringBundler(6 +
7443 (orderByComparator.getOrderByFields().length * 6));
7444 }
7445 else {
7446 query = new StringBundler(3);
7447 }
7448
7449 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
7450
7451 query.append(_FINDER_COLUMN_U_DT_D_A_USERID_2);
7452
7453 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2);
7454
7455 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERED_2);
7456
7457 query.append(_FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2);
7458
7459 if (orderByComparator != null) {
7460 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7461
7462 if (orderByConditionFields.length > 0) {
7463 query.append(WHERE_AND);
7464 }
7465
7466 for (int i = 0; i < orderByConditionFields.length; i++) {
7467 query.append(_ORDER_BY_ENTITY_ALIAS);
7468 query.append(orderByConditionFields[i]);
7469
7470 if ((i + 1) < orderByConditionFields.length) {
7471 if (orderByComparator.isAscending() ^ previous) {
7472 query.append(WHERE_GREATER_THAN_HAS_NEXT);
7473 }
7474 else {
7475 query.append(WHERE_LESSER_THAN_HAS_NEXT);
7476 }
7477 }
7478 else {
7479 if (orderByComparator.isAscending() ^ previous) {
7480 query.append(WHERE_GREATER_THAN);
7481 }
7482 else {
7483 query.append(WHERE_LESSER_THAN);
7484 }
7485 }
7486 }
7487
7488 query.append(ORDER_BY_CLAUSE);
7489
7490 String[] orderByFields = orderByComparator.getOrderByFields();
7491
7492 for (int i = 0; i < orderByFields.length; i++) {
7493 query.append(_ORDER_BY_ENTITY_ALIAS);
7494 query.append(orderByFields[i]);
7495
7496 if ((i + 1) < orderByFields.length) {
7497 if (orderByComparator.isAscending() ^ previous) {
7498 query.append(ORDER_BY_ASC_HAS_NEXT);
7499 }
7500 else {
7501 query.append(ORDER_BY_DESC_HAS_NEXT);
7502 }
7503 }
7504 else {
7505 if (orderByComparator.isAscending() ^ previous) {
7506 query.append(ORDER_BY_ASC);
7507 }
7508 else {
7509 query.append(ORDER_BY_DESC);
7510 }
7511 }
7512 }
7513 }
7514 else {
7515 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
7516 }
7517
7518 String sql = query.toString();
7519
7520 Query q = session.createQuery(sql);
7521
7522 q.setFirstResult(0);
7523 q.setMaxResults(2);
7524
7525 QueryPos qPos = QueryPos.getInstance(q);
7526
7527 qPos.add(userId);
7528
7529 qPos.add(deliveryType);
7530
7531 qPos.add(delivered);
7532
7533 qPos.add(actionRequired);
7534
7535 if (orderByComparator != null) {
7536 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
7537
7538 for (Object value : values) {
7539 qPos.add(value);
7540 }
7541 }
7542
7543 List<UserNotificationEvent> list = q.list();
7544
7545 if (list.size() == 2) {
7546 return list.get(1);
7547 }
7548 else {
7549 return null;
7550 }
7551 }
7552
7553
7561 @Override
7562 public void removeByU_DT_D_A(long userId, int deliveryType,
7563 boolean delivered, boolean actionRequired) {
7564 for (UserNotificationEvent userNotificationEvent : findByU_DT_D_A(
7565 userId, deliveryType, delivered, actionRequired,
7566 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7567 remove(userNotificationEvent);
7568 }
7569 }
7570
7571
7580 @Override
7581 public int countByU_DT_D_A(long userId, int deliveryType,
7582 boolean delivered, boolean actionRequired) {
7583 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_D_A;
7584
7585 Object[] finderArgs = new Object[] {
7586 userId, deliveryType, delivered, actionRequired
7587 };
7588
7589 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7590
7591 if (count == null) {
7592 StringBundler query = new StringBundler(5);
7593
7594 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
7595
7596 query.append(_FINDER_COLUMN_U_DT_D_A_USERID_2);
7597
7598 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2);
7599
7600 query.append(_FINDER_COLUMN_U_DT_D_A_DELIVERED_2);
7601
7602 query.append(_FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2);
7603
7604 String sql = query.toString();
7605
7606 Session session = null;
7607
7608 try {
7609 session = openSession();
7610
7611 Query q = session.createQuery(sql);
7612
7613 QueryPos qPos = QueryPos.getInstance(q);
7614
7615 qPos.add(userId);
7616
7617 qPos.add(deliveryType);
7618
7619 qPos.add(delivered);
7620
7621 qPos.add(actionRequired);
7622
7623 count = (Long)q.uniqueResult();
7624
7625 finderCache.putResult(finderPath, finderArgs, count);
7626 }
7627 catch (Exception e) {
7628 finderCache.removeResult(finderPath, finderArgs);
7629
7630 throw processException(e);
7631 }
7632 finally {
7633 closeSession(session);
7634 }
7635 }
7636
7637 return count.intValue();
7638 }
7639
7640 private static final String _FINDER_COLUMN_U_DT_D_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
7641 private static final String _FINDER_COLUMN_U_DT_D_A_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
7642 private static final String _FINDER_COLUMN_U_DT_D_A_DELIVERED_2 = "userNotificationEvent.delivered = ? AND ";
7643 private static final String _FINDER_COLUMN_U_DT_D_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ?";
7644 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7645 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
7646 UserNotificationEventImpl.class,
7647 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_DT_A_A",
7648 new String[] {
7649 Long.class.getName(), Integer.class.getName(),
7650 Boolean.class.getName(), Boolean.class.getName(),
7651
7652 Integer.class.getName(), Integer.class.getName(),
7653 OrderByComparator.class.getName()
7654 });
7655 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A =
7656 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7657 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
7658 UserNotificationEventImpl.class,
7659 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_DT_A_A",
7660 new String[] {
7661 Long.class.getName(), Integer.class.getName(),
7662 Boolean.class.getName(), Boolean.class.getName()
7663 },
7664 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
7665 UserNotificationEventModelImpl.DELIVERYTYPE_COLUMN_BITMASK |
7666 UserNotificationEventModelImpl.ACTIONREQUIRED_COLUMN_BITMASK |
7667 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
7668 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
7669 public static final FinderPath FINDER_PATH_COUNT_BY_U_DT_A_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
7670 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
7671 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_DT_A_A",
7672 new String[] {
7673 Long.class.getName(), Integer.class.getName(),
7674 Boolean.class.getName(), Boolean.class.getName()
7675 });
7676
7677
7686 @Override
7687 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
7688 int deliveryType, boolean actionRequired, boolean archived) {
7689 return findByU_DT_A_A(userId, deliveryType, actionRequired, archived,
7690 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7691 }
7692
7693
7708 @Override
7709 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
7710 int deliveryType, boolean actionRequired, boolean archived, int start,
7711 int end) {
7712 return findByU_DT_A_A(userId, deliveryType, actionRequired, archived,
7713 start, end, null);
7714 }
7715
7716
7732 @Override
7733 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
7734 int deliveryType, boolean actionRequired, boolean archived, int start,
7735 int end, OrderByComparator<UserNotificationEvent> orderByComparator) {
7736 return findByU_DT_A_A(userId, deliveryType, actionRequired, archived,
7737 start, end, orderByComparator, true);
7738 }
7739
7740
7757 @Override
7758 public List<UserNotificationEvent> findByU_DT_A_A(long userId,
7759 int deliveryType, boolean actionRequired, boolean archived, int start,
7760 int end, OrderByComparator<UserNotificationEvent> orderByComparator,
7761 boolean retrieveFromCache) {
7762 boolean pagination = true;
7763 FinderPath finderPath = null;
7764 Object[] finderArgs = null;
7765
7766 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7767 (orderByComparator == null)) {
7768 pagination = false;
7769 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A;
7770 finderArgs = new Object[] {
7771 userId, deliveryType, actionRequired, archived
7772 };
7773 }
7774 else {
7775 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_DT_A_A;
7776 finderArgs = new Object[] {
7777 userId, deliveryType, actionRequired, archived,
7778
7779 start, end, orderByComparator
7780 };
7781 }
7782
7783 List<UserNotificationEvent> list = null;
7784
7785 if (retrieveFromCache) {
7786 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
7787 finderArgs, this);
7788
7789 if ((list != null) && !list.isEmpty()) {
7790 for (UserNotificationEvent userNotificationEvent : list) {
7791 if ((userId != userNotificationEvent.getUserId()) ||
7792 (deliveryType != userNotificationEvent.getDeliveryType()) ||
7793 (actionRequired != userNotificationEvent.getActionRequired()) ||
7794 (archived != userNotificationEvent.getArchived())) {
7795 list = null;
7796
7797 break;
7798 }
7799 }
7800 }
7801 }
7802
7803 if (list == null) {
7804 StringBundler query = null;
7805
7806 if (orderByComparator != null) {
7807 query = new StringBundler(6 +
7808 (orderByComparator.getOrderByFields().length * 3));
7809 }
7810 else {
7811 query = new StringBundler(6);
7812 }
7813
7814 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
7815
7816 query.append(_FINDER_COLUMN_U_DT_A_A_USERID_2);
7817
7818 query.append(_FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2);
7819
7820 query.append(_FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2);
7821
7822 query.append(_FINDER_COLUMN_U_DT_A_A_ARCHIVED_2);
7823
7824 if (orderByComparator != null) {
7825 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7826 orderByComparator);
7827 }
7828 else
7829 if (pagination) {
7830 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
7831 }
7832
7833 String sql = query.toString();
7834
7835 Session session = null;
7836
7837 try {
7838 session = openSession();
7839
7840 Query q = session.createQuery(sql);
7841
7842 QueryPos qPos = QueryPos.getInstance(q);
7843
7844 qPos.add(userId);
7845
7846 qPos.add(deliveryType);
7847
7848 qPos.add(actionRequired);
7849
7850 qPos.add(archived);
7851
7852 if (!pagination) {
7853 list = (List<UserNotificationEvent>)QueryUtil.list(q,
7854 getDialect(), start, end, false);
7855
7856 Collections.sort(list);
7857
7858 list = Collections.unmodifiableList(list);
7859 }
7860 else {
7861 list = (List<UserNotificationEvent>)QueryUtil.list(q,
7862 getDialect(), start, end);
7863 }
7864
7865 cacheResult(list);
7866
7867 finderCache.putResult(finderPath, finderArgs, list);
7868 }
7869 catch (Exception e) {
7870 finderCache.removeResult(finderPath, finderArgs);
7871
7872 throw processException(e);
7873 }
7874 finally {
7875 closeSession(session);
7876 }
7877 }
7878
7879 return list;
7880 }
7881
7882
7893 @Override
7894 public UserNotificationEvent findByU_DT_A_A_First(long userId,
7895 int deliveryType, boolean actionRequired, boolean archived,
7896 OrderByComparator<UserNotificationEvent> orderByComparator)
7897 throws NoSuchUserNotificationEventException {
7898 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_A_First(userId,
7899 deliveryType, actionRequired, archived, orderByComparator);
7900
7901 if (userNotificationEvent != null) {
7902 return userNotificationEvent;
7903 }
7904
7905 StringBundler msg = new StringBundler(10);
7906
7907 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7908
7909 msg.append("userId=");
7910 msg.append(userId);
7911
7912 msg.append(", deliveryType=");
7913 msg.append(deliveryType);
7914
7915 msg.append(", actionRequired=");
7916 msg.append(actionRequired);
7917
7918 msg.append(", archived=");
7919 msg.append(archived);
7920
7921 msg.append(StringPool.CLOSE_CURLY_BRACE);
7922
7923 throw new NoSuchUserNotificationEventException(msg.toString());
7924 }
7925
7926
7936 @Override
7937 public UserNotificationEvent fetchByU_DT_A_A_First(long userId,
7938 int deliveryType, boolean actionRequired, boolean archived,
7939 OrderByComparator<UserNotificationEvent> orderByComparator) {
7940 List<UserNotificationEvent> list = findByU_DT_A_A(userId, deliveryType,
7941 actionRequired, archived, 0, 1, orderByComparator);
7942
7943 if (!list.isEmpty()) {
7944 return list.get(0);
7945 }
7946
7947 return null;
7948 }
7949
7950
7961 @Override
7962 public UserNotificationEvent findByU_DT_A_A_Last(long userId,
7963 int deliveryType, boolean actionRequired, boolean archived,
7964 OrderByComparator<UserNotificationEvent> orderByComparator)
7965 throws NoSuchUserNotificationEventException {
7966 UserNotificationEvent userNotificationEvent = fetchByU_DT_A_A_Last(userId,
7967 deliveryType, actionRequired, archived, orderByComparator);
7968
7969 if (userNotificationEvent != null) {
7970 return userNotificationEvent;
7971 }
7972
7973 StringBundler msg = new StringBundler(10);
7974
7975 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7976
7977 msg.append("userId=");
7978 msg.append(userId);
7979
7980 msg.append(", deliveryType=");
7981 msg.append(deliveryType);
7982
7983 msg.append(", actionRequired=");
7984 msg.append(actionRequired);
7985
7986 msg.append(", archived=");
7987 msg.append(archived);
7988
7989 msg.append(StringPool.CLOSE_CURLY_BRACE);
7990
7991 throw new NoSuchUserNotificationEventException(msg.toString());
7992 }
7993
7994
8004 @Override
8005 public UserNotificationEvent fetchByU_DT_A_A_Last(long userId,
8006 int deliveryType, boolean actionRequired, boolean archived,
8007 OrderByComparator<UserNotificationEvent> orderByComparator) {
8008 int count = countByU_DT_A_A(userId, deliveryType, actionRequired,
8009 archived);
8010
8011 if (count == 0) {
8012 return null;
8013 }
8014
8015 List<UserNotificationEvent> list = findByU_DT_A_A(userId, deliveryType,
8016 actionRequired, archived, count - 1, count, orderByComparator);
8017
8018 if (!list.isEmpty()) {
8019 return list.get(0);
8020 }
8021
8022 return null;
8023 }
8024
8025
8037 @Override
8038 public UserNotificationEvent[] findByU_DT_A_A_PrevAndNext(
8039 long userNotificationEventId, long userId, int deliveryType,
8040 boolean actionRequired, boolean archived,
8041 OrderByComparator<UserNotificationEvent> orderByComparator)
8042 throws NoSuchUserNotificationEventException {
8043 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
8044
8045 Session session = null;
8046
8047 try {
8048 session = openSession();
8049
8050 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
8051
8052 array[0] = getByU_DT_A_A_PrevAndNext(session,
8053 userNotificationEvent, userId, deliveryType,
8054 actionRequired, archived, orderByComparator, true);
8055
8056 array[1] = userNotificationEvent;
8057
8058 array[2] = getByU_DT_A_A_PrevAndNext(session,
8059 userNotificationEvent, userId, deliveryType,
8060 actionRequired, archived, orderByComparator, false);
8061
8062 return array;
8063 }
8064 catch (Exception e) {
8065 throw processException(e);
8066 }
8067 finally {
8068 closeSession(session);
8069 }
8070 }
8071
8072 protected UserNotificationEvent getByU_DT_A_A_PrevAndNext(Session session,
8073 UserNotificationEvent userNotificationEvent, long userId,
8074 int deliveryType, boolean actionRequired, boolean archived,
8075 OrderByComparator<UserNotificationEvent> orderByComparator,
8076 boolean previous) {
8077 StringBundler query = null;
8078
8079 if (orderByComparator != null) {
8080 query = new StringBundler(6 +
8081 (orderByComparator.getOrderByFields().length * 6));
8082 }
8083 else {
8084 query = new StringBundler(3);
8085 }
8086
8087 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
8088
8089 query.append(_FINDER_COLUMN_U_DT_A_A_USERID_2);
8090
8091 query.append(_FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2);
8092
8093 query.append(_FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2);
8094
8095 query.append(_FINDER_COLUMN_U_DT_A_A_ARCHIVED_2);
8096
8097 if (orderByComparator != null) {
8098 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8099
8100 if (orderByConditionFields.length > 0) {
8101 query.append(WHERE_AND);
8102 }
8103
8104 for (int i = 0; i < orderByConditionFields.length; i++) {
8105 query.append(_ORDER_BY_ENTITY_ALIAS);
8106 query.append(orderByConditionFields[i]);
8107
8108 if ((i + 1) < orderByConditionFields.length) {
8109 if (orderByComparator.isAscending() ^ previous) {
8110 query.append(WHERE_GREATER_THAN_HAS_NEXT);
8111 }
8112 else {
8113 query.append(WHERE_LESSER_THAN_HAS_NEXT);
8114 }
8115 }
8116 else {
8117 if (orderByComparator.isAscending() ^ previous) {
8118 query.append(WHERE_GREATER_THAN);
8119 }
8120 else {
8121 query.append(WHERE_LESSER_THAN);
8122 }
8123 }
8124 }
8125
8126 query.append(ORDER_BY_CLAUSE);
8127
8128 String[] orderByFields = orderByComparator.getOrderByFields();
8129
8130 for (int i = 0; i < orderByFields.length; i++) {
8131 query.append(_ORDER_BY_ENTITY_ALIAS);
8132 query.append(orderByFields[i]);
8133
8134 if ((i + 1) < orderByFields.length) {
8135 if (orderByComparator.isAscending() ^ previous) {
8136 query.append(ORDER_BY_ASC_HAS_NEXT);
8137 }
8138 else {
8139 query.append(ORDER_BY_DESC_HAS_NEXT);
8140 }
8141 }
8142 else {
8143 if (orderByComparator.isAscending() ^ previous) {
8144 query.append(ORDER_BY_ASC);
8145 }
8146 else {
8147 query.append(ORDER_BY_DESC);
8148 }
8149 }
8150 }
8151 }
8152 else {
8153 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
8154 }
8155
8156 String sql = query.toString();
8157
8158 Query q = session.createQuery(sql);
8159
8160 q.setFirstResult(0);
8161 q.setMaxResults(2);
8162
8163 QueryPos qPos = QueryPos.getInstance(q);
8164
8165 qPos.add(userId);
8166
8167 qPos.add(deliveryType);
8168
8169 qPos.add(actionRequired);
8170
8171 qPos.add(archived);
8172
8173 if (orderByComparator != null) {
8174 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
8175
8176 for (Object value : values) {
8177 qPos.add(value);
8178 }
8179 }
8180
8181 List<UserNotificationEvent> list = q.list();
8182
8183 if (list.size() == 2) {
8184 return list.get(1);
8185 }
8186 else {
8187 return null;
8188 }
8189 }
8190
8191
8199 @Override
8200 public void removeByU_DT_A_A(long userId, int deliveryType,
8201 boolean actionRequired, boolean archived) {
8202 for (UserNotificationEvent userNotificationEvent : findByU_DT_A_A(
8203 userId, deliveryType, actionRequired, archived,
8204 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8205 remove(userNotificationEvent);
8206 }
8207 }
8208
8209
8218 @Override
8219 public int countByU_DT_A_A(long userId, int deliveryType,
8220 boolean actionRequired, boolean archived) {
8221 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_DT_A_A;
8222
8223 Object[] finderArgs = new Object[] {
8224 userId, deliveryType, actionRequired, archived
8225 };
8226
8227 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8228
8229 if (count == null) {
8230 StringBundler query = new StringBundler(5);
8231
8232 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
8233
8234 query.append(_FINDER_COLUMN_U_DT_A_A_USERID_2);
8235
8236 query.append(_FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2);
8237
8238 query.append(_FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2);
8239
8240 query.append(_FINDER_COLUMN_U_DT_A_A_ARCHIVED_2);
8241
8242 String sql = query.toString();
8243
8244 Session session = null;
8245
8246 try {
8247 session = openSession();
8248
8249 Query q = session.createQuery(sql);
8250
8251 QueryPos qPos = QueryPos.getInstance(q);
8252
8253 qPos.add(userId);
8254
8255 qPos.add(deliveryType);
8256
8257 qPos.add(actionRequired);
8258
8259 qPos.add(archived);
8260
8261 count = (Long)q.uniqueResult();
8262
8263 finderCache.putResult(finderPath, finderArgs, count);
8264 }
8265 catch (Exception e) {
8266 finderCache.removeResult(finderPath, finderArgs);
8267
8268 throw processException(e);
8269 }
8270 finally {
8271 closeSession(session);
8272 }
8273 }
8274
8275 return count.intValue();
8276 }
8277
8278 private static final String _FINDER_COLUMN_U_DT_A_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
8279 private static final String _FINDER_COLUMN_U_DT_A_A_DELIVERYTYPE_2 = "userNotificationEvent.deliveryType = ? AND ";
8280 private static final String _FINDER_COLUMN_U_DT_A_A_ACTIONREQUIRED_2 = "userNotificationEvent.actionRequired = ? AND ";
8281 private static final String _FINDER_COLUMN_U_DT_A_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
8282
8283 public UserNotificationEventPersistenceImpl() {
8284 setModelClass(UserNotificationEvent.class);
8285 }
8286
8287
8292 @Override
8293 public void cacheResult(UserNotificationEvent userNotificationEvent) {
8294 entityCache.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8295 UserNotificationEventImpl.class,
8296 userNotificationEvent.getPrimaryKey(), userNotificationEvent);
8297
8298 userNotificationEvent.resetOriginalValues();
8299 }
8300
8301
8306 @Override
8307 public void cacheResult(List<UserNotificationEvent> userNotificationEvents) {
8308 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
8309 if (entityCache.getResult(
8310 UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8311 UserNotificationEventImpl.class,
8312 userNotificationEvent.getPrimaryKey()) == null) {
8313 cacheResult(userNotificationEvent);
8314 }
8315 else {
8316 userNotificationEvent.resetOriginalValues();
8317 }
8318 }
8319 }
8320
8321
8328 @Override
8329 public void clearCache() {
8330 entityCache.clearCache(UserNotificationEventImpl.class);
8331
8332 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
8333 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8334 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8335 }
8336
8337
8344 @Override
8345 public void clearCache(UserNotificationEvent userNotificationEvent) {
8346 entityCache.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8347 UserNotificationEventImpl.class,
8348 userNotificationEvent.getPrimaryKey());
8349
8350 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8351 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8352 }
8353
8354 @Override
8355 public void clearCache(List<UserNotificationEvent> userNotificationEvents) {
8356 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8357 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8358
8359 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
8360 entityCache.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8361 UserNotificationEventImpl.class,
8362 userNotificationEvent.getPrimaryKey());
8363 }
8364 }
8365
8366
8372 @Override
8373 public UserNotificationEvent create(long userNotificationEventId) {
8374 UserNotificationEvent userNotificationEvent = new UserNotificationEventImpl();
8375
8376 userNotificationEvent.setNew(true);
8377 userNotificationEvent.setPrimaryKey(userNotificationEventId);
8378
8379 String uuid = PortalUUIDUtil.generate();
8380
8381 userNotificationEvent.setUuid(uuid);
8382
8383 userNotificationEvent.setCompanyId(companyProvider.getCompanyId());
8384
8385 return userNotificationEvent;
8386 }
8387
8388
8395 @Override
8396 public UserNotificationEvent remove(long userNotificationEventId)
8397 throws NoSuchUserNotificationEventException {
8398 return remove((Serializable)userNotificationEventId);
8399 }
8400
8401
8408 @Override
8409 public UserNotificationEvent remove(Serializable primaryKey)
8410 throws NoSuchUserNotificationEventException {
8411 Session session = null;
8412
8413 try {
8414 session = openSession();
8415
8416 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
8417 primaryKey);
8418
8419 if (userNotificationEvent == null) {
8420 if (_log.isWarnEnabled()) {
8421 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
8422 }
8423
8424 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
8425 primaryKey);
8426 }
8427
8428 return remove(userNotificationEvent);
8429 }
8430 catch (NoSuchUserNotificationEventException nsee) {
8431 throw nsee;
8432 }
8433 catch (Exception e) {
8434 throw processException(e);
8435 }
8436 finally {
8437 closeSession(session);
8438 }
8439 }
8440
8441 @Override
8442 protected UserNotificationEvent removeImpl(
8443 UserNotificationEvent userNotificationEvent) {
8444 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
8445
8446 Session session = null;
8447
8448 try {
8449 session = openSession();
8450
8451 if (!session.contains(userNotificationEvent)) {
8452 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
8453 userNotificationEvent.getPrimaryKeyObj());
8454 }
8455
8456 if (userNotificationEvent != null) {
8457 session.delete(userNotificationEvent);
8458 }
8459 }
8460 catch (Exception e) {
8461 throw processException(e);
8462 }
8463 finally {
8464 closeSession(session);
8465 }
8466
8467 if (userNotificationEvent != null) {
8468 clearCache(userNotificationEvent);
8469 }
8470
8471 return userNotificationEvent;
8472 }
8473
8474 @Override
8475 public UserNotificationEvent updateImpl(
8476 UserNotificationEvent userNotificationEvent) {
8477 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
8478
8479 boolean isNew = userNotificationEvent.isNew();
8480
8481 UserNotificationEventModelImpl userNotificationEventModelImpl = (UserNotificationEventModelImpl)userNotificationEvent;
8482
8483 if (Validator.isNull(userNotificationEvent.getUuid())) {
8484 String uuid = PortalUUIDUtil.generate();
8485
8486 userNotificationEvent.setUuid(uuid);
8487 }
8488
8489 Session session = null;
8490
8491 try {
8492 session = openSession();
8493
8494 if (userNotificationEvent.isNew()) {
8495 session.save(userNotificationEvent);
8496
8497 userNotificationEvent.setNew(false);
8498 }
8499 else {
8500 userNotificationEvent = (UserNotificationEvent)session.merge(userNotificationEvent);
8501 }
8502 }
8503 catch (Exception e) {
8504 throw processException(e);
8505 }
8506 finally {
8507 closeSession(session);
8508 }
8509
8510 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8511
8512 if (isNew || !UserNotificationEventModelImpl.COLUMN_BITMASK_ENABLED) {
8513 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8514 }
8515
8516 else {
8517 if ((userNotificationEventModelImpl.getColumnBitmask() &
8518 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
8519 Object[] args = new Object[] {
8520 userNotificationEventModelImpl.getOriginalUuid()
8521 };
8522
8523 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
8524 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
8525 args);
8526
8527 args = new Object[] { userNotificationEventModelImpl.getUuid() };
8528
8529 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
8530 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
8531 args);
8532 }
8533
8534 if ((userNotificationEventModelImpl.getColumnBitmask() &
8535 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
8536 Object[] args = new Object[] {
8537 userNotificationEventModelImpl.getOriginalUuid(),
8538 userNotificationEventModelImpl.getOriginalCompanyId()
8539 };
8540
8541 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
8542 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
8543 args);
8544
8545 args = new Object[] {
8546 userNotificationEventModelImpl.getUuid(),
8547 userNotificationEventModelImpl.getCompanyId()
8548 };
8549
8550 finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
8551 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
8552 args);
8553 }
8554
8555 if ((userNotificationEventModelImpl.getColumnBitmask() &
8556 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
8557 Object[] args = new Object[] {
8558 userNotificationEventModelImpl.getOriginalUserId()
8559 };
8560
8561 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
8562 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
8563 args);
8564
8565 args = new Object[] { userNotificationEventModelImpl.getUserId() };
8566
8567 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
8568 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
8569 args);
8570 }
8571
8572 if ((userNotificationEventModelImpl.getColumnBitmask() &
8573 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE.getColumnBitmask()) != 0) {
8574 Object[] args = new Object[] {
8575 userNotificationEventModelImpl.getOriginalType()
8576 };
8577
8578 finderCache.removeResult(FINDER_PATH_COUNT_BY_TYPE, args);
8579 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE,
8580 args);
8581
8582 args = new Object[] { userNotificationEventModelImpl.getType() };
8583
8584 finderCache.removeResult(FINDER_PATH_COUNT_BY_TYPE, args);
8585 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE,
8586 args);
8587 }
8588
8589 if ((userNotificationEventModelImpl.getColumnBitmask() &
8590 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT.getColumnBitmask()) != 0) {
8591 Object[] args = new Object[] {
8592 userNotificationEventModelImpl.getOriginalUserId(),
8593 userNotificationEventModelImpl.getOriginalDeliveryType()
8594 };
8595
8596 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT, args);
8597 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT,
8598 args);
8599
8600 args = new Object[] {
8601 userNotificationEventModelImpl.getUserId(),
8602 userNotificationEventModelImpl.getDeliveryType()
8603 };
8604
8605 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT, args);
8606 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT,
8607 args);
8608 }
8609
8610 if ((userNotificationEventModelImpl.getColumnBitmask() &
8611 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D.getColumnBitmask()) != 0) {
8612 Object[] args = new Object[] {
8613 userNotificationEventModelImpl.getOriginalUserId(),
8614 userNotificationEventModelImpl.getOriginalDelivered()
8615 };
8616
8617 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_D, args);
8618 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D,
8619 args);
8620
8621 args = new Object[] {
8622 userNotificationEventModelImpl.getUserId(),
8623 userNotificationEventModelImpl.getDelivered()
8624 };
8625
8626 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_D, args);
8627 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D,
8628 args);
8629 }
8630
8631 if ((userNotificationEventModelImpl.getColumnBitmask() &
8632 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A.getColumnBitmask()) != 0) {
8633 Object[] args = new Object[] {
8634 userNotificationEventModelImpl.getOriginalUserId(),
8635 userNotificationEventModelImpl.getOriginalArchived()
8636 };
8637
8638 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
8639 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
8640 args);
8641
8642 args = new Object[] {
8643 userNotificationEventModelImpl.getUserId(),
8644 userNotificationEventModelImpl.getArchived()
8645 };
8646
8647 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
8648 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
8649 args);
8650 }
8651
8652 if ((userNotificationEventModelImpl.getColumnBitmask() &
8653 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D.getColumnBitmask()) != 0) {
8654 Object[] args = new Object[] {
8655 userNotificationEventModelImpl.getOriginalUserId(),
8656 userNotificationEventModelImpl.getOriginalDeliveryType(),
8657 userNotificationEventModelImpl.getOriginalDelivered()
8658 };
8659
8660 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_D, args);
8661 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D,
8662 args);
8663
8664 args = new Object[] {
8665 userNotificationEventModelImpl.getUserId(),
8666 userNotificationEventModelImpl.getDeliveryType(),
8667 userNotificationEventModelImpl.getDelivered()
8668 };
8669
8670 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_D, args);
8671 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D,
8672 args);
8673 }
8674
8675 if ((userNotificationEventModelImpl.getColumnBitmask() &
8676 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A.getColumnBitmask()) != 0) {
8677 Object[] args = new Object[] {
8678 userNotificationEventModelImpl.getOriginalUserId(),
8679 userNotificationEventModelImpl.getOriginalDeliveryType(),
8680 userNotificationEventModelImpl.getOriginalArchived()
8681 };
8682
8683 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_A, args);
8684 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A,
8685 args);
8686
8687 args = new Object[] {
8688 userNotificationEventModelImpl.getUserId(),
8689 userNotificationEventModelImpl.getDeliveryType(),
8690 userNotificationEventModelImpl.getArchived()
8691 };
8692
8693 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_A, args);
8694 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A,
8695 args);
8696 }
8697
8698 if ((userNotificationEventModelImpl.getColumnBitmask() &
8699 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A.getColumnBitmask()) != 0) {
8700 Object[] args = new Object[] {
8701 userNotificationEventModelImpl.getOriginalUserId(),
8702 userNotificationEventModelImpl.getOriginalDelivered(),
8703 userNotificationEventModelImpl.getOriginalActionRequired()
8704 };
8705
8706 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_D_A, args);
8707 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A,
8708 args);
8709
8710 args = new Object[] {
8711 userNotificationEventModelImpl.getUserId(),
8712 userNotificationEventModelImpl.getDelivered(),
8713 userNotificationEventModelImpl.getActionRequired()
8714 };
8715
8716 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_D_A, args);
8717 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D_A,
8718 args);
8719 }
8720
8721 if ((userNotificationEventModelImpl.getColumnBitmask() &
8722 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A.getColumnBitmask()) != 0) {
8723 Object[] args = new Object[] {
8724 userNotificationEventModelImpl.getOriginalUserId(),
8725 userNotificationEventModelImpl.getOriginalActionRequired(),
8726 userNotificationEventModelImpl.getOriginalArchived()
8727 };
8728
8729 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_A_A, args);
8730 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A,
8731 args);
8732
8733 args = new Object[] {
8734 userNotificationEventModelImpl.getUserId(),
8735 userNotificationEventModelImpl.getActionRequired(),
8736 userNotificationEventModelImpl.getArchived()
8737 };
8738
8739 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_A_A, args);
8740 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A_A,
8741 args);
8742 }
8743
8744 if ((userNotificationEventModelImpl.getColumnBitmask() &
8745 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_T_DT_D.getColumnBitmask()) != 0) {
8746 Object[] args = new Object[] {
8747 userNotificationEventModelImpl.getOriginalUserId(),
8748 userNotificationEventModelImpl.getOriginalType(),
8749 userNotificationEventModelImpl.getOriginalDeliveryType(),
8750 userNotificationEventModelImpl.getOriginalDelivered()
8751 };
8752
8753 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_T_DT_D, args);
8754 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_T_DT_D,
8755 args);
8756
8757 args = new Object[] {
8758 userNotificationEventModelImpl.getUserId(),
8759 userNotificationEventModelImpl.getType(),
8760 userNotificationEventModelImpl.getDeliveryType(),
8761 userNotificationEventModelImpl.getDelivered()
8762 };
8763
8764 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_T_DT_D, args);
8765 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_T_DT_D,
8766 args);
8767 }
8768
8769 if ((userNotificationEventModelImpl.getColumnBitmask() &
8770 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A.getColumnBitmask()) != 0) {
8771 Object[] args = new Object[] {
8772 userNotificationEventModelImpl.getOriginalUserId(),
8773 userNotificationEventModelImpl.getOriginalDeliveryType(),
8774 userNotificationEventModelImpl.getOriginalDelivered(),
8775 userNotificationEventModelImpl.getOriginalActionRequired()
8776 };
8777
8778 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_D_A, args);
8779 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A,
8780 args);
8781
8782 args = new Object[] {
8783 userNotificationEventModelImpl.getUserId(),
8784 userNotificationEventModelImpl.getDeliveryType(),
8785 userNotificationEventModelImpl.getDelivered(),
8786 userNotificationEventModelImpl.getActionRequired()
8787 };
8788
8789 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_D_A, args);
8790 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_D_A,
8791 args);
8792 }
8793
8794 if ((userNotificationEventModelImpl.getColumnBitmask() &
8795 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A.getColumnBitmask()) != 0) {
8796 Object[] args = new Object[] {
8797 userNotificationEventModelImpl.getOriginalUserId(),
8798 userNotificationEventModelImpl.getOriginalDeliveryType(),
8799 userNotificationEventModelImpl.getOriginalActionRequired(),
8800 userNotificationEventModelImpl.getOriginalArchived()
8801 };
8802
8803 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_A_A, args);
8804 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A,
8805 args);
8806
8807 args = new Object[] {
8808 userNotificationEventModelImpl.getUserId(),
8809 userNotificationEventModelImpl.getDeliveryType(),
8810 userNotificationEventModelImpl.getActionRequired(),
8811 userNotificationEventModelImpl.getArchived()
8812 };
8813
8814 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_DT_A_A, args);
8815 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_DT_A_A,
8816 args);
8817 }
8818 }
8819
8820 entityCache.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8821 UserNotificationEventImpl.class,
8822 userNotificationEvent.getPrimaryKey(), userNotificationEvent, false);
8823
8824 userNotificationEvent.resetOriginalValues();
8825
8826 return userNotificationEvent;
8827 }
8828
8829 protected UserNotificationEvent toUnwrappedModel(
8830 UserNotificationEvent userNotificationEvent) {
8831 if (userNotificationEvent instanceof UserNotificationEventImpl) {
8832 return userNotificationEvent;
8833 }
8834
8835 UserNotificationEventImpl userNotificationEventImpl = new UserNotificationEventImpl();
8836
8837 userNotificationEventImpl.setNew(userNotificationEvent.isNew());
8838 userNotificationEventImpl.setPrimaryKey(userNotificationEvent.getPrimaryKey());
8839
8840 userNotificationEventImpl.setMvccVersion(userNotificationEvent.getMvccVersion());
8841 userNotificationEventImpl.setUuid(userNotificationEvent.getUuid());
8842 userNotificationEventImpl.setUserNotificationEventId(userNotificationEvent.getUserNotificationEventId());
8843 userNotificationEventImpl.setCompanyId(userNotificationEvent.getCompanyId());
8844 userNotificationEventImpl.setUserId(userNotificationEvent.getUserId());
8845 userNotificationEventImpl.setType(userNotificationEvent.getType());
8846 userNotificationEventImpl.setTimestamp(userNotificationEvent.getTimestamp());
8847 userNotificationEventImpl.setDeliveryType(userNotificationEvent.getDeliveryType());
8848 userNotificationEventImpl.setDeliverBy(userNotificationEvent.getDeliverBy());
8849 userNotificationEventImpl.setDelivered(userNotificationEvent.isDelivered());
8850 userNotificationEventImpl.setPayload(userNotificationEvent.getPayload());
8851 userNotificationEventImpl.setActionRequired(userNotificationEvent.isActionRequired());
8852 userNotificationEventImpl.setArchived(userNotificationEvent.isArchived());
8853
8854 return userNotificationEventImpl;
8855 }
8856
8857
8864 @Override
8865 public UserNotificationEvent findByPrimaryKey(Serializable primaryKey)
8866 throws NoSuchUserNotificationEventException {
8867 UserNotificationEvent userNotificationEvent = fetchByPrimaryKey(primaryKey);
8868
8869 if (userNotificationEvent == null) {
8870 if (_log.isWarnEnabled()) {
8871 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
8872 }
8873
8874 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
8875 primaryKey);
8876 }
8877
8878 return userNotificationEvent;
8879 }
8880
8881
8888 @Override
8889 public UserNotificationEvent findByPrimaryKey(long userNotificationEventId)
8890 throws NoSuchUserNotificationEventException {
8891 return findByPrimaryKey((Serializable)userNotificationEventId);
8892 }
8893
8894
8900 @Override
8901 public UserNotificationEvent fetchByPrimaryKey(Serializable primaryKey) {
8902 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)entityCache.getResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8903 UserNotificationEventImpl.class, primaryKey);
8904
8905 if (userNotificationEvent == _nullUserNotificationEvent) {
8906 return null;
8907 }
8908
8909 if (userNotificationEvent == null) {
8910 Session session = null;
8911
8912 try {
8913 session = openSession();
8914
8915 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
8916 primaryKey);
8917
8918 if (userNotificationEvent != null) {
8919 cacheResult(userNotificationEvent);
8920 }
8921 else {
8922 entityCache.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8923 UserNotificationEventImpl.class, primaryKey,
8924 _nullUserNotificationEvent);
8925 }
8926 }
8927 catch (Exception e) {
8928 entityCache.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8929 UserNotificationEventImpl.class, primaryKey);
8930
8931 throw processException(e);
8932 }
8933 finally {
8934 closeSession(session);
8935 }
8936 }
8937
8938 return userNotificationEvent;
8939 }
8940
8941
8947 @Override
8948 public UserNotificationEvent fetchByPrimaryKey(long userNotificationEventId) {
8949 return fetchByPrimaryKey((Serializable)userNotificationEventId);
8950 }
8951
8952 @Override
8953 public Map<Serializable, UserNotificationEvent> fetchByPrimaryKeys(
8954 Set<Serializable> primaryKeys) {
8955 if (primaryKeys.isEmpty()) {
8956 return Collections.emptyMap();
8957 }
8958
8959 Map<Serializable, UserNotificationEvent> map = new HashMap<Serializable, UserNotificationEvent>();
8960
8961 if (primaryKeys.size() == 1) {
8962 Iterator<Serializable> iterator = primaryKeys.iterator();
8963
8964 Serializable primaryKey = iterator.next();
8965
8966 UserNotificationEvent userNotificationEvent = fetchByPrimaryKey(primaryKey);
8967
8968 if (userNotificationEvent != null) {
8969 map.put(primaryKey, userNotificationEvent);
8970 }
8971
8972 return map;
8973 }
8974
8975 Set<Serializable> uncachedPrimaryKeys = null;
8976
8977 for (Serializable primaryKey : primaryKeys) {
8978 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)entityCache.getResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
8979 UserNotificationEventImpl.class, primaryKey);
8980
8981 if (userNotificationEvent == null) {
8982 if (uncachedPrimaryKeys == null) {
8983 uncachedPrimaryKeys = new HashSet<Serializable>();
8984 }
8985
8986 uncachedPrimaryKeys.add(primaryKey);
8987 }
8988 else {
8989 map.put(primaryKey, userNotificationEvent);
8990 }
8991 }
8992
8993 if (uncachedPrimaryKeys == null) {
8994 return map;
8995 }
8996
8997 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
8998 1);
8999
9000 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE_PKS_IN);
9001
9002 for (Serializable primaryKey : uncachedPrimaryKeys) {
9003 query.append(String.valueOf(primaryKey));
9004
9005 query.append(StringPool.COMMA);
9006 }
9007
9008 query.setIndex(query.index() - 1);
9009
9010 query.append(StringPool.CLOSE_PARENTHESIS);
9011
9012 String sql = query.toString();
9013
9014 Session session = null;
9015
9016 try {
9017 session = openSession();
9018
9019 Query q = session.createQuery(sql);
9020
9021 for (UserNotificationEvent userNotificationEvent : (List<UserNotificationEvent>)q.list()) {
9022 map.put(userNotificationEvent.getPrimaryKeyObj(),
9023 userNotificationEvent);
9024
9025 cacheResult(userNotificationEvent);
9026
9027 uncachedPrimaryKeys.remove(userNotificationEvent.getPrimaryKeyObj());
9028 }
9029
9030 for (Serializable primaryKey : uncachedPrimaryKeys) {
9031 entityCache.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
9032 UserNotificationEventImpl.class, primaryKey,
9033 _nullUserNotificationEvent);
9034 }
9035 }
9036 catch (Exception e) {
9037 throw processException(e);
9038 }
9039 finally {
9040 closeSession(session);
9041 }
9042
9043 return map;
9044 }
9045
9046
9051 @Override
9052 public List<UserNotificationEvent> findAll() {
9053 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9054 }
9055
9056
9067 @Override
9068 public List<UserNotificationEvent> findAll(int start, int end) {
9069 return findAll(start, end, null);
9070 }
9071
9072
9084 @Override
9085 public List<UserNotificationEvent> findAll(int start, int end,
9086 OrderByComparator<UserNotificationEvent> orderByComparator) {
9087 return findAll(start, end, orderByComparator, true);
9088 }
9089
9090
9103 @Override
9104 public List<UserNotificationEvent> findAll(int start, int end,
9105 OrderByComparator<UserNotificationEvent> orderByComparator,
9106 boolean retrieveFromCache) {
9107 boolean pagination = true;
9108 FinderPath finderPath = null;
9109 Object[] finderArgs = null;
9110
9111 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9112 (orderByComparator == null)) {
9113 pagination = false;
9114 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
9115 finderArgs = FINDER_ARGS_EMPTY;
9116 }
9117 else {
9118 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
9119 finderArgs = new Object[] { start, end, orderByComparator };
9120 }
9121
9122 List<UserNotificationEvent> list = null;
9123
9124 if (retrieveFromCache) {
9125 list = (List<UserNotificationEvent>)finderCache.getResult(finderPath,
9126 finderArgs, this);
9127 }
9128
9129 if (list == null) {
9130 StringBundler query = null;
9131 String sql = null;
9132
9133 if (orderByComparator != null) {
9134 query = new StringBundler(2 +
9135 (orderByComparator.getOrderByFields().length * 3));
9136
9137 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT);
9138
9139 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9140 orderByComparator);
9141
9142 sql = query.toString();
9143 }
9144 else {
9145 sql = _SQL_SELECT_USERNOTIFICATIONEVENT;
9146
9147 if (pagination) {
9148 sql = sql.concat(UserNotificationEventModelImpl.ORDER_BY_JPQL);
9149 }
9150 }
9151
9152 Session session = null;
9153
9154 try {
9155 session = openSession();
9156
9157 Query q = session.createQuery(sql);
9158
9159 if (!pagination) {
9160 list = (List<UserNotificationEvent>)QueryUtil.list(q,
9161 getDialect(), start, end, false);
9162
9163 Collections.sort(list);
9164
9165 list = Collections.unmodifiableList(list);
9166 }
9167 else {
9168 list = (List<UserNotificationEvent>)QueryUtil.list(q,
9169 getDialect(), start, end);
9170 }
9171
9172 cacheResult(list);
9173
9174 finderCache.putResult(finderPath, finderArgs, list);
9175 }
9176 catch (Exception e) {
9177 finderCache.removeResult(finderPath, finderArgs);
9178
9179 throw processException(e);
9180 }
9181 finally {
9182 closeSession(session);
9183 }
9184 }
9185
9186 return list;
9187 }
9188
9189
9193 @Override
9194 public void removeAll() {
9195 for (UserNotificationEvent userNotificationEvent : findAll()) {
9196 remove(userNotificationEvent);
9197 }
9198 }
9199
9200
9205 @Override
9206 public int countAll() {
9207 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
9208 FINDER_ARGS_EMPTY, this);
9209
9210 if (count == null) {
9211 Session session = null;
9212
9213 try {
9214 session = openSession();
9215
9216 Query q = session.createQuery(_SQL_COUNT_USERNOTIFICATIONEVENT);
9217
9218 count = (Long)q.uniqueResult();
9219
9220 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
9221 count);
9222 }
9223 catch (Exception e) {
9224 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
9225 FINDER_ARGS_EMPTY);
9226
9227 throw processException(e);
9228 }
9229 finally {
9230 closeSession(session);
9231 }
9232 }
9233
9234 return count.intValue();
9235 }
9236
9237 @Override
9238 public Set<String> getBadColumnNames() {
9239 return _badColumnNames;
9240 }
9241
9242 @Override
9243 protected Map<String, Integer> getTableColumnsMap() {
9244 return UserNotificationEventModelImpl.TABLE_COLUMNS_MAP;
9245 }
9246
9247
9250 public void afterPropertiesSet() {
9251 }
9252
9253 public void destroy() {
9254 entityCache.removeCache(UserNotificationEventImpl.class.getName());
9255 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
9256 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
9257 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
9258 }
9259
9260 @BeanReference(type = CompanyProviderWrapper.class)
9261 protected CompanyProvider companyProvider;
9262 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
9263 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
9264 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent";
9265 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT_WHERE_PKS_IN = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent WHERE userNotificationEventId IN (";
9266 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT_WHERE = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent WHERE ";
9267 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent";
9268 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT_WHERE = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent WHERE ";
9269 private static final String _ORDER_BY_ENTITY_ALIAS = "userNotificationEvent.";
9270 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserNotificationEvent exists with the primary key ";
9271 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserNotificationEvent exists with the key {";
9272 private static final Log _log = LogFactoryUtil.getLog(UserNotificationEventPersistenceImpl.class);
9273 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
9274 "uuid", "type"
9275 });
9276 private static final UserNotificationEvent _nullUserNotificationEvent = new UserNotificationEventImpl() {
9277 @Override
9278 public Object clone() {
9279 return this;
9280 }
9281
9282 @Override
9283 public CacheModel<UserNotificationEvent> toCacheModel() {
9284 return _nullUserNotificationEventCacheModel;
9285 }
9286 };
9287
9288 private static final CacheModel<UserNotificationEvent> _nullUserNotificationEventCacheModel =
9289 new NullCacheModel();
9290
9291 private static class NullCacheModel implements CacheModel<UserNotificationEvent>,
9292 MVCCModel {
9293 @Override
9294 public long getMvccVersion() {
9295 return -1;
9296 }
9297
9298 @Override
9299 public void setMvccVersion(long mvccVersion) {
9300 }
9301
9302 @Override
9303 public UserNotificationEvent toEntityModel() {
9304 return _nullUserNotificationEvent;
9305 }
9306 }
9307 }