001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchUserNotificationEventException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
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
052
064 public class UserNotificationEventPersistenceImpl extends BasePersistenceImpl<UserNotificationEvent>
065 implements UserNotificationEventPersistence {
066
071 public static final String FINDER_CLASS_NAME_ENTITY = UserNotificationEventImpl.class.getName();
072 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List1";
074 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List2";
076 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
077 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
078 UserNotificationEventImpl.class,
079 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
080 new String[] {
081 String.class.getName(),
082
083 "java.lang.Integer", "java.lang.Integer",
084 "com.liferay.portal.kernel.util.OrderByComparator"
085 });
086 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
087 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
088 UserNotificationEventImpl.class,
089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
090 new String[] { String.class.getName() },
091 UserNotificationEventModelImpl.UUID_COLUMN_BITMASK);
092 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
093 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
095 new String[] { String.class.getName() });
096 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
097 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
098 UserNotificationEventImpl.class,
099 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
100 new String[] {
101 Long.class.getName(),
102
103 "java.lang.Integer", "java.lang.Integer",
104 "com.liferay.portal.kernel.util.OrderByComparator"
105 });
106 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
107 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
108 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
109 UserNotificationEventImpl.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
111 new String[] { Long.class.getName() },
112 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK);
113 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
114 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
115 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
116 new String[] { Long.class.getName() });
117 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
118 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
119 UserNotificationEventImpl.class,
120 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_A",
121 new String[] {
122 Long.class.getName(), Boolean.class.getName(),
123
124 "java.lang.Integer", "java.lang.Integer",
125 "com.liferay.portal.kernel.util.OrderByComparator"
126 });
127 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
128 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
129 UserNotificationEventImpl.class,
130 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_A",
131 new String[] { Long.class.getName(), Boolean.class.getName() },
132 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
133 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK);
134 public static final FinderPath FINDER_PATH_COUNT_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
135 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
136 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_A",
137 new String[] { Long.class.getName(), Boolean.class.getName() });
138 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
139 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
140 UserNotificationEventImpl.class,
141 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
142 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
143 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
144 UserNotificationEventImpl.class,
145 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
146 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
147 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
148 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
149
150
155 public void cacheResult(UserNotificationEvent userNotificationEvent) {
156 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
157 UserNotificationEventImpl.class,
158 userNotificationEvent.getPrimaryKey(), userNotificationEvent);
159
160 userNotificationEvent.resetOriginalValues();
161 }
162
163
168 public void cacheResult(List<UserNotificationEvent> userNotificationEvents) {
169 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
170 if (EntityCacheUtil.getResult(
171 UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
172 UserNotificationEventImpl.class,
173 userNotificationEvent.getPrimaryKey()) == null) {
174 cacheResult(userNotificationEvent);
175 }
176 else {
177 userNotificationEvent.resetOriginalValues();
178 }
179 }
180 }
181
182
189 @Override
190 public void clearCache() {
191 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
192 CacheRegistryUtil.clear(UserNotificationEventImpl.class.getName());
193 }
194
195 EntityCacheUtil.clearCache(UserNotificationEventImpl.class.getName());
196
197 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
198 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
199 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
200 }
201
202
209 @Override
210 public void clearCache(UserNotificationEvent userNotificationEvent) {
211 EntityCacheUtil.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
212 UserNotificationEventImpl.class,
213 userNotificationEvent.getPrimaryKey());
214
215 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
216 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
217 }
218
219 @Override
220 public void clearCache(List<UserNotificationEvent> userNotificationEvents) {
221 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
222 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
223
224 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
225 EntityCacheUtil.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
226 UserNotificationEventImpl.class,
227 userNotificationEvent.getPrimaryKey());
228 }
229 }
230
231
237 public UserNotificationEvent create(long userNotificationEventId) {
238 UserNotificationEvent userNotificationEvent = new UserNotificationEventImpl();
239
240 userNotificationEvent.setNew(true);
241 userNotificationEvent.setPrimaryKey(userNotificationEventId);
242
243 String uuid = PortalUUIDUtil.generate();
244
245 userNotificationEvent.setUuid(uuid);
246
247 return userNotificationEvent;
248 }
249
250
258 public UserNotificationEvent remove(long userNotificationEventId)
259 throws NoSuchUserNotificationEventException, SystemException {
260 return remove(Long.valueOf(userNotificationEventId));
261 }
262
263
271 @Override
272 public UserNotificationEvent remove(Serializable primaryKey)
273 throws NoSuchUserNotificationEventException, SystemException {
274 Session session = null;
275
276 try {
277 session = openSession();
278
279 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
280 primaryKey);
281
282 if (userNotificationEvent == null) {
283 if (_log.isWarnEnabled()) {
284 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
285 }
286
287 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
288 primaryKey);
289 }
290
291 return remove(userNotificationEvent);
292 }
293 catch (NoSuchUserNotificationEventException nsee) {
294 throw nsee;
295 }
296 catch (Exception e) {
297 throw processException(e);
298 }
299 finally {
300 closeSession(session);
301 }
302 }
303
304 @Override
305 protected UserNotificationEvent removeImpl(
306 UserNotificationEvent userNotificationEvent) throws SystemException {
307 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
308
309 Session session = null;
310
311 try {
312 session = openSession();
313
314 BatchSessionUtil.delete(session, userNotificationEvent);
315 }
316 catch (Exception e) {
317 throw processException(e);
318 }
319 finally {
320 closeSession(session);
321 }
322
323 clearCache(userNotificationEvent);
324
325 return userNotificationEvent;
326 }
327
328 @Override
329 public UserNotificationEvent updateImpl(
330 com.liferay.portal.model.UserNotificationEvent userNotificationEvent,
331 boolean merge) throws SystemException {
332 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
333
334 boolean isNew = userNotificationEvent.isNew();
335
336 UserNotificationEventModelImpl userNotificationEventModelImpl = (UserNotificationEventModelImpl)userNotificationEvent;
337
338 if (Validator.isNull(userNotificationEvent.getUuid())) {
339 String uuid = PortalUUIDUtil.generate();
340
341 userNotificationEvent.setUuid(uuid);
342 }
343
344 Session session = null;
345
346 try {
347 session = openSession();
348
349 BatchSessionUtil.update(session, userNotificationEvent, merge);
350
351 userNotificationEvent.setNew(false);
352 }
353 catch (Exception e) {
354 throw processException(e);
355 }
356 finally {
357 closeSession(session);
358 }
359
360 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
361
362 if (isNew || !UserNotificationEventModelImpl.COLUMN_BITMASK_ENABLED) {
363 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
364 }
365
366 else {
367 if ((userNotificationEventModelImpl.getColumnBitmask() &
368 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
369 Object[] args = new Object[] {
370 userNotificationEventModelImpl.getOriginalUuid()
371 };
372
373 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
374 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
375 args);
376
377 args = new Object[] { userNotificationEventModelImpl.getUuid() };
378
379 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
380 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
381 args);
382 }
383
384 if ((userNotificationEventModelImpl.getColumnBitmask() &
385 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
386 Object[] args = new Object[] {
387 Long.valueOf(userNotificationEventModelImpl.getOriginalUserId())
388 };
389
390 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
391 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
392 args);
393
394 args = new Object[] {
395 Long.valueOf(userNotificationEventModelImpl.getUserId())
396 };
397
398 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
399 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
400 args);
401 }
402
403 if ((userNotificationEventModelImpl.getColumnBitmask() &
404 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A.getColumnBitmask()) != 0) {
405 Object[] args = new Object[] {
406 Long.valueOf(userNotificationEventModelImpl.getOriginalUserId()),
407 Boolean.valueOf(userNotificationEventModelImpl.getOriginalArchived())
408 };
409
410 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
411 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
412 args);
413
414 args = new Object[] {
415 Long.valueOf(userNotificationEventModelImpl.getUserId()),
416 Boolean.valueOf(userNotificationEventModelImpl.getArchived())
417 };
418
419 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
420 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
421 args);
422 }
423 }
424
425 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
426 UserNotificationEventImpl.class,
427 userNotificationEvent.getPrimaryKey(), userNotificationEvent);
428
429 return userNotificationEvent;
430 }
431
432 protected UserNotificationEvent toUnwrappedModel(
433 UserNotificationEvent userNotificationEvent) {
434 if (userNotificationEvent instanceof UserNotificationEventImpl) {
435 return userNotificationEvent;
436 }
437
438 UserNotificationEventImpl userNotificationEventImpl = new UserNotificationEventImpl();
439
440 userNotificationEventImpl.setNew(userNotificationEvent.isNew());
441 userNotificationEventImpl.setPrimaryKey(userNotificationEvent.getPrimaryKey());
442
443 userNotificationEventImpl.setUuid(userNotificationEvent.getUuid());
444 userNotificationEventImpl.setUserNotificationEventId(userNotificationEvent.getUserNotificationEventId());
445 userNotificationEventImpl.setCompanyId(userNotificationEvent.getCompanyId());
446 userNotificationEventImpl.setUserId(userNotificationEvent.getUserId());
447 userNotificationEventImpl.setType(userNotificationEvent.getType());
448 userNotificationEventImpl.setTimestamp(userNotificationEvent.getTimestamp());
449 userNotificationEventImpl.setDeliverBy(userNotificationEvent.getDeliverBy());
450 userNotificationEventImpl.setPayload(userNotificationEvent.getPayload());
451 userNotificationEventImpl.setArchived(userNotificationEvent.isArchived());
452
453 return userNotificationEventImpl;
454 }
455
456
464 @Override
465 public UserNotificationEvent findByPrimaryKey(Serializable primaryKey)
466 throws NoSuchModelException, SystemException {
467 return findByPrimaryKey(((Long)primaryKey).longValue());
468 }
469
470
478 public UserNotificationEvent findByPrimaryKey(long userNotificationEventId)
479 throws NoSuchUserNotificationEventException, SystemException {
480 UserNotificationEvent userNotificationEvent = fetchByPrimaryKey(userNotificationEventId);
481
482 if (userNotificationEvent == null) {
483 if (_log.isWarnEnabled()) {
484 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
485 userNotificationEventId);
486 }
487
488 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
489 userNotificationEventId);
490 }
491
492 return userNotificationEvent;
493 }
494
495
502 @Override
503 public UserNotificationEvent fetchByPrimaryKey(Serializable primaryKey)
504 throws SystemException {
505 return fetchByPrimaryKey(((Long)primaryKey).longValue());
506 }
507
508
515 public UserNotificationEvent fetchByPrimaryKey(long userNotificationEventId)
516 throws SystemException {
517 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)EntityCacheUtil.getResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
518 UserNotificationEventImpl.class, userNotificationEventId);
519
520 if (userNotificationEvent == _nullUserNotificationEvent) {
521 return null;
522 }
523
524 if (userNotificationEvent == null) {
525 Session session = null;
526
527 boolean hasException = false;
528
529 try {
530 session = openSession();
531
532 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
533 Long.valueOf(userNotificationEventId));
534 }
535 catch (Exception e) {
536 hasException = true;
537
538 throw processException(e);
539 }
540 finally {
541 if (userNotificationEvent != null) {
542 cacheResult(userNotificationEvent);
543 }
544 else if (!hasException) {
545 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
546 UserNotificationEventImpl.class,
547 userNotificationEventId, _nullUserNotificationEvent);
548 }
549
550 closeSession(session);
551 }
552 }
553
554 return userNotificationEvent;
555 }
556
557
564 public List<UserNotificationEvent> findByUuid(String uuid)
565 throws SystemException {
566 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
567 }
568
569
582 public List<UserNotificationEvent> findByUuid(String uuid, int start,
583 int end) throws SystemException {
584 return findByUuid(uuid, start, end, null);
585 }
586
587
601 public List<UserNotificationEvent> findByUuid(String uuid, int start,
602 int end, OrderByComparator orderByComparator) throws SystemException {
603 FinderPath finderPath = null;
604 Object[] finderArgs = null;
605
606 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
607 (orderByComparator == null)) {
608 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
609 finderArgs = new Object[] { uuid };
610 }
611 else {
612 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
613 finderArgs = new Object[] { uuid, start, end, orderByComparator };
614 }
615
616 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
617 finderArgs, this);
618
619 if (list == null) {
620 StringBundler query = null;
621
622 if (orderByComparator != null) {
623 query = new StringBundler(3 +
624 (orderByComparator.getOrderByFields().length * 3));
625 }
626 else {
627 query = new StringBundler(3);
628 }
629
630 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
631
632 if (uuid == null) {
633 query.append(_FINDER_COLUMN_UUID_UUID_1);
634 }
635 else {
636 if (uuid.equals(StringPool.BLANK)) {
637 query.append(_FINDER_COLUMN_UUID_UUID_3);
638 }
639 else {
640 query.append(_FINDER_COLUMN_UUID_UUID_2);
641 }
642 }
643
644 if (orderByComparator != null) {
645 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
646 orderByComparator);
647 }
648
649 else {
650 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
651 }
652
653 String sql = query.toString();
654
655 Session session = null;
656
657 try {
658 session = openSession();
659
660 Query q = session.createQuery(sql);
661
662 QueryPos qPos = QueryPos.getInstance(q);
663
664 if (uuid != null) {
665 qPos.add(uuid);
666 }
667
668 list = (List<UserNotificationEvent>)QueryUtil.list(q,
669 getDialect(), start, end);
670 }
671 catch (Exception e) {
672 throw processException(e);
673 }
674 finally {
675 if (list == null) {
676 FinderCacheUtil.removeResult(finderPath, finderArgs);
677 }
678 else {
679 cacheResult(list);
680
681 FinderCacheUtil.putResult(finderPath, finderArgs, list);
682 }
683
684 closeSession(session);
685 }
686 }
687
688 return list;
689 }
690
691
704 public UserNotificationEvent findByUuid_First(String uuid,
705 OrderByComparator orderByComparator)
706 throws NoSuchUserNotificationEventException, SystemException {
707 List<UserNotificationEvent> list = findByUuid(uuid, 0, 1,
708 orderByComparator);
709
710 if (list.isEmpty()) {
711 StringBundler msg = new StringBundler(4);
712
713 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
714
715 msg.append("uuid=");
716 msg.append(uuid);
717
718 msg.append(StringPool.CLOSE_CURLY_BRACE);
719
720 throw new NoSuchUserNotificationEventException(msg.toString());
721 }
722 else {
723 return list.get(0);
724 }
725 }
726
727
740 public UserNotificationEvent findByUuid_Last(String uuid,
741 OrderByComparator orderByComparator)
742 throws NoSuchUserNotificationEventException, SystemException {
743 int count = countByUuid(uuid);
744
745 List<UserNotificationEvent> list = findByUuid(uuid, count - 1, count,
746 orderByComparator);
747
748 if (list.isEmpty()) {
749 StringBundler msg = new StringBundler(4);
750
751 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
752
753 msg.append("uuid=");
754 msg.append(uuid);
755
756 msg.append(StringPool.CLOSE_CURLY_BRACE);
757
758 throw new NoSuchUserNotificationEventException(msg.toString());
759 }
760 else {
761 return list.get(0);
762 }
763 }
764
765
779 public UserNotificationEvent[] findByUuid_PrevAndNext(
780 long userNotificationEventId, String uuid,
781 OrderByComparator orderByComparator)
782 throws NoSuchUserNotificationEventException, SystemException {
783 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
784
785 Session session = null;
786
787 try {
788 session = openSession();
789
790 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
791
792 array[0] = getByUuid_PrevAndNext(session, userNotificationEvent,
793 uuid, orderByComparator, true);
794
795 array[1] = userNotificationEvent;
796
797 array[2] = getByUuid_PrevAndNext(session, userNotificationEvent,
798 uuid, orderByComparator, false);
799
800 return array;
801 }
802 catch (Exception e) {
803 throw processException(e);
804 }
805 finally {
806 closeSession(session);
807 }
808 }
809
810 protected UserNotificationEvent getByUuid_PrevAndNext(Session session,
811 UserNotificationEvent userNotificationEvent, String uuid,
812 OrderByComparator orderByComparator, boolean previous) {
813 StringBundler query = null;
814
815 if (orderByComparator != null) {
816 query = new StringBundler(6 +
817 (orderByComparator.getOrderByFields().length * 6));
818 }
819 else {
820 query = new StringBundler(3);
821 }
822
823 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
824
825 if (uuid == null) {
826 query.append(_FINDER_COLUMN_UUID_UUID_1);
827 }
828 else {
829 if (uuid.equals(StringPool.BLANK)) {
830 query.append(_FINDER_COLUMN_UUID_UUID_3);
831 }
832 else {
833 query.append(_FINDER_COLUMN_UUID_UUID_2);
834 }
835 }
836
837 if (orderByComparator != null) {
838 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
839
840 if (orderByConditionFields.length > 0) {
841 query.append(WHERE_AND);
842 }
843
844 for (int i = 0; i < orderByConditionFields.length; i++) {
845 query.append(_ORDER_BY_ENTITY_ALIAS);
846 query.append(orderByConditionFields[i]);
847
848 if ((i + 1) < orderByConditionFields.length) {
849 if (orderByComparator.isAscending() ^ previous) {
850 query.append(WHERE_GREATER_THAN_HAS_NEXT);
851 }
852 else {
853 query.append(WHERE_LESSER_THAN_HAS_NEXT);
854 }
855 }
856 else {
857 if (orderByComparator.isAscending() ^ previous) {
858 query.append(WHERE_GREATER_THAN);
859 }
860 else {
861 query.append(WHERE_LESSER_THAN);
862 }
863 }
864 }
865
866 query.append(ORDER_BY_CLAUSE);
867
868 String[] orderByFields = orderByComparator.getOrderByFields();
869
870 for (int i = 0; i < orderByFields.length; i++) {
871 query.append(_ORDER_BY_ENTITY_ALIAS);
872 query.append(orderByFields[i]);
873
874 if ((i + 1) < orderByFields.length) {
875 if (orderByComparator.isAscending() ^ previous) {
876 query.append(ORDER_BY_ASC_HAS_NEXT);
877 }
878 else {
879 query.append(ORDER_BY_DESC_HAS_NEXT);
880 }
881 }
882 else {
883 if (orderByComparator.isAscending() ^ previous) {
884 query.append(ORDER_BY_ASC);
885 }
886 else {
887 query.append(ORDER_BY_DESC);
888 }
889 }
890 }
891 }
892
893 else {
894 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
895 }
896
897 String sql = query.toString();
898
899 Query q = session.createQuery(sql);
900
901 q.setFirstResult(0);
902 q.setMaxResults(2);
903
904 QueryPos qPos = QueryPos.getInstance(q);
905
906 if (uuid != null) {
907 qPos.add(uuid);
908 }
909
910 if (orderByComparator != null) {
911 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
912
913 for (Object value : values) {
914 qPos.add(value);
915 }
916 }
917
918 List<UserNotificationEvent> list = q.list();
919
920 if (list.size() == 2) {
921 return list.get(1);
922 }
923 else {
924 return null;
925 }
926 }
927
928
935 public List<UserNotificationEvent> findByUserId(long userId)
936 throws SystemException {
937 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
938 }
939
940
953 public List<UserNotificationEvent> findByUserId(long userId, int start,
954 int end) throws SystemException {
955 return findByUserId(userId, start, end, null);
956 }
957
958
972 public List<UserNotificationEvent> findByUserId(long userId, int start,
973 int end, OrderByComparator orderByComparator) throws SystemException {
974 FinderPath finderPath = null;
975 Object[] finderArgs = null;
976
977 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
978 (orderByComparator == null)) {
979 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
980 finderArgs = new Object[] { userId };
981 }
982 else {
983 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
984 finderArgs = new Object[] { userId, start, end, orderByComparator };
985 }
986
987 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
988 finderArgs, this);
989
990 if (list == null) {
991 StringBundler query = null;
992
993 if (orderByComparator != null) {
994 query = new StringBundler(3 +
995 (orderByComparator.getOrderByFields().length * 3));
996 }
997 else {
998 query = new StringBundler(3);
999 }
1000
1001 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1002
1003 query.append(_FINDER_COLUMN_USERID_USERID_2);
1004
1005 if (orderByComparator != null) {
1006 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1007 orderByComparator);
1008 }
1009
1010 else {
1011 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1012 }
1013
1014 String sql = query.toString();
1015
1016 Session session = null;
1017
1018 try {
1019 session = openSession();
1020
1021 Query q = session.createQuery(sql);
1022
1023 QueryPos qPos = QueryPos.getInstance(q);
1024
1025 qPos.add(userId);
1026
1027 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1028 getDialect(), start, end);
1029 }
1030 catch (Exception e) {
1031 throw processException(e);
1032 }
1033 finally {
1034 if (list == null) {
1035 FinderCacheUtil.removeResult(finderPath, finderArgs);
1036 }
1037 else {
1038 cacheResult(list);
1039
1040 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1041 }
1042
1043 closeSession(session);
1044 }
1045 }
1046
1047 return list;
1048 }
1049
1050
1063 public UserNotificationEvent findByUserId_First(long userId,
1064 OrderByComparator orderByComparator)
1065 throws NoSuchUserNotificationEventException, SystemException {
1066 List<UserNotificationEvent> list = findByUserId(userId, 0, 1,
1067 orderByComparator);
1068
1069 if (list.isEmpty()) {
1070 StringBundler msg = new StringBundler(4);
1071
1072 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1073
1074 msg.append("userId=");
1075 msg.append(userId);
1076
1077 msg.append(StringPool.CLOSE_CURLY_BRACE);
1078
1079 throw new NoSuchUserNotificationEventException(msg.toString());
1080 }
1081 else {
1082 return list.get(0);
1083 }
1084 }
1085
1086
1099 public UserNotificationEvent findByUserId_Last(long userId,
1100 OrderByComparator orderByComparator)
1101 throws NoSuchUserNotificationEventException, SystemException {
1102 int count = countByUserId(userId);
1103
1104 List<UserNotificationEvent> list = findByUserId(userId, count - 1,
1105 count, orderByComparator);
1106
1107 if (list.isEmpty()) {
1108 StringBundler msg = new StringBundler(4);
1109
1110 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1111
1112 msg.append("userId=");
1113 msg.append(userId);
1114
1115 msg.append(StringPool.CLOSE_CURLY_BRACE);
1116
1117 throw new NoSuchUserNotificationEventException(msg.toString());
1118 }
1119 else {
1120 return list.get(0);
1121 }
1122 }
1123
1124
1138 public UserNotificationEvent[] findByUserId_PrevAndNext(
1139 long userNotificationEventId, long userId,
1140 OrderByComparator orderByComparator)
1141 throws NoSuchUserNotificationEventException, SystemException {
1142 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
1143
1144 Session session = null;
1145
1146 try {
1147 session = openSession();
1148
1149 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1150
1151 array[0] = getByUserId_PrevAndNext(session, userNotificationEvent,
1152 userId, orderByComparator, true);
1153
1154 array[1] = userNotificationEvent;
1155
1156 array[2] = getByUserId_PrevAndNext(session, userNotificationEvent,
1157 userId, orderByComparator, false);
1158
1159 return array;
1160 }
1161 catch (Exception e) {
1162 throw processException(e);
1163 }
1164 finally {
1165 closeSession(session);
1166 }
1167 }
1168
1169 protected UserNotificationEvent getByUserId_PrevAndNext(Session session,
1170 UserNotificationEvent userNotificationEvent, long userId,
1171 OrderByComparator orderByComparator, boolean previous) {
1172 StringBundler query = null;
1173
1174 if (orderByComparator != null) {
1175 query = new StringBundler(6 +
1176 (orderByComparator.getOrderByFields().length * 6));
1177 }
1178 else {
1179 query = new StringBundler(3);
1180 }
1181
1182 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1183
1184 query.append(_FINDER_COLUMN_USERID_USERID_2);
1185
1186 if (orderByComparator != null) {
1187 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1188
1189 if (orderByConditionFields.length > 0) {
1190 query.append(WHERE_AND);
1191 }
1192
1193 for (int i = 0; i < orderByConditionFields.length; i++) {
1194 query.append(_ORDER_BY_ENTITY_ALIAS);
1195 query.append(orderByConditionFields[i]);
1196
1197 if ((i + 1) < orderByConditionFields.length) {
1198 if (orderByComparator.isAscending() ^ previous) {
1199 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1200 }
1201 else {
1202 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1203 }
1204 }
1205 else {
1206 if (orderByComparator.isAscending() ^ previous) {
1207 query.append(WHERE_GREATER_THAN);
1208 }
1209 else {
1210 query.append(WHERE_LESSER_THAN);
1211 }
1212 }
1213 }
1214
1215 query.append(ORDER_BY_CLAUSE);
1216
1217 String[] orderByFields = orderByComparator.getOrderByFields();
1218
1219 for (int i = 0; i < orderByFields.length; i++) {
1220 query.append(_ORDER_BY_ENTITY_ALIAS);
1221 query.append(orderByFields[i]);
1222
1223 if ((i + 1) < orderByFields.length) {
1224 if (orderByComparator.isAscending() ^ previous) {
1225 query.append(ORDER_BY_ASC_HAS_NEXT);
1226 }
1227 else {
1228 query.append(ORDER_BY_DESC_HAS_NEXT);
1229 }
1230 }
1231 else {
1232 if (orderByComparator.isAscending() ^ previous) {
1233 query.append(ORDER_BY_ASC);
1234 }
1235 else {
1236 query.append(ORDER_BY_DESC);
1237 }
1238 }
1239 }
1240 }
1241
1242 else {
1243 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1244 }
1245
1246 String sql = query.toString();
1247
1248 Query q = session.createQuery(sql);
1249
1250 q.setFirstResult(0);
1251 q.setMaxResults(2);
1252
1253 QueryPos qPos = QueryPos.getInstance(q);
1254
1255 qPos.add(userId);
1256
1257 if (orderByComparator != null) {
1258 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1259
1260 for (Object value : values) {
1261 qPos.add(value);
1262 }
1263 }
1264
1265 List<UserNotificationEvent> list = q.list();
1266
1267 if (list.size() == 2) {
1268 return list.get(1);
1269 }
1270 else {
1271 return null;
1272 }
1273 }
1274
1275
1283 public List<UserNotificationEvent> findByU_A(long userId, boolean archived)
1284 throws SystemException {
1285 return findByU_A(userId, archived, QueryUtil.ALL_POS,
1286 QueryUtil.ALL_POS, null);
1287 }
1288
1289
1303 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
1304 int start, int end) throws SystemException {
1305 return findByU_A(userId, archived, start, end, null);
1306 }
1307
1308
1323 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
1324 int start, int end, OrderByComparator orderByComparator)
1325 throws SystemException {
1326 FinderPath finderPath = null;
1327 Object[] finderArgs = null;
1328
1329 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1330 (orderByComparator == null)) {
1331 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A;
1332 finderArgs = new Object[] { userId, archived };
1333 }
1334 else {
1335 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A;
1336 finderArgs = new Object[] {
1337 userId, archived,
1338
1339 start, end, orderByComparator
1340 };
1341 }
1342
1343 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
1344 finderArgs, this);
1345
1346 if (list == null) {
1347 StringBundler query = null;
1348
1349 if (orderByComparator != null) {
1350 query = new StringBundler(4 +
1351 (orderByComparator.getOrderByFields().length * 3));
1352 }
1353 else {
1354 query = new StringBundler(4);
1355 }
1356
1357 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1358
1359 query.append(_FINDER_COLUMN_U_A_USERID_2);
1360
1361 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
1362
1363 if (orderByComparator != null) {
1364 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1365 orderByComparator);
1366 }
1367
1368 else {
1369 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1370 }
1371
1372 String sql = query.toString();
1373
1374 Session session = null;
1375
1376 try {
1377 session = openSession();
1378
1379 Query q = session.createQuery(sql);
1380
1381 QueryPos qPos = QueryPos.getInstance(q);
1382
1383 qPos.add(userId);
1384
1385 qPos.add(archived);
1386
1387 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1388 getDialect(), start, end);
1389 }
1390 catch (Exception e) {
1391 throw processException(e);
1392 }
1393 finally {
1394 if (list == null) {
1395 FinderCacheUtil.removeResult(finderPath, finderArgs);
1396 }
1397 else {
1398 cacheResult(list);
1399
1400 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1401 }
1402
1403 closeSession(session);
1404 }
1405 }
1406
1407 return list;
1408 }
1409
1410
1424 public UserNotificationEvent findByU_A_First(long userId, boolean archived,
1425 OrderByComparator orderByComparator)
1426 throws NoSuchUserNotificationEventException, SystemException {
1427 List<UserNotificationEvent> list = findByU_A(userId, archived, 0, 1,
1428 orderByComparator);
1429
1430 if (list.isEmpty()) {
1431 StringBundler msg = new StringBundler(6);
1432
1433 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1434
1435 msg.append("userId=");
1436 msg.append(userId);
1437
1438 msg.append(", archived=");
1439 msg.append(archived);
1440
1441 msg.append(StringPool.CLOSE_CURLY_BRACE);
1442
1443 throw new NoSuchUserNotificationEventException(msg.toString());
1444 }
1445 else {
1446 return list.get(0);
1447 }
1448 }
1449
1450
1464 public UserNotificationEvent findByU_A_Last(long userId, boolean archived,
1465 OrderByComparator orderByComparator)
1466 throws NoSuchUserNotificationEventException, SystemException {
1467 int count = countByU_A(userId, archived);
1468
1469 List<UserNotificationEvent> list = findByU_A(userId, archived,
1470 count - 1, count, orderByComparator);
1471
1472 if (list.isEmpty()) {
1473 StringBundler msg = new StringBundler(6);
1474
1475 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1476
1477 msg.append("userId=");
1478 msg.append(userId);
1479
1480 msg.append(", archived=");
1481 msg.append(archived);
1482
1483 msg.append(StringPool.CLOSE_CURLY_BRACE);
1484
1485 throw new NoSuchUserNotificationEventException(msg.toString());
1486 }
1487 else {
1488 return list.get(0);
1489 }
1490 }
1491
1492
1507 public UserNotificationEvent[] findByU_A_PrevAndNext(
1508 long userNotificationEventId, long userId, boolean archived,
1509 OrderByComparator orderByComparator)
1510 throws NoSuchUserNotificationEventException, SystemException {
1511 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
1512
1513 Session session = null;
1514
1515 try {
1516 session = openSession();
1517
1518 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1519
1520 array[0] = getByU_A_PrevAndNext(session, userNotificationEvent,
1521 userId, archived, orderByComparator, true);
1522
1523 array[1] = userNotificationEvent;
1524
1525 array[2] = getByU_A_PrevAndNext(session, userNotificationEvent,
1526 userId, archived, orderByComparator, false);
1527
1528 return array;
1529 }
1530 catch (Exception e) {
1531 throw processException(e);
1532 }
1533 finally {
1534 closeSession(session);
1535 }
1536 }
1537
1538 protected UserNotificationEvent getByU_A_PrevAndNext(Session session,
1539 UserNotificationEvent userNotificationEvent, long userId,
1540 boolean archived, OrderByComparator orderByComparator, boolean previous) {
1541 StringBundler query = null;
1542
1543 if (orderByComparator != null) {
1544 query = new StringBundler(6 +
1545 (orderByComparator.getOrderByFields().length * 6));
1546 }
1547 else {
1548 query = new StringBundler(3);
1549 }
1550
1551 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1552
1553 query.append(_FINDER_COLUMN_U_A_USERID_2);
1554
1555 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
1556
1557 if (orderByComparator != null) {
1558 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1559
1560 if (orderByConditionFields.length > 0) {
1561 query.append(WHERE_AND);
1562 }
1563
1564 for (int i = 0; i < orderByConditionFields.length; i++) {
1565 query.append(_ORDER_BY_ENTITY_ALIAS);
1566 query.append(orderByConditionFields[i]);
1567
1568 if ((i + 1) < orderByConditionFields.length) {
1569 if (orderByComparator.isAscending() ^ previous) {
1570 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1571 }
1572 else {
1573 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1574 }
1575 }
1576 else {
1577 if (orderByComparator.isAscending() ^ previous) {
1578 query.append(WHERE_GREATER_THAN);
1579 }
1580 else {
1581 query.append(WHERE_LESSER_THAN);
1582 }
1583 }
1584 }
1585
1586 query.append(ORDER_BY_CLAUSE);
1587
1588 String[] orderByFields = orderByComparator.getOrderByFields();
1589
1590 for (int i = 0; i < orderByFields.length; i++) {
1591 query.append(_ORDER_BY_ENTITY_ALIAS);
1592 query.append(orderByFields[i]);
1593
1594 if ((i + 1) < orderByFields.length) {
1595 if (orderByComparator.isAscending() ^ previous) {
1596 query.append(ORDER_BY_ASC_HAS_NEXT);
1597 }
1598 else {
1599 query.append(ORDER_BY_DESC_HAS_NEXT);
1600 }
1601 }
1602 else {
1603 if (orderByComparator.isAscending() ^ previous) {
1604 query.append(ORDER_BY_ASC);
1605 }
1606 else {
1607 query.append(ORDER_BY_DESC);
1608 }
1609 }
1610 }
1611 }
1612
1613 else {
1614 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1615 }
1616
1617 String sql = query.toString();
1618
1619 Query q = session.createQuery(sql);
1620
1621 q.setFirstResult(0);
1622 q.setMaxResults(2);
1623
1624 QueryPos qPos = QueryPos.getInstance(q);
1625
1626 qPos.add(userId);
1627
1628 qPos.add(archived);
1629
1630 if (orderByComparator != null) {
1631 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1632
1633 for (Object value : values) {
1634 qPos.add(value);
1635 }
1636 }
1637
1638 List<UserNotificationEvent> list = q.list();
1639
1640 if (list.size() == 2) {
1641 return list.get(1);
1642 }
1643 else {
1644 return null;
1645 }
1646 }
1647
1648
1654 public List<UserNotificationEvent> findAll() throws SystemException {
1655 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1656 }
1657
1658
1670 public List<UserNotificationEvent> findAll(int start, int end)
1671 throws SystemException {
1672 return findAll(start, end, null);
1673 }
1674
1675
1688 public List<UserNotificationEvent> findAll(int start, int end,
1689 OrderByComparator orderByComparator) throws SystemException {
1690 FinderPath finderPath = null;
1691 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1692
1693 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1694 (orderByComparator == null)) {
1695 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1696 finderArgs = FINDER_ARGS_EMPTY;
1697 }
1698 else {
1699 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1700 finderArgs = new Object[] { start, end, orderByComparator };
1701 }
1702
1703 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
1704 finderArgs, this);
1705
1706 if (list == null) {
1707 StringBundler query = null;
1708 String sql = null;
1709
1710 if (orderByComparator != null) {
1711 query = new StringBundler(2 +
1712 (orderByComparator.getOrderByFields().length * 3));
1713
1714 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT);
1715
1716 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1717 orderByComparator);
1718
1719 sql = query.toString();
1720 }
1721 else {
1722 sql = _SQL_SELECT_USERNOTIFICATIONEVENT.concat(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1723 }
1724
1725 Session session = null;
1726
1727 try {
1728 session = openSession();
1729
1730 Query q = session.createQuery(sql);
1731
1732 if (orderByComparator == null) {
1733 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1734 getDialect(), start, end, false);
1735
1736 Collections.sort(list);
1737 }
1738 else {
1739 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1740 getDialect(), start, end);
1741 }
1742 }
1743 catch (Exception e) {
1744 throw processException(e);
1745 }
1746 finally {
1747 if (list == null) {
1748 FinderCacheUtil.removeResult(finderPath, finderArgs);
1749 }
1750 else {
1751 cacheResult(list);
1752
1753 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1754 }
1755
1756 closeSession(session);
1757 }
1758 }
1759
1760 return list;
1761 }
1762
1763
1769 public void removeByUuid(String uuid) throws SystemException {
1770 for (UserNotificationEvent userNotificationEvent : findByUuid(uuid)) {
1771 remove(userNotificationEvent);
1772 }
1773 }
1774
1775
1781 public void removeByUserId(long userId) throws SystemException {
1782 for (UserNotificationEvent userNotificationEvent : findByUserId(userId)) {
1783 remove(userNotificationEvent);
1784 }
1785 }
1786
1787
1794 public void removeByU_A(long userId, boolean archived)
1795 throws SystemException {
1796 for (UserNotificationEvent userNotificationEvent : findByU_A(userId,
1797 archived)) {
1798 remove(userNotificationEvent);
1799 }
1800 }
1801
1802
1807 public void removeAll() throws SystemException {
1808 for (UserNotificationEvent userNotificationEvent : findAll()) {
1809 remove(userNotificationEvent);
1810 }
1811 }
1812
1813
1820 public int countByUuid(String uuid) throws SystemException {
1821 Object[] finderArgs = new Object[] { uuid };
1822
1823 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1824 finderArgs, this);
1825
1826 if (count == null) {
1827 StringBundler query = new StringBundler(2);
1828
1829 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1830
1831 if (uuid == null) {
1832 query.append(_FINDER_COLUMN_UUID_UUID_1);
1833 }
1834 else {
1835 if (uuid.equals(StringPool.BLANK)) {
1836 query.append(_FINDER_COLUMN_UUID_UUID_3);
1837 }
1838 else {
1839 query.append(_FINDER_COLUMN_UUID_UUID_2);
1840 }
1841 }
1842
1843 String sql = query.toString();
1844
1845 Session session = null;
1846
1847 try {
1848 session = openSession();
1849
1850 Query q = session.createQuery(sql);
1851
1852 QueryPos qPos = QueryPos.getInstance(q);
1853
1854 if (uuid != null) {
1855 qPos.add(uuid);
1856 }
1857
1858 count = (Long)q.uniqueResult();
1859 }
1860 catch (Exception e) {
1861 throw processException(e);
1862 }
1863 finally {
1864 if (count == null) {
1865 count = Long.valueOf(0);
1866 }
1867
1868 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1869 finderArgs, count);
1870
1871 closeSession(session);
1872 }
1873 }
1874
1875 return count.intValue();
1876 }
1877
1878
1885 public int countByUserId(long userId) throws SystemException {
1886 Object[] finderArgs = new Object[] { userId };
1887
1888 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1889 finderArgs, this);
1890
1891 if (count == null) {
1892 StringBundler query = new StringBundler(2);
1893
1894 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1895
1896 query.append(_FINDER_COLUMN_USERID_USERID_2);
1897
1898 String sql = query.toString();
1899
1900 Session session = null;
1901
1902 try {
1903 session = openSession();
1904
1905 Query q = session.createQuery(sql);
1906
1907 QueryPos qPos = QueryPos.getInstance(q);
1908
1909 qPos.add(userId);
1910
1911 count = (Long)q.uniqueResult();
1912 }
1913 catch (Exception e) {
1914 throw processException(e);
1915 }
1916 finally {
1917 if (count == null) {
1918 count = Long.valueOf(0);
1919 }
1920
1921 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1922 finderArgs, count);
1923
1924 closeSession(session);
1925 }
1926 }
1927
1928 return count.intValue();
1929 }
1930
1931
1939 public int countByU_A(long userId, boolean archived)
1940 throws SystemException {
1941 Object[] finderArgs = new Object[] { userId, archived };
1942
1943 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_A,
1944 finderArgs, this);
1945
1946 if (count == null) {
1947 StringBundler query = new StringBundler(3);
1948
1949 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
1950
1951 query.append(_FINDER_COLUMN_U_A_USERID_2);
1952
1953 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
1954
1955 String sql = query.toString();
1956
1957 Session session = null;
1958
1959 try {
1960 session = openSession();
1961
1962 Query q = session.createQuery(sql);
1963
1964 QueryPos qPos = QueryPos.getInstance(q);
1965
1966 qPos.add(userId);
1967
1968 qPos.add(archived);
1969
1970 count = (Long)q.uniqueResult();
1971 }
1972 catch (Exception e) {
1973 throw processException(e);
1974 }
1975 finally {
1976 if (count == null) {
1977 count = Long.valueOf(0);
1978 }
1979
1980 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_A, finderArgs,
1981 count);
1982
1983 closeSession(session);
1984 }
1985 }
1986
1987 return count.intValue();
1988 }
1989
1990
1996 public int countAll() throws SystemException {
1997 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1998 FINDER_ARGS_EMPTY, this);
1999
2000 if (count == null) {
2001 Session session = null;
2002
2003 try {
2004 session = openSession();
2005
2006 Query q = session.createQuery(_SQL_COUNT_USERNOTIFICATIONEVENT);
2007
2008 count = (Long)q.uniqueResult();
2009 }
2010 catch (Exception e) {
2011 throw processException(e);
2012 }
2013 finally {
2014 if (count == null) {
2015 count = Long.valueOf(0);
2016 }
2017
2018 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2019 FINDER_ARGS_EMPTY, count);
2020
2021 closeSession(session);
2022 }
2023 }
2024
2025 return count.intValue();
2026 }
2027
2028
2031 public void afterPropertiesSet() {
2032 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2033 com.liferay.portal.util.PropsUtil.get(
2034 "value.object.listener.com.liferay.portal.model.UserNotificationEvent")));
2035
2036 if (listenerClassNames.length > 0) {
2037 try {
2038 List<ModelListener<UserNotificationEvent>> listenersList = new ArrayList<ModelListener<UserNotificationEvent>>();
2039
2040 for (String listenerClassName : listenerClassNames) {
2041 listenersList.add((ModelListener<UserNotificationEvent>)InstanceFactory.newInstance(
2042 listenerClassName));
2043 }
2044
2045 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2046 }
2047 catch (Exception e) {
2048 _log.error(e);
2049 }
2050 }
2051 }
2052
2053 public void destroy() {
2054 EntityCacheUtil.removeCache(UserNotificationEventImpl.class.getName());
2055 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2056 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2057 }
2058
2059 @BeanReference(type = AccountPersistence.class)
2060 protected AccountPersistence accountPersistence;
2061 @BeanReference(type = AddressPersistence.class)
2062 protected AddressPersistence addressPersistence;
2063 @BeanReference(type = BrowserTrackerPersistence.class)
2064 protected BrowserTrackerPersistence browserTrackerPersistence;
2065 @BeanReference(type = ClassNamePersistence.class)
2066 protected ClassNamePersistence classNamePersistence;
2067 @BeanReference(type = ClusterGroupPersistence.class)
2068 protected ClusterGroupPersistence clusterGroupPersistence;
2069 @BeanReference(type = CompanyPersistence.class)
2070 protected CompanyPersistence companyPersistence;
2071 @BeanReference(type = ContactPersistence.class)
2072 protected ContactPersistence contactPersistence;
2073 @BeanReference(type = CountryPersistence.class)
2074 protected CountryPersistence countryPersistence;
2075 @BeanReference(type = EmailAddressPersistence.class)
2076 protected EmailAddressPersistence emailAddressPersistence;
2077 @BeanReference(type = GroupPersistence.class)
2078 protected GroupPersistence groupPersistence;
2079 @BeanReference(type = ImagePersistence.class)
2080 protected ImagePersistence imagePersistence;
2081 @BeanReference(type = LayoutPersistence.class)
2082 protected LayoutPersistence layoutPersistence;
2083 @BeanReference(type = LayoutBranchPersistence.class)
2084 protected LayoutBranchPersistence layoutBranchPersistence;
2085 @BeanReference(type = LayoutPrototypePersistence.class)
2086 protected LayoutPrototypePersistence layoutPrototypePersistence;
2087 @BeanReference(type = LayoutRevisionPersistence.class)
2088 protected LayoutRevisionPersistence layoutRevisionPersistence;
2089 @BeanReference(type = LayoutSetPersistence.class)
2090 protected LayoutSetPersistence layoutSetPersistence;
2091 @BeanReference(type = LayoutSetBranchPersistence.class)
2092 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2093 @BeanReference(type = LayoutSetPrototypePersistence.class)
2094 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2095 @BeanReference(type = ListTypePersistence.class)
2096 protected ListTypePersistence listTypePersistence;
2097 @BeanReference(type = LockPersistence.class)
2098 protected LockPersistence lockPersistence;
2099 @BeanReference(type = MembershipRequestPersistence.class)
2100 protected MembershipRequestPersistence membershipRequestPersistence;
2101 @BeanReference(type = OrganizationPersistence.class)
2102 protected OrganizationPersistence organizationPersistence;
2103 @BeanReference(type = OrgGroupPermissionPersistence.class)
2104 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2105 @BeanReference(type = OrgGroupRolePersistence.class)
2106 protected OrgGroupRolePersistence orgGroupRolePersistence;
2107 @BeanReference(type = OrgLaborPersistence.class)
2108 protected OrgLaborPersistence orgLaborPersistence;
2109 @BeanReference(type = PasswordPolicyPersistence.class)
2110 protected PasswordPolicyPersistence passwordPolicyPersistence;
2111 @BeanReference(type = PasswordPolicyRelPersistence.class)
2112 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2113 @BeanReference(type = PasswordTrackerPersistence.class)
2114 protected PasswordTrackerPersistence passwordTrackerPersistence;
2115 @BeanReference(type = PermissionPersistence.class)
2116 protected PermissionPersistence permissionPersistence;
2117 @BeanReference(type = PhonePersistence.class)
2118 protected PhonePersistence phonePersistence;
2119 @BeanReference(type = PluginSettingPersistence.class)
2120 protected PluginSettingPersistence pluginSettingPersistence;
2121 @BeanReference(type = PortalPreferencesPersistence.class)
2122 protected PortalPreferencesPersistence portalPreferencesPersistence;
2123 @BeanReference(type = PortletPersistence.class)
2124 protected PortletPersistence portletPersistence;
2125 @BeanReference(type = PortletItemPersistence.class)
2126 protected PortletItemPersistence portletItemPersistence;
2127 @BeanReference(type = PortletPreferencesPersistence.class)
2128 protected PortletPreferencesPersistence portletPreferencesPersistence;
2129 @BeanReference(type = RegionPersistence.class)
2130 protected RegionPersistence regionPersistence;
2131 @BeanReference(type = ReleasePersistence.class)
2132 protected ReleasePersistence releasePersistence;
2133 @BeanReference(type = RepositoryPersistence.class)
2134 protected RepositoryPersistence repositoryPersistence;
2135 @BeanReference(type = RepositoryEntryPersistence.class)
2136 protected RepositoryEntryPersistence repositoryEntryPersistence;
2137 @BeanReference(type = ResourcePersistence.class)
2138 protected ResourcePersistence resourcePersistence;
2139 @BeanReference(type = ResourceActionPersistence.class)
2140 protected ResourceActionPersistence resourceActionPersistence;
2141 @BeanReference(type = ResourceBlockPersistence.class)
2142 protected ResourceBlockPersistence resourceBlockPersistence;
2143 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2144 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2145 @BeanReference(type = ResourceCodePersistence.class)
2146 protected ResourceCodePersistence resourceCodePersistence;
2147 @BeanReference(type = ResourcePermissionPersistence.class)
2148 protected ResourcePermissionPersistence resourcePermissionPersistence;
2149 @BeanReference(type = ResourceTypePermissionPersistence.class)
2150 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2151 @BeanReference(type = RolePersistence.class)
2152 protected RolePersistence rolePersistence;
2153 @BeanReference(type = ServiceComponentPersistence.class)
2154 protected ServiceComponentPersistence serviceComponentPersistence;
2155 @BeanReference(type = ShardPersistence.class)
2156 protected ShardPersistence shardPersistence;
2157 @BeanReference(type = SubscriptionPersistence.class)
2158 protected SubscriptionPersistence subscriptionPersistence;
2159 @BeanReference(type = TeamPersistence.class)
2160 protected TeamPersistence teamPersistence;
2161 @BeanReference(type = TicketPersistence.class)
2162 protected TicketPersistence ticketPersistence;
2163 @BeanReference(type = UserPersistence.class)
2164 protected UserPersistence userPersistence;
2165 @BeanReference(type = UserGroupPersistence.class)
2166 protected UserGroupPersistence userGroupPersistence;
2167 @BeanReference(type = UserGroupGroupRolePersistence.class)
2168 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2169 @BeanReference(type = UserGroupRolePersistence.class)
2170 protected UserGroupRolePersistence userGroupRolePersistence;
2171 @BeanReference(type = UserIdMapperPersistence.class)
2172 protected UserIdMapperPersistence userIdMapperPersistence;
2173 @BeanReference(type = UserNotificationEventPersistence.class)
2174 protected UserNotificationEventPersistence userNotificationEventPersistence;
2175 @BeanReference(type = UserTrackerPersistence.class)
2176 protected UserTrackerPersistence userTrackerPersistence;
2177 @BeanReference(type = UserTrackerPathPersistence.class)
2178 protected UserTrackerPathPersistence userTrackerPathPersistence;
2179 @BeanReference(type = VirtualHostPersistence.class)
2180 protected VirtualHostPersistence virtualHostPersistence;
2181 @BeanReference(type = WebDAVPropsPersistence.class)
2182 protected WebDAVPropsPersistence webDAVPropsPersistence;
2183 @BeanReference(type = WebsitePersistence.class)
2184 protected WebsitePersistence websitePersistence;
2185 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2186 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2187 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2188 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2189 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent";
2190 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT_WHERE = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent WHERE ";
2191 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent";
2192 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT_WHERE = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent WHERE ";
2193 private static final String _FINDER_COLUMN_UUID_UUID_1 = "userNotificationEvent.uuid IS NULL";
2194 private static final String _FINDER_COLUMN_UUID_UUID_2 = "userNotificationEvent.uuid = ?";
2195 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = ?)";
2196 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userNotificationEvent.userId = ?";
2197 private static final String _FINDER_COLUMN_U_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
2198 private static final String _FINDER_COLUMN_U_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
2199 private static final String _ORDER_BY_ENTITY_ALIAS = "userNotificationEvent.";
2200 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserNotificationEvent exists with the primary key ";
2201 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserNotificationEvent exists with the key {";
2202 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2203 private static Log _log = LogFactoryUtil.getLog(UserNotificationEventPersistenceImpl.class);
2204 private static UserNotificationEvent _nullUserNotificationEvent = new UserNotificationEventImpl() {
2205 @Override
2206 public Object clone() {
2207 return this;
2208 }
2209
2210 @Override
2211 public CacheModel<UserNotificationEvent> toCacheModel() {
2212 return _nullUserNotificationEventCacheModel;
2213 }
2214 };
2215
2216 private static CacheModel<UserNotificationEvent> _nullUserNotificationEventCacheModel =
2217 new CacheModel<UserNotificationEvent>() {
2218 public UserNotificationEvent toEntityModel() {
2219 return _nullUserNotificationEvent;
2220 }
2221 };
2222 }