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