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