001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchUserNotificationEventException;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.exception.SystemException;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.GetterUtil;
030 import com.liferay.portal.kernel.util.InstanceFactory;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.kernel.util.SetUtil;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.UnmodifiableList;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.model.UserNotificationEvent;
042 import com.liferay.portal.model.impl.UserNotificationEventImpl;
043 import com.liferay.portal.model.impl.UserNotificationEventModelImpl;
044 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045
046 import java.io.Serializable;
047
048 import java.util.ArrayList;
049 import java.util.Collections;
050 import java.util.List;
051 import java.util.Set;
052
053
065 public class UserNotificationEventPersistenceImpl extends BasePersistenceImpl<UserNotificationEvent>
066 implements UserNotificationEventPersistence {
067
072 public static final String FINDER_CLASS_NAME_ENTITY = UserNotificationEventImpl.class.getName();
073 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List1";
075 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List2";
077 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
078 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
079 UserNotificationEventImpl.class,
080 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
081 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
082 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
083 UserNotificationEventImpl.class,
084 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
086 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
089 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
090 UserNotificationEventImpl.class,
091 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
092 new String[] {
093 String.class.getName(),
094
095 Integer.class.getName(), Integer.class.getName(),
096 OrderByComparator.class.getName()
097 });
098 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
099 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
100 UserNotificationEventImpl.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
102 new String[] { String.class.getName() },
103 UserNotificationEventModelImpl.UUID_COLUMN_BITMASK |
104 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
106 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
108 new String[] { String.class.getName() });
109
110
117 @Override
118 public List<UserNotificationEvent> findByUuid(String uuid)
119 throws SystemException {
120 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
121 }
122
123
136 @Override
137 public List<UserNotificationEvent> findByUuid(String uuid, int start,
138 int end) throws SystemException {
139 return findByUuid(uuid, start, end, null);
140 }
141
142
156 @Override
157 public List<UserNotificationEvent> findByUuid(String uuid, int start,
158 int end, OrderByComparator orderByComparator) throws SystemException {
159 boolean pagination = true;
160 FinderPath finderPath = null;
161 Object[] finderArgs = null;
162
163 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
164 (orderByComparator == null)) {
165 pagination = false;
166 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
167 finderArgs = new Object[] { uuid };
168 }
169 else {
170 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
171 finderArgs = new Object[] { uuid, start, end, orderByComparator };
172 }
173
174 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
175 finderArgs, this);
176
177 if ((list != null) && !list.isEmpty()) {
178 for (UserNotificationEvent userNotificationEvent : list) {
179 if (!Validator.equals(uuid, userNotificationEvent.getUuid())) {
180 list = null;
181
182 break;
183 }
184 }
185 }
186
187 if (list == null) {
188 StringBundler query = null;
189
190 if (orderByComparator != null) {
191 query = new StringBundler(3 +
192 (orderByComparator.getOrderByFields().length * 3));
193 }
194 else {
195 query = new StringBundler(3);
196 }
197
198 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
199
200 boolean bindUuid = false;
201
202 if (uuid == null) {
203 query.append(_FINDER_COLUMN_UUID_UUID_1);
204 }
205 else if (uuid.equals(StringPool.BLANK)) {
206 query.append(_FINDER_COLUMN_UUID_UUID_3);
207 }
208 else {
209 bindUuid = true;
210
211 query.append(_FINDER_COLUMN_UUID_UUID_2);
212 }
213
214 if (orderByComparator != null) {
215 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
216 orderByComparator);
217 }
218 else
219 if (pagination) {
220 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
221 }
222
223 String sql = query.toString();
224
225 Session session = null;
226
227 try {
228 session = openSession();
229
230 Query q = session.createQuery(sql);
231
232 QueryPos qPos = QueryPos.getInstance(q);
233
234 if (bindUuid) {
235 qPos.add(uuid);
236 }
237
238 if (!pagination) {
239 list = (List<UserNotificationEvent>)QueryUtil.list(q,
240 getDialect(), start, end, false);
241
242 Collections.sort(list);
243
244 list = new UnmodifiableList<UserNotificationEvent>(list);
245 }
246 else {
247 list = (List<UserNotificationEvent>)QueryUtil.list(q,
248 getDialect(), start, end);
249 }
250
251 cacheResult(list);
252
253 FinderCacheUtil.putResult(finderPath, finderArgs, list);
254 }
255 catch (Exception e) {
256 FinderCacheUtil.removeResult(finderPath, finderArgs);
257
258 throw processException(e);
259 }
260 finally {
261 closeSession(session);
262 }
263 }
264
265 return list;
266 }
267
268
277 @Override
278 public UserNotificationEvent findByUuid_First(String uuid,
279 OrderByComparator orderByComparator)
280 throws NoSuchUserNotificationEventException, SystemException {
281 UserNotificationEvent userNotificationEvent = fetchByUuid_First(uuid,
282 orderByComparator);
283
284 if (userNotificationEvent != null) {
285 return userNotificationEvent;
286 }
287
288 StringBundler msg = new StringBundler(4);
289
290 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
291
292 msg.append("uuid=");
293 msg.append(uuid);
294
295 msg.append(StringPool.CLOSE_CURLY_BRACE);
296
297 throw new NoSuchUserNotificationEventException(msg.toString());
298 }
299
300
308 @Override
309 public UserNotificationEvent fetchByUuid_First(String uuid,
310 OrderByComparator orderByComparator) throws SystemException {
311 List<UserNotificationEvent> list = findByUuid(uuid, 0, 1,
312 orderByComparator);
313
314 if (!list.isEmpty()) {
315 return list.get(0);
316 }
317
318 return null;
319 }
320
321
330 @Override
331 public UserNotificationEvent findByUuid_Last(String uuid,
332 OrderByComparator orderByComparator)
333 throws NoSuchUserNotificationEventException, SystemException {
334 UserNotificationEvent userNotificationEvent = fetchByUuid_Last(uuid,
335 orderByComparator);
336
337 if (userNotificationEvent != null) {
338 return userNotificationEvent;
339 }
340
341 StringBundler msg = new StringBundler(4);
342
343 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
344
345 msg.append("uuid=");
346 msg.append(uuid);
347
348 msg.append(StringPool.CLOSE_CURLY_BRACE);
349
350 throw new NoSuchUserNotificationEventException(msg.toString());
351 }
352
353
361 @Override
362 public UserNotificationEvent fetchByUuid_Last(String uuid,
363 OrderByComparator orderByComparator) throws SystemException {
364 int count = countByUuid(uuid);
365
366 if (count == 0) {
367 return null;
368 }
369
370 List<UserNotificationEvent> list = findByUuid(uuid, count - 1, count,
371 orderByComparator);
372
373 if (!list.isEmpty()) {
374 return list.get(0);
375 }
376
377 return null;
378 }
379
380
390 @Override
391 public UserNotificationEvent[] findByUuid_PrevAndNext(
392 long userNotificationEventId, String uuid,
393 OrderByComparator orderByComparator)
394 throws NoSuchUserNotificationEventException, SystemException {
395 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
396
397 Session session = null;
398
399 try {
400 session = openSession();
401
402 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
403
404 array[0] = getByUuid_PrevAndNext(session, userNotificationEvent,
405 uuid, orderByComparator, true);
406
407 array[1] = userNotificationEvent;
408
409 array[2] = getByUuid_PrevAndNext(session, userNotificationEvent,
410 uuid, orderByComparator, false);
411
412 return array;
413 }
414 catch (Exception e) {
415 throw processException(e);
416 }
417 finally {
418 closeSession(session);
419 }
420 }
421
422 protected UserNotificationEvent getByUuid_PrevAndNext(Session session,
423 UserNotificationEvent userNotificationEvent, String uuid,
424 OrderByComparator orderByComparator, boolean previous) {
425 StringBundler query = null;
426
427 if (orderByComparator != null) {
428 query = new StringBundler(6 +
429 (orderByComparator.getOrderByFields().length * 6));
430 }
431 else {
432 query = new StringBundler(3);
433 }
434
435 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
436
437 boolean bindUuid = false;
438
439 if (uuid == null) {
440 query.append(_FINDER_COLUMN_UUID_UUID_1);
441 }
442 else if (uuid.equals(StringPool.BLANK)) {
443 query.append(_FINDER_COLUMN_UUID_UUID_3);
444 }
445 else {
446 bindUuid = true;
447
448 query.append(_FINDER_COLUMN_UUID_UUID_2);
449 }
450
451 if (orderByComparator != null) {
452 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
453
454 if (orderByConditionFields.length > 0) {
455 query.append(WHERE_AND);
456 }
457
458 for (int i = 0; i < orderByConditionFields.length; i++) {
459 query.append(_ORDER_BY_ENTITY_ALIAS);
460 query.append(orderByConditionFields[i]);
461
462 if ((i + 1) < orderByConditionFields.length) {
463 if (orderByComparator.isAscending() ^ previous) {
464 query.append(WHERE_GREATER_THAN_HAS_NEXT);
465 }
466 else {
467 query.append(WHERE_LESSER_THAN_HAS_NEXT);
468 }
469 }
470 else {
471 if (orderByComparator.isAscending() ^ previous) {
472 query.append(WHERE_GREATER_THAN);
473 }
474 else {
475 query.append(WHERE_LESSER_THAN);
476 }
477 }
478 }
479
480 query.append(ORDER_BY_CLAUSE);
481
482 String[] orderByFields = orderByComparator.getOrderByFields();
483
484 for (int i = 0; i < orderByFields.length; i++) {
485 query.append(_ORDER_BY_ENTITY_ALIAS);
486 query.append(orderByFields[i]);
487
488 if ((i + 1) < orderByFields.length) {
489 if (orderByComparator.isAscending() ^ previous) {
490 query.append(ORDER_BY_ASC_HAS_NEXT);
491 }
492 else {
493 query.append(ORDER_BY_DESC_HAS_NEXT);
494 }
495 }
496 else {
497 if (orderByComparator.isAscending() ^ previous) {
498 query.append(ORDER_BY_ASC);
499 }
500 else {
501 query.append(ORDER_BY_DESC);
502 }
503 }
504 }
505 }
506 else {
507 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
508 }
509
510 String sql = query.toString();
511
512 Query q = session.createQuery(sql);
513
514 q.setFirstResult(0);
515 q.setMaxResults(2);
516
517 QueryPos qPos = QueryPos.getInstance(q);
518
519 if (bindUuid) {
520 qPos.add(uuid);
521 }
522
523 if (orderByComparator != null) {
524 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
525
526 for (Object value : values) {
527 qPos.add(value);
528 }
529 }
530
531 List<UserNotificationEvent> list = q.list();
532
533 if (list.size() == 2) {
534 return list.get(1);
535 }
536 else {
537 return null;
538 }
539 }
540
541
547 @Override
548 public void removeByUuid(String uuid) throws SystemException {
549 for (UserNotificationEvent userNotificationEvent : findByUuid(uuid,
550 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
551 remove(userNotificationEvent);
552 }
553 }
554
555
562 @Override
563 public int countByUuid(String uuid) throws SystemException {
564 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
565
566 Object[] finderArgs = new Object[] { uuid };
567
568 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
569 this);
570
571 if (count == null) {
572 StringBundler query = new StringBundler(2);
573
574 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
575
576 boolean bindUuid = false;
577
578 if (uuid == null) {
579 query.append(_FINDER_COLUMN_UUID_UUID_1);
580 }
581 else if (uuid.equals(StringPool.BLANK)) {
582 query.append(_FINDER_COLUMN_UUID_UUID_3);
583 }
584 else {
585 bindUuid = true;
586
587 query.append(_FINDER_COLUMN_UUID_UUID_2);
588 }
589
590 String sql = query.toString();
591
592 Session session = null;
593
594 try {
595 session = openSession();
596
597 Query q = session.createQuery(sql);
598
599 QueryPos qPos = QueryPos.getInstance(q);
600
601 if (bindUuid) {
602 qPos.add(uuid);
603 }
604
605 count = (Long)q.uniqueResult();
606
607 FinderCacheUtil.putResult(finderPath, finderArgs, count);
608 }
609 catch (Exception e) {
610 FinderCacheUtil.removeResult(finderPath, finderArgs);
611
612 throw processException(e);
613 }
614 finally {
615 closeSession(session);
616 }
617 }
618
619 return count.intValue();
620 }
621
622 private static final String _FINDER_COLUMN_UUID_UUID_1 = "userNotificationEvent.uuid IS NULL";
623 private static final String _FINDER_COLUMN_UUID_UUID_2 = "userNotificationEvent.uuid = ?";
624 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = '')";
625 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
626 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
627 UserNotificationEventImpl.class,
628 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
629 new String[] {
630 String.class.getName(), Long.class.getName(),
631
632 Integer.class.getName(), Integer.class.getName(),
633 OrderByComparator.class.getName()
634 });
635 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
636 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
637 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
638 UserNotificationEventImpl.class,
639 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
640 new String[] { String.class.getName(), Long.class.getName() },
641 UserNotificationEventModelImpl.UUID_COLUMN_BITMASK |
642 UserNotificationEventModelImpl.COMPANYID_COLUMN_BITMASK |
643 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
644 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
645 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
646 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
647 new String[] { String.class.getName(), Long.class.getName() });
648
649
657 @Override
658 public List<UserNotificationEvent> findByUuid_C(String uuid, long companyId)
659 throws SystemException {
660 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
661 QueryUtil.ALL_POS, null);
662 }
663
664
678 @Override
679 public List<UserNotificationEvent> findByUuid_C(String uuid,
680 long companyId, int start, int end) throws SystemException {
681 return findByUuid_C(uuid, companyId, start, end, null);
682 }
683
684
699 @Override
700 public List<UserNotificationEvent> findByUuid_C(String uuid,
701 long companyId, int start, int end, OrderByComparator orderByComparator)
702 throws SystemException {
703 boolean pagination = true;
704 FinderPath finderPath = null;
705 Object[] finderArgs = null;
706
707 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
708 (orderByComparator == null)) {
709 pagination = false;
710 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
711 finderArgs = new Object[] { uuid, companyId };
712 }
713 else {
714 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
715 finderArgs = new Object[] {
716 uuid, companyId,
717
718 start, end, orderByComparator
719 };
720 }
721
722 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
723 finderArgs, this);
724
725 if ((list != null) && !list.isEmpty()) {
726 for (UserNotificationEvent userNotificationEvent : list) {
727 if (!Validator.equals(uuid, userNotificationEvent.getUuid()) ||
728 (companyId != userNotificationEvent.getCompanyId())) {
729 list = null;
730
731 break;
732 }
733 }
734 }
735
736 if (list == null) {
737 StringBundler query = null;
738
739 if (orderByComparator != null) {
740 query = new StringBundler(4 +
741 (orderByComparator.getOrderByFields().length * 3));
742 }
743 else {
744 query = new StringBundler(4);
745 }
746
747 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
748
749 boolean bindUuid = false;
750
751 if (uuid == null) {
752 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
753 }
754 else if (uuid.equals(StringPool.BLANK)) {
755 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
756 }
757 else {
758 bindUuid = true;
759
760 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
761 }
762
763 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
764
765 if (orderByComparator != null) {
766 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
767 orderByComparator);
768 }
769 else
770 if (pagination) {
771 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
772 }
773
774 String sql = query.toString();
775
776 Session session = null;
777
778 try {
779 session = openSession();
780
781 Query q = session.createQuery(sql);
782
783 QueryPos qPos = QueryPos.getInstance(q);
784
785 if (bindUuid) {
786 qPos.add(uuid);
787 }
788
789 qPos.add(companyId);
790
791 if (!pagination) {
792 list = (List<UserNotificationEvent>)QueryUtil.list(q,
793 getDialect(), start, end, false);
794
795 Collections.sort(list);
796
797 list = new UnmodifiableList<UserNotificationEvent>(list);
798 }
799 else {
800 list = (List<UserNotificationEvent>)QueryUtil.list(q,
801 getDialect(), start, end);
802 }
803
804 cacheResult(list);
805
806 FinderCacheUtil.putResult(finderPath, finderArgs, list);
807 }
808 catch (Exception e) {
809 FinderCacheUtil.removeResult(finderPath, finderArgs);
810
811 throw processException(e);
812 }
813 finally {
814 closeSession(session);
815 }
816 }
817
818 return list;
819 }
820
821
831 @Override
832 public UserNotificationEvent findByUuid_C_First(String uuid,
833 long companyId, OrderByComparator orderByComparator)
834 throws NoSuchUserNotificationEventException, SystemException {
835 UserNotificationEvent userNotificationEvent = fetchByUuid_C_First(uuid,
836 companyId, orderByComparator);
837
838 if (userNotificationEvent != null) {
839 return userNotificationEvent;
840 }
841
842 StringBundler msg = new StringBundler(6);
843
844 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
845
846 msg.append("uuid=");
847 msg.append(uuid);
848
849 msg.append(", companyId=");
850 msg.append(companyId);
851
852 msg.append(StringPool.CLOSE_CURLY_BRACE);
853
854 throw new NoSuchUserNotificationEventException(msg.toString());
855 }
856
857
866 @Override
867 public UserNotificationEvent fetchByUuid_C_First(String uuid,
868 long companyId, OrderByComparator orderByComparator)
869 throws SystemException {
870 List<UserNotificationEvent> list = findByUuid_C(uuid, companyId, 0, 1,
871 orderByComparator);
872
873 if (!list.isEmpty()) {
874 return list.get(0);
875 }
876
877 return null;
878 }
879
880
890 @Override
891 public UserNotificationEvent findByUuid_C_Last(String uuid, long companyId,
892 OrderByComparator orderByComparator)
893 throws NoSuchUserNotificationEventException, SystemException {
894 UserNotificationEvent userNotificationEvent = fetchByUuid_C_Last(uuid,
895 companyId, orderByComparator);
896
897 if (userNotificationEvent != null) {
898 return userNotificationEvent;
899 }
900
901 StringBundler msg = new StringBundler(6);
902
903 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
904
905 msg.append("uuid=");
906 msg.append(uuid);
907
908 msg.append(", companyId=");
909 msg.append(companyId);
910
911 msg.append(StringPool.CLOSE_CURLY_BRACE);
912
913 throw new NoSuchUserNotificationEventException(msg.toString());
914 }
915
916
925 @Override
926 public UserNotificationEvent fetchByUuid_C_Last(String uuid,
927 long companyId, OrderByComparator orderByComparator)
928 throws SystemException {
929 int count = countByUuid_C(uuid, companyId);
930
931 if (count == 0) {
932 return null;
933 }
934
935 List<UserNotificationEvent> list = findByUuid_C(uuid, companyId,
936 count - 1, count, orderByComparator);
937
938 if (!list.isEmpty()) {
939 return list.get(0);
940 }
941
942 return null;
943 }
944
945
956 @Override
957 public UserNotificationEvent[] findByUuid_C_PrevAndNext(
958 long userNotificationEventId, String uuid, long companyId,
959 OrderByComparator orderByComparator)
960 throws NoSuchUserNotificationEventException, SystemException {
961 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
962
963 Session session = null;
964
965 try {
966 session = openSession();
967
968 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
969
970 array[0] = getByUuid_C_PrevAndNext(session, userNotificationEvent,
971 uuid, companyId, orderByComparator, true);
972
973 array[1] = userNotificationEvent;
974
975 array[2] = getByUuid_C_PrevAndNext(session, userNotificationEvent,
976 uuid, companyId, orderByComparator, false);
977
978 return array;
979 }
980 catch (Exception e) {
981 throw processException(e);
982 }
983 finally {
984 closeSession(session);
985 }
986 }
987
988 protected UserNotificationEvent getByUuid_C_PrevAndNext(Session session,
989 UserNotificationEvent userNotificationEvent, String uuid,
990 long companyId, OrderByComparator orderByComparator, boolean previous) {
991 StringBundler query = null;
992
993 if (orderByComparator != null) {
994 query = new StringBundler(6 +
995 (orderByComparator.getOrderByFields().length * 6));
996 }
997 else {
998 query = new StringBundler(3);
999 }
1000
1001 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1002
1003 boolean bindUuid = false;
1004
1005 if (uuid == null) {
1006 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1007 }
1008 else if (uuid.equals(StringPool.BLANK)) {
1009 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1010 }
1011 else {
1012 bindUuid = true;
1013
1014 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1015 }
1016
1017 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1018
1019 if (orderByComparator != null) {
1020 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1021
1022 if (orderByConditionFields.length > 0) {
1023 query.append(WHERE_AND);
1024 }
1025
1026 for (int i = 0; i < orderByConditionFields.length; i++) {
1027 query.append(_ORDER_BY_ENTITY_ALIAS);
1028 query.append(orderByConditionFields[i]);
1029
1030 if ((i + 1) < orderByConditionFields.length) {
1031 if (orderByComparator.isAscending() ^ previous) {
1032 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1033 }
1034 else {
1035 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1036 }
1037 }
1038 else {
1039 if (orderByComparator.isAscending() ^ previous) {
1040 query.append(WHERE_GREATER_THAN);
1041 }
1042 else {
1043 query.append(WHERE_LESSER_THAN);
1044 }
1045 }
1046 }
1047
1048 query.append(ORDER_BY_CLAUSE);
1049
1050 String[] orderByFields = orderByComparator.getOrderByFields();
1051
1052 for (int i = 0; i < orderByFields.length; i++) {
1053 query.append(_ORDER_BY_ENTITY_ALIAS);
1054 query.append(orderByFields[i]);
1055
1056 if ((i + 1) < orderByFields.length) {
1057 if (orderByComparator.isAscending() ^ previous) {
1058 query.append(ORDER_BY_ASC_HAS_NEXT);
1059 }
1060 else {
1061 query.append(ORDER_BY_DESC_HAS_NEXT);
1062 }
1063 }
1064 else {
1065 if (orderByComparator.isAscending() ^ previous) {
1066 query.append(ORDER_BY_ASC);
1067 }
1068 else {
1069 query.append(ORDER_BY_DESC);
1070 }
1071 }
1072 }
1073 }
1074 else {
1075 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1076 }
1077
1078 String sql = query.toString();
1079
1080 Query q = session.createQuery(sql);
1081
1082 q.setFirstResult(0);
1083 q.setMaxResults(2);
1084
1085 QueryPos qPos = QueryPos.getInstance(q);
1086
1087 if (bindUuid) {
1088 qPos.add(uuid);
1089 }
1090
1091 qPos.add(companyId);
1092
1093 if (orderByComparator != null) {
1094 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1095
1096 for (Object value : values) {
1097 qPos.add(value);
1098 }
1099 }
1100
1101 List<UserNotificationEvent> list = q.list();
1102
1103 if (list.size() == 2) {
1104 return list.get(1);
1105 }
1106 else {
1107 return null;
1108 }
1109 }
1110
1111
1118 @Override
1119 public void removeByUuid_C(String uuid, long companyId)
1120 throws SystemException {
1121 for (UserNotificationEvent userNotificationEvent : findByUuid_C(uuid,
1122 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1123 remove(userNotificationEvent);
1124 }
1125 }
1126
1127
1135 @Override
1136 public int countByUuid_C(String uuid, long companyId)
1137 throws SystemException {
1138 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1139
1140 Object[] finderArgs = new Object[] { uuid, companyId };
1141
1142 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1143 this);
1144
1145 if (count == null) {
1146 StringBundler query = new StringBundler(3);
1147
1148 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1149
1150 boolean bindUuid = false;
1151
1152 if (uuid == null) {
1153 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1154 }
1155 else if (uuid.equals(StringPool.BLANK)) {
1156 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1157 }
1158 else {
1159 bindUuid = true;
1160
1161 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1162 }
1163
1164 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1165
1166 String sql = query.toString();
1167
1168 Session session = null;
1169
1170 try {
1171 session = openSession();
1172
1173 Query q = session.createQuery(sql);
1174
1175 QueryPos qPos = QueryPos.getInstance(q);
1176
1177 if (bindUuid) {
1178 qPos.add(uuid);
1179 }
1180
1181 qPos.add(companyId);
1182
1183 count = (Long)q.uniqueResult();
1184
1185 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1186 }
1187 catch (Exception e) {
1188 FinderCacheUtil.removeResult(finderPath, finderArgs);
1189
1190 throw processException(e);
1191 }
1192 finally {
1193 closeSession(session);
1194 }
1195 }
1196
1197 return count.intValue();
1198 }
1199
1200 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "userNotificationEvent.uuid IS NULL AND ";
1201 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "userNotificationEvent.uuid = ? AND ";
1202 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = '') AND ";
1203 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "userNotificationEvent.companyId = ?";
1204 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1205 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1206 UserNotificationEventImpl.class,
1207 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
1208 new String[] {
1209 Long.class.getName(),
1210
1211 Integer.class.getName(), Integer.class.getName(),
1212 OrderByComparator.class.getName()
1213 });
1214 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
1215 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1216 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1217 UserNotificationEventImpl.class,
1218 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
1219 new String[] { Long.class.getName() },
1220 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
1221 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
1222 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1223 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
1224 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
1225 new String[] { Long.class.getName() });
1226
1227
1234 @Override
1235 public List<UserNotificationEvent> findByUserId(long userId)
1236 throws SystemException {
1237 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1238 }
1239
1240
1253 @Override
1254 public List<UserNotificationEvent> findByUserId(long userId, int start,
1255 int end) throws SystemException {
1256 return findByUserId(userId, start, end, null);
1257 }
1258
1259
1273 @Override
1274 public List<UserNotificationEvent> findByUserId(long userId, int start,
1275 int end, OrderByComparator orderByComparator) throws SystemException {
1276 boolean pagination = true;
1277 FinderPath finderPath = null;
1278 Object[] finderArgs = null;
1279
1280 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1281 (orderByComparator == null)) {
1282 pagination = false;
1283 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1284 finderArgs = new Object[] { userId };
1285 }
1286 else {
1287 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1288 finderArgs = new Object[] { userId, start, end, orderByComparator };
1289 }
1290
1291 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
1292 finderArgs, this);
1293
1294 if ((list != null) && !list.isEmpty()) {
1295 for (UserNotificationEvent userNotificationEvent : list) {
1296 if ((userId != userNotificationEvent.getUserId())) {
1297 list = null;
1298
1299 break;
1300 }
1301 }
1302 }
1303
1304 if (list == null) {
1305 StringBundler query = null;
1306
1307 if (orderByComparator != null) {
1308 query = new StringBundler(3 +
1309 (orderByComparator.getOrderByFields().length * 3));
1310 }
1311 else {
1312 query = new StringBundler(3);
1313 }
1314
1315 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1316
1317 query.append(_FINDER_COLUMN_USERID_USERID_2);
1318
1319 if (orderByComparator != null) {
1320 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1321 orderByComparator);
1322 }
1323 else
1324 if (pagination) {
1325 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1326 }
1327
1328 String sql = query.toString();
1329
1330 Session session = null;
1331
1332 try {
1333 session = openSession();
1334
1335 Query q = session.createQuery(sql);
1336
1337 QueryPos qPos = QueryPos.getInstance(q);
1338
1339 qPos.add(userId);
1340
1341 if (!pagination) {
1342 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1343 getDialect(), start, end, false);
1344
1345 Collections.sort(list);
1346
1347 list = new UnmodifiableList<UserNotificationEvent>(list);
1348 }
1349 else {
1350 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1351 getDialect(), start, end);
1352 }
1353
1354 cacheResult(list);
1355
1356 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1357 }
1358 catch (Exception e) {
1359 FinderCacheUtil.removeResult(finderPath, finderArgs);
1360
1361 throw processException(e);
1362 }
1363 finally {
1364 closeSession(session);
1365 }
1366 }
1367
1368 return list;
1369 }
1370
1371
1380 @Override
1381 public UserNotificationEvent findByUserId_First(long userId,
1382 OrderByComparator orderByComparator)
1383 throws NoSuchUserNotificationEventException, SystemException {
1384 UserNotificationEvent userNotificationEvent = fetchByUserId_First(userId,
1385 orderByComparator);
1386
1387 if (userNotificationEvent != null) {
1388 return userNotificationEvent;
1389 }
1390
1391 StringBundler msg = new StringBundler(4);
1392
1393 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1394
1395 msg.append("userId=");
1396 msg.append(userId);
1397
1398 msg.append(StringPool.CLOSE_CURLY_BRACE);
1399
1400 throw new NoSuchUserNotificationEventException(msg.toString());
1401 }
1402
1403
1411 @Override
1412 public UserNotificationEvent fetchByUserId_First(long userId,
1413 OrderByComparator orderByComparator) throws SystemException {
1414 List<UserNotificationEvent> list = findByUserId(userId, 0, 1,
1415 orderByComparator);
1416
1417 if (!list.isEmpty()) {
1418 return list.get(0);
1419 }
1420
1421 return null;
1422 }
1423
1424
1433 @Override
1434 public UserNotificationEvent findByUserId_Last(long userId,
1435 OrderByComparator orderByComparator)
1436 throws NoSuchUserNotificationEventException, SystemException {
1437 UserNotificationEvent userNotificationEvent = fetchByUserId_Last(userId,
1438 orderByComparator);
1439
1440 if (userNotificationEvent != null) {
1441 return userNotificationEvent;
1442 }
1443
1444 StringBundler msg = new StringBundler(4);
1445
1446 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1447
1448 msg.append("userId=");
1449 msg.append(userId);
1450
1451 msg.append(StringPool.CLOSE_CURLY_BRACE);
1452
1453 throw new NoSuchUserNotificationEventException(msg.toString());
1454 }
1455
1456
1464 @Override
1465 public UserNotificationEvent fetchByUserId_Last(long userId,
1466 OrderByComparator orderByComparator) throws SystemException {
1467 int count = countByUserId(userId);
1468
1469 if (count == 0) {
1470 return null;
1471 }
1472
1473 List<UserNotificationEvent> list = findByUserId(userId, count - 1,
1474 count, orderByComparator);
1475
1476 if (!list.isEmpty()) {
1477 return list.get(0);
1478 }
1479
1480 return null;
1481 }
1482
1483
1493 @Override
1494 public UserNotificationEvent[] findByUserId_PrevAndNext(
1495 long userNotificationEventId, long userId,
1496 OrderByComparator orderByComparator)
1497 throws NoSuchUserNotificationEventException, SystemException {
1498 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
1499
1500 Session session = null;
1501
1502 try {
1503 session = openSession();
1504
1505 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1506
1507 array[0] = getByUserId_PrevAndNext(session, userNotificationEvent,
1508 userId, orderByComparator, true);
1509
1510 array[1] = userNotificationEvent;
1511
1512 array[2] = getByUserId_PrevAndNext(session, userNotificationEvent,
1513 userId, orderByComparator, false);
1514
1515 return array;
1516 }
1517 catch (Exception e) {
1518 throw processException(e);
1519 }
1520 finally {
1521 closeSession(session);
1522 }
1523 }
1524
1525 protected UserNotificationEvent getByUserId_PrevAndNext(Session session,
1526 UserNotificationEvent userNotificationEvent, long userId,
1527 OrderByComparator orderByComparator, boolean previous) {
1528 StringBundler query = null;
1529
1530 if (orderByComparator != null) {
1531 query = new StringBundler(6 +
1532 (orderByComparator.getOrderByFields().length * 6));
1533 }
1534 else {
1535 query = new StringBundler(3);
1536 }
1537
1538 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1539
1540 query.append(_FINDER_COLUMN_USERID_USERID_2);
1541
1542 if (orderByComparator != null) {
1543 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1544
1545 if (orderByConditionFields.length > 0) {
1546 query.append(WHERE_AND);
1547 }
1548
1549 for (int i = 0; i < orderByConditionFields.length; i++) {
1550 query.append(_ORDER_BY_ENTITY_ALIAS);
1551 query.append(orderByConditionFields[i]);
1552
1553 if ((i + 1) < orderByConditionFields.length) {
1554 if (orderByComparator.isAscending() ^ previous) {
1555 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1556 }
1557 else {
1558 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1559 }
1560 }
1561 else {
1562 if (orderByComparator.isAscending() ^ previous) {
1563 query.append(WHERE_GREATER_THAN);
1564 }
1565 else {
1566 query.append(WHERE_LESSER_THAN);
1567 }
1568 }
1569 }
1570
1571 query.append(ORDER_BY_CLAUSE);
1572
1573 String[] orderByFields = orderByComparator.getOrderByFields();
1574
1575 for (int i = 0; i < orderByFields.length; i++) {
1576 query.append(_ORDER_BY_ENTITY_ALIAS);
1577 query.append(orderByFields[i]);
1578
1579 if ((i + 1) < orderByFields.length) {
1580 if (orderByComparator.isAscending() ^ previous) {
1581 query.append(ORDER_BY_ASC_HAS_NEXT);
1582 }
1583 else {
1584 query.append(ORDER_BY_DESC_HAS_NEXT);
1585 }
1586 }
1587 else {
1588 if (orderByComparator.isAscending() ^ previous) {
1589 query.append(ORDER_BY_ASC);
1590 }
1591 else {
1592 query.append(ORDER_BY_DESC);
1593 }
1594 }
1595 }
1596 }
1597 else {
1598 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1599 }
1600
1601 String sql = query.toString();
1602
1603 Query q = session.createQuery(sql);
1604
1605 q.setFirstResult(0);
1606 q.setMaxResults(2);
1607
1608 QueryPos qPos = QueryPos.getInstance(q);
1609
1610 qPos.add(userId);
1611
1612 if (orderByComparator != null) {
1613 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1614
1615 for (Object value : values) {
1616 qPos.add(value);
1617 }
1618 }
1619
1620 List<UserNotificationEvent> list = q.list();
1621
1622 if (list.size() == 2) {
1623 return list.get(1);
1624 }
1625 else {
1626 return null;
1627 }
1628 }
1629
1630
1636 @Override
1637 public void removeByUserId(long userId) throws SystemException {
1638 for (UserNotificationEvent userNotificationEvent : findByUserId(
1639 userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1640 remove(userNotificationEvent);
1641 }
1642 }
1643
1644
1651 @Override
1652 public int countByUserId(long userId) throws SystemException {
1653 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
1654
1655 Object[] finderArgs = new Object[] { userId };
1656
1657 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1658 this);
1659
1660 if (count == null) {
1661 StringBundler query = new StringBundler(2);
1662
1663 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1664
1665 query.append(_FINDER_COLUMN_USERID_USERID_2);
1666
1667 String sql = query.toString();
1668
1669 Session session = null;
1670
1671 try {
1672 session = openSession();
1673
1674 Query q = session.createQuery(sql);
1675
1676 QueryPos qPos = QueryPos.getInstance(q);
1677
1678 qPos.add(userId);
1679
1680 count = (Long)q.uniqueResult();
1681
1682 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1683 }
1684 catch (Exception e) {
1685 FinderCacheUtil.removeResult(finderPath, finderArgs);
1686
1687 throw processException(e);
1688 }
1689 finally {
1690 closeSession(session);
1691 }
1692 }
1693
1694 return count.intValue();
1695 }
1696
1697 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userNotificationEvent.userId = ?";
1698 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1699 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1700 UserNotificationEventImpl.class,
1701 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_D",
1702 new String[] {
1703 Long.class.getName(), Boolean.class.getName(),
1704
1705 Integer.class.getName(), Integer.class.getName(),
1706 OrderByComparator.class.getName()
1707 });
1708 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1709 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
1710 UserNotificationEventImpl.class,
1711 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_D",
1712 new String[] { Long.class.getName(), Boolean.class.getName() },
1713 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
1714 UserNotificationEventModelImpl.DELIVERED_COLUMN_BITMASK |
1715 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
1716 public static final FinderPath FINDER_PATH_COUNT_BY_U_D = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
1717 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
1718 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_D",
1719 new String[] { Long.class.getName(), Boolean.class.getName() });
1720
1721
1729 @Override
1730 public List<UserNotificationEvent> findByU_D(long userId, boolean delivered)
1731 throws SystemException {
1732 return findByU_D(userId, delivered, QueryUtil.ALL_POS,
1733 QueryUtil.ALL_POS, null);
1734 }
1735
1736
1750 @Override
1751 public List<UserNotificationEvent> findByU_D(long userId,
1752 boolean delivered, int start, int end) throws SystemException {
1753 return findByU_D(userId, delivered, start, end, null);
1754 }
1755
1756
1771 @Override
1772 public List<UserNotificationEvent> findByU_D(long userId,
1773 boolean delivered, int start, int end,
1774 OrderByComparator orderByComparator) throws SystemException {
1775 boolean pagination = true;
1776 FinderPath finderPath = null;
1777 Object[] finderArgs = null;
1778
1779 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1780 (orderByComparator == null)) {
1781 pagination = false;
1782 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D;
1783 finderArgs = new Object[] { userId, delivered };
1784 }
1785 else {
1786 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_D;
1787 finderArgs = new Object[] {
1788 userId, delivered,
1789
1790 start, end, orderByComparator
1791 };
1792 }
1793
1794 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
1795 finderArgs, this);
1796
1797 if ((list != null) && !list.isEmpty()) {
1798 for (UserNotificationEvent userNotificationEvent : list) {
1799 if ((userId != userNotificationEvent.getUserId()) ||
1800 (delivered != userNotificationEvent.getDelivered())) {
1801 list = null;
1802
1803 break;
1804 }
1805 }
1806 }
1807
1808 if (list == null) {
1809 StringBundler query = null;
1810
1811 if (orderByComparator != null) {
1812 query = new StringBundler(4 +
1813 (orderByComparator.getOrderByFields().length * 3));
1814 }
1815 else {
1816 query = new StringBundler(4);
1817 }
1818
1819 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1820
1821 query.append(_FINDER_COLUMN_U_D_USERID_2);
1822
1823 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
1824
1825 if (orderByComparator != null) {
1826 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1827 orderByComparator);
1828 }
1829 else
1830 if (pagination) {
1831 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1832 }
1833
1834 String sql = query.toString();
1835
1836 Session session = null;
1837
1838 try {
1839 session = openSession();
1840
1841 Query q = session.createQuery(sql);
1842
1843 QueryPos qPos = QueryPos.getInstance(q);
1844
1845 qPos.add(userId);
1846
1847 qPos.add(delivered);
1848
1849 if (!pagination) {
1850 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1851 getDialect(), start, end, false);
1852
1853 Collections.sort(list);
1854
1855 list = new UnmodifiableList<UserNotificationEvent>(list);
1856 }
1857 else {
1858 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1859 getDialect(), start, end);
1860 }
1861
1862 cacheResult(list);
1863
1864 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1865 }
1866 catch (Exception e) {
1867 FinderCacheUtil.removeResult(finderPath, finderArgs);
1868
1869 throw processException(e);
1870 }
1871 finally {
1872 closeSession(session);
1873 }
1874 }
1875
1876 return list;
1877 }
1878
1879
1889 @Override
1890 public UserNotificationEvent findByU_D_First(long userId,
1891 boolean delivered, OrderByComparator orderByComparator)
1892 throws NoSuchUserNotificationEventException, SystemException {
1893 UserNotificationEvent userNotificationEvent = fetchByU_D_First(userId,
1894 delivered, orderByComparator);
1895
1896 if (userNotificationEvent != null) {
1897 return userNotificationEvent;
1898 }
1899
1900 StringBundler msg = new StringBundler(6);
1901
1902 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1903
1904 msg.append("userId=");
1905 msg.append(userId);
1906
1907 msg.append(", delivered=");
1908 msg.append(delivered);
1909
1910 msg.append(StringPool.CLOSE_CURLY_BRACE);
1911
1912 throw new NoSuchUserNotificationEventException(msg.toString());
1913 }
1914
1915
1924 @Override
1925 public UserNotificationEvent fetchByU_D_First(long userId,
1926 boolean delivered, OrderByComparator orderByComparator)
1927 throws SystemException {
1928 List<UserNotificationEvent> list = findByU_D(userId, delivered, 0, 1,
1929 orderByComparator);
1930
1931 if (!list.isEmpty()) {
1932 return list.get(0);
1933 }
1934
1935 return null;
1936 }
1937
1938
1948 @Override
1949 public UserNotificationEvent findByU_D_Last(long userId, boolean delivered,
1950 OrderByComparator orderByComparator)
1951 throws NoSuchUserNotificationEventException, SystemException {
1952 UserNotificationEvent userNotificationEvent = fetchByU_D_Last(userId,
1953 delivered, orderByComparator);
1954
1955 if (userNotificationEvent != null) {
1956 return userNotificationEvent;
1957 }
1958
1959 StringBundler msg = new StringBundler(6);
1960
1961 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1962
1963 msg.append("userId=");
1964 msg.append(userId);
1965
1966 msg.append(", delivered=");
1967 msg.append(delivered);
1968
1969 msg.append(StringPool.CLOSE_CURLY_BRACE);
1970
1971 throw new NoSuchUserNotificationEventException(msg.toString());
1972 }
1973
1974
1983 @Override
1984 public UserNotificationEvent fetchByU_D_Last(long userId,
1985 boolean delivered, OrderByComparator orderByComparator)
1986 throws SystemException {
1987 int count = countByU_D(userId, delivered);
1988
1989 if (count == 0) {
1990 return null;
1991 }
1992
1993 List<UserNotificationEvent> list = findByU_D(userId, delivered,
1994 count - 1, count, orderByComparator);
1995
1996 if (!list.isEmpty()) {
1997 return list.get(0);
1998 }
1999
2000 return null;
2001 }
2002
2003
2014 @Override
2015 public UserNotificationEvent[] findByU_D_PrevAndNext(
2016 long userNotificationEventId, long userId, boolean delivered,
2017 OrderByComparator orderByComparator)
2018 throws NoSuchUserNotificationEventException, SystemException {
2019 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
2020
2021 Session session = null;
2022
2023 try {
2024 session = openSession();
2025
2026 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
2027
2028 array[0] = getByU_D_PrevAndNext(session, userNotificationEvent,
2029 userId, delivered, orderByComparator, true);
2030
2031 array[1] = userNotificationEvent;
2032
2033 array[2] = getByU_D_PrevAndNext(session, userNotificationEvent,
2034 userId, delivered, orderByComparator, false);
2035
2036 return array;
2037 }
2038 catch (Exception e) {
2039 throw processException(e);
2040 }
2041 finally {
2042 closeSession(session);
2043 }
2044 }
2045
2046 protected UserNotificationEvent getByU_D_PrevAndNext(Session session,
2047 UserNotificationEvent userNotificationEvent, long userId,
2048 boolean delivered, OrderByComparator orderByComparator, boolean previous) {
2049 StringBundler query = null;
2050
2051 if (orderByComparator != null) {
2052 query = new StringBundler(6 +
2053 (orderByComparator.getOrderByFields().length * 6));
2054 }
2055 else {
2056 query = new StringBundler(3);
2057 }
2058
2059 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2060
2061 query.append(_FINDER_COLUMN_U_D_USERID_2);
2062
2063 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
2064
2065 if (orderByComparator != null) {
2066 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2067
2068 if (orderByConditionFields.length > 0) {
2069 query.append(WHERE_AND);
2070 }
2071
2072 for (int i = 0; i < orderByConditionFields.length; i++) {
2073 query.append(_ORDER_BY_ENTITY_ALIAS);
2074 query.append(orderByConditionFields[i]);
2075
2076 if ((i + 1) < orderByConditionFields.length) {
2077 if (orderByComparator.isAscending() ^ previous) {
2078 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2079 }
2080 else {
2081 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2082 }
2083 }
2084 else {
2085 if (orderByComparator.isAscending() ^ previous) {
2086 query.append(WHERE_GREATER_THAN);
2087 }
2088 else {
2089 query.append(WHERE_LESSER_THAN);
2090 }
2091 }
2092 }
2093
2094 query.append(ORDER_BY_CLAUSE);
2095
2096 String[] orderByFields = orderByComparator.getOrderByFields();
2097
2098 for (int i = 0; i < orderByFields.length; i++) {
2099 query.append(_ORDER_BY_ENTITY_ALIAS);
2100 query.append(orderByFields[i]);
2101
2102 if ((i + 1) < orderByFields.length) {
2103 if (orderByComparator.isAscending() ^ previous) {
2104 query.append(ORDER_BY_ASC_HAS_NEXT);
2105 }
2106 else {
2107 query.append(ORDER_BY_DESC_HAS_NEXT);
2108 }
2109 }
2110 else {
2111 if (orderByComparator.isAscending() ^ previous) {
2112 query.append(ORDER_BY_ASC);
2113 }
2114 else {
2115 query.append(ORDER_BY_DESC);
2116 }
2117 }
2118 }
2119 }
2120 else {
2121 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2122 }
2123
2124 String sql = query.toString();
2125
2126 Query q = session.createQuery(sql);
2127
2128 q.setFirstResult(0);
2129 q.setMaxResults(2);
2130
2131 QueryPos qPos = QueryPos.getInstance(q);
2132
2133 qPos.add(userId);
2134
2135 qPos.add(delivered);
2136
2137 if (orderByComparator != null) {
2138 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
2139
2140 for (Object value : values) {
2141 qPos.add(value);
2142 }
2143 }
2144
2145 List<UserNotificationEvent> list = q.list();
2146
2147 if (list.size() == 2) {
2148 return list.get(1);
2149 }
2150 else {
2151 return null;
2152 }
2153 }
2154
2155
2162 @Override
2163 public void removeByU_D(long userId, boolean delivered)
2164 throws SystemException {
2165 for (UserNotificationEvent userNotificationEvent : findByU_D(userId,
2166 delivered, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2167 remove(userNotificationEvent);
2168 }
2169 }
2170
2171
2179 @Override
2180 public int countByU_D(long userId, boolean delivered)
2181 throws SystemException {
2182 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_D;
2183
2184 Object[] finderArgs = new Object[] { userId, delivered };
2185
2186 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2187 this);
2188
2189 if (count == null) {
2190 StringBundler query = new StringBundler(3);
2191
2192 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2193
2194 query.append(_FINDER_COLUMN_U_D_USERID_2);
2195
2196 query.append(_FINDER_COLUMN_U_D_DELIVERED_2);
2197
2198 String sql = query.toString();
2199
2200 Session session = null;
2201
2202 try {
2203 session = openSession();
2204
2205 Query q = session.createQuery(sql);
2206
2207 QueryPos qPos = QueryPos.getInstance(q);
2208
2209 qPos.add(userId);
2210
2211 qPos.add(delivered);
2212
2213 count = (Long)q.uniqueResult();
2214
2215 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2216 }
2217 catch (Exception e) {
2218 FinderCacheUtil.removeResult(finderPath, finderArgs);
2219
2220 throw processException(e);
2221 }
2222 finally {
2223 closeSession(session);
2224 }
2225 }
2226
2227 return count.intValue();
2228 }
2229
2230 private static final String _FINDER_COLUMN_U_D_USERID_2 = "userNotificationEvent.userId = ? AND ";
2231 private static final String _FINDER_COLUMN_U_D_DELIVERED_2 = "userNotificationEvent.delivered = ?";
2232 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2233 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2234 UserNotificationEventImpl.class,
2235 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_A",
2236 new String[] {
2237 Long.class.getName(), Boolean.class.getName(),
2238
2239 Integer.class.getName(), Integer.class.getName(),
2240 OrderByComparator.class.getName()
2241 });
2242 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2243 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
2244 UserNotificationEventImpl.class,
2245 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_A",
2246 new String[] { Long.class.getName(), Boolean.class.getName() },
2247 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
2248 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK |
2249 UserNotificationEventModelImpl.TIMESTAMP_COLUMN_BITMASK);
2250 public static final FinderPath FINDER_PATH_COUNT_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2251 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
2252 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_A",
2253 new String[] { Long.class.getName(), Boolean.class.getName() });
2254
2255
2263 @Override
2264 public List<UserNotificationEvent> findByU_A(long userId, boolean archived)
2265 throws SystemException {
2266 return findByU_A(userId, archived, QueryUtil.ALL_POS,
2267 QueryUtil.ALL_POS, null);
2268 }
2269
2270
2284 @Override
2285 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
2286 int start, int end) throws SystemException {
2287 return findByU_A(userId, archived, start, end, null);
2288 }
2289
2290
2305 @Override
2306 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
2307 int start, int end, OrderByComparator orderByComparator)
2308 throws SystemException {
2309 boolean pagination = true;
2310 FinderPath finderPath = null;
2311 Object[] finderArgs = null;
2312
2313 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2314 (orderByComparator == null)) {
2315 pagination = false;
2316 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A;
2317 finderArgs = new Object[] { userId, archived };
2318 }
2319 else {
2320 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A;
2321 finderArgs = new Object[] {
2322 userId, archived,
2323
2324 start, end, orderByComparator
2325 };
2326 }
2327
2328 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
2329 finderArgs, this);
2330
2331 if ((list != null) && !list.isEmpty()) {
2332 for (UserNotificationEvent userNotificationEvent : list) {
2333 if ((userId != userNotificationEvent.getUserId()) ||
2334 (archived != userNotificationEvent.getArchived())) {
2335 list = null;
2336
2337 break;
2338 }
2339 }
2340 }
2341
2342 if (list == null) {
2343 StringBundler query = null;
2344
2345 if (orderByComparator != null) {
2346 query = new StringBundler(4 +
2347 (orderByComparator.getOrderByFields().length * 3));
2348 }
2349 else {
2350 query = new StringBundler(4);
2351 }
2352
2353 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2354
2355 query.append(_FINDER_COLUMN_U_A_USERID_2);
2356
2357 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
2358
2359 if (orderByComparator != null) {
2360 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2361 orderByComparator);
2362 }
2363 else
2364 if (pagination) {
2365 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2366 }
2367
2368 String sql = query.toString();
2369
2370 Session session = null;
2371
2372 try {
2373 session = openSession();
2374
2375 Query q = session.createQuery(sql);
2376
2377 QueryPos qPos = QueryPos.getInstance(q);
2378
2379 qPos.add(userId);
2380
2381 qPos.add(archived);
2382
2383 if (!pagination) {
2384 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2385 getDialect(), start, end, false);
2386
2387 Collections.sort(list);
2388
2389 list = new UnmodifiableList<UserNotificationEvent>(list);
2390 }
2391 else {
2392 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2393 getDialect(), start, end);
2394 }
2395
2396 cacheResult(list);
2397
2398 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2399 }
2400 catch (Exception e) {
2401 FinderCacheUtil.removeResult(finderPath, finderArgs);
2402
2403 throw processException(e);
2404 }
2405 finally {
2406 closeSession(session);
2407 }
2408 }
2409
2410 return list;
2411 }
2412
2413
2423 @Override
2424 public UserNotificationEvent findByU_A_First(long userId, boolean archived,
2425 OrderByComparator orderByComparator)
2426 throws NoSuchUserNotificationEventException, SystemException {
2427 UserNotificationEvent userNotificationEvent = fetchByU_A_First(userId,
2428 archived, orderByComparator);
2429
2430 if (userNotificationEvent != null) {
2431 return userNotificationEvent;
2432 }
2433
2434 StringBundler msg = new StringBundler(6);
2435
2436 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2437
2438 msg.append("userId=");
2439 msg.append(userId);
2440
2441 msg.append(", archived=");
2442 msg.append(archived);
2443
2444 msg.append(StringPool.CLOSE_CURLY_BRACE);
2445
2446 throw new NoSuchUserNotificationEventException(msg.toString());
2447 }
2448
2449
2458 @Override
2459 public UserNotificationEvent fetchByU_A_First(long userId,
2460 boolean archived, OrderByComparator orderByComparator)
2461 throws SystemException {
2462 List<UserNotificationEvent> list = findByU_A(userId, archived, 0, 1,
2463 orderByComparator);
2464
2465 if (!list.isEmpty()) {
2466 return list.get(0);
2467 }
2468
2469 return null;
2470 }
2471
2472
2482 @Override
2483 public UserNotificationEvent findByU_A_Last(long userId, boolean archived,
2484 OrderByComparator orderByComparator)
2485 throws NoSuchUserNotificationEventException, SystemException {
2486 UserNotificationEvent userNotificationEvent = fetchByU_A_Last(userId,
2487 archived, orderByComparator);
2488
2489 if (userNotificationEvent != null) {
2490 return userNotificationEvent;
2491 }
2492
2493 StringBundler msg = new StringBundler(6);
2494
2495 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2496
2497 msg.append("userId=");
2498 msg.append(userId);
2499
2500 msg.append(", archived=");
2501 msg.append(archived);
2502
2503 msg.append(StringPool.CLOSE_CURLY_BRACE);
2504
2505 throw new NoSuchUserNotificationEventException(msg.toString());
2506 }
2507
2508
2517 @Override
2518 public UserNotificationEvent fetchByU_A_Last(long userId, boolean archived,
2519 OrderByComparator orderByComparator) throws SystemException {
2520 int count = countByU_A(userId, archived);
2521
2522 if (count == 0) {
2523 return null;
2524 }
2525
2526 List<UserNotificationEvent> list = findByU_A(userId, archived,
2527 count - 1, count, orderByComparator);
2528
2529 if (!list.isEmpty()) {
2530 return list.get(0);
2531 }
2532
2533 return null;
2534 }
2535
2536
2547 @Override
2548 public UserNotificationEvent[] findByU_A_PrevAndNext(
2549 long userNotificationEventId, long userId, boolean archived,
2550 OrderByComparator orderByComparator)
2551 throws NoSuchUserNotificationEventException, SystemException {
2552 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
2553
2554 Session session = null;
2555
2556 try {
2557 session = openSession();
2558
2559 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
2560
2561 array[0] = getByU_A_PrevAndNext(session, userNotificationEvent,
2562 userId, archived, orderByComparator, true);
2563
2564 array[1] = userNotificationEvent;
2565
2566 array[2] = getByU_A_PrevAndNext(session, userNotificationEvent,
2567 userId, archived, orderByComparator, false);
2568
2569 return array;
2570 }
2571 catch (Exception e) {
2572 throw processException(e);
2573 }
2574 finally {
2575 closeSession(session);
2576 }
2577 }
2578
2579 protected UserNotificationEvent getByU_A_PrevAndNext(Session session,
2580 UserNotificationEvent userNotificationEvent, long userId,
2581 boolean archived, OrderByComparator orderByComparator, boolean previous) {
2582 StringBundler query = null;
2583
2584 if (orderByComparator != null) {
2585 query = new StringBundler(6 +
2586 (orderByComparator.getOrderByFields().length * 6));
2587 }
2588 else {
2589 query = new StringBundler(3);
2590 }
2591
2592 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2593
2594 query.append(_FINDER_COLUMN_U_A_USERID_2);
2595
2596 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
2597
2598 if (orderByComparator != null) {
2599 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2600
2601 if (orderByConditionFields.length > 0) {
2602 query.append(WHERE_AND);
2603 }
2604
2605 for (int i = 0; i < orderByConditionFields.length; i++) {
2606 query.append(_ORDER_BY_ENTITY_ALIAS);
2607 query.append(orderByConditionFields[i]);
2608
2609 if ((i + 1) < orderByConditionFields.length) {
2610 if (orderByComparator.isAscending() ^ previous) {
2611 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2612 }
2613 else {
2614 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2615 }
2616 }
2617 else {
2618 if (orderByComparator.isAscending() ^ previous) {
2619 query.append(WHERE_GREATER_THAN);
2620 }
2621 else {
2622 query.append(WHERE_LESSER_THAN);
2623 }
2624 }
2625 }
2626
2627 query.append(ORDER_BY_CLAUSE);
2628
2629 String[] orderByFields = orderByComparator.getOrderByFields();
2630
2631 for (int i = 0; i < orderByFields.length; i++) {
2632 query.append(_ORDER_BY_ENTITY_ALIAS);
2633 query.append(orderByFields[i]);
2634
2635 if ((i + 1) < orderByFields.length) {
2636 if (orderByComparator.isAscending() ^ previous) {
2637 query.append(ORDER_BY_ASC_HAS_NEXT);
2638 }
2639 else {
2640 query.append(ORDER_BY_DESC_HAS_NEXT);
2641 }
2642 }
2643 else {
2644 if (orderByComparator.isAscending() ^ previous) {
2645 query.append(ORDER_BY_ASC);
2646 }
2647 else {
2648 query.append(ORDER_BY_DESC);
2649 }
2650 }
2651 }
2652 }
2653 else {
2654 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2655 }
2656
2657 String sql = query.toString();
2658
2659 Query q = session.createQuery(sql);
2660
2661 q.setFirstResult(0);
2662 q.setMaxResults(2);
2663
2664 QueryPos qPos = QueryPos.getInstance(q);
2665
2666 qPos.add(userId);
2667
2668 qPos.add(archived);
2669
2670 if (orderByComparator != null) {
2671 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
2672
2673 for (Object value : values) {
2674 qPos.add(value);
2675 }
2676 }
2677
2678 List<UserNotificationEvent> list = q.list();
2679
2680 if (list.size() == 2) {
2681 return list.get(1);
2682 }
2683 else {
2684 return null;
2685 }
2686 }
2687
2688
2695 @Override
2696 public void removeByU_A(long userId, boolean archived)
2697 throws SystemException {
2698 for (UserNotificationEvent userNotificationEvent : findByU_A(userId,
2699 archived, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2700 remove(userNotificationEvent);
2701 }
2702 }
2703
2704
2712 @Override
2713 public int countByU_A(long userId, boolean archived)
2714 throws SystemException {
2715 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_A;
2716
2717 Object[] finderArgs = new Object[] { userId, archived };
2718
2719 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2720 this);
2721
2722 if (count == null) {
2723 StringBundler query = new StringBundler(3);
2724
2725 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2726
2727 query.append(_FINDER_COLUMN_U_A_USERID_2);
2728
2729 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
2730
2731 String sql = query.toString();
2732
2733 Session session = null;
2734
2735 try {
2736 session = openSession();
2737
2738 Query q = session.createQuery(sql);
2739
2740 QueryPos qPos = QueryPos.getInstance(q);
2741
2742 qPos.add(userId);
2743
2744 qPos.add(archived);
2745
2746 count = (Long)q.uniqueResult();
2747
2748 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2749 }
2750 catch (Exception e) {
2751 FinderCacheUtil.removeResult(finderPath, finderArgs);
2752
2753 throw processException(e);
2754 }
2755 finally {
2756 closeSession(session);
2757 }
2758 }
2759
2760 return count.intValue();
2761 }
2762
2763 private static final String _FINDER_COLUMN_U_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
2764 private static final String _FINDER_COLUMN_U_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
2765
2766
2771 @Override
2772 public void cacheResult(UserNotificationEvent userNotificationEvent) {
2773 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2774 UserNotificationEventImpl.class,
2775 userNotificationEvent.getPrimaryKey(), userNotificationEvent);
2776
2777 userNotificationEvent.resetOriginalValues();
2778 }
2779
2780
2785 @Override
2786 public void cacheResult(List<UserNotificationEvent> userNotificationEvents) {
2787 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
2788 if (EntityCacheUtil.getResult(
2789 UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2790 UserNotificationEventImpl.class,
2791 userNotificationEvent.getPrimaryKey()) == null) {
2792 cacheResult(userNotificationEvent);
2793 }
2794 else {
2795 userNotificationEvent.resetOriginalValues();
2796 }
2797 }
2798 }
2799
2800
2807 @Override
2808 public void clearCache() {
2809 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2810 CacheRegistryUtil.clear(UserNotificationEventImpl.class.getName());
2811 }
2812
2813 EntityCacheUtil.clearCache(UserNotificationEventImpl.class.getName());
2814
2815 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2816 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2817 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2818 }
2819
2820
2827 @Override
2828 public void clearCache(UserNotificationEvent userNotificationEvent) {
2829 EntityCacheUtil.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2830 UserNotificationEventImpl.class,
2831 userNotificationEvent.getPrimaryKey());
2832
2833 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2834 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2835 }
2836
2837 @Override
2838 public void clearCache(List<UserNotificationEvent> userNotificationEvents) {
2839 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2840 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2841
2842 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
2843 EntityCacheUtil.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
2844 UserNotificationEventImpl.class,
2845 userNotificationEvent.getPrimaryKey());
2846 }
2847 }
2848
2849
2855 @Override
2856 public UserNotificationEvent create(long userNotificationEventId) {
2857 UserNotificationEvent userNotificationEvent = new UserNotificationEventImpl();
2858
2859 userNotificationEvent.setNew(true);
2860 userNotificationEvent.setPrimaryKey(userNotificationEventId);
2861
2862 String uuid = PortalUUIDUtil.generate();
2863
2864 userNotificationEvent.setUuid(uuid);
2865
2866 return userNotificationEvent;
2867 }
2868
2869
2877 @Override
2878 public UserNotificationEvent remove(long userNotificationEventId)
2879 throws NoSuchUserNotificationEventException, SystemException {
2880 return remove((Serializable)userNotificationEventId);
2881 }
2882
2883
2891 @Override
2892 public UserNotificationEvent remove(Serializable primaryKey)
2893 throws NoSuchUserNotificationEventException, SystemException {
2894 Session session = null;
2895
2896 try {
2897 session = openSession();
2898
2899 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
2900 primaryKey);
2901
2902 if (userNotificationEvent == null) {
2903 if (_log.isWarnEnabled()) {
2904 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2905 }
2906
2907 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2908 primaryKey);
2909 }
2910
2911 return remove(userNotificationEvent);
2912 }
2913 catch (NoSuchUserNotificationEventException nsee) {
2914 throw nsee;
2915 }
2916 catch (Exception e) {
2917 throw processException(e);
2918 }
2919 finally {
2920 closeSession(session);
2921 }
2922 }
2923
2924 @Override
2925 protected UserNotificationEvent removeImpl(
2926 UserNotificationEvent userNotificationEvent) throws SystemException {
2927 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
2928
2929 Session session = null;
2930
2931 try {
2932 session = openSession();
2933
2934 if (!session.contains(userNotificationEvent)) {
2935 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
2936 userNotificationEvent.getPrimaryKeyObj());
2937 }
2938
2939 if (userNotificationEvent != null) {
2940 session.delete(userNotificationEvent);
2941 }
2942 }
2943 catch (Exception e) {
2944 throw processException(e);
2945 }
2946 finally {
2947 closeSession(session);
2948 }
2949
2950 if (userNotificationEvent != null) {
2951 clearCache(userNotificationEvent);
2952 }
2953
2954 return userNotificationEvent;
2955 }
2956
2957 @Override
2958 public UserNotificationEvent updateImpl(
2959 com.liferay.portal.model.UserNotificationEvent userNotificationEvent)
2960 throws SystemException {
2961 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
2962
2963 boolean isNew = userNotificationEvent.isNew();
2964
2965 UserNotificationEventModelImpl userNotificationEventModelImpl = (UserNotificationEventModelImpl)userNotificationEvent;
2966
2967 if (Validator.isNull(userNotificationEvent.getUuid())) {
2968 String uuid = PortalUUIDUtil.generate();
2969
2970 userNotificationEvent.setUuid(uuid);
2971 }
2972
2973 Session session = null;
2974
2975 try {
2976 session = openSession();
2977
2978 if (userNotificationEvent.isNew()) {
2979 session.save(userNotificationEvent);
2980
2981 userNotificationEvent.setNew(false);
2982 }
2983 else {
2984 session.merge(userNotificationEvent);
2985 }
2986 }
2987 catch (Exception e) {
2988 throw processException(e);
2989 }
2990 finally {
2991 closeSession(session);
2992 }
2993
2994 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2995
2996 if (isNew || !UserNotificationEventModelImpl.COLUMN_BITMASK_ENABLED) {
2997 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2998 }
2999
3000 else {
3001 if ((userNotificationEventModelImpl.getColumnBitmask() &
3002 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
3003 Object[] args = new Object[] {
3004 userNotificationEventModelImpl.getOriginalUuid()
3005 };
3006
3007 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3008 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3009 args);
3010
3011 args = new Object[] { userNotificationEventModelImpl.getUuid() };
3012
3013 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3014 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3015 args);
3016 }
3017
3018 if ((userNotificationEventModelImpl.getColumnBitmask() &
3019 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
3020 Object[] args = new Object[] {
3021 userNotificationEventModelImpl.getOriginalUuid(),
3022 userNotificationEventModelImpl.getOriginalCompanyId()
3023 };
3024
3025 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3026 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3027 args);
3028
3029 args = new Object[] {
3030 userNotificationEventModelImpl.getUuid(),
3031 userNotificationEventModelImpl.getCompanyId()
3032 };
3033
3034 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3035 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3036 args);
3037 }
3038
3039 if ((userNotificationEventModelImpl.getColumnBitmask() &
3040 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
3041 Object[] args = new Object[] {
3042 userNotificationEventModelImpl.getOriginalUserId()
3043 };
3044
3045 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
3046 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
3047 args);
3048
3049 args = new Object[] { userNotificationEventModelImpl.getUserId() };
3050
3051 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
3052 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
3053 args);
3054 }
3055
3056 if ((userNotificationEventModelImpl.getColumnBitmask() &
3057 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D.getColumnBitmask()) != 0) {
3058 Object[] args = new Object[] {
3059 userNotificationEventModelImpl.getOriginalUserId(),
3060 userNotificationEventModelImpl.getOriginalDelivered()
3061 };
3062
3063 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_D, args);
3064 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D,
3065 args);
3066
3067 args = new Object[] {
3068 userNotificationEventModelImpl.getUserId(),
3069 userNotificationEventModelImpl.getDelivered()
3070 };
3071
3072 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_D, args);
3073 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_D,
3074 args);
3075 }
3076
3077 if ((userNotificationEventModelImpl.getColumnBitmask() &
3078 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A.getColumnBitmask()) != 0) {
3079 Object[] args = new Object[] {
3080 userNotificationEventModelImpl.getOriginalUserId(),
3081 userNotificationEventModelImpl.getOriginalArchived()
3082 };
3083
3084 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
3085 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
3086 args);
3087
3088 args = new Object[] {
3089 userNotificationEventModelImpl.getUserId(),
3090 userNotificationEventModelImpl.getArchived()
3091 };
3092
3093 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
3094 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
3095 args);
3096 }
3097 }
3098
3099 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3100 UserNotificationEventImpl.class,
3101 userNotificationEvent.getPrimaryKey(), userNotificationEvent);
3102
3103 return userNotificationEvent;
3104 }
3105
3106 protected UserNotificationEvent toUnwrappedModel(
3107 UserNotificationEvent userNotificationEvent) {
3108 if (userNotificationEvent instanceof UserNotificationEventImpl) {
3109 return userNotificationEvent;
3110 }
3111
3112 UserNotificationEventImpl userNotificationEventImpl = new UserNotificationEventImpl();
3113
3114 userNotificationEventImpl.setNew(userNotificationEvent.isNew());
3115 userNotificationEventImpl.setPrimaryKey(userNotificationEvent.getPrimaryKey());
3116
3117 userNotificationEventImpl.setUuid(userNotificationEvent.getUuid());
3118 userNotificationEventImpl.setUserNotificationEventId(userNotificationEvent.getUserNotificationEventId());
3119 userNotificationEventImpl.setCompanyId(userNotificationEvent.getCompanyId());
3120 userNotificationEventImpl.setUserId(userNotificationEvent.getUserId());
3121 userNotificationEventImpl.setType(userNotificationEvent.getType());
3122 userNotificationEventImpl.setTimestamp(userNotificationEvent.getTimestamp());
3123 userNotificationEventImpl.setDeliverBy(userNotificationEvent.getDeliverBy());
3124 userNotificationEventImpl.setDelivered(userNotificationEvent.isDelivered());
3125 userNotificationEventImpl.setPayload(userNotificationEvent.getPayload());
3126 userNotificationEventImpl.setArchived(userNotificationEvent.isArchived());
3127
3128 return userNotificationEventImpl;
3129 }
3130
3131
3139 @Override
3140 public UserNotificationEvent findByPrimaryKey(Serializable primaryKey)
3141 throws NoSuchUserNotificationEventException, SystemException {
3142 UserNotificationEvent userNotificationEvent = fetchByPrimaryKey(primaryKey);
3143
3144 if (userNotificationEvent == null) {
3145 if (_log.isWarnEnabled()) {
3146 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3147 }
3148
3149 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3150 primaryKey);
3151 }
3152
3153 return userNotificationEvent;
3154 }
3155
3156
3164 @Override
3165 public UserNotificationEvent findByPrimaryKey(long userNotificationEventId)
3166 throws NoSuchUserNotificationEventException, SystemException {
3167 return findByPrimaryKey((Serializable)userNotificationEventId);
3168 }
3169
3170
3177 @Override
3178 public UserNotificationEvent fetchByPrimaryKey(Serializable primaryKey)
3179 throws SystemException {
3180 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)EntityCacheUtil.getResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3181 UserNotificationEventImpl.class, primaryKey);
3182
3183 if (userNotificationEvent == _nullUserNotificationEvent) {
3184 return null;
3185 }
3186
3187 if (userNotificationEvent == null) {
3188 Session session = null;
3189
3190 try {
3191 session = openSession();
3192
3193 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
3194 primaryKey);
3195
3196 if (userNotificationEvent != null) {
3197 cacheResult(userNotificationEvent);
3198 }
3199 else {
3200 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3201 UserNotificationEventImpl.class, primaryKey,
3202 _nullUserNotificationEvent);
3203 }
3204 }
3205 catch (Exception e) {
3206 EntityCacheUtil.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
3207 UserNotificationEventImpl.class, primaryKey);
3208
3209 throw processException(e);
3210 }
3211 finally {
3212 closeSession(session);
3213 }
3214 }
3215
3216 return userNotificationEvent;
3217 }
3218
3219
3226 @Override
3227 public UserNotificationEvent fetchByPrimaryKey(long userNotificationEventId)
3228 throws SystemException {
3229 return fetchByPrimaryKey((Serializable)userNotificationEventId);
3230 }
3231
3232
3238 @Override
3239 public List<UserNotificationEvent> findAll() throws SystemException {
3240 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3241 }
3242
3243
3255 @Override
3256 public List<UserNotificationEvent> findAll(int start, int end)
3257 throws SystemException {
3258 return findAll(start, end, null);
3259 }
3260
3261
3274 @Override
3275 public List<UserNotificationEvent> findAll(int start, int end,
3276 OrderByComparator orderByComparator) throws SystemException {
3277 boolean pagination = true;
3278 FinderPath finderPath = null;
3279 Object[] finderArgs = null;
3280
3281 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3282 (orderByComparator == null)) {
3283 pagination = false;
3284 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3285 finderArgs = FINDER_ARGS_EMPTY;
3286 }
3287 else {
3288 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3289 finderArgs = new Object[] { start, end, orderByComparator };
3290 }
3291
3292 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
3293 finderArgs, this);
3294
3295 if (list == null) {
3296 StringBundler query = null;
3297 String sql = null;
3298
3299 if (orderByComparator != null) {
3300 query = new StringBundler(2 +
3301 (orderByComparator.getOrderByFields().length * 3));
3302
3303 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT);
3304
3305 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3306 orderByComparator);
3307
3308 sql = query.toString();
3309 }
3310 else {
3311 sql = _SQL_SELECT_USERNOTIFICATIONEVENT;
3312
3313 if (pagination) {
3314 sql = sql.concat(UserNotificationEventModelImpl.ORDER_BY_JPQL);
3315 }
3316 }
3317
3318 Session session = null;
3319
3320 try {
3321 session = openSession();
3322
3323 Query q = session.createQuery(sql);
3324
3325 if (!pagination) {
3326 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3327 getDialect(), start, end, false);
3328
3329 Collections.sort(list);
3330
3331 list = new UnmodifiableList<UserNotificationEvent>(list);
3332 }
3333 else {
3334 list = (List<UserNotificationEvent>)QueryUtil.list(q,
3335 getDialect(), start, end);
3336 }
3337
3338 cacheResult(list);
3339
3340 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3341 }
3342 catch (Exception e) {
3343 FinderCacheUtil.removeResult(finderPath, finderArgs);
3344
3345 throw processException(e);
3346 }
3347 finally {
3348 closeSession(session);
3349 }
3350 }
3351
3352 return list;
3353 }
3354
3355
3360 @Override
3361 public void removeAll() throws SystemException {
3362 for (UserNotificationEvent userNotificationEvent : findAll()) {
3363 remove(userNotificationEvent);
3364 }
3365 }
3366
3367
3373 @Override
3374 public int countAll() throws SystemException {
3375 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3376 FINDER_ARGS_EMPTY, this);
3377
3378 if (count == null) {
3379 Session session = null;
3380
3381 try {
3382 session = openSession();
3383
3384 Query q = session.createQuery(_SQL_COUNT_USERNOTIFICATIONEVENT);
3385
3386 count = (Long)q.uniqueResult();
3387
3388 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3389 FINDER_ARGS_EMPTY, count);
3390 }
3391 catch (Exception e) {
3392 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
3393 FINDER_ARGS_EMPTY);
3394
3395 throw processException(e);
3396 }
3397 finally {
3398 closeSession(session);
3399 }
3400 }
3401
3402 return count.intValue();
3403 }
3404
3405 @Override
3406 protected Set<String> getBadColumnNames() {
3407 return _badColumnNames;
3408 }
3409
3410
3413 public void afterPropertiesSet() {
3414 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3415 com.liferay.portal.util.PropsUtil.get(
3416 "value.object.listener.com.liferay.portal.model.UserNotificationEvent")));
3417
3418 if (listenerClassNames.length > 0) {
3419 try {
3420 List<ModelListener<UserNotificationEvent>> listenersList = new ArrayList<ModelListener<UserNotificationEvent>>();
3421
3422 for (String listenerClassName : listenerClassNames) {
3423 listenersList.add((ModelListener<UserNotificationEvent>)InstanceFactory.newInstance(
3424 getClassLoader(), listenerClassName));
3425 }
3426
3427 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3428 }
3429 catch (Exception e) {
3430 _log.error(e);
3431 }
3432 }
3433 }
3434
3435 public void destroy() {
3436 EntityCacheUtil.removeCache(UserNotificationEventImpl.class.getName());
3437 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3438 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3439 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3440 }
3441
3442 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent";
3443 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT_WHERE = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent WHERE ";
3444 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent";
3445 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT_WHERE = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent WHERE ";
3446 private static final String _ORDER_BY_ENTITY_ALIAS = "userNotificationEvent.";
3447 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserNotificationEvent exists with the primary key ";
3448 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserNotificationEvent exists with the key {";
3449 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3450 private static Log _log = LogFactoryUtil.getLog(UserNotificationEventPersistenceImpl.class);
3451 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
3452 "uuid", "type"
3453 });
3454 private static UserNotificationEvent _nullUserNotificationEvent = new UserNotificationEventImpl() {
3455 @Override
3456 public Object clone() {
3457 return this;
3458 }
3459
3460 @Override
3461 public CacheModel<UserNotificationEvent> toCacheModel() {
3462 return _nullUserNotificationEventCacheModel;
3463 }
3464 };
3465
3466 private static CacheModel<UserNotificationEvent> _nullUserNotificationEventCacheModel =
3467 new CacheModel<UserNotificationEvent>() {
3468 @Override
3469 public UserNotificationEvent toEntityModel() {
3470 return _nullUserNotificationEvent;
3471 }
3472 };
3473 }