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.SetUtil;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.UnmodifiableList;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.UserTrackerPath;
040 import com.liferay.portal.model.impl.UserTrackerPathImpl;
041 import com.liferay.portal.model.impl.UserTrackerPathModelImpl;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import java.io.Serializable;
045
046 import java.util.ArrayList;
047 import java.util.Collections;
048 import java.util.List;
049 import java.util.Set;
050
051
063 public class UserTrackerPathPersistenceImpl extends BasePersistenceImpl<UserTrackerPath>
064 implements UserTrackerPathPersistence {
065
070 public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerPathImpl.class.getName();
071 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List1";
073 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List2";
075 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
076 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
077 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
078 "findAll", new String[0]);
079 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
080 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
081 UserTrackerPathImpl.class,
082 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
083 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
084 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
085 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
086 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID =
087 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
088 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
089 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
090 "findByUserTrackerId",
091 new String[] {
092 Long.class.getName(),
093
094 Integer.class.getName(), Integer.class.getName(),
095 OrderByComparator.class.getName()
096 });
097 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID =
098 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
099 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
100 UserTrackerPathImpl.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserTrackerId",
102 new String[] { Long.class.getName() },
103 UserTrackerPathModelImpl.USERTRACKERID_COLUMN_BITMASK);
104 public static final FinderPath FINDER_PATH_COUNT_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
105 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserTrackerId",
107 new String[] { Long.class.getName() });
108
109
116 @Override
117 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId)
118 throws SystemException {
119 return findByUserTrackerId(userTrackerId, QueryUtil.ALL_POS,
120 QueryUtil.ALL_POS, null);
121 }
122
123
136 @Override
137 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
138 int start, int end) throws SystemException {
139 return findByUserTrackerId(userTrackerId, start, end, null);
140 }
141
142
156 @Override
157 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
158 int start, int end, OrderByComparator orderByComparator)
159 throws SystemException {
160 boolean pagination = true;
161 FinderPath finderPath = null;
162 Object[] finderArgs = null;
163
164 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
165 (orderByComparator == null)) {
166 pagination = false;
167 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID;
168 finderArgs = new Object[] { userTrackerId };
169 }
170 else {
171 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID;
172 finderArgs = new Object[] {
173 userTrackerId,
174
175 start, end, orderByComparator
176 };
177 }
178
179 List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(finderPath,
180 finderArgs, this);
181
182 if ((list != null) && !list.isEmpty()) {
183 for (UserTrackerPath userTrackerPath : list) {
184 if ((userTrackerId != userTrackerPath.getUserTrackerId())) {
185 list = null;
186
187 break;
188 }
189 }
190 }
191
192 if (list == null) {
193 StringBundler query = null;
194
195 if (orderByComparator != null) {
196 query = new StringBundler(3 +
197 (orderByComparator.getOrderByFields().length * 3));
198 }
199 else {
200 query = new StringBundler(3);
201 }
202
203 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
204
205 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
206
207 if (orderByComparator != null) {
208 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
209 orderByComparator);
210 }
211 else
212 if (pagination) {
213 query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
214 }
215
216 String sql = query.toString();
217
218 Session session = null;
219
220 try {
221 session = openSession();
222
223 Query q = session.createQuery(sql);
224
225 QueryPos qPos = QueryPos.getInstance(q);
226
227 qPos.add(userTrackerId);
228
229 if (!pagination) {
230 list = (List<UserTrackerPath>)QueryUtil.list(q,
231 getDialect(), start, end, false);
232
233 Collections.sort(list);
234
235 list = new UnmodifiableList<UserTrackerPath>(list);
236 }
237 else {
238 list = (List<UserTrackerPath>)QueryUtil.list(q,
239 getDialect(), start, end);
240 }
241
242 cacheResult(list);
243
244 FinderCacheUtil.putResult(finderPath, finderArgs, list);
245 }
246 catch (Exception e) {
247 FinderCacheUtil.removeResult(finderPath, finderArgs);
248
249 throw processException(e);
250 }
251 finally {
252 closeSession(session);
253 }
254 }
255
256 return list;
257 }
258
259
268 @Override
269 public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
270 OrderByComparator orderByComparator)
271 throws NoSuchUserTrackerPathException, SystemException {
272 UserTrackerPath userTrackerPath = fetchByUserTrackerId_First(userTrackerId,
273 orderByComparator);
274
275 if (userTrackerPath != null) {
276 return userTrackerPath;
277 }
278
279 StringBundler msg = new StringBundler(4);
280
281 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
282
283 msg.append("userTrackerId=");
284 msg.append(userTrackerId);
285
286 msg.append(StringPool.CLOSE_CURLY_BRACE);
287
288 throw new NoSuchUserTrackerPathException(msg.toString());
289 }
290
291
299 @Override
300 public UserTrackerPath fetchByUserTrackerId_First(long userTrackerId,
301 OrderByComparator orderByComparator) throws SystemException {
302 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId, 0, 1,
303 orderByComparator);
304
305 if (!list.isEmpty()) {
306 return list.get(0);
307 }
308
309 return null;
310 }
311
312
321 @Override
322 public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
323 OrderByComparator orderByComparator)
324 throws NoSuchUserTrackerPathException, SystemException {
325 UserTrackerPath userTrackerPath = fetchByUserTrackerId_Last(userTrackerId,
326 orderByComparator);
327
328 if (userTrackerPath != null) {
329 return userTrackerPath;
330 }
331
332 StringBundler msg = new StringBundler(4);
333
334 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
335
336 msg.append("userTrackerId=");
337 msg.append(userTrackerId);
338
339 msg.append(StringPool.CLOSE_CURLY_BRACE);
340
341 throw new NoSuchUserTrackerPathException(msg.toString());
342 }
343
344
352 @Override
353 public UserTrackerPath fetchByUserTrackerId_Last(long userTrackerId,
354 OrderByComparator orderByComparator) throws SystemException {
355 int count = countByUserTrackerId(userTrackerId);
356
357 if (count == 0) {
358 return null;
359 }
360
361 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
362 count - 1, count, orderByComparator);
363
364 if (!list.isEmpty()) {
365 return list.get(0);
366 }
367
368 return null;
369 }
370
371
381 @Override
382 public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
383 long userTrackerPathId, long userTrackerId,
384 OrderByComparator orderByComparator)
385 throws NoSuchUserTrackerPathException, SystemException {
386 UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
387
388 Session session = null;
389
390 try {
391 session = openSession();
392
393 UserTrackerPath[] array = new UserTrackerPathImpl[3];
394
395 array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
396 userTrackerId, orderByComparator, true);
397
398 array[1] = userTrackerPath;
399
400 array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
401 userTrackerId, orderByComparator, false);
402
403 return array;
404 }
405 catch (Exception e) {
406 throw processException(e);
407 }
408 finally {
409 closeSession(session);
410 }
411 }
412
413 protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
414 UserTrackerPath userTrackerPath, long userTrackerId,
415 OrderByComparator orderByComparator, boolean previous) {
416 StringBundler query = null;
417
418 if (orderByComparator != null) {
419 query = new StringBundler(6 +
420 (orderByComparator.getOrderByFields().length * 6));
421 }
422 else {
423 query = new StringBundler(3);
424 }
425
426 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
427
428 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
429
430 if (orderByComparator != null) {
431 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
432
433 if (orderByConditionFields.length > 0) {
434 query.append(WHERE_AND);
435 }
436
437 for (int i = 0; i < orderByConditionFields.length; i++) {
438 query.append(_ORDER_BY_ENTITY_ALIAS);
439 query.append(orderByConditionFields[i]);
440
441 if ((i + 1) < orderByConditionFields.length) {
442 if (orderByComparator.isAscending() ^ previous) {
443 query.append(WHERE_GREATER_THAN_HAS_NEXT);
444 }
445 else {
446 query.append(WHERE_LESSER_THAN_HAS_NEXT);
447 }
448 }
449 else {
450 if (orderByComparator.isAscending() ^ previous) {
451 query.append(WHERE_GREATER_THAN);
452 }
453 else {
454 query.append(WHERE_LESSER_THAN);
455 }
456 }
457 }
458
459 query.append(ORDER_BY_CLAUSE);
460
461 String[] orderByFields = orderByComparator.getOrderByFields();
462
463 for (int i = 0; i < orderByFields.length; i++) {
464 query.append(_ORDER_BY_ENTITY_ALIAS);
465 query.append(orderByFields[i]);
466
467 if ((i + 1) < orderByFields.length) {
468 if (orderByComparator.isAscending() ^ previous) {
469 query.append(ORDER_BY_ASC_HAS_NEXT);
470 }
471 else {
472 query.append(ORDER_BY_DESC_HAS_NEXT);
473 }
474 }
475 else {
476 if (orderByComparator.isAscending() ^ previous) {
477 query.append(ORDER_BY_ASC);
478 }
479 else {
480 query.append(ORDER_BY_DESC);
481 }
482 }
483 }
484 }
485 else {
486 query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
487 }
488
489 String sql = query.toString();
490
491 Query q = session.createQuery(sql);
492
493 q.setFirstResult(0);
494 q.setMaxResults(2);
495
496 QueryPos qPos = QueryPos.getInstance(q);
497
498 qPos.add(userTrackerId);
499
500 if (orderByComparator != null) {
501 Object[] values = orderByComparator.getOrderByConditionValues(userTrackerPath);
502
503 for (Object value : values) {
504 qPos.add(value);
505 }
506 }
507
508 List<UserTrackerPath> list = q.list();
509
510 if (list.size() == 2) {
511 return list.get(1);
512 }
513 else {
514 return null;
515 }
516 }
517
518
524 @Override
525 public void removeByUserTrackerId(long userTrackerId)
526 throws SystemException {
527 for (UserTrackerPath userTrackerPath : findByUserTrackerId(
528 userTrackerId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
529 remove(userTrackerPath);
530 }
531 }
532
533
540 @Override
541 public int countByUserTrackerId(long userTrackerId)
542 throws SystemException {
543 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERTRACKERID;
544
545 Object[] finderArgs = new Object[] { userTrackerId };
546
547 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
548 this);
549
550 if (count == null) {
551 StringBundler query = new StringBundler(2);
552
553 query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
554
555 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
556
557 String sql = query.toString();
558
559 Session session = null;
560
561 try {
562 session = openSession();
563
564 Query q = session.createQuery(sql);
565
566 QueryPos qPos = QueryPos.getInstance(q);
567
568 qPos.add(userTrackerId);
569
570 count = (Long)q.uniqueResult();
571
572 FinderCacheUtil.putResult(finderPath, finderArgs, count);
573 }
574 catch (Exception e) {
575 FinderCacheUtil.removeResult(finderPath, finderArgs);
576
577 throw processException(e);
578 }
579 finally {
580 closeSession(session);
581 }
582 }
583
584 return count.intValue();
585 }
586
587 private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
588
589 public UserTrackerPathPersistenceImpl() {
590 setModelClass(UserTrackerPath.class);
591 }
592
593
598 @Override
599 public void cacheResult(UserTrackerPath userTrackerPath) {
600 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
601 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
602 userTrackerPath);
603
604 userTrackerPath.resetOriginalValues();
605 }
606
607
612 @Override
613 public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
614 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
615 if (EntityCacheUtil.getResult(
616 UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
617 UserTrackerPathImpl.class,
618 userTrackerPath.getPrimaryKey()) == null) {
619 cacheResult(userTrackerPath);
620 }
621 else {
622 userTrackerPath.resetOriginalValues();
623 }
624 }
625 }
626
627
634 @Override
635 public void clearCache() {
636 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
637 CacheRegistryUtil.clear(UserTrackerPathImpl.class.getName());
638 }
639
640 EntityCacheUtil.clearCache(UserTrackerPathImpl.class.getName());
641
642 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
643 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
644 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
645 }
646
647
654 @Override
655 public void clearCache(UserTrackerPath userTrackerPath) {
656 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
657 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
658
659 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
660 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
661 }
662
663 @Override
664 public void clearCache(List<UserTrackerPath> userTrackerPaths) {
665 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
666 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
667
668 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
669 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
670 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
671 }
672 }
673
674
680 @Override
681 public UserTrackerPath create(long userTrackerPathId) {
682 UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
683
684 userTrackerPath.setNew(true);
685 userTrackerPath.setPrimaryKey(userTrackerPathId);
686
687 return userTrackerPath;
688 }
689
690
698 @Override
699 public UserTrackerPath remove(long userTrackerPathId)
700 throws NoSuchUserTrackerPathException, SystemException {
701 return remove((Serializable)userTrackerPathId);
702 }
703
704
712 @Override
713 public UserTrackerPath remove(Serializable primaryKey)
714 throws NoSuchUserTrackerPathException, SystemException {
715 Session session = null;
716
717 try {
718 session = openSession();
719
720 UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
721 primaryKey);
722
723 if (userTrackerPath == null) {
724 if (_log.isWarnEnabled()) {
725 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
726 }
727
728 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
729 primaryKey);
730 }
731
732 return remove(userTrackerPath);
733 }
734 catch (NoSuchUserTrackerPathException nsee) {
735 throw nsee;
736 }
737 catch (Exception e) {
738 throw processException(e);
739 }
740 finally {
741 closeSession(session);
742 }
743 }
744
745 @Override
746 protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath)
747 throws SystemException {
748 userTrackerPath = toUnwrappedModel(userTrackerPath);
749
750 Session session = null;
751
752 try {
753 session = openSession();
754
755 if (!session.contains(userTrackerPath)) {
756 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
757 userTrackerPath.getPrimaryKeyObj());
758 }
759
760 if (userTrackerPath != null) {
761 session.delete(userTrackerPath);
762 }
763 }
764 catch (Exception e) {
765 throw processException(e);
766 }
767 finally {
768 closeSession(session);
769 }
770
771 if (userTrackerPath != null) {
772 clearCache(userTrackerPath);
773 }
774
775 return userTrackerPath;
776 }
777
778 @Override
779 public UserTrackerPath updateImpl(
780 com.liferay.portal.model.UserTrackerPath userTrackerPath)
781 throws SystemException {
782 userTrackerPath = toUnwrappedModel(userTrackerPath);
783
784 boolean isNew = userTrackerPath.isNew();
785
786 UserTrackerPathModelImpl userTrackerPathModelImpl = (UserTrackerPathModelImpl)userTrackerPath;
787
788 Session session = null;
789
790 try {
791 session = openSession();
792
793 if (userTrackerPath.isNew()) {
794 session.save(userTrackerPath);
795
796 userTrackerPath.setNew(false);
797 }
798 else {
799 session.merge(userTrackerPath);
800 }
801 }
802 catch (Exception e) {
803 throw processException(e);
804 }
805 finally {
806 closeSession(session);
807 }
808
809 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
810
811 if (isNew || !UserTrackerPathModelImpl.COLUMN_BITMASK_ENABLED) {
812 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
813 }
814
815 else {
816 if ((userTrackerPathModelImpl.getColumnBitmask() &
817 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID.getColumnBitmask()) != 0) {
818 Object[] args = new Object[] {
819 userTrackerPathModelImpl.getOriginalUserTrackerId()
820 };
821
822 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
823 args);
824 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
825 args);
826
827 args = new Object[] { userTrackerPathModelImpl.getUserTrackerId() };
828
829 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
830 args);
831 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
832 args);
833 }
834 }
835
836 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
837 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
838 userTrackerPath);
839
840 return userTrackerPath;
841 }
842
843 protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
844 if (userTrackerPath instanceof UserTrackerPathImpl) {
845 return userTrackerPath;
846 }
847
848 UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
849
850 userTrackerPathImpl.setNew(userTrackerPath.isNew());
851 userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
852
853 userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
854 userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
855 userTrackerPathImpl.setPath(userTrackerPath.getPath());
856 userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
857
858 return userTrackerPathImpl;
859 }
860
861
869 @Override
870 public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
871 throws NoSuchUserTrackerPathException, SystemException {
872 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
873
874 if (userTrackerPath == null) {
875 if (_log.isWarnEnabled()) {
876 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
877 }
878
879 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
880 primaryKey);
881 }
882
883 return userTrackerPath;
884 }
885
886
894 @Override
895 public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
896 throws NoSuchUserTrackerPathException, SystemException {
897 return findByPrimaryKey((Serializable)userTrackerPathId);
898 }
899
900
907 @Override
908 public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey)
909 throws SystemException {
910 UserTrackerPath userTrackerPath = (UserTrackerPath)EntityCacheUtil.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
911 UserTrackerPathImpl.class, primaryKey);
912
913 if (userTrackerPath == _nullUserTrackerPath) {
914 return null;
915 }
916
917 if (userTrackerPath == null) {
918 Session session = null;
919
920 try {
921 session = openSession();
922
923 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
924 primaryKey);
925
926 if (userTrackerPath != null) {
927 cacheResult(userTrackerPath);
928 }
929 else {
930 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
931 UserTrackerPathImpl.class, primaryKey,
932 _nullUserTrackerPath);
933 }
934 }
935 catch (Exception e) {
936 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
937 UserTrackerPathImpl.class, primaryKey);
938
939 throw processException(e);
940 }
941 finally {
942 closeSession(session);
943 }
944 }
945
946 return userTrackerPath;
947 }
948
949
956 @Override
957 public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId)
958 throws SystemException {
959 return fetchByPrimaryKey((Serializable)userTrackerPathId);
960 }
961
962
968 @Override
969 public List<UserTrackerPath> findAll() throws SystemException {
970 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
971 }
972
973
985 @Override
986 public List<UserTrackerPath> findAll(int start, int end)
987 throws SystemException {
988 return findAll(start, end, null);
989 }
990
991
1004 @Override
1005 public List<UserTrackerPath> findAll(int start, int end,
1006 OrderByComparator orderByComparator) throws SystemException {
1007 boolean pagination = true;
1008 FinderPath finderPath = null;
1009 Object[] finderArgs = null;
1010
1011 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1012 (orderByComparator == null)) {
1013 pagination = false;
1014 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1015 finderArgs = FINDER_ARGS_EMPTY;
1016 }
1017 else {
1018 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1019 finderArgs = new Object[] { start, end, orderByComparator };
1020 }
1021
1022 List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(finderPath,
1023 finderArgs, this);
1024
1025 if (list == null) {
1026 StringBundler query = null;
1027 String sql = null;
1028
1029 if (orderByComparator != null) {
1030 query = new StringBundler(2 +
1031 (orderByComparator.getOrderByFields().length * 3));
1032
1033 query.append(_SQL_SELECT_USERTRACKERPATH);
1034
1035 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1036 orderByComparator);
1037
1038 sql = query.toString();
1039 }
1040 else {
1041 sql = _SQL_SELECT_USERTRACKERPATH;
1042
1043 if (pagination) {
1044 sql = sql.concat(UserTrackerPathModelImpl.ORDER_BY_JPQL);
1045 }
1046 }
1047
1048 Session session = null;
1049
1050 try {
1051 session = openSession();
1052
1053 Query q = session.createQuery(sql);
1054
1055 if (!pagination) {
1056 list = (List<UserTrackerPath>)QueryUtil.list(q,
1057 getDialect(), start, end, false);
1058
1059 Collections.sort(list);
1060
1061 list = new UnmodifiableList<UserTrackerPath>(list);
1062 }
1063 else {
1064 list = (List<UserTrackerPath>)QueryUtil.list(q,
1065 getDialect(), start, end);
1066 }
1067
1068 cacheResult(list);
1069
1070 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1071 }
1072 catch (Exception e) {
1073 FinderCacheUtil.removeResult(finderPath, finderArgs);
1074
1075 throw processException(e);
1076 }
1077 finally {
1078 closeSession(session);
1079 }
1080 }
1081
1082 return list;
1083 }
1084
1085
1090 @Override
1091 public void removeAll() throws SystemException {
1092 for (UserTrackerPath userTrackerPath : findAll()) {
1093 remove(userTrackerPath);
1094 }
1095 }
1096
1097
1103 @Override
1104 public int countAll() throws SystemException {
1105 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1106 FINDER_ARGS_EMPTY, this);
1107
1108 if (count == null) {
1109 Session session = null;
1110
1111 try {
1112 session = openSession();
1113
1114 Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
1115
1116 count = (Long)q.uniqueResult();
1117
1118 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1119 FINDER_ARGS_EMPTY, count);
1120 }
1121 catch (Exception e) {
1122 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1123 FINDER_ARGS_EMPTY);
1124
1125 throw processException(e);
1126 }
1127 finally {
1128 closeSession(session);
1129 }
1130 }
1131
1132 return count.intValue();
1133 }
1134
1135 @Override
1136 protected Set<String> getBadColumnNames() {
1137 return _badColumnNames;
1138 }
1139
1140
1143 public void afterPropertiesSet() {
1144 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1145 com.liferay.portal.util.PropsUtil.get(
1146 "value.object.listener.com.liferay.portal.model.UserTrackerPath")));
1147
1148 if (listenerClassNames.length > 0) {
1149 try {
1150 List<ModelListener<UserTrackerPath>> listenersList = new ArrayList<ModelListener<UserTrackerPath>>();
1151
1152 for (String listenerClassName : listenerClassNames) {
1153 listenersList.add((ModelListener<UserTrackerPath>)InstanceFactory.newInstance(
1154 getClassLoader(), listenerClassName));
1155 }
1156
1157 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1158 }
1159 catch (Exception e) {
1160 _log.error(e);
1161 }
1162 }
1163 }
1164
1165 public void destroy() {
1166 EntityCacheUtil.removeCache(UserTrackerPathImpl.class.getName());
1167 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1168 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1169 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1170 }
1171
1172 private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1173 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1174 private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1175 private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1176 private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1177 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1178 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1179 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1180 private static Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1181 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1182 "path"
1183 });
1184 private static UserTrackerPath _nullUserTrackerPath = new UserTrackerPathImpl() {
1185 @Override
1186 public Object clone() {
1187 return this;
1188 }
1189
1190 @Override
1191 public CacheModel<UserTrackerPath> toCacheModel() {
1192 return _nullUserTrackerPathCacheModel;
1193 }
1194 };
1195
1196 private static CacheModel<UserTrackerPath> _nullUserTrackerPathCacheModel = new CacheModel<UserTrackerPath>() {
1197 @Override
1198 public UserTrackerPath toEntityModel() {
1199 return _nullUserTrackerPath;
1200 }
1201 };
1202 }