001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchUserTrackerPathException;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.exception.SystemException;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.GetterUtil;
030 import com.liferay.portal.kernel.util.InstanceFactory;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.kernel.util.StringUtil;
035 import com.liferay.portal.kernel.util.UnmodifiableList;
036 import com.liferay.portal.model.CacheModel;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.model.UserTrackerPath;
039 import com.liferay.portal.model.impl.UserTrackerPathImpl;
040 import com.liferay.portal.model.impl.UserTrackerPathModelImpl;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import java.io.Serializable;
044
045 import java.util.ArrayList;
046 import java.util.Collections;
047 import java.util.List;
048
049
061 public class UserTrackerPathPersistenceImpl extends BasePersistenceImpl<UserTrackerPath>
062 implements UserTrackerPathPersistence {
063
068 public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerPathImpl.class.getName();
069 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
070 ".List1";
071 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List2";
073 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
074 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
075 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
076 "findAll", new String[0]);
077 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
078 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
079 UserTrackerPathImpl.class,
080 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
081 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
082 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
083 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
084 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID =
085 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
086 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
087 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
088 "findByUserTrackerId",
089 new String[] {
090 Long.class.getName(),
091
092 Integer.class.getName(), Integer.class.getName(),
093 OrderByComparator.class.getName()
094 });
095 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID =
096 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
097 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
098 UserTrackerPathImpl.class,
099 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserTrackerId",
100 new String[] { Long.class.getName() },
101 UserTrackerPathModelImpl.USERTRACKERID_COLUMN_BITMASK);
102 public static final FinderPath FINDER_PATH_COUNT_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
103 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
104 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserTrackerId",
105 new String[] { Long.class.getName() });
106
107
114 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId)
115 throws SystemException {
116 return findByUserTrackerId(userTrackerId, QueryUtil.ALL_POS,
117 QueryUtil.ALL_POS, null);
118 }
119
120
133 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
134 int start, int end) throws SystemException {
135 return findByUserTrackerId(userTrackerId, start, end, null);
136 }
137
138
152 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
153 int start, int end, OrderByComparator orderByComparator)
154 throws SystemException {
155 boolean pagination = true;
156 FinderPath finderPath = null;
157 Object[] finderArgs = null;
158
159 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
160 (orderByComparator == null)) {
161 pagination = false;
162 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID;
163 finderArgs = new Object[] { userTrackerId };
164 }
165 else {
166 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID;
167 finderArgs = new Object[] {
168 userTrackerId,
169
170 start, end, orderByComparator
171 };
172 }
173
174 List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(finderPath,
175 finderArgs, this);
176
177 if ((list != null) && !list.isEmpty()) {
178 for (UserTrackerPath userTrackerPath : list) {
179 if ((userTrackerId != userTrackerPath.getUserTrackerId())) {
180 list = null;
181
182 break;
183 }
184 }
185 }
186
187 if (list == null) {
188 StringBundler query = null;
189
190 if (orderByComparator != null) {
191 query = new StringBundler(3 +
192 (orderByComparator.getOrderByFields().length * 3));
193 }
194 else {
195 query = new StringBundler(3);
196 }
197
198 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
199
200 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
201
202 if (orderByComparator != null) {
203 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
204 orderByComparator);
205 }
206 else
207 if (pagination) {
208 query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
209 }
210
211 String sql = query.toString();
212
213 Session session = null;
214
215 try {
216 session = openSession();
217
218 Query q = session.createQuery(sql);
219
220 QueryPos qPos = QueryPos.getInstance(q);
221
222 qPos.add(userTrackerId);
223
224 if (!pagination) {
225 list = (List<UserTrackerPath>)QueryUtil.list(q,
226 getDialect(), start, end, false);
227
228 Collections.sort(list);
229
230 list = new UnmodifiableList<UserTrackerPath>(list);
231 }
232 else {
233 list = (List<UserTrackerPath>)QueryUtil.list(q,
234 getDialect(), start, end);
235 }
236
237 cacheResult(list);
238
239 FinderCacheUtil.putResult(finderPath, finderArgs, list);
240 }
241 catch (Exception e) {
242 FinderCacheUtil.removeResult(finderPath, finderArgs);
243
244 throw processException(e);
245 }
246 finally {
247 closeSession(session);
248 }
249 }
250
251 return list;
252 }
253
254
263 public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
264 OrderByComparator orderByComparator)
265 throws NoSuchUserTrackerPathException, SystemException {
266 UserTrackerPath userTrackerPath = fetchByUserTrackerId_First(userTrackerId,
267 orderByComparator);
268
269 if (userTrackerPath != null) {
270 return userTrackerPath;
271 }
272
273 StringBundler msg = new StringBundler(4);
274
275 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
276
277 msg.append("userTrackerId=");
278 msg.append(userTrackerId);
279
280 msg.append(StringPool.CLOSE_CURLY_BRACE);
281
282 throw new NoSuchUserTrackerPathException(msg.toString());
283 }
284
285
293 public UserTrackerPath fetchByUserTrackerId_First(long userTrackerId,
294 OrderByComparator orderByComparator) throws SystemException {
295 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId, 0, 1,
296 orderByComparator);
297
298 if (!list.isEmpty()) {
299 return list.get(0);
300 }
301
302 return null;
303 }
304
305
314 public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
315 OrderByComparator orderByComparator)
316 throws NoSuchUserTrackerPathException, SystemException {
317 UserTrackerPath userTrackerPath = fetchByUserTrackerId_Last(userTrackerId,
318 orderByComparator);
319
320 if (userTrackerPath != null) {
321 return userTrackerPath;
322 }
323
324 StringBundler msg = new StringBundler(4);
325
326 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
327
328 msg.append("userTrackerId=");
329 msg.append(userTrackerId);
330
331 msg.append(StringPool.CLOSE_CURLY_BRACE);
332
333 throw new NoSuchUserTrackerPathException(msg.toString());
334 }
335
336
344 public UserTrackerPath fetchByUserTrackerId_Last(long userTrackerId,
345 OrderByComparator orderByComparator) throws SystemException {
346 int count = countByUserTrackerId(userTrackerId);
347
348 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
349 count - 1, count, orderByComparator);
350
351 if (!list.isEmpty()) {
352 return list.get(0);
353 }
354
355 return null;
356 }
357
358
368 public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
369 long userTrackerPathId, long userTrackerId,
370 OrderByComparator orderByComparator)
371 throws NoSuchUserTrackerPathException, SystemException {
372 UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
373
374 Session session = null;
375
376 try {
377 session = openSession();
378
379 UserTrackerPath[] array = new UserTrackerPathImpl[3];
380
381 array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
382 userTrackerId, orderByComparator, true);
383
384 array[1] = userTrackerPath;
385
386 array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
387 userTrackerId, orderByComparator, false);
388
389 return array;
390 }
391 catch (Exception e) {
392 throw processException(e);
393 }
394 finally {
395 closeSession(session);
396 }
397 }
398
399 protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
400 UserTrackerPath userTrackerPath, long userTrackerId,
401 OrderByComparator orderByComparator, boolean previous) {
402 StringBundler query = null;
403
404 if (orderByComparator != null) {
405 query = new StringBundler(6 +
406 (orderByComparator.getOrderByFields().length * 6));
407 }
408 else {
409 query = new StringBundler(3);
410 }
411
412 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
413
414 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
415
416 if (orderByComparator != null) {
417 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
418
419 if (orderByConditionFields.length > 0) {
420 query.append(WHERE_AND);
421 }
422
423 for (int i = 0; i < orderByConditionFields.length; i++) {
424 query.append(_ORDER_BY_ENTITY_ALIAS);
425 query.append(orderByConditionFields[i]);
426
427 if ((i + 1) < orderByConditionFields.length) {
428 if (orderByComparator.isAscending() ^ previous) {
429 query.append(WHERE_GREATER_THAN_HAS_NEXT);
430 }
431 else {
432 query.append(WHERE_LESSER_THAN_HAS_NEXT);
433 }
434 }
435 else {
436 if (orderByComparator.isAscending() ^ previous) {
437 query.append(WHERE_GREATER_THAN);
438 }
439 else {
440 query.append(WHERE_LESSER_THAN);
441 }
442 }
443 }
444
445 query.append(ORDER_BY_CLAUSE);
446
447 String[] orderByFields = orderByComparator.getOrderByFields();
448
449 for (int i = 0; i < orderByFields.length; i++) {
450 query.append(_ORDER_BY_ENTITY_ALIAS);
451 query.append(orderByFields[i]);
452
453 if ((i + 1) < orderByFields.length) {
454 if (orderByComparator.isAscending() ^ previous) {
455 query.append(ORDER_BY_ASC_HAS_NEXT);
456 }
457 else {
458 query.append(ORDER_BY_DESC_HAS_NEXT);
459 }
460 }
461 else {
462 if (orderByComparator.isAscending() ^ previous) {
463 query.append(ORDER_BY_ASC);
464 }
465 else {
466 query.append(ORDER_BY_DESC);
467 }
468 }
469 }
470 }
471 else {
472 query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
473 }
474
475 String sql = query.toString();
476
477 Query q = session.createQuery(sql);
478
479 q.setFirstResult(0);
480 q.setMaxResults(2);
481
482 QueryPos qPos = QueryPos.getInstance(q);
483
484 qPos.add(userTrackerId);
485
486 if (orderByComparator != null) {
487 Object[] values = orderByComparator.getOrderByConditionValues(userTrackerPath);
488
489 for (Object value : values) {
490 qPos.add(value);
491 }
492 }
493
494 List<UserTrackerPath> list = q.list();
495
496 if (list.size() == 2) {
497 return list.get(1);
498 }
499 else {
500 return null;
501 }
502 }
503
504
510 public void removeByUserTrackerId(long userTrackerId)
511 throws SystemException {
512 for (UserTrackerPath userTrackerPath : findByUserTrackerId(
513 userTrackerId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
514 remove(userTrackerPath);
515 }
516 }
517
518
525 public int countByUserTrackerId(long userTrackerId)
526 throws SystemException {
527 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERTRACKERID;
528
529 Object[] finderArgs = new Object[] { userTrackerId };
530
531 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
532 this);
533
534 if (count == null) {
535 StringBundler query = new StringBundler(2);
536
537 query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
538
539 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
540
541 String sql = query.toString();
542
543 Session session = null;
544
545 try {
546 session = openSession();
547
548 Query q = session.createQuery(sql);
549
550 QueryPos qPos = QueryPos.getInstance(q);
551
552 qPos.add(userTrackerId);
553
554 count = (Long)q.uniqueResult();
555
556 FinderCacheUtil.putResult(finderPath, finderArgs, count);
557 }
558 catch (Exception e) {
559 FinderCacheUtil.removeResult(finderPath, finderArgs);
560
561 throw processException(e);
562 }
563 finally {
564 closeSession(session);
565 }
566 }
567
568 return count.intValue();
569 }
570
571 private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
572
573
578 public void cacheResult(UserTrackerPath userTrackerPath) {
579 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
580 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
581 userTrackerPath);
582
583 userTrackerPath.resetOriginalValues();
584 }
585
586
591 public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
592 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
593 if (EntityCacheUtil.getResult(
594 UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
595 UserTrackerPathImpl.class,
596 userTrackerPath.getPrimaryKey()) == null) {
597 cacheResult(userTrackerPath);
598 }
599 else {
600 userTrackerPath.resetOriginalValues();
601 }
602 }
603 }
604
605
612 @Override
613 public void clearCache() {
614 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
615 CacheRegistryUtil.clear(UserTrackerPathImpl.class.getName());
616 }
617
618 EntityCacheUtil.clearCache(UserTrackerPathImpl.class.getName());
619
620 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
621 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
622 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
623 }
624
625
632 @Override
633 public void clearCache(UserTrackerPath userTrackerPath) {
634 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
635 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
636
637 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
638 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
639 }
640
641 @Override
642 public void clearCache(List<UserTrackerPath> userTrackerPaths) {
643 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
644 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
645
646 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
647 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
648 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
649 }
650 }
651
652
658 public UserTrackerPath create(long userTrackerPathId) {
659 UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
660
661 userTrackerPath.setNew(true);
662 userTrackerPath.setPrimaryKey(userTrackerPathId);
663
664 return userTrackerPath;
665 }
666
667
675 public UserTrackerPath remove(long userTrackerPathId)
676 throws NoSuchUserTrackerPathException, SystemException {
677 return remove((Serializable)userTrackerPathId);
678 }
679
680
688 @Override
689 public UserTrackerPath remove(Serializable primaryKey)
690 throws NoSuchUserTrackerPathException, SystemException {
691 Session session = null;
692
693 try {
694 session = openSession();
695
696 UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
697 primaryKey);
698
699 if (userTrackerPath == null) {
700 if (_log.isWarnEnabled()) {
701 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
702 }
703
704 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
705 primaryKey);
706 }
707
708 return remove(userTrackerPath);
709 }
710 catch (NoSuchUserTrackerPathException nsee) {
711 throw nsee;
712 }
713 catch (Exception e) {
714 throw processException(e);
715 }
716 finally {
717 closeSession(session);
718 }
719 }
720
721 @Override
722 protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath)
723 throws SystemException {
724 userTrackerPath = toUnwrappedModel(userTrackerPath);
725
726 Session session = null;
727
728 try {
729 session = openSession();
730
731 if (!session.contains(userTrackerPath)) {
732 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
733 userTrackerPath.getPrimaryKeyObj());
734 }
735
736 if (userTrackerPath != null) {
737 session.delete(userTrackerPath);
738 }
739 }
740 catch (Exception e) {
741 throw processException(e);
742 }
743 finally {
744 closeSession(session);
745 }
746
747 if (userTrackerPath != null) {
748 clearCache(userTrackerPath);
749 }
750
751 return userTrackerPath;
752 }
753
754 @Override
755 public UserTrackerPath updateImpl(
756 com.liferay.portal.model.UserTrackerPath userTrackerPath)
757 throws SystemException {
758 userTrackerPath = toUnwrappedModel(userTrackerPath);
759
760 boolean isNew = userTrackerPath.isNew();
761
762 UserTrackerPathModelImpl userTrackerPathModelImpl = (UserTrackerPathModelImpl)userTrackerPath;
763
764 Session session = null;
765
766 try {
767 session = openSession();
768
769 if (userTrackerPath.isNew()) {
770 session.save(userTrackerPath);
771
772 userTrackerPath.setNew(false);
773 }
774 else {
775 session.merge(userTrackerPath);
776 }
777 }
778 catch (Exception e) {
779 throw processException(e);
780 }
781 finally {
782 closeSession(session);
783 }
784
785 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
786
787 if (isNew || !UserTrackerPathModelImpl.COLUMN_BITMASK_ENABLED) {
788 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
789 }
790
791 else {
792 if ((userTrackerPathModelImpl.getColumnBitmask() &
793 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID.getColumnBitmask()) != 0) {
794 Object[] args = new Object[] {
795 userTrackerPathModelImpl.getOriginalUserTrackerId()
796 };
797
798 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
799 args);
800 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
801 args);
802
803 args = new Object[] { userTrackerPathModelImpl.getUserTrackerId() };
804
805 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
806 args);
807 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
808 args);
809 }
810 }
811
812 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
813 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
814 userTrackerPath);
815
816 return userTrackerPath;
817 }
818
819 protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
820 if (userTrackerPath instanceof UserTrackerPathImpl) {
821 return userTrackerPath;
822 }
823
824 UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
825
826 userTrackerPathImpl.setNew(userTrackerPath.isNew());
827 userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
828
829 userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
830 userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
831 userTrackerPathImpl.setPath(userTrackerPath.getPath());
832 userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
833
834 return userTrackerPathImpl;
835 }
836
837
845 @Override
846 public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
847 throws NoSuchUserTrackerPathException, SystemException {
848 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
849
850 if (userTrackerPath == null) {
851 if (_log.isWarnEnabled()) {
852 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
853 }
854
855 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
856 primaryKey);
857 }
858
859 return userTrackerPath;
860 }
861
862
870 public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
871 throws NoSuchUserTrackerPathException, SystemException {
872 return findByPrimaryKey((Serializable)userTrackerPathId);
873 }
874
875
882 @Override
883 public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey)
884 throws SystemException {
885 UserTrackerPath userTrackerPath = (UserTrackerPath)EntityCacheUtil.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
886 UserTrackerPathImpl.class, primaryKey);
887
888 if (userTrackerPath == _nullUserTrackerPath) {
889 return null;
890 }
891
892 if (userTrackerPath == null) {
893 Session session = null;
894
895 try {
896 session = openSession();
897
898 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
899 primaryKey);
900
901 if (userTrackerPath != null) {
902 cacheResult(userTrackerPath);
903 }
904 else {
905 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
906 UserTrackerPathImpl.class, primaryKey,
907 _nullUserTrackerPath);
908 }
909 }
910 catch (Exception e) {
911 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
912 UserTrackerPathImpl.class, primaryKey);
913
914 throw processException(e);
915 }
916 finally {
917 closeSession(session);
918 }
919 }
920
921 return userTrackerPath;
922 }
923
924
931 public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId)
932 throws SystemException {
933 return fetchByPrimaryKey((Serializable)userTrackerPathId);
934 }
935
936
942 public List<UserTrackerPath> findAll() throws SystemException {
943 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
944 }
945
946
958 public List<UserTrackerPath> findAll(int start, int end)
959 throws SystemException {
960 return findAll(start, end, null);
961 }
962
963
976 public List<UserTrackerPath> findAll(int start, int end,
977 OrderByComparator orderByComparator) throws SystemException {
978 boolean pagination = true;
979 FinderPath finderPath = null;
980 Object[] finderArgs = null;
981
982 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
983 (orderByComparator == null)) {
984 pagination = false;
985 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
986 finderArgs = FINDER_ARGS_EMPTY;
987 }
988 else {
989 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
990 finderArgs = new Object[] { start, end, orderByComparator };
991 }
992
993 List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(finderPath,
994 finderArgs, this);
995
996 if (list == null) {
997 StringBundler query = null;
998 String sql = null;
999
1000 if (orderByComparator != null) {
1001 query = new StringBundler(2 +
1002 (orderByComparator.getOrderByFields().length * 3));
1003
1004 query.append(_SQL_SELECT_USERTRACKERPATH);
1005
1006 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1007 orderByComparator);
1008
1009 sql = query.toString();
1010 }
1011 else {
1012 sql = _SQL_SELECT_USERTRACKERPATH;
1013
1014 if (pagination) {
1015 sql = sql.concat(UserTrackerPathModelImpl.ORDER_BY_JPQL);
1016 }
1017 }
1018
1019 Session session = null;
1020
1021 try {
1022 session = openSession();
1023
1024 Query q = session.createQuery(sql);
1025
1026 if (!pagination) {
1027 list = (List<UserTrackerPath>)QueryUtil.list(q,
1028 getDialect(), start, end, false);
1029
1030 Collections.sort(list);
1031
1032 list = new UnmodifiableList<UserTrackerPath>(list);
1033 }
1034 else {
1035 list = (List<UserTrackerPath>)QueryUtil.list(q,
1036 getDialect(), start, end);
1037 }
1038
1039 cacheResult(list);
1040
1041 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1042 }
1043 catch (Exception e) {
1044 FinderCacheUtil.removeResult(finderPath, finderArgs);
1045
1046 throw processException(e);
1047 }
1048 finally {
1049 closeSession(session);
1050 }
1051 }
1052
1053 return list;
1054 }
1055
1056
1061 public void removeAll() throws SystemException {
1062 for (UserTrackerPath userTrackerPath : findAll()) {
1063 remove(userTrackerPath);
1064 }
1065 }
1066
1067
1073 public int countAll() throws SystemException {
1074 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1075 FINDER_ARGS_EMPTY, this);
1076
1077 if (count == null) {
1078 Session session = null;
1079
1080 try {
1081 session = openSession();
1082
1083 Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
1084
1085 count = (Long)q.uniqueResult();
1086
1087 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1088 FINDER_ARGS_EMPTY, count);
1089 }
1090 catch (Exception e) {
1091 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1092 FINDER_ARGS_EMPTY);
1093
1094 throw processException(e);
1095 }
1096 finally {
1097 closeSession(session);
1098 }
1099 }
1100
1101 return count.intValue();
1102 }
1103
1104
1107 public void afterPropertiesSet() {
1108 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1109 com.liferay.portal.util.PropsUtil.get(
1110 "value.object.listener.com.liferay.portal.model.UserTrackerPath")));
1111
1112 if (listenerClassNames.length > 0) {
1113 try {
1114 List<ModelListener<UserTrackerPath>> listenersList = new ArrayList<ModelListener<UserTrackerPath>>();
1115
1116 for (String listenerClassName : listenerClassNames) {
1117 listenersList.add((ModelListener<UserTrackerPath>)InstanceFactory.newInstance(
1118 listenerClassName));
1119 }
1120
1121 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1122 }
1123 catch (Exception e) {
1124 _log.error(e);
1125 }
1126 }
1127 }
1128
1129 public void destroy() {
1130 EntityCacheUtil.removeCache(UserTrackerPathImpl.class.getName());
1131 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1132 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1133 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1134 }
1135
1136 private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1137 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1138 private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1139 private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1140 private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1141 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1142 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1143 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1144 private static Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1145 private static UserTrackerPath _nullUserTrackerPath = new UserTrackerPathImpl() {
1146 @Override
1147 public Object clone() {
1148 return this;
1149 }
1150
1151 @Override
1152 public CacheModel<UserTrackerPath> toCacheModel() {
1153 return _nullUserTrackerPathCacheModel;
1154 }
1155 };
1156
1157 private static CacheModel<UserTrackerPath> _nullUserTrackerPathCacheModel = new CacheModel<UserTrackerPath>() {
1158 public UserTrackerPath toEntityModel() {
1159 return _nullUserTrackerPath;
1160 }
1161 };
1162 }