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_UUID_C = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
097 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
098 UserNotificationEventImpl.class,
099 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
100 new String[] {
101 String.class.getName(), 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_UUID_C =
107 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
108 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
109 UserNotificationEventImpl.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
111 new String[] { String.class.getName(), Long.class.getName() },
112 UserNotificationEventModelImpl.UUID_COLUMN_BITMASK |
113 UserNotificationEventModelImpl.COMPANYID_COLUMN_BITMASK);
114 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
115 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
116 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
117 new String[] { String.class.getName(), Long.class.getName() });
118 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
119 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
120 UserNotificationEventImpl.class,
121 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
122 new String[] {
123 Long.class.getName(),
124
125 "java.lang.Integer", "java.lang.Integer",
126 "com.liferay.portal.kernel.util.OrderByComparator"
127 });
128 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
129 new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
130 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
131 UserNotificationEventImpl.class,
132 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
133 new String[] { Long.class.getName() },
134 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK);
135 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
136 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
137 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
138 new String[] { Long.class.getName() });
139 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
140 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
141 UserNotificationEventImpl.class,
142 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_A",
143 new String[] {
144 Long.class.getName(), Boolean.class.getName(),
145
146 "java.lang.Integer", "java.lang.Integer",
147 "com.liferay.portal.kernel.util.OrderByComparator"
148 });
149 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
150 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
151 UserNotificationEventImpl.class,
152 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_A",
153 new String[] { Long.class.getName(), Boolean.class.getName() },
154 UserNotificationEventModelImpl.USERID_COLUMN_BITMASK |
155 UserNotificationEventModelImpl.ARCHIVED_COLUMN_BITMASK);
156 public static final FinderPath FINDER_PATH_COUNT_BY_U_A = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
157 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
158 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_A",
159 new String[] { Long.class.getName(), Boolean.class.getName() });
160 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
161 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
162 UserNotificationEventImpl.class,
163 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
164 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
165 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED,
166 UserNotificationEventImpl.class,
167 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
168 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
169 UserNotificationEventModelImpl.FINDER_CACHE_ENABLED, Long.class,
170 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
171
172
177 public void cacheResult(UserNotificationEvent userNotificationEvent) {
178 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
179 UserNotificationEventImpl.class,
180 userNotificationEvent.getPrimaryKey(), userNotificationEvent);
181
182 userNotificationEvent.resetOriginalValues();
183 }
184
185
190 public void cacheResult(List<UserNotificationEvent> userNotificationEvents) {
191 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
192 if (EntityCacheUtil.getResult(
193 UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
194 UserNotificationEventImpl.class,
195 userNotificationEvent.getPrimaryKey()) == null) {
196 cacheResult(userNotificationEvent);
197 }
198 else {
199 userNotificationEvent.resetOriginalValues();
200 }
201 }
202 }
203
204
211 @Override
212 public void clearCache() {
213 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
214 CacheRegistryUtil.clear(UserNotificationEventImpl.class.getName());
215 }
216
217 EntityCacheUtil.clearCache(UserNotificationEventImpl.class.getName());
218
219 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
220 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
221 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
222 }
223
224
231 @Override
232 public void clearCache(UserNotificationEvent userNotificationEvent) {
233 EntityCacheUtil.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
234 UserNotificationEventImpl.class,
235 userNotificationEvent.getPrimaryKey());
236
237 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
238 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
239 }
240
241 @Override
242 public void clearCache(List<UserNotificationEvent> userNotificationEvents) {
243 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
244 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
245
246 for (UserNotificationEvent userNotificationEvent : userNotificationEvents) {
247 EntityCacheUtil.removeResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
248 UserNotificationEventImpl.class,
249 userNotificationEvent.getPrimaryKey());
250 }
251 }
252
253
259 public UserNotificationEvent create(long userNotificationEventId) {
260 UserNotificationEvent userNotificationEvent = new UserNotificationEventImpl();
261
262 userNotificationEvent.setNew(true);
263 userNotificationEvent.setPrimaryKey(userNotificationEventId);
264
265 String uuid = PortalUUIDUtil.generate();
266
267 userNotificationEvent.setUuid(uuid);
268
269 return userNotificationEvent;
270 }
271
272
280 public UserNotificationEvent remove(long userNotificationEventId)
281 throws NoSuchUserNotificationEventException, SystemException {
282 return remove(Long.valueOf(userNotificationEventId));
283 }
284
285
293 @Override
294 public UserNotificationEvent remove(Serializable primaryKey)
295 throws NoSuchUserNotificationEventException, SystemException {
296 Session session = null;
297
298 try {
299 session = openSession();
300
301 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
302 primaryKey);
303
304 if (userNotificationEvent == null) {
305 if (_log.isWarnEnabled()) {
306 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
307 }
308
309 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
310 primaryKey);
311 }
312
313 return remove(userNotificationEvent);
314 }
315 catch (NoSuchUserNotificationEventException nsee) {
316 throw nsee;
317 }
318 catch (Exception e) {
319 throw processException(e);
320 }
321 finally {
322 closeSession(session);
323 }
324 }
325
326 @Override
327 protected UserNotificationEvent removeImpl(
328 UserNotificationEvent userNotificationEvent) throws SystemException {
329 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
330
331 Session session = null;
332
333 try {
334 session = openSession();
335
336 if (userNotificationEvent.isCachedModel()) {
337 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
338 userNotificationEvent.getPrimaryKeyObj());
339 }
340
341 session.delete(userNotificationEvent);
342 }
343 catch (Exception e) {
344 throw processException(e);
345 }
346 finally {
347 closeSession(session);
348 }
349
350 clearCache(userNotificationEvent);
351
352 return userNotificationEvent;
353 }
354
355 @Override
356 public UserNotificationEvent updateImpl(
357 com.liferay.portal.model.UserNotificationEvent userNotificationEvent)
358 throws SystemException {
359 userNotificationEvent = toUnwrappedModel(userNotificationEvent);
360
361 boolean isNew = userNotificationEvent.isNew();
362
363 UserNotificationEventModelImpl userNotificationEventModelImpl = (UserNotificationEventModelImpl)userNotificationEvent;
364
365 if (Validator.isNull(userNotificationEvent.getUuid())) {
366 String uuid = PortalUUIDUtil.generate();
367
368 userNotificationEvent.setUuid(uuid);
369 }
370
371 Session session = null;
372
373 try {
374 session = openSession();
375
376 if (userNotificationEvent.isNew()) {
377 session.save(userNotificationEvent);
378
379 userNotificationEvent.setNew(false);
380 }
381 else {
382 session.merge(userNotificationEvent);
383 }
384 }
385 catch (Exception e) {
386 throw processException(e);
387 }
388 finally {
389 closeSession(session);
390 }
391
392 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
393
394 if (isNew || !UserNotificationEventModelImpl.COLUMN_BITMASK_ENABLED) {
395 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
396 }
397
398 else {
399 if ((userNotificationEventModelImpl.getColumnBitmask() &
400 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
401 Object[] args = new Object[] {
402 userNotificationEventModelImpl.getOriginalUuid()
403 };
404
405 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
406 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
407 args);
408
409 args = new Object[] { userNotificationEventModelImpl.getUuid() };
410
411 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
412 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
413 args);
414 }
415
416 if ((userNotificationEventModelImpl.getColumnBitmask() &
417 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
418 Object[] args = new Object[] {
419 userNotificationEventModelImpl.getOriginalUuid(),
420 Long.valueOf(userNotificationEventModelImpl.getOriginalCompanyId())
421 };
422
423 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
424 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
425 args);
426
427 args = new Object[] {
428 userNotificationEventModelImpl.getUuid(),
429 Long.valueOf(userNotificationEventModelImpl.getCompanyId())
430 };
431
432 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
433 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
434 args);
435 }
436
437 if ((userNotificationEventModelImpl.getColumnBitmask() &
438 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
439 Object[] args = new Object[] {
440 Long.valueOf(userNotificationEventModelImpl.getOriginalUserId())
441 };
442
443 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
444 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
445 args);
446
447 args = new Object[] {
448 Long.valueOf(userNotificationEventModelImpl.getUserId())
449 };
450
451 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
452 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
453 args);
454 }
455
456 if ((userNotificationEventModelImpl.getColumnBitmask() &
457 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A.getColumnBitmask()) != 0) {
458 Object[] args = new Object[] {
459 Long.valueOf(userNotificationEventModelImpl.getOriginalUserId()),
460 Boolean.valueOf(userNotificationEventModelImpl.getOriginalArchived())
461 };
462
463 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
464 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
465 args);
466
467 args = new Object[] {
468 Long.valueOf(userNotificationEventModelImpl.getUserId()),
469 Boolean.valueOf(userNotificationEventModelImpl.getArchived())
470 };
471
472 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_A, args);
473 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A,
474 args);
475 }
476 }
477
478 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
479 UserNotificationEventImpl.class,
480 userNotificationEvent.getPrimaryKey(), userNotificationEvent);
481
482 return userNotificationEvent;
483 }
484
485 protected UserNotificationEvent toUnwrappedModel(
486 UserNotificationEvent userNotificationEvent) {
487 if (userNotificationEvent instanceof UserNotificationEventImpl) {
488 return userNotificationEvent;
489 }
490
491 UserNotificationEventImpl userNotificationEventImpl = new UserNotificationEventImpl();
492
493 userNotificationEventImpl.setNew(userNotificationEvent.isNew());
494 userNotificationEventImpl.setPrimaryKey(userNotificationEvent.getPrimaryKey());
495
496 userNotificationEventImpl.setUuid(userNotificationEvent.getUuid());
497 userNotificationEventImpl.setUserNotificationEventId(userNotificationEvent.getUserNotificationEventId());
498 userNotificationEventImpl.setCompanyId(userNotificationEvent.getCompanyId());
499 userNotificationEventImpl.setUserId(userNotificationEvent.getUserId());
500 userNotificationEventImpl.setType(userNotificationEvent.getType());
501 userNotificationEventImpl.setTimestamp(userNotificationEvent.getTimestamp());
502 userNotificationEventImpl.setDeliverBy(userNotificationEvent.getDeliverBy());
503 userNotificationEventImpl.setPayload(userNotificationEvent.getPayload());
504 userNotificationEventImpl.setArchived(userNotificationEvent.isArchived());
505
506 return userNotificationEventImpl;
507 }
508
509
517 @Override
518 public UserNotificationEvent findByPrimaryKey(Serializable primaryKey)
519 throws NoSuchModelException, SystemException {
520 return findByPrimaryKey(((Long)primaryKey).longValue());
521 }
522
523
531 public UserNotificationEvent findByPrimaryKey(long userNotificationEventId)
532 throws NoSuchUserNotificationEventException, SystemException {
533 UserNotificationEvent userNotificationEvent = fetchByPrimaryKey(userNotificationEventId);
534
535 if (userNotificationEvent == null) {
536 if (_log.isWarnEnabled()) {
537 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
538 userNotificationEventId);
539 }
540
541 throw new NoSuchUserNotificationEventException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
542 userNotificationEventId);
543 }
544
545 return userNotificationEvent;
546 }
547
548
555 @Override
556 public UserNotificationEvent fetchByPrimaryKey(Serializable primaryKey)
557 throws SystemException {
558 return fetchByPrimaryKey(((Long)primaryKey).longValue());
559 }
560
561
568 public UserNotificationEvent fetchByPrimaryKey(long userNotificationEventId)
569 throws SystemException {
570 UserNotificationEvent userNotificationEvent = (UserNotificationEvent)EntityCacheUtil.getResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
571 UserNotificationEventImpl.class, userNotificationEventId);
572
573 if (userNotificationEvent == _nullUserNotificationEvent) {
574 return null;
575 }
576
577 if (userNotificationEvent == null) {
578 Session session = null;
579
580 boolean hasException = false;
581
582 try {
583 session = openSession();
584
585 userNotificationEvent = (UserNotificationEvent)session.get(UserNotificationEventImpl.class,
586 Long.valueOf(userNotificationEventId));
587 }
588 catch (Exception e) {
589 hasException = true;
590
591 throw processException(e);
592 }
593 finally {
594 if (userNotificationEvent != null) {
595 cacheResult(userNotificationEvent);
596 }
597 else if (!hasException) {
598 EntityCacheUtil.putResult(UserNotificationEventModelImpl.ENTITY_CACHE_ENABLED,
599 UserNotificationEventImpl.class,
600 userNotificationEventId, _nullUserNotificationEvent);
601 }
602
603 closeSession(session);
604 }
605 }
606
607 return userNotificationEvent;
608 }
609
610
617 public List<UserNotificationEvent> findByUuid(String uuid)
618 throws SystemException {
619 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
620 }
621
622
635 public List<UserNotificationEvent> findByUuid(String uuid, int start,
636 int end) throws SystemException {
637 return findByUuid(uuid, start, end, null);
638 }
639
640
654 public List<UserNotificationEvent> findByUuid(String uuid, int start,
655 int end, OrderByComparator orderByComparator) throws SystemException {
656 FinderPath finderPath = null;
657 Object[] finderArgs = null;
658
659 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
660 (orderByComparator == null)) {
661 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
662 finderArgs = new Object[] { uuid };
663 }
664 else {
665 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
666 finderArgs = new Object[] { uuid, start, end, orderByComparator };
667 }
668
669 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
670 finderArgs, this);
671
672 if ((list != null) && !list.isEmpty()) {
673 for (UserNotificationEvent userNotificationEvent : list) {
674 if (!Validator.equals(uuid, userNotificationEvent.getUuid())) {
675 list = null;
676
677 break;
678 }
679 }
680 }
681
682 if (list == null) {
683 StringBundler query = null;
684
685 if (orderByComparator != null) {
686 query = new StringBundler(3 +
687 (orderByComparator.getOrderByFields().length * 3));
688 }
689 else {
690 query = new StringBundler(3);
691 }
692
693 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
694
695 if (uuid == null) {
696 query.append(_FINDER_COLUMN_UUID_UUID_1);
697 }
698 else {
699 if (uuid.equals(StringPool.BLANK)) {
700 query.append(_FINDER_COLUMN_UUID_UUID_3);
701 }
702 else {
703 query.append(_FINDER_COLUMN_UUID_UUID_2);
704 }
705 }
706
707 if (orderByComparator != null) {
708 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
709 orderByComparator);
710 }
711
712 else {
713 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
714 }
715
716 String sql = query.toString();
717
718 Session session = null;
719
720 try {
721 session = openSession();
722
723 Query q = session.createQuery(sql);
724
725 QueryPos qPos = QueryPos.getInstance(q);
726
727 if (uuid != null) {
728 qPos.add(uuid);
729 }
730
731 list = (List<UserNotificationEvent>)QueryUtil.list(q,
732 getDialect(), start, end);
733 }
734 catch (Exception e) {
735 throw processException(e);
736 }
737 finally {
738 if (list == null) {
739 FinderCacheUtil.removeResult(finderPath, finderArgs);
740 }
741 else {
742 cacheResult(list);
743
744 FinderCacheUtil.putResult(finderPath, finderArgs, list);
745 }
746
747 closeSession(session);
748 }
749 }
750
751 return list;
752 }
753
754
763 public UserNotificationEvent findByUuid_First(String uuid,
764 OrderByComparator orderByComparator)
765 throws NoSuchUserNotificationEventException, SystemException {
766 UserNotificationEvent userNotificationEvent = fetchByUuid_First(uuid,
767 orderByComparator);
768
769 if (userNotificationEvent != null) {
770 return userNotificationEvent;
771 }
772
773 StringBundler msg = new StringBundler(4);
774
775 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
776
777 msg.append("uuid=");
778 msg.append(uuid);
779
780 msg.append(StringPool.CLOSE_CURLY_BRACE);
781
782 throw new NoSuchUserNotificationEventException(msg.toString());
783 }
784
785
793 public UserNotificationEvent fetchByUuid_First(String uuid,
794 OrderByComparator orderByComparator) throws SystemException {
795 List<UserNotificationEvent> list = findByUuid(uuid, 0, 1,
796 orderByComparator);
797
798 if (!list.isEmpty()) {
799 return list.get(0);
800 }
801
802 return null;
803 }
804
805
814 public UserNotificationEvent findByUuid_Last(String uuid,
815 OrderByComparator orderByComparator)
816 throws NoSuchUserNotificationEventException, SystemException {
817 UserNotificationEvent userNotificationEvent = fetchByUuid_Last(uuid,
818 orderByComparator);
819
820 if (userNotificationEvent != null) {
821 return userNotificationEvent;
822 }
823
824 StringBundler msg = new StringBundler(4);
825
826 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
827
828 msg.append("uuid=");
829 msg.append(uuid);
830
831 msg.append(StringPool.CLOSE_CURLY_BRACE);
832
833 throw new NoSuchUserNotificationEventException(msg.toString());
834 }
835
836
844 public UserNotificationEvent fetchByUuid_Last(String uuid,
845 OrderByComparator orderByComparator) throws SystemException {
846 int count = countByUuid(uuid);
847
848 List<UserNotificationEvent> list = findByUuid(uuid, count - 1, count,
849 orderByComparator);
850
851 if (!list.isEmpty()) {
852 return list.get(0);
853 }
854
855 return null;
856 }
857
858
868 public UserNotificationEvent[] findByUuid_PrevAndNext(
869 long userNotificationEventId, String uuid,
870 OrderByComparator orderByComparator)
871 throws NoSuchUserNotificationEventException, SystemException {
872 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
873
874 Session session = null;
875
876 try {
877 session = openSession();
878
879 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
880
881 array[0] = getByUuid_PrevAndNext(session, userNotificationEvent,
882 uuid, orderByComparator, true);
883
884 array[1] = userNotificationEvent;
885
886 array[2] = getByUuid_PrevAndNext(session, userNotificationEvent,
887 uuid, orderByComparator, false);
888
889 return array;
890 }
891 catch (Exception e) {
892 throw processException(e);
893 }
894 finally {
895 closeSession(session);
896 }
897 }
898
899 protected UserNotificationEvent getByUuid_PrevAndNext(Session session,
900 UserNotificationEvent userNotificationEvent, String uuid,
901 OrderByComparator orderByComparator, boolean previous) {
902 StringBundler query = null;
903
904 if (orderByComparator != null) {
905 query = new StringBundler(6 +
906 (orderByComparator.getOrderByFields().length * 6));
907 }
908 else {
909 query = new StringBundler(3);
910 }
911
912 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
913
914 if (uuid == null) {
915 query.append(_FINDER_COLUMN_UUID_UUID_1);
916 }
917 else {
918 if (uuid.equals(StringPool.BLANK)) {
919 query.append(_FINDER_COLUMN_UUID_UUID_3);
920 }
921 else {
922 query.append(_FINDER_COLUMN_UUID_UUID_2);
923 }
924 }
925
926 if (orderByComparator != null) {
927 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
928
929 if (orderByConditionFields.length > 0) {
930 query.append(WHERE_AND);
931 }
932
933 for (int i = 0; i < orderByConditionFields.length; i++) {
934 query.append(_ORDER_BY_ENTITY_ALIAS);
935 query.append(orderByConditionFields[i]);
936
937 if ((i + 1) < orderByConditionFields.length) {
938 if (orderByComparator.isAscending() ^ previous) {
939 query.append(WHERE_GREATER_THAN_HAS_NEXT);
940 }
941 else {
942 query.append(WHERE_LESSER_THAN_HAS_NEXT);
943 }
944 }
945 else {
946 if (orderByComparator.isAscending() ^ previous) {
947 query.append(WHERE_GREATER_THAN);
948 }
949 else {
950 query.append(WHERE_LESSER_THAN);
951 }
952 }
953 }
954
955 query.append(ORDER_BY_CLAUSE);
956
957 String[] orderByFields = orderByComparator.getOrderByFields();
958
959 for (int i = 0; i < orderByFields.length; i++) {
960 query.append(_ORDER_BY_ENTITY_ALIAS);
961 query.append(orderByFields[i]);
962
963 if ((i + 1) < orderByFields.length) {
964 if (orderByComparator.isAscending() ^ previous) {
965 query.append(ORDER_BY_ASC_HAS_NEXT);
966 }
967 else {
968 query.append(ORDER_BY_DESC_HAS_NEXT);
969 }
970 }
971 else {
972 if (orderByComparator.isAscending() ^ previous) {
973 query.append(ORDER_BY_ASC);
974 }
975 else {
976 query.append(ORDER_BY_DESC);
977 }
978 }
979 }
980 }
981
982 else {
983 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
984 }
985
986 String sql = query.toString();
987
988 Query q = session.createQuery(sql);
989
990 q.setFirstResult(0);
991 q.setMaxResults(2);
992
993 QueryPos qPos = QueryPos.getInstance(q);
994
995 if (uuid != null) {
996 qPos.add(uuid);
997 }
998
999 if (orderByComparator != null) {
1000 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1001
1002 for (Object value : values) {
1003 qPos.add(value);
1004 }
1005 }
1006
1007 List<UserNotificationEvent> list = q.list();
1008
1009 if (list.size() == 2) {
1010 return list.get(1);
1011 }
1012 else {
1013 return null;
1014 }
1015 }
1016
1017
1025 public List<UserNotificationEvent> findByUuid_C(String uuid, long companyId)
1026 throws SystemException {
1027 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1028 QueryUtil.ALL_POS, null);
1029 }
1030
1031
1045 public List<UserNotificationEvent> findByUuid_C(String uuid,
1046 long companyId, int start, int end) throws SystemException {
1047 return findByUuid_C(uuid, companyId, start, end, null);
1048 }
1049
1050
1065 public List<UserNotificationEvent> findByUuid_C(String uuid,
1066 long companyId, int start, int end, OrderByComparator orderByComparator)
1067 throws SystemException {
1068 FinderPath finderPath = null;
1069 Object[] finderArgs = null;
1070
1071 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1072 (orderByComparator == null)) {
1073 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1074 finderArgs = new Object[] { uuid, companyId };
1075 }
1076 else {
1077 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1078 finderArgs = new Object[] {
1079 uuid, companyId,
1080
1081 start, end, orderByComparator
1082 };
1083 }
1084
1085 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
1086 finderArgs, this);
1087
1088 if ((list != null) && !list.isEmpty()) {
1089 for (UserNotificationEvent userNotificationEvent : list) {
1090 if (!Validator.equals(uuid, userNotificationEvent.getUuid()) ||
1091 (companyId != userNotificationEvent.getCompanyId())) {
1092 list = null;
1093
1094 break;
1095 }
1096 }
1097 }
1098
1099 if (list == null) {
1100 StringBundler query = null;
1101
1102 if (orderByComparator != null) {
1103 query = new StringBundler(4 +
1104 (orderByComparator.getOrderByFields().length * 3));
1105 }
1106 else {
1107 query = new StringBundler(4);
1108 }
1109
1110 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1111
1112 if (uuid == null) {
1113 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1114 }
1115 else {
1116 if (uuid.equals(StringPool.BLANK)) {
1117 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1118 }
1119 else {
1120 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1121 }
1122 }
1123
1124 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1125
1126 if (orderByComparator != null) {
1127 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1128 orderByComparator);
1129 }
1130
1131 else {
1132 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1133 }
1134
1135 String sql = query.toString();
1136
1137 Session session = null;
1138
1139 try {
1140 session = openSession();
1141
1142 Query q = session.createQuery(sql);
1143
1144 QueryPos qPos = QueryPos.getInstance(q);
1145
1146 if (uuid != null) {
1147 qPos.add(uuid);
1148 }
1149
1150 qPos.add(companyId);
1151
1152 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1153 getDialect(), start, end);
1154 }
1155 catch (Exception e) {
1156 throw processException(e);
1157 }
1158 finally {
1159 if (list == null) {
1160 FinderCacheUtil.removeResult(finderPath, finderArgs);
1161 }
1162 else {
1163 cacheResult(list);
1164
1165 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1166 }
1167
1168 closeSession(session);
1169 }
1170 }
1171
1172 return list;
1173 }
1174
1175
1185 public UserNotificationEvent findByUuid_C_First(String uuid,
1186 long companyId, OrderByComparator orderByComparator)
1187 throws NoSuchUserNotificationEventException, SystemException {
1188 UserNotificationEvent userNotificationEvent = fetchByUuid_C_First(uuid,
1189 companyId, orderByComparator);
1190
1191 if (userNotificationEvent != null) {
1192 return userNotificationEvent;
1193 }
1194
1195 StringBundler msg = new StringBundler(6);
1196
1197 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1198
1199 msg.append("uuid=");
1200 msg.append(uuid);
1201
1202 msg.append(", companyId=");
1203 msg.append(companyId);
1204
1205 msg.append(StringPool.CLOSE_CURLY_BRACE);
1206
1207 throw new NoSuchUserNotificationEventException(msg.toString());
1208 }
1209
1210
1219 public UserNotificationEvent fetchByUuid_C_First(String uuid,
1220 long companyId, OrderByComparator orderByComparator)
1221 throws SystemException {
1222 List<UserNotificationEvent> list = findByUuid_C(uuid, companyId, 0, 1,
1223 orderByComparator);
1224
1225 if (!list.isEmpty()) {
1226 return list.get(0);
1227 }
1228
1229 return null;
1230 }
1231
1232
1242 public UserNotificationEvent findByUuid_C_Last(String uuid, long companyId,
1243 OrderByComparator orderByComparator)
1244 throws NoSuchUserNotificationEventException, SystemException {
1245 UserNotificationEvent userNotificationEvent = fetchByUuid_C_Last(uuid,
1246 companyId, orderByComparator);
1247
1248 if (userNotificationEvent != null) {
1249 return userNotificationEvent;
1250 }
1251
1252 StringBundler msg = new StringBundler(6);
1253
1254 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1255
1256 msg.append("uuid=");
1257 msg.append(uuid);
1258
1259 msg.append(", companyId=");
1260 msg.append(companyId);
1261
1262 msg.append(StringPool.CLOSE_CURLY_BRACE);
1263
1264 throw new NoSuchUserNotificationEventException(msg.toString());
1265 }
1266
1267
1276 public UserNotificationEvent fetchByUuid_C_Last(String uuid,
1277 long companyId, OrderByComparator orderByComparator)
1278 throws SystemException {
1279 int count = countByUuid_C(uuid, companyId);
1280
1281 List<UserNotificationEvent> list = findByUuid_C(uuid, companyId,
1282 count - 1, count, orderByComparator);
1283
1284 if (!list.isEmpty()) {
1285 return list.get(0);
1286 }
1287
1288 return null;
1289 }
1290
1291
1302 public UserNotificationEvent[] findByUuid_C_PrevAndNext(
1303 long userNotificationEventId, String uuid, long companyId,
1304 OrderByComparator orderByComparator)
1305 throws NoSuchUserNotificationEventException, SystemException {
1306 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
1307
1308 Session session = null;
1309
1310 try {
1311 session = openSession();
1312
1313 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1314
1315 array[0] = getByUuid_C_PrevAndNext(session, userNotificationEvent,
1316 uuid, companyId, orderByComparator, true);
1317
1318 array[1] = userNotificationEvent;
1319
1320 array[2] = getByUuid_C_PrevAndNext(session, userNotificationEvent,
1321 uuid, companyId, orderByComparator, false);
1322
1323 return array;
1324 }
1325 catch (Exception e) {
1326 throw processException(e);
1327 }
1328 finally {
1329 closeSession(session);
1330 }
1331 }
1332
1333 protected UserNotificationEvent getByUuid_C_PrevAndNext(Session session,
1334 UserNotificationEvent userNotificationEvent, String uuid,
1335 long companyId, OrderByComparator orderByComparator, boolean previous) {
1336 StringBundler query = null;
1337
1338 if (orderByComparator != null) {
1339 query = new StringBundler(6 +
1340 (orderByComparator.getOrderByFields().length * 6));
1341 }
1342 else {
1343 query = new StringBundler(3);
1344 }
1345
1346 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1347
1348 if (uuid == null) {
1349 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1350 }
1351 else {
1352 if (uuid.equals(StringPool.BLANK)) {
1353 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1354 }
1355 else {
1356 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1357 }
1358 }
1359
1360 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1361
1362 if (orderByComparator != null) {
1363 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1364
1365 if (orderByConditionFields.length > 0) {
1366 query.append(WHERE_AND);
1367 }
1368
1369 for (int i = 0; i < orderByConditionFields.length; i++) {
1370 query.append(_ORDER_BY_ENTITY_ALIAS);
1371 query.append(orderByConditionFields[i]);
1372
1373 if ((i + 1) < orderByConditionFields.length) {
1374 if (orderByComparator.isAscending() ^ previous) {
1375 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1376 }
1377 else {
1378 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1379 }
1380 }
1381 else {
1382 if (orderByComparator.isAscending() ^ previous) {
1383 query.append(WHERE_GREATER_THAN);
1384 }
1385 else {
1386 query.append(WHERE_LESSER_THAN);
1387 }
1388 }
1389 }
1390
1391 query.append(ORDER_BY_CLAUSE);
1392
1393 String[] orderByFields = orderByComparator.getOrderByFields();
1394
1395 for (int i = 0; i < orderByFields.length; i++) {
1396 query.append(_ORDER_BY_ENTITY_ALIAS);
1397 query.append(orderByFields[i]);
1398
1399 if ((i + 1) < orderByFields.length) {
1400 if (orderByComparator.isAscending() ^ previous) {
1401 query.append(ORDER_BY_ASC_HAS_NEXT);
1402 }
1403 else {
1404 query.append(ORDER_BY_DESC_HAS_NEXT);
1405 }
1406 }
1407 else {
1408 if (orderByComparator.isAscending() ^ previous) {
1409 query.append(ORDER_BY_ASC);
1410 }
1411 else {
1412 query.append(ORDER_BY_DESC);
1413 }
1414 }
1415 }
1416 }
1417
1418 else {
1419 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1420 }
1421
1422 String sql = query.toString();
1423
1424 Query q = session.createQuery(sql);
1425
1426 q.setFirstResult(0);
1427 q.setMaxResults(2);
1428
1429 QueryPos qPos = QueryPos.getInstance(q);
1430
1431 if (uuid != null) {
1432 qPos.add(uuid);
1433 }
1434
1435 qPos.add(companyId);
1436
1437 if (orderByComparator != null) {
1438 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1439
1440 for (Object value : values) {
1441 qPos.add(value);
1442 }
1443 }
1444
1445 List<UserNotificationEvent> list = q.list();
1446
1447 if (list.size() == 2) {
1448 return list.get(1);
1449 }
1450 else {
1451 return null;
1452 }
1453 }
1454
1455
1462 public List<UserNotificationEvent> findByUserId(long userId)
1463 throws SystemException {
1464 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1465 }
1466
1467
1480 public List<UserNotificationEvent> findByUserId(long userId, int start,
1481 int end) throws SystemException {
1482 return findByUserId(userId, start, end, null);
1483 }
1484
1485
1499 public List<UserNotificationEvent> findByUserId(long userId, int start,
1500 int end, OrderByComparator orderByComparator) throws SystemException {
1501 FinderPath finderPath = null;
1502 Object[] finderArgs = null;
1503
1504 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1505 (orderByComparator == null)) {
1506 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1507 finderArgs = new Object[] { userId };
1508 }
1509 else {
1510 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1511 finderArgs = new Object[] { userId, start, end, orderByComparator };
1512 }
1513
1514 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
1515 finderArgs, this);
1516
1517 if ((list != null) && !list.isEmpty()) {
1518 for (UserNotificationEvent userNotificationEvent : list) {
1519 if ((userId != userNotificationEvent.getUserId())) {
1520 list = null;
1521
1522 break;
1523 }
1524 }
1525 }
1526
1527 if (list == null) {
1528 StringBundler query = null;
1529
1530 if (orderByComparator != null) {
1531 query = new StringBundler(3 +
1532 (orderByComparator.getOrderByFields().length * 3));
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 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1544 orderByComparator);
1545 }
1546
1547 else {
1548 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1549 }
1550
1551 String sql = query.toString();
1552
1553 Session session = null;
1554
1555 try {
1556 session = openSession();
1557
1558 Query q = session.createQuery(sql);
1559
1560 QueryPos qPos = QueryPos.getInstance(q);
1561
1562 qPos.add(userId);
1563
1564 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1565 getDialect(), start, end);
1566 }
1567 catch (Exception e) {
1568 throw processException(e);
1569 }
1570 finally {
1571 if (list == null) {
1572 FinderCacheUtil.removeResult(finderPath, finderArgs);
1573 }
1574 else {
1575 cacheResult(list);
1576
1577 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1578 }
1579
1580 closeSession(session);
1581 }
1582 }
1583
1584 return list;
1585 }
1586
1587
1596 public UserNotificationEvent findByUserId_First(long userId,
1597 OrderByComparator orderByComparator)
1598 throws NoSuchUserNotificationEventException, SystemException {
1599 UserNotificationEvent userNotificationEvent = fetchByUserId_First(userId,
1600 orderByComparator);
1601
1602 if (userNotificationEvent != null) {
1603 return userNotificationEvent;
1604 }
1605
1606 StringBundler msg = new StringBundler(4);
1607
1608 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1609
1610 msg.append("userId=");
1611 msg.append(userId);
1612
1613 msg.append(StringPool.CLOSE_CURLY_BRACE);
1614
1615 throw new NoSuchUserNotificationEventException(msg.toString());
1616 }
1617
1618
1626 public UserNotificationEvent fetchByUserId_First(long userId,
1627 OrderByComparator orderByComparator) throws SystemException {
1628 List<UserNotificationEvent> list = findByUserId(userId, 0, 1,
1629 orderByComparator);
1630
1631 if (!list.isEmpty()) {
1632 return list.get(0);
1633 }
1634
1635 return null;
1636 }
1637
1638
1647 public UserNotificationEvent findByUserId_Last(long userId,
1648 OrderByComparator orderByComparator)
1649 throws NoSuchUserNotificationEventException, SystemException {
1650 UserNotificationEvent userNotificationEvent = fetchByUserId_Last(userId,
1651 orderByComparator);
1652
1653 if (userNotificationEvent != null) {
1654 return userNotificationEvent;
1655 }
1656
1657 StringBundler msg = new StringBundler(4);
1658
1659 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1660
1661 msg.append("userId=");
1662 msg.append(userId);
1663
1664 msg.append(StringPool.CLOSE_CURLY_BRACE);
1665
1666 throw new NoSuchUserNotificationEventException(msg.toString());
1667 }
1668
1669
1677 public UserNotificationEvent fetchByUserId_Last(long userId,
1678 OrderByComparator orderByComparator) throws SystemException {
1679 int count = countByUserId(userId);
1680
1681 List<UserNotificationEvent> list = findByUserId(userId, count - 1,
1682 count, orderByComparator);
1683
1684 if (!list.isEmpty()) {
1685 return list.get(0);
1686 }
1687
1688 return null;
1689 }
1690
1691
1701 public UserNotificationEvent[] findByUserId_PrevAndNext(
1702 long userNotificationEventId, long userId,
1703 OrderByComparator orderByComparator)
1704 throws NoSuchUserNotificationEventException, SystemException {
1705 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
1706
1707 Session session = null;
1708
1709 try {
1710 session = openSession();
1711
1712 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
1713
1714 array[0] = getByUserId_PrevAndNext(session, userNotificationEvent,
1715 userId, orderByComparator, true);
1716
1717 array[1] = userNotificationEvent;
1718
1719 array[2] = getByUserId_PrevAndNext(session, userNotificationEvent,
1720 userId, orderByComparator, false);
1721
1722 return array;
1723 }
1724 catch (Exception e) {
1725 throw processException(e);
1726 }
1727 finally {
1728 closeSession(session);
1729 }
1730 }
1731
1732 protected UserNotificationEvent getByUserId_PrevAndNext(Session session,
1733 UserNotificationEvent userNotificationEvent, long userId,
1734 OrderByComparator orderByComparator, boolean previous) {
1735 StringBundler query = null;
1736
1737 if (orderByComparator != null) {
1738 query = new StringBundler(6 +
1739 (orderByComparator.getOrderByFields().length * 6));
1740 }
1741 else {
1742 query = new StringBundler(3);
1743 }
1744
1745 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1746
1747 query.append(_FINDER_COLUMN_USERID_USERID_2);
1748
1749 if (orderByComparator != null) {
1750 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1751
1752 if (orderByConditionFields.length > 0) {
1753 query.append(WHERE_AND);
1754 }
1755
1756 for (int i = 0; i < orderByConditionFields.length; i++) {
1757 query.append(_ORDER_BY_ENTITY_ALIAS);
1758 query.append(orderByConditionFields[i]);
1759
1760 if ((i + 1) < orderByConditionFields.length) {
1761 if (orderByComparator.isAscending() ^ previous) {
1762 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1763 }
1764 else {
1765 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1766 }
1767 }
1768 else {
1769 if (orderByComparator.isAscending() ^ previous) {
1770 query.append(WHERE_GREATER_THAN);
1771 }
1772 else {
1773 query.append(WHERE_LESSER_THAN);
1774 }
1775 }
1776 }
1777
1778 query.append(ORDER_BY_CLAUSE);
1779
1780 String[] orderByFields = orderByComparator.getOrderByFields();
1781
1782 for (int i = 0; i < orderByFields.length; i++) {
1783 query.append(_ORDER_BY_ENTITY_ALIAS);
1784 query.append(orderByFields[i]);
1785
1786 if ((i + 1) < orderByFields.length) {
1787 if (orderByComparator.isAscending() ^ previous) {
1788 query.append(ORDER_BY_ASC_HAS_NEXT);
1789 }
1790 else {
1791 query.append(ORDER_BY_DESC_HAS_NEXT);
1792 }
1793 }
1794 else {
1795 if (orderByComparator.isAscending() ^ previous) {
1796 query.append(ORDER_BY_ASC);
1797 }
1798 else {
1799 query.append(ORDER_BY_DESC);
1800 }
1801 }
1802 }
1803 }
1804
1805 else {
1806 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1807 }
1808
1809 String sql = query.toString();
1810
1811 Query q = session.createQuery(sql);
1812
1813 q.setFirstResult(0);
1814 q.setMaxResults(2);
1815
1816 QueryPos qPos = QueryPos.getInstance(q);
1817
1818 qPos.add(userId);
1819
1820 if (orderByComparator != null) {
1821 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
1822
1823 for (Object value : values) {
1824 qPos.add(value);
1825 }
1826 }
1827
1828 List<UserNotificationEvent> list = q.list();
1829
1830 if (list.size() == 2) {
1831 return list.get(1);
1832 }
1833 else {
1834 return null;
1835 }
1836 }
1837
1838
1846 public List<UserNotificationEvent> findByU_A(long userId, boolean archived)
1847 throws SystemException {
1848 return findByU_A(userId, archived, QueryUtil.ALL_POS,
1849 QueryUtil.ALL_POS, null);
1850 }
1851
1852
1866 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
1867 int start, int end) throws SystemException {
1868 return findByU_A(userId, archived, start, end, null);
1869 }
1870
1871
1886 public List<UserNotificationEvent> findByU_A(long userId, boolean archived,
1887 int start, int end, OrderByComparator orderByComparator)
1888 throws SystemException {
1889 FinderPath finderPath = null;
1890 Object[] finderArgs = null;
1891
1892 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1893 (orderByComparator == null)) {
1894 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_A;
1895 finderArgs = new Object[] { userId, archived };
1896 }
1897 else {
1898 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_A;
1899 finderArgs = new Object[] {
1900 userId, archived,
1901
1902 start, end, orderByComparator
1903 };
1904 }
1905
1906 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
1907 finderArgs, this);
1908
1909 if ((list != null) && !list.isEmpty()) {
1910 for (UserNotificationEvent userNotificationEvent : list) {
1911 if ((userId != userNotificationEvent.getUserId()) ||
1912 (archived != userNotificationEvent.getArchived())) {
1913 list = null;
1914
1915 break;
1916 }
1917 }
1918 }
1919
1920 if (list == null) {
1921 StringBundler query = null;
1922
1923 if (orderByComparator != null) {
1924 query = new StringBundler(4 +
1925 (orderByComparator.getOrderByFields().length * 3));
1926 }
1927 else {
1928 query = new StringBundler(4);
1929 }
1930
1931 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
1932
1933 query.append(_FINDER_COLUMN_U_A_USERID_2);
1934
1935 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
1936
1937 if (orderByComparator != null) {
1938 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1939 orderByComparator);
1940 }
1941
1942 else {
1943 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
1944 }
1945
1946 String sql = query.toString();
1947
1948 Session session = null;
1949
1950 try {
1951 session = openSession();
1952
1953 Query q = session.createQuery(sql);
1954
1955 QueryPos qPos = QueryPos.getInstance(q);
1956
1957 qPos.add(userId);
1958
1959 qPos.add(archived);
1960
1961 list = (List<UserNotificationEvent>)QueryUtil.list(q,
1962 getDialect(), start, end);
1963 }
1964 catch (Exception e) {
1965 throw processException(e);
1966 }
1967 finally {
1968 if (list == null) {
1969 FinderCacheUtil.removeResult(finderPath, finderArgs);
1970 }
1971 else {
1972 cacheResult(list);
1973
1974 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1975 }
1976
1977 closeSession(session);
1978 }
1979 }
1980
1981 return list;
1982 }
1983
1984
1994 public UserNotificationEvent findByU_A_First(long userId, boolean archived,
1995 OrderByComparator orderByComparator)
1996 throws NoSuchUserNotificationEventException, SystemException {
1997 UserNotificationEvent userNotificationEvent = fetchByU_A_First(userId,
1998 archived, orderByComparator);
1999
2000 if (userNotificationEvent != null) {
2001 return userNotificationEvent;
2002 }
2003
2004 StringBundler msg = new StringBundler(6);
2005
2006 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2007
2008 msg.append("userId=");
2009 msg.append(userId);
2010
2011 msg.append(", archived=");
2012 msg.append(archived);
2013
2014 msg.append(StringPool.CLOSE_CURLY_BRACE);
2015
2016 throw new NoSuchUserNotificationEventException(msg.toString());
2017 }
2018
2019
2028 public UserNotificationEvent fetchByU_A_First(long userId,
2029 boolean archived, OrderByComparator orderByComparator)
2030 throws SystemException {
2031 List<UserNotificationEvent> list = findByU_A(userId, archived, 0, 1,
2032 orderByComparator);
2033
2034 if (!list.isEmpty()) {
2035 return list.get(0);
2036 }
2037
2038 return null;
2039 }
2040
2041
2051 public UserNotificationEvent findByU_A_Last(long userId, boolean archived,
2052 OrderByComparator orderByComparator)
2053 throws NoSuchUserNotificationEventException, SystemException {
2054 UserNotificationEvent userNotificationEvent = fetchByU_A_Last(userId,
2055 archived, orderByComparator);
2056
2057 if (userNotificationEvent != null) {
2058 return userNotificationEvent;
2059 }
2060
2061 StringBundler msg = new StringBundler(6);
2062
2063 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2064
2065 msg.append("userId=");
2066 msg.append(userId);
2067
2068 msg.append(", archived=");
2069 msg.append(archived);
2070
2071 msg.append(StringPool.CLOSE_CURLY_BRACE);
2072
2073 throw new NoSuchUserNotificationEventException(msg.toString());
2074 }
2075
2076
2085 public UserNotificationEvent fetchByU_A_Last(long userId, boolean archived,
2086 OrderByComparator orderByComparator) throws SystemException {
2087 int count = countByU_A(userId, archived);
2088
2089 List<UserNotificationEvent> list = findByU_A(userId, archived,
2090 count - 1, count, orderByComparator);
2091
2092 if (!list.isEmpty()) {
2093 return list.get(0);
2094 }
2095
2096 return null;
2097 }
2098
2099
2110 public UserNotificationEvent[] findByU_A_PrevAndNext(
2111 long userNotificationEventId, long userId, boolean archived,
2112 OrderByComparator orderByComparator)
2113 throws NoSuchUserNotificationEventException, SystemException {
2114 UserNotificationEvent userNotificationEvent = findByPrimaryKey(userNotificationEventId);
2115
2116 Session session = null;
2117
2118 try {
2119 session = openSession();
2120
2121 UserNotificationEvent[] array = new UserNotificationEventImpl[3];
2122
2123 array[0] = getByU_A_PrevAndNext(session, userNotificationEvent,
2124 userId, archived, orderByComparator, true);
2125
2126 array[1] = userNotificationEvent;
2127
2128 array[2] = getByU_A_PrevAndNext(session, userNotificationEvent,
2129 userId, archived, orderByComparator, false);
2130
2131 return array;
2132 }
2133 catch (Exception e) {
2134 throw processException(e);
2135 }
2136 finally {
2137 closeSession(session);
2138 }
2139 }
2140
2141 protected UserNotificationEvent getByU_A_PrevAndNext(Session session,
2142 UserNotificationEvent userNotificationEvent, long userId,
2143 boolean archived, OrderByComparator orderByComparator, boolean previous) {
2144 StringBundler query = null;
2145
2146 if (orderByComparator != null) {
2147 query = new StringBundler(6 +
2148 (orderByComparator.getOrderByFields().length * 6));
2149 }
2150 else {
2151 query = new StringBundler(3);
2152 }
2153
2154 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT_WHERE);
2155
2156 query.append(_FINDER_COLUMN_U_A_USERID_2);
2157
2158 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
2159
2160 if (orderByComparator != null) {
2161 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2162
2163 if (orderByConditionFields.length > 0) {
2164 query.append(WHERE_AND);
2165 }
2166
2167 for (int i = 0; i < orderByConditionFields.length; i++) {
2168 query.append(_ORDER_BY_ENTITY_ALIAS);
2169 query.append(orderByConditionFields[i]);
2170
2171 if ((i + 1) < orderByConditionFields.length) {
2172 if (orderByComparator.isAscending() ^ previous) {
2173 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2174 }
2175 else {
2176 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2177 }
2178 }
2179 else {
2180 if (orderByComparator.isAscending() ^ previous) {
2181 query.append(WHERE_GREATER_THAN);
2182 }
2183 else {
2184 query.append(WHERE_LESSER_THAN);
2185 }
2186 }
2187 }
2188
2189 query.append(ORDER_BY_CLAUSE);
2190
2191 String[] orderByFields = orderByComparator.getOrderByFields();
2192
2193 for (int i = 0; i < orderByFields.length; i++) {
2194 query.append(_ORDER_BY_ENTITY_ALIAS);
2195 query.append(orderByFields[i]);
2196
2197 if ((i + 1) < orderByFields.length) {
2198 if (orderByComparator.isAscending() ^ previous) {
2199 query.append(ORDER_BY_ASC_HAS_NEXT);
2200 }
2201 else {
2202 query.append(ORDER_BY_DESC_HAS_NEXT);
2203 }
2204 }
2205 else {
2206 if (orderByComparator.isAscending() ^ previous) {
2207 query.append(ORDER_BY_ASC);
2208 }
2209 else {
2210 query.append(ORDER_BY_DESC);
2211 }
2212 }
2213 }
2214 }
2215
2216 else {
2217 query.append(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2218 }
2219
2220 String sql = query.toString();
2221
2222 Query q = session.createQuery(sql);
2223
2224 q.setFirstResult(0);
2225 q.setMaxResults(2);
2226
2227 QueryPos qPos = QueryPos.getInstance(q);
2228
2229 qPos.add(userId);
2230
2231 qPos.add(archived);
2232
2233 if (orderByComparator != null) {
2234 Object[] values = orderByComparator.getOrderByConditionValues(userNotificationEvent);
2235
2236 for (Object value : values) {
2237 qPos.add(value);
2238 }
2239 }
2240
2241 List<UserNotificationEvent> list = q.list();
2242
2243 if (list.size() == 2) {
2244 return list.get(1);
2245 }
2246 else {
2247 return null;
2248 }
2249 }
2250
2251
2257 public List<UserNotificationEvent> findAll() throws SystemException {
2258 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2259 }
2260
2261
2273 public List<UserNotificationEvent> findAll(int start, int end)
2274 throws SystemException {
2275 return findAll(start, end, null);
2276 }
2277
2278
2291 public List<UserNotificationEvent> findAll(int start, int end,
2292 OrderByComparator orderByComparator) throws SystemException {
2293 FinderPath finderPath = null;
2294 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2295
2296 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2297 (orderByComparator == null)) {
2298 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2299 finderArgs = FINDER_ARGS_EMPTY;
2300 }
2301 else {
2302 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2303 finderArgs = new Object[] { start, end, orderByComparator };
2304 }
2305
2306 List<UserNotificationEvent> list = (List<UserNotificationEvent>)FinderCacheUtil.getResult(finderPath,
2307 finderArgs, this);
2308
2309 if (list == null) {
2310 StringBundler query = null;
2311 String sql = null;
2312
2313 if (orderByComparator != null) {
2314 query = new StringBundler(2 +
2315 (orderByComparator.getOrderByFields().length * 3));
2316
2317 query.append(_SQL_SELECT_USERNOTIFICATIONEVENT);
2318
2319 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2320 orderByComparator);
2321
2322 sql = query.toString();
2323 }
2324 else {
2325 sql = _SQL_SELECT_USERNOTIFICATIONEVENT.concat(UserNotificationEventModelImpl.ORDER_BY_JPQL);
2326 }
2327
2328 Session session = null;
2329
2330 try {
2331 session = openSession();
2332
2333 Query q = session.createQuery(sql);
2334
2335 if (orderByComparator == null) {
2336 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2337 getDialect(), start, end, false);
2338
2339 Collections.sort(list);
2340 }
2341 else {
2342 list = (List<UserNotificationEvent>)QueryUtil.list(q,
2343 getDialect(), start, end);
2344 }
2345 }
2346 catch (Exception e) {
2347 throw processException(e);
2348 }
2349 finally {
2350 if (list == null) {
2351 FinderCacheUtil.removeResult(finderPath, finderArgs);
2352 }
2353 else {
2354 cacheResult(list);
2355
2356 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2357 }
2358
2359 closeSession(session);
2360 }
2361 }
2362
2363 return list;
2364 }
2365
2366
2372 public void removeByUuid(String uuid) throws SystemException {
2373 for (UserNotificationEvent userNotificationEvent : findByUuid(uuid)) {
2374 remove(userNotificationEvent);
2375 }
2376 }
2377
2378
2385 public void removeByUuid_C(String uuid, long companyId)
2386 throws SystemException {
2387 for (UserNotificationEvent userNotificationEvent : findByUuid_C(uuid,
2388 companyId)) {
2389 remove(userNotificationEvent);
2390 }
2391 }
2392
2393
2399 public void removeByUserId(long userId) throws SystemException {
2400 for (UserNotificationEvent userNotificationEvent : findByUserId(userId)) {
2401 remove(userNotificationEvent);
2402 }
2403 }
2404
2405
2412 public void removeByU_A(long userId, boolean archived)
2413 throws SystemException {
2414 for (UserNotificationEvent userNotificationEvent : findByU_A(userId,
2415 archived)) {
2416 remove(userNotificationEvent);
2417 }
2418 }
2419
2420
2425 public void removeAll() throws SystemException {
2426 for (UserNotificationEvent userNotificationEvent : findAll()) {
2427 remove(userNotificationEvent);
2428 }
2429 }
2430
2431
2438 public int countByUuid(String uuid) throws SystemException {
2439 Object[] finderArgs = new Object[] { uuid };
2440
2441 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2442 finderArgs, this);
2443
2444 if (count == null) {
2445 StringBundler query = new StringBundler(2);
2446
2447 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2448
2449 if (uuid == null) {
2450 query.append(_FINDER_COLUMN_UUID_UUID_1);
2451 }
2452 else {
2453 if (uuid.equals(StringPool.BLANK)) {
2454 query.append(_FINDER_COLUMN_UUID_UUID_3);
2455 }
2456 else {
2457 query.append(_FINDER_COLUMN_UUID_UUID_2);
2458 }
2459 }
2460
2461 String sql = query.toString();
2462
2463 Session session = null;
2464
2465 try {
2466 session = openSession();
2467
2468 Query q = session.createQuery(sql);
2469
2470 QueryPos qPos = QueryPos.getInstance(q);
2471
2472 if (uuid != null) {
2473 qPos.add(uuid);
2474 }
2475
2476 count = (Long)q.uniqueResult();
2477 }
2478 catch (Exception e) {
2479 throw processException(e);
2480 }
2481 finally {
2482 if (count == null) {
2483 count = Long.valueOf(0);
2484 }
2485
2486 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2487 finderArgs, count);
2488
2489 closeSession(session);
2490 }
2491 }
2492
2493 return count.intValue();
2494 }
2495
2496
2504 public int countByUuid_C(String uuid, long companyId)
2505 throws SystemException {
2506 Object[] finderArgs = new Object[] { uuid, companyId };
2507
2508 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
2509 finderArgs, this);
2510
2511 if (count == null) {
2512 StringBundler query = new StringBundler(3);
2513
2514 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2515
2516 if (uuid == null) {
2517 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
2518 }
2519 else {
2520 if (uuid.equals(StringPool.BLANK)) {
2521 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
2522 }
2523 else {
2524 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
2525 }
2526 }
2527
2528 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
2529
2530 String sql = query.toString();
2531
2532 Session session = null;
2533
2534 try {
2535 session = openSession();
2536
2537 Query q = session.createQuery(sql);
2538
2539 QueryPos qPos = QueryPos.getInstance(q);
2540
2541 if (uuid != null) {
2542 qPos.add(uuid);
2543 }
2544
2545 qPos.add(companyId);
2546
2547 count = (Long)q.uniqueResult();
2548 }
2549 catch (Exception e) {
2550 throw processException(e);
2551 }
2552 finally {
2553 if (count == null) {
2554 count = Long.valueOf(0);
2555 }
2556
2557 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
2558 finderArgs, count);
2559
2560 closeSession(session);
2561 }
2562 }
2563
2564 return count.intValue();
2565 }
2566
2567
2574 public int countByUserId(long userId) throws SystemException {
2575 Object[] finderArgs = new Object[] { userId };
2576
2577 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2578 finderArgs, this);
2579
2580 if (count == null) {
2581 StringBundler query = new StringBundler(2);
2582
2583 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2584
2585 query.append(_FINDER_COLUMN_USERID_USERID_2);
2586
2587 String sql = query.toString();
2588
2589 Session session = null;
2590
2591 try {
2592 session = openSession();
2593
2594 Query q = session.createQuery(sql);
2595
2596 QueryPos qPos = QueryPos.getInstance(q);
2597
2598 qPos.add(userId);
2599
2600 count = (Long)q.uniqueResult();
2601 }
2602 catch (Exception e) {
2603 throw processException(e);
2604 }
2605 finally {
2606 if (count == null) {
2607 count = Long.valueOf(0);
2608 }
2609
2610 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2611 finderArgs, count);
2612
2613 closeSession(session);
2614 }
2615 }
2616
2617 return count.intValue();
2618 }
2619
2620
2628 public int countByU_A(long userId, boolean archived)
2629 throws SystemException {
2630 Object[] finderArgs = new Object[] { userId, archived };
2631
2632 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_A,
2633 finderArgs, this);
2634
2635 if (count == null) {
2636 StringBundler query = new StringBundler(3);
2637
2638 query.append(_SQL_COUNT_USERNOTIFICATIONEVENT_WHERE);
2639
2640 query.append(_FINDER_COLUMN_U_A_USERID_2);
2641
2642 query.append(_FINDER_COLUMN_U_A_ARCHIVED_2);
2643
2644 String sql = query.toString();
2645
2646 Session session = null;
2647
2648 try {
2649 session = openSession();
2650
2651 Query q = session.createQuery(sql);
2652
2653 QueryPos qPos = QueryPos.getInstance(q);
2654
2655 qPos.add(userId);
2656
2657 qPos.add(archived);
2658
2659 count = (Long)q.uniqueResult();
2660 }
2661 catch (Exception e) {
2662 throw processException(e);
2663 }
2664 finally {
2665 if (count == null) {
2666 count = Long.valueOf(0);
2667 }
2668
2669 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_A, finderArgs,
2670 count);
2671
2672 closeSession(session);
2673 }
2674 }
2675
2676 return count.intValue();
2677 }
2678
2679
2685 public int countAll() throws SystemException {
2686 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2687 FINDER_ARGS_EMPTY, this);
2688
2689 if (count == null) {
2690 Session session = null;
2691
2692 try {
2693 session = openSession();
2694
2695 Query q = session.createQuery(_SQL_COUNT_USERNOTIFICATIONEVENT);
2696
2697 count = (Long)q.uniqueResult();
2698 }
2699 catch (Exception e) {
2700 throw processException(e);
2701 }
2702 finally {
2703 if (count == null) {
2704 count = Long.valueOf(0);
2705 }
2706
2707 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2708 FINDER_ARGS_EMPTY, count);
2709
2710 closeSession(session);
2711 }
2712 }
2713
2714 return count.intValue();
2715 }
2716
2717
2720 public void afterPropertiesSet() {
2721 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2722 com.liferay.portal.util.PropsUtil.get(
2723 "value.object.listener.com.liferay.portal.model.UserNotificationEvent")));
2724
2725 if (listenerClassNames.length > 0) {
2726 try {
2727 List<ModelListener<UserNotificationEvent>> listenersList = new ArrayList<ModelListener<UserNotificationEvent>>();
2728
2729 for (String listenerClassName : listenerClassNames) {
2730 listenersList.add((ModelListener<UserNotificationEvent>)InstanceFactory.newInstance(
2731 listenerClassName));
2732 }
2733
2734 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2735 }
2736 catch (Exception e) {
2737 _log.error(e);
2738 }
2739 }
2740 }
2741
2742 public void destroy() {
2743 EntityCacheUtil.removeCache(UserNotificationEventImpl.class.getName());
2744 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2745 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2746 }
2747
2748 @BeanReference(type = AccountPersistence.class)
2749 protected AccountPersistence accountPersistence;
2750 @BeanReference(type = AddressPersistence.class)
2751 protected AddressPersistence addressPersistence;
2752 @BeanReference(type = BrowserTrackerPersistence.class)
2753 protected BrowserTrackerPersistence browserTrackerPersistence;
2754 @BeanReference(type = ClassNamePersistence.class)
2755 protected ClassNamePersistence classNamePersistence;
2756 @BeanReference(type = ClusterGroupPersistence.class)
2757 protected ClusterGroupPersistence clusterGroupPersistence;
2758 @BeanReference(type = CompanyPersistence.class)
2759 protected CompanyPersistence companyPersistence;
2760 @BeanReference(type = ContactPersistence.class)
2761 protected ContactPersistence contactPersistence;
2762 @BeanReference(type = CountryPersistence.class)
2763 protected CountryPersistence countryPersistence;
2764 @BeanReference(type = EmailAddressPersistence.class)
2765 protected EmailAddressPersistence emailAddressPersistence;
2766 @BeanReference(type = GroupPersistence.class)
2767 protected GroupPersistence groupPersistence;
2768 @BeanReference(type = ImagePersistence.class)
2769 protected ImagePersistence imagePersistence;
2770 @BeanReference(type = LayoutPersistence.class)
2771 protected LayoutPersistence layoutPersistence;
2772 @BeanReference(type = LayoutBranchPersistence.class)
2773 protected LayoutBranchPersistence layoutBranchPersistence;
2774 @BeanReference(type = LayoutPrototypePersistence.class)
2775 protected LayoutPrototypePersistence layoutPrototypePersistence;
2776 @BeanReference(type = LayoutRevisionPersistence.class)
2777 protected LayoutRevisionPersistence layoutRevisionPersistence;
2778 @BeanReference(type = LayoutSetPersistence.class)
2779 protected LayoutSetPersistence layoutSetPersistence;
2780 @BeanReference(type = LayoutSetBranchPersistence.class)
2781 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2782 @BeanReference(type = LayoutSetPrototypePersistence.class)
2783 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2784 @BeanReference(type = ListTypePersistence.class)
2785 protected ListTypePersistence listTypePersistence;
2786 @BeanReference(type = LockPersistence.class)
2787 protected LockPersistence lockPersistence;
2788 @BeanReference(type = MembershipRequestPersistence.class)
2789 protected MembershipRequestPersistence membershipRequestPersistence;
2790 @BeanReference(type = OrganizationPersistence.class)
2791 protected OrganizationPersistence organizationPersistence;
2792 @BeanReference(type = OrgGroupRolePersistence.class)
2793 protected OrgGroupRolePersistence orgGroupRolePersistence;
2794 @BeanReference(type = OrgLaborPersistence.class)
2795 protected OrgLaborPersistence orgLaborPersistence;
2796 @BeanReference(type = PasswordPolicyPersistence.class)
2797 protected PasswordPolicyPersistence passwordPolicyPersistence;
2798 @BeanReference(type = PasswordPolicyRelPersistence.class)
2799 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2800 @BeanReference(type = PasswordTrackerPersistence.class)
2801 protected PasswordTrackerPersistence passwordTrackerPersistence;
2802 @BeanReference(type = PhonePersistence.class)
2803 protected PhonePersistence phonePersistence;
2804 @BeanReference(type = PluginSettingPersistence.class)
2805 protected PluginSettingPersistence pluginSettingPersistence;
2806 @BeanReference(type = PortalPreferencesPersistence.class)
2807 protected PortalPreferencesPersistence portalPreferencesPersistence;
2808 @BeanReference(type = PortletPersistence.class)
2809 protected PortletPersistence portletPersistence;
2810 @BeanReference(type = PortletItemPersistence.class)
2811 protected PortletItemPersistence portletItemPersistence;
2812 @BeanReference(type = PortletPreferencesPersistence.class)
2813 protected PortletPreferencesPersistence portletPreferencesPersistence;
2814 @BeanReference(type = RegionPersistence.class)
2815 protected RegionPersistence regionPersistence;
2816 @BeanReference(type = ReleasePersistence.class)
2817 protected ReleasePersistence releasePersistence;
2818 @BeanReference(type = RepositoryPersistence.class)
2819 protected RepositoryPersistence repositoryPersistence;
2820 @BeanReference(type = RepositoryEntryPersistence.class)
2821 protected RepositoryEntryPersistence repositoryEntryPersistence;
2822 @BeanReference(type = ResourceActionPersistence.class)
2823 protected ResourceActionPersistence resourceActionPersistence;
2824 @BeanReference(type = ResourceBlockPersistence.class)
2825 protected ResourceBlockPersistence resourceBlockPersistence;
2826 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2827 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2828 @BeanReference(type = ResourcePermissionPersistence.class)
2829 protected ResourcePermissionPersistence resourcePermissionPersistence;
2830 @BeanReference(type = ResourceTypePermissionPersistence.class)
2831 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2832 @BeanReference(type = RolePersistence.class)
2833 protected RolePersistence rolePersistence;
2834 @BeanReference(type = ServiceComponentPersistence.class)
2835 protected ServiceComponentPersistence serviceComponentPersistence;
2836 @BeanReference(type = ShardPersistence.class)
2837 protected ShardPersistence shardPersistence;
2838 @BeanReference(type = SubscriptionPersistence.class)
2839 protected SubscriptionPersistence subscriptionPersistence;
2840 @BeanReference(type = TeamPersistence.class)
2841 protected TeamPersistence teamPersistence;
2842 @BeanReference(type = TicketPersistence.class)
2843 protected TicketPersistence ticketPersistence;
2844 @BeanReference(type = UserPersistence.class)
2845 protected UserPersistence userPersistence;
2846 @BeanReference(type = UserGroupPersistence.class)
2847 protected UserGroupPersistence userGroupPersistence;
2848 @BeanReference(type = UserGroupGroupRolePersistence.class)
2849 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2850 @BeanReference(type = UserGroupRolePersistence.class)
2851 protected UserGroupRolePersistence userGroupRolePersistence;
2852 @BeanReference(type = UserIdMapperPersistence.class)
2853 protected UserIdMapperPersistence userIdMapperPersistence;
2854 @BeanReference(type = UserNotificationEventPersistence.class)
2855 protected UserNotificationEventPersistence userNotificationEventPersistence;
2856 @BeanReference(type = UserTrackerPersistence.class)
2857 protected UserTrackerPersistence userTrackerPersistence;
2858 @BeanReference(type = UserTrackerPathPersistence.class)
2859 protected UserTrackerPathPersistence userTrackerPathPersistence;
2860 @BeanReference(type = VirtualHostPersistence.class)
2861 protected VirtualHostPersistence virtualHostPersistence;
2862 @BeanReference(type = WebDAVPropsPersistence.class)
2863 protected WebDAVPropsPersistence webDAVPropsPersistence;
2864 @BeanReference(type = WebsitePersistence.class)
2865 protected WebsitePersistence websitePersistence;
2866 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2867 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2868 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2869 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2870 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent";
2871 private static final String _SQL_SELECT_USERNOTIFICATIONEVENT_WHERE = "SELECT userNotificationEvent FROM UserNotificationEvent userNotificationEvent WHERE ";
2872 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent";
2873 private static final String _SQL_COUNT_USERNOTIFICATIONEVENT_WHERE = "SELECT COUNT(userNotificationEvent) FROM UserNotificationEvent userNotificationEvent WHERE ";
2874 private static final String _FINDER_COLUMN_UUID_UUID_1 = "userNotificationEvent.uuid IS NULL";
2875 private static final String _FINDER_COLUMN_UUID_UUID_2 = "userNotificationEvent.uuid = ?";
2876 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = ?)";
2877 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "userNotificationEvent.uuid IS NULL AND ";
2878 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "userNotificationEvent.uuid = ? AND ";
2879 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(userNotificationEvent.uuid IS NULL OR userNotificationEvent.uuid = ?) AND ";
2880 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "userNotificationEvent.companyId = ?";
2881 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userNotificationEvent.userId = ?";
2882 private static final String _FINDER_COLUMN_U_A_USERID_2 = "userNotificationEvent.userId = ? AND ";
2883 private static final String _FINDER_COLUMN_U_A_ARCHIVED_2 = "userNotificationEvent.archived = ?";
2884 private static final String _ORDER_BY_ENTITY_ALIAS = "userNotificationEvent.";
2885 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserNotificationEvent exists with the primary key ";
2886 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserNotificationEvent exists with the key {";
2887 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2888 private static Log _log = LogFactoryUtil.getLog(UserNotificationEventPersistenceImpl.class);
2889 private static UserNotificationEvent _nullUserNotificationEvent = new UserNotificationEventImpl() {
2890 @Override
2891 public Object clone() {
2892 return this;
2893 }
2894
2895 @Override
2896 public CacheModel<UserNotificationEvent> toCacheModel() {
2897 return _nullUserNotificationEventCacheModel;
2898 }
2899 };
2900
2901 private static CacheModel<UserNotificationEvent> _nullUserNotificationEventCacheModel =
2902 new CacheModel<UserNotificationEvent>() {
2903 public UserNotificationEvent toEntityModel() {
2904 return _nullUserNotificationEvent;
2905 }
2906 };
2907 }