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
594 @Override
595 public void cacheResult(UserTrackerPath userTrackerPath) {
596 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
597 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
598 userTrackerPath);
599
600 userTrackerPath.resetOriginalValues();
601 }
602
603
608 @Override
609 public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
610 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
611 if (EntityCacheUtil.getResult(
612 UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
613 UserTrackerPathImpl.class,
614 userTrackerPath.getPrimaryKey()) == null) {
615 cacheResult(userTrackerPath);
616 }
617 else {
618 userTrackerPath.resetOriginalValues();
619 }
620 }
621 }
622
623
630 @Override
631 public void clearCache() {
632 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
633 CacheRegistryUtil.clear(UserTrackerPathImpl.class.getName());
634 }
635
636 EntityCacheUtil.clearCache(UserTrackerPathImpl.class.getName());
637
638 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
639 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
640 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
641 }
642
643
650 @Override
651 public void clearCache(UserTrackerPath userTrackerPath) {
652 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
653 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
654
655 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
656 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
657 }
658
659 @Override
660 public void clearCache(List<UserTrackerPath> userTrackerPaths) {
661 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
662 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
663
664 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
665 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
666 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
667 }
668 }
669
670
676 @Override
677 public UserTrackerPath create(long userTrackerPathId) {
678 UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
679
680 userTrackerPath.setNew(true);
681 userTrackerPath.setPrimaryKey(userTrackerPathId);
682
683 return userTrackerPath;
684 }
685
686
694 @Override
695 public UserTrackerPath remove(long userTrackerPathId)
696 throws NoSuchUserTrackerPathException, SystemException {
697 return remove((Serializable)userTrackerPathId);
698 }
699
700
708 @Override
709 public UserTrackerPath remove(Serializable primaryKey)
710 throws NoSuchUserTrackerPathException, SystemException {
711 Session session = null;
712
713 try {
714 session = openSession();
715
716 UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
717 primaryKey);
718
719 if (userTrackerPath == null) {
720 if (_log.isWarnEnabled()) {
721 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
722 }
723
724 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
725 primaryKey);
726 }
727
728 return remove(userTrackerPath);
729 }
730 catch (NoSuchUserTrackerPathException nsee) {
731 throw nsee;
732 }
733 catch (Exception e) {
734 throw processException(e);
735 }
736 finally {
737 closeSession(session);
738 }
739 }
740
741 @Override
742 protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath)
743 throws SystemException {
744 userTrackerPath = toUnwrappedModel(userTrackerPath);
745
746 Session session = null;
747
748 try {
749 session = openSession();
750
751 if (!session.contains(userTrackerPath)) {
752 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
753 userTrackerPath.getPrimaryKeyObj());
754 }
755
756 if (userTrackerPath != null) {
757 session.delete(userTrackerPath);
758 }
759 }
760 catch (Exception e) {
761 throw processException(e);
762 }
763 finally {
764 closeSession(session);
765 }
766
767 if (userTrackerPath != null) {
768 clearCache(userTrackerPath);
769 }
770
771 return userTrackerPath;
772 }
773
774 @Override
775 public UserTrackerPath updateImpl(
776 com.liferay.portal.model.UserTrackerPath userTrackerPath)
777 throws SystemException {
778 userTrackerPath = toUnwrappedModel(userTrackerPath);
779
780 boolean isNew = userTrackerPath.isNew();
781
782 UserTrackerPathModelImpl userTrackerPathModelImpl = (UserTrackerPathModelImpl)userTrackerPath;
783
784 Session session = null;
785
786 try {
787 session = openSession();
788
789 if (userTrackerPath.isNew()) {
790 session.save(userTrackerPath);
791
792 userTrackerPath.setNew(false);
793 }
794 else {
795 session.merge(userTrackerPath);
796 }
797 }
798 catch (Exception e) {
799 throw processException(e);
800 }
801 finally {
802 closeSession(session);
803 }
804
805 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
806
807 if (isNew || !UserTrackerPathModelImpl.COLUMN_BITMASK_ENABLED) {
808 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
809 }
810
811 else {
812 if ((userTrackerPathModelImpl.getColumnBitmask() &
813 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID.getColumnBitmask()) != 0) {
814 Object[] args = new Object[] {
815 userTrackerPathModelImpl.getOriginalUserTrackerId()
816 };
817
818 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
819 args);
820 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
821 args);
822
823 args = new Object[] { userTrackerPathModelImpl.getUserTrackerId() };
824
825 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
826 args);
827 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
828 args);
829 }
830 }
831
832 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
833 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
834 userTrackerPath);
835
836 return userTrackerPath;
837 }
838
839 protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
840 if (userTrackerPath instanceof UserTrackerPathImpl) {
841 return userTrackerPath;
842 }
843
844 UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
845
846 userTrackerPathImpl.setNew(userTrackerPath.isNew());
847 userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
848
849 userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
850 userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
851 userTrackerPathImpl.setPath(userTrackerPath.getPath());
852 userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
853
854 return userTrackerPathImpl;
855 }
856
857
865 @Override
866 public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
867 throws NoSuchUserTrackerPathException, SystemException {
868 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
869
870 if (userTrackerPath == null) {
871 if (_log.isWarnEnabled()) {
872 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
873 }
874
875 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
876 primaryKey);
877 }
878
879 return userTrackerPath;
880 }
881
882
890 @Override
891 public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
892 throws NoSuchUserTrackerPathException, SystemException {
893 return findByPrimaryKey((Serializable)userTrackerPathId);
894 }
895
896
903 @Override
904 public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey)
905 throws SystemException {
906 UserTrackerPath userTrackerPath = (UserTrackerPath)EntityCacheUtil.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
907 UserTrackerPathImpl.class, primaryKey);
908
909 if (userTrackerPath == _nullUserTrackerPath) {
910 return null;
911 }
912
913 if (userTrackerPath == null) {
914 Session session = null;
915
916 try {
917 session = openSession();
918
919 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
920 primaryKey);
921
922 if (userTrackerPath != null) {
923 cacheResult(userTrackerPath);
924 }
925 else {
926 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
927 UserTrackerPathImpl.class, primaryKey,
928 _nullUserTrackerPath);
929 }
930 }
931 catch (Exception e) {
932 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
933 UserTrackerPathImpl.class, primaryKey);
934
935 throw processException(e);
936 }
937 finally {
938 closeSession(session);
939 }
940 }
941
942 return userTrackerPath;
943 }
944
945
952 @Override
953 public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId)
954 throws SystemException {
955 return fetchByPrimaryKey((Serializable)userTrackerPathId);
956 }
957
958
964 @Override
965 public List<UserTrackerPath> findAll() throws SystemException {
966 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
967 }
968
969
981 @Override
982 public List<UserTrackerPath> findAll(int start, int end)
983 throws SystemException {
984 return findAll(start, end, null);
985 }
986
987
1000 @Override
1001 public List<UserTrackerPath> findAll(int start, int end,
1002 OrderByComparator orderByComparator) throws SystemException {
1003 boolean pagination = true;
1004 FinderPath finderPath = null;
1005 Object[] finderArgs = null;
1006
1007 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1008 (orderByComparator == null)) {
1009 pagination = false;
1010 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1011 finderArgs = FINDER_ARGS_EMPTY;
1012 }
1013 else {
1014 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1015 finderArgs = new Object[] { start, end, orderByComparator };
1016 }
1017
1018 List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(finderPath,
1019 finderArgs, this);
1020
1021 if (list == null) {
1022 StringBundler query = null;
1023 String sql = null;
1024
1025 if (orderByComparator != null) {
1026 query = new StringBundler(2 +
1027 (orderByComparator.getOrderByFields().length * 3));
1028
1029 query.append(_SQL_SELECT_USERTRACKERPATH);
1030
1031 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1032 orderByComparator);
1033
1034 sql = query.toString();
1035 }
1036 else {
1037 sql = _SQL_SELECT_USERTRACKERPATH;
1038
1039 if (pagination) {
1040 sql = sql.concat(UserTrackerPathModelImpl.ORDER_BY_JPQL);
1041 }
1042 }
1043
1044 Session session = null;
1045
1046 try {
1047 session = openSession();
1048
1049 Query q = session.createQuery(sql);
1050
1051 if (!pagination) {
1052 list = (List<UserTrackerPath>)QueryUtil.list(q,
1053 getDialect(), start, end, false);
1054
1055 Collections.sort(list);
1056
1057 list = new UnmodifiableList<UserTrackerPath>(list);
1058 }
1059 else {
1060 list = (List<UserTrackerPath>)QueryUtil.list(q,
1061 getDialect(), start, end);
1062 }
1063
1064 cacheResult(list);
1065
1066 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1067 }
1068 catch (Exception e) {
1069 FinderCacheUtil.removeResult(finderPath, finderArgs);
1070
1071 throw processException(e);
1072 }
1073 finally {
1074 closeSession(session);
1075 }
1076 }
1077
1078 return list;
1079 }
1080
1081
1086 @Override
1087 public void removeAll() throws SystemException {
1088 for (UserTrackerPath userTrackerPath : findAll()) {
1089 remove(userTrackerPath);
1090 }
1091 }
1092
1093
1099 @Override
1100 public int countAll() throws SystemException {
1101 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1102 FINDER_ARGS_EMPTY, this);
1103
1104 if (count == null) {
1105 Session session = null;
1106
1107 try {
1108 session = openSession();
1109
1110 Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
1111
1112 count = (Long)q.uniqueResult();
1113
1114 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1115 FINDER_ARGS_EMPTY, count);
1116 }
1117 catch (Exception e) {
1118 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1119 FINDER_ARGS_EMPTY);
1120
1121 throw processException(e);
1122 }
1123 finally {
1124 closeSession(session);
1125 }
1126 }
1127
1128 return count.intValue();
1129 }
1130
1131 @Override
1132 protected Set<String> getBadColumnNames() {
1133 return _badColumnNames;
1134 }
1135
1136
1139 public void afterPropertiesSet() {
1140 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1141 com.liferay.portal.util.PropsUtil.get(
1142 "value.object.listener.com.liferay.portal.model.UserTrackerPath")));
1143
1144 if (listenerClassNames.length > 0) {
1145 try {
1146 List<ModelListener<UserTrackerPath>> listenersList = new ArrayList<ModelListener<UserTrackerPath>>();
1147
1148 for (String listenerClassName : listenerClassNames) {
1149 listenersList.add((ModelListener<UserTrackerPath>)InstanceFactory.newInstance(
1150 getClassLoader(), listenerClassName));
1151 }
1152
1153 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1154 }
1155 catch (Exception e) {
1156 _log.error(e);
1157 }
1158 }
1159 }
1160
1161 public void destroy() {
1162 EntityCacheUtil.removeCache(UserTrackerPathImpl.class.getName());
1163 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1164 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1165 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1166 }
1167
1168 private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1169 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1170 private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1171 private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1172 private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1173 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1174 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1175 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1176 private static Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1177 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1178 "path"
1179 });
1180 private static UserTrackerPath _nullUserTrackerPath = new UserTrackerPathImpl() {
1181 @Override
1182 public Object clone() {
1183 return this;
1184 }
1185
1186 @Override
1187 public CacheModel<UserTrackerPath> toCacheModel() {
1188 return _nullUserTrackerPathCacheModel;
1189 }
1190 };
1191
1192 private static CacheModel<UserTrackerPath> _nullUserTrackerPathCacheModel = new CacheModel<UserTrackerPath>() {
1193 @Override
1194 public UserTrackerPath toEntityModel() {
1195 return _nullUserTrackerPath;
1196 }
1197 };
1198 }