001
014
015 package com.liferay.portal.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.NoSuchUserTrackerPathException;
020 import com.liferay.portal.kernel.dao.orm.EntityCache;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCache;
023 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024 import com.liferay.portal.kernel.dao.orm.FinderPath;
025 import com.liferay.portal.kernel.dao.orm.Query;
026 import com.liferay.portal.kernel.dao.orm.QueryPos;
027 import com.liferay.portal.kernel.dao.orm.QueryUtil;
028 import com.liferay.portal.kernel.dao.orm.Session;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
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.model.CacheModel;
036 import com.liferay.portal.model.MVCCModel;
037 import com.liferay.portal.model.UserTrackerPath;
038 import com.liferay.portal.model.impl.UserTrackerPathImpl;
039 import com.liferay.portal.model.impl.UserTrackerPathModelImpl;
040 import com.liferay.portal.service.persistence.UserTrackerPathPersistence;
041
042 import java.io.Serializable;
043
044 import java.util.Collections;
045 import java.util.HashMap;
046 import java.util.HashSet;
047 import java.util.Iterator;
048 import java.util.List;
049 import java.util.Map;
050 import java.util.Set;
051
052
064 @ProviderType
065 public class UserTrackerPathPersistenceImpl extends BasePersistenceImpl<UserTrackerPath>
066 implements UserTrackerPathPersistence {
067
072 public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerPathImpl.class.getName();
073 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List1";
075 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List2";
077 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
078 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
079 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
080 "findAll", new String[0]);
081 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
082 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
083 UserTrackerPathImpl.class,
084 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
086 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID =
089 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
090 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
091 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
092 "findByUserTrackerId",
093 new String[] {
094 Long.class.getName(),
095
096 Integer.class.getName(), Integer.class.getName(),
097 OrderByComparator.class.getName()
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID =
100 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
101 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
102 UserTrackerPathImpl.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserTrackerId",
104 new String[] { Long.class.getName() },
105 UserTrackerPathModelImpl.USERTRACKERID_COLUMN_BITMASK);
106 public static final FinderPath FINDER_PATH_COUNT_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
107 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserTrackerId",
109 new String[] { Long.class.getName() });
110
111
117 @Override
118 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId) {
119 return findByUserTrackerId(userTrackerId, QueryUtil.ALL_POS,
120 QueryUtil.ALL_POS, null);
121 }
122
123
135 @Override
136 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
137 int start, int end) {
138 return findByUserTrackerId(userTrackerId, start, end, null);
139 }
140
141
154 @Override
155 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
156 int start, int end, OrderByComparator<UserTrackerPath> orderByComparator) {
157 return findByUserTrackerId(userTrackerId, start, end,
158 orderByComparator, true);
159 }
160
161
175 @Override
176 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
177 int start, int end,
178 OrderByComparator<UserTrackerPath> orderByComparator,
179 boolean retrieveFromCache) {
180 boolean pagination = true;
181 FinderPath finderPath = null;
182 Object[] finderArgs = null;
183
184 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
185 (orderByComparator == null)) {
186 pagination = false;
187 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID;
188 finderArgs = new Object[] { userTrackerId };
189 }
190 else {
191 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID;
192 finderArgs = new Object[] {
193 userTrackerId,
194
195 start, end, orderByComparator
196 };
197 }
198
199 List<UserTrackerPath> list = null;
200
201 if (retrieveFromCache) {
202 list = (List<UserTrackerPath>)finderCache.getResult(finderPath,
203 finderArgs, this);
204
205 if ((list != null) && !list.isEmpty()) {
206 for (UserTrackerPath userTrackerPath : list) {
207 if ((userTrackerId != userTrackerPath.getUserTrackerId())) {
208 list = null;
209
210 break;
211 }
212 }
213 }
214 }
215
216 if (list == null) {
217 StringBundler query = null;
218
219 if (orderByComparator != null) {
220 query = new StringBundler(3 +
221 (orderByComparator.getOrderByFields().length * 3));
222 }
223 else {
224 query = new StringBundler(3);
225 }
226
227 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
228
229 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
230
231 if (orderByComparator != null) {
232 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
233 orderByComparator);
234 }
235 else
236 if (pagination) {
237 query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
238 }
239
240 String sql = query.toString();
241
242 Session session = null;
243
244 try {
245 session = openSession();
246
247 Query q = session.createQuery(sql);
248
249 QueryPos qPos = QueryPos.getInstance(q);
250
251 qPos.add(userTrackerId);
252
253 if (!pagination) {
254 list = (List<UserTrackerPath>)QueryUtil.list(q,
255 getDialect(), start, end, false);
256
257 Collections.sort(list);
258
259 list = Collections.unmodifiableList(list);
260 }
261 else {
262 list = (List<UserTrackerPath>)QueryUtil.list(q,
263 getDialect(), start, end);
264 }
265
266 cacheResult(list);
267
268 finderCache.putResult(finderPath, finderArgs, list);
269 }
270 catch (Exception e) {
271 finderCache.removeResult(finderPath, finderArgs);
272
273 throw processException(e);
274 }
275 finally {
276 closeSession(session);
277 }
278 }
279
280 return list;
281 }
282
283
291 @Override
292 public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
293 OrderByComparator<UserTrackerPath> orderByComparator)
294 throws NoSuchUserTrackerPathException {
295 UserTrackerPath userTrackerPath = fetchByUserTrackerId_First(userTrackerId,
296 orderByComparator);
297
298 if (userTrackerPath != null) {
299 return userTrackerPath;
300 }
301
302 StringBundler msg = new StringBundler(4);
303
304 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
305
306 msg.append("userTrackerId=");
307 msg.append(userTrackerId);
308
309 msg.append(StringPool.CLOSE_CURLY_BRACE);
310
311 throw new NoSuchUserTrackerPathException(msg.toString());
312 }
313
314
321 @Override
322 public UserTrackerPath fetchByUserTrackerId_First(long userTrackerId,
323 OrderByComparator<UserTrackerPath> orderByComparator) {
324 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId, 0, 1,
325 orderByComparator);
326
327 if (!list.isEmpty()) {
328 return list.get(0);
329 }
330
331 return null;
332 }
333
334
342 @Override
343 public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
344 OrderByComparator<UserTrackerPath> orderByComparator)
345 throws NoSuchUserTrackerPathException {
346 UserTrackerPath userTrackerPath = fetchByUserTrackerId_Last(userTrackerId,
347 orderByComparator);
348
349 if (userTrackerPath != null) {
350 return userTrackerPath;
351 }
352
353 StringBundler msg = new StringBundler(4);
354
355 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
356
357 msg.append("userTrackerId=");
358 msg.append(userTrackerId);
359
360 msg.append(StringPool.CLOSE_CURLY_BRACE);
361
362 throw new NoSuchUserTrackerPathException(msg.toString());
363 }
364
365
372 @Override
373 public UserTrackerPath fetchByUserTrackerId_Last(long userTrackerId,
374 OrderByComparator<UserTrackerPath> orderByComparator) {
375 int count = countByUserTrackerId(userTrackerId);
376
377 if (count == 0) {
378 return null;
379 }
380
381 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
382 count - 1, count, orderByComparator);
383
384 if (!list.isEmpty()) {
385 return list.get(0);
386 }
387
388 return null;
389 }
390
391
400 @Override
401 public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
402 long userTrackerPathId, long userTrackerId,
403 OrderByComparator<UserTrackerPath> orderByComparator)
404 throws NoSuchUserTrackerPathException {
405 UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
406
407 Session session = null;
408
409 try {
410 session = openSession();
411
412 UserTrackerPath[] array = new UserTrackerPathImpl[3];
413
414 array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
415 userTrackerId, orderByComparator, true);
416
417 array[1] = userTrackerPath;
418
419 array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
420 userTrackerId, orderByComparator, false);
421
422 return array;
423 }
424 catch (Exception e) {
425 throw processException(e);
426 }
427 finally {
428 closeSession(session);
429 }
430 }
431
432 protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
433 UserTrackerPath userTrackerPath, long userTrackerId,
434 OrderByComparator<UserTrackerPath> orderByComparator, boolean previous) {
435 StringBundler query = null;
436
437 if (orderByComparator != null) {
438 query = new StringBundler(6 +
439 (orderByComparator.getOrderByFields().length * 6));
440 }
441 else {
442 query = new StringBundler(3);
443 }
444
445 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
446
447 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
448
449 if (orderByComparator != null) {
450 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
451
452 if (orderByConditionFields.length > 0) {
453 query.append(WHERE_AND);
454 }
455
456 for (int i = 0; i < orderByConditionFields.length; i++) {
457 query.append(_ORDER_BY_ENTITY_ALIAS);
458 query.append(orderByConditionFields[i]);
459
460 if ((i + 1) < orderByConditionFields.length) {
461 if (orderByComparator.isAscending() ^ previous) {
462 query.append(WHERE_GREATER_THAN_HAS_NEXT);
463 }
464 else {
465 query.append(WHERE_LESSER_THAN_HAS_NEXT);
466 }
467 }
468 else {
469 if (orderByComparator.isAscending() ^ previous) {
470 query.append(WHERE_GREATER_THAN);
471 }
472 else {
473 query.append(WHERE_LESSER_THAN);
474 }
475 }
476 }
477
478 query.append(ORDER_BY_CLAUSE);
479
480 String[] orderByFields = orderByComparator.getOrderByFields();
481
482 for (int i = 0; i < orderByFields.length; i++) {
483 query.append(_ORDER_BY_ENTITY_ALIAS);
484 query.append(orderByFields[i]);
485
486 if ((i + 1) < orderByFields.length) {
487 if (orderByComparator.isAscending() ^ previous) {
488 query.append(ORDER_BY_ASC_HAS_NEXT);
489 }
490 else {
491 query.append(ORDER_BY_DESC_HAS_NEXT);
492 }
493 }
494 else {
495 if (orderByComparator.isAscending() ^ previous) {
496 query.append(ORDER_BY_ASC);
497 }
498 else {
499 query.append(ORDER_BY_DESC);
500 }
501 }
502 }
503 }
504 else {
505 query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
506 }
507
508 String sql = query.toString();
509
510 Query q = session.createQuery(sql);
511
512 q.setFirstResult(0);
513 q.setMaxResults(2);
514
515 QueryPos qPos = QueryPos.getInstance(q);
516
517 qPos.add(userTrackerId);
518
519 if (orderByComparator != null) {
520 Object[] values = orderByComparator.getOrderByConditionValues(userTrackerPath);
521
522 for (Object value : values) {
523 qPos.add(value);
524 }
525 }
526
527 List<UserTrackerPath> list = q.list();
528
529 if (list.size() == 2) {
530 return list.get(1);
531 }
532 else {
533 return null;
534 }
535 }
536
537
542 @Override
543 public void removeByUserTrackerId(long userTrackerId) {
544 for (UserTrackerPath userTrackerPath : findByUserTrackerId(
545 userTrackerId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
546 remove(userTrackerPath);
547 }
548 }
549
550
556 @Override
557 public int countByUserTrackerId(long userTrackerId) {
558 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERTRACKERID;
559
560 Object[] finderArgs = new Object[] { userTrackerId };
561
562 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
563
564 if (count == null) {
565 StringBundler query = new StringBundler(2);
566
567 query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
568
569 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
570
571 String sql = query.toString();
572
573 Session session = null;
574
575 try {
576 session = openSession();
577
578 Query q = session.createQuery(sql);
579
580 QueryPos qPos = QueryPos.getInstance(q);
581
582 qPos.add(userTrackerId);
583
584 count = (Long)q.uniqueResult();
585
586 finderCache.putResult(finderPath, finderArgs, count);
587 }
588 catch (Exception e) {
589 finderCache.removeResult(finderPath, finderArgs);
590
591 throw processException(e);
592 }
593 finally {
594 closeSession(session);
595 }
596 }
597
598 return count.intValue();
599 }
600
601 private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
602
603 public UserTrackerPathPersistenceImpl() {
604 setModelClass(UserTrackerPath.class);
605 }
606
607
612 @Override
613 public void cacheResult(UserTrackerPath userTrackerPath) {
614 entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
615 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
616 userTrackerPath);
617
618 userTrackerPath.resetOriginalValues();
619 }
620
621
626 @Override
627 public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
628 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
629 if (entityCache.getResult(
630 UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
631 UserTrackerPathImpl.class,
632 userTrackerPath.getPrimaryKey()) == null) {
633 cacheResult(userTrackerPath);
634 }
635 else {
636 userTrackerPath.resetOriginalValues();
637 }
638 }
639 }
640
641
648 @Override
649 public void clearCache() {
650 entityCache.clearCache(UserTrackerPathImpl.class);
651
652 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
653 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
654 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
655 }
656
657
664 @Override
665 public void clearCache(UserTrackerPath userTrackerPath) {
666 entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
667 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
668
669 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
670 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
671 }
672
673 @Override
674 public void clearCache(List<UserTrackerPath> userTrackerPaths) {
675 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
676 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
677
678 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
679 entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
680 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
681 }
682 }
683
684
690 @Override
691 public UserTrackerPath create(long userTrackerPathId) {
692 UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
693
694 userTrackerPath.setNew(true);
695 userTrackerPath.setPrimaryKey(userTrackerPathId);
696
697 return userTrackerPath;
698 }
699
700
707 @Override
708 public UserTrackerPath remove(long userTrackerPathId)
709 throws NoSuchUserTrackerPathException {
710 return remove((Serializable)userTrackerPathId);
711 }
712
713
720 @Override
721 public UserTrackerPath remove(Serializable primaryKey)
722 throws NoSuchUserTrackerPathException {
723 Session session = null;
724
725 try {
726 session = openSession();
727
728 UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
729 primaryKey);
730
731 if (userTrackerPath == null) {
732 if (_log.isWarnEnabled()) {
733 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
734 }
735
736 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
737 primaryKey);
738 }
739
740 return remove(userTrackerPath);
741 }
742 catch (NoSuchUserTrackerPathException nsee) {
743 throw nsee;
744 }
745 catch (Exception e) {
746 throw processException(e);
747 }
748 finally {
749 closeSession(session);
750 }
751 }
752
753 @Override
754 protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath) {
755 userTrackerPath = toUnwrappedModel(userTrackerPath);
756
757 Session session = null;
758
759 try {
760 session = openSession();
761
762 if (!session.contains(userTrackerPath)) {
763 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
764 userTrackerPath.getPrimaryKeyObj());
765 }
766
767 if (userTrackerPath != null) {
768 session.delete(userTrackerPath);
769 }
770 }
771 catch (Exception e) {
772 throw processException(e);
773 }
774 finally {
775 closeSession(session);
776 }
777
778 if (userTrackerPath != null) {
779 clearCache(userTrackerPath);
780 }
781
782 return userTrackerPath;
783 }
784
785 @Override
786 public UserTrackerPath updateImpl(UserTrackerPath userTrackerPath) {
787 userTrackerPath = toUnwrappedModel(userTrackerPath);
788
789 boolean isNew = userTrackerPath.isNew();
790
791 UserTrackerPathModelImpl userTrackerPathModelImpl = (UserTrackerPathModelImpl)userTrackerPath;
792
793 Session session = null;
794
795 try {
796 session = openSession();
797
798 if (userTrackerPath.isNew()) {
799 session.save(userTrackerPath);
800
801 userTrackerPath.setNew(false);
802 }
803 else {
804 userTrackerPath = (UserTrackerPath)session.merge(userTrackerPath);
805 }
806 }
807 catch (Exception e) {
808 throw processException(e);
809 }
810 finally {
811 closeSession(session);
812 }
813
814 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
815
816 if (isNew || !UserTrackerPathModelImpl.COLUMN_BITMASK_ENABLED) {
817 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
818 }
819
820 else {
821 if ((userTrackerPathModelImpl.getColumnBitmask() &
822 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID.getColumnBitmask()) != 0) {
823 Object[] args = new Object[] {
824 userTrackerPathModelImpl.getOriginalUserTrackerId()
825 };
826
827 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
828 args);
829 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
830 args);
831
832 args = new Object[] { userTrackerPathModelImpl.getUserTrackerId() };
833
834 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
835 args);
836 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
837 args);
838 }
839 }
840
841 entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
842 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
843 userTrackerPath, false);
844
845 userTrackerPath.resetOriginalValues();
846
847 return userTrackerPath;
848 }
849
850 protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
851 if (userTrackerPath instanceof UserTrackerPathImpl) {
852 return userTrackerPath;
853 }
854
855 UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
856
857 userTrackerPathImpl.setNew(userTrackerPath.isNew());
858 userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
859
860 userTrackerPathImpl.setMvccVersion(userTrackerPath.getMvccVersion());
861 userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
862 userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
863 userTrackerPathImpl.setPath(userTrackerPath.getPath());
864 userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
865
866 return userTrackerPathImpl;
867 }
868
869
876 @Override
877 public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
878 throws NoSuchUserTrackerPathException {
879 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
880
881 if (userTrackerPath == null) {
882 if (_log.isWarnEnabled()) {
883 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
884 }
885
886 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
887 primaryKey);
888 }
889
890 return userTrackerPath;
891 }
892
893
900 @Override
901 public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
902 throws NoSuchUserTrackerPathException {
903 return findByPrimaryKey((Serializable)userTrackerPathId);
904 }
905
906
912 @Override
913 public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey) {
914 UserTrackerPath userTrackerPath = (UserTrackerPath)entityCache.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
915 UserTrackerPathImpl.class, primaryKey);
916
917 if (userTrackerPath == _nullUserTrackerPath) {
918 return null;
919 }
920
921 if (userTrackerPath == null) {
922 Session session = null;
923
924 try {
925 session = openSession();
926
927 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
928 primaryKey);
929
930 if (userTrackerPath != null) {
931 cacheResult(userTrackerPath);
932 }
933 else {
934 entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
935 UserTrackerPathImpl.class, primaryKey,
936 _nullUserTrackerPath);
937 }
938 }
939 catch (Exception e) {
940 entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
941 UserTrackerPathImpl.class, primaryKey);
942
943 throw processException(e);
944 }
945 finally {
946 closeSession(session);
947 }
948 }
949
950 return userTrackerPath;
951 }
952
953
959 @Override
960 public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId) {
961 return fetchByPrimaryKey((Serializable)userTrackerPathId);
962 }
963
964 @Override
965 public Map<Serializable, UserTrackerPath> fetchByPrimaryKeys(
966 Set<Serializable> primaryKeys) {
967 if (primaryKeys.isEmpty()) {
968 return Collections.emptyMap();
969 }
970
971 Map<Serializable, UserTrackerPath> map = new HashMap<Serializable, UserTrackerPath>();
972
973 if (primaryKeys.size() == 1) {
974 Iterator<Serializable> iterator = primaryKeys.iterator();
975
976 Serializable primaryKey = iterator.next();
977
978 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
979
980 if (userTrackerPath != null) {
981 map.put(primaryKey, userTrackerPath);
982 }
983
984 return map;
985 }
986
987 Set<Serializable> uncachedPrimaryKeys = null;
988
989 for (Serializable primaryKey : primaryKeys) {
990 UserTrackerPath userTrackerPath = (UserTrackerPath)entityCache.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
991 UserTrackerPathImpl.class, primaryKey);
992
993 if (userTrackerPath == null) {
994 if (uncachedPrimaryKeys == null) {
995 uncachedPrimaryKeys = new HashSet<Serializable>();
996 }
997
998 uncachedPrimaryKeys.add(primaryKey);
999 }
1000 else {
1001 map.put(primaryKey, userTrackerPath);
1002 }
1003 }
1004
1005 if (uncachedPrimaryKeys == null) {
1006 return map;
1007 }
1008
1009 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1010 1);
1011
1012 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN);
1013
1014 for (Serializable primaryKey : uncachedPrimaryKeys) {
1015 query.append(String.valueOf(primaryKey));
1016
1017 query.append(StringPool.COMMA);
1018 }
1019
1020 query.setIndex(query.index() - 1);
1021
1022 query.append(StringPool.CLOSE_PARENTHESIS);
1023
1024 String sql = query.toString();
1025
1026 Session session = null;
1027
1028 try {
1029 session = openSession();
1030
1031 Query q = session.createQuery(sql);
1032
1033 for (UserTrackerPath userTrackerPath : (List<UserTrackerPath>)q.list()) {
1034 map.put(userTrackerPath.getPrimaryKeyObj(), userTrackerPath);
1035
1036 cacheResult(userTrackerPath);
1037
1038 uncachedPrimaryKeys.remove(userTrackerPath.getPrimaryKeyObj());
1039 }
1040
1041 for (Serializable primaryKey : uncachedPrimaryKeys) {
1042 entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
1043 UserTrackerPathImpl.class, primaryKey, _nullUserTrackerPath);
1044 }
1045 }
1046 catch (Exception e) {
1047 throw processException(e);
1048 }
1049 finally {
1050 closeSession(session);
1051 }
1052
1053 return map;
1054 }
1055
1056
1061 @Override
1062 public List<UserTrackerPath> findAll() {
1063 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1064 }
1065
1066
1077 @Override
1078 public List<UserTrackerPath> findAll(int start, int end) {
1079 return findAll(start, end, null);
1080 }
1081
1082
1094 @Override
1095 public List<UserTrackerPath> findAll(int start, int end,
1096 OrderByComparator<UserTrackerPath> orderByComparator) {
1097 return findAll(start, end, orderByComparator, true);
1098 }
1099
1100
1113 @Override
1114 public List<UserTrackerPath> findAll(int start, int end,
1115 OrderByComparator<UserTrackerPath> orderByComparator,
1116 boolean retrieveFromCache) {
1117 boolean pagination = true;
1118 FinderPath finderPath = null;
1119 Object[] finderArgs = null;
1120
1121 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1122 (orderByComparator == null)) {
1123 pagination = false;
1124 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1125 finderArgs = FINDER_ARGS_EMPTY;
1126 }
1127 else {
1128 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1129 finderArgs = new Object[] { start, end, orderByComparator };
1130 }
1131
1132 List<UserTrackerPath> list = null;
1133
1134 if (retrieveFromCache) {
1135 list = (List<UserTrackerPath>)finderCache.getResult(finderPath,
1136 finderArgs, this);
1137 }
1138
1139 if (list == null) {
1140 StringBundler query = null;
1141 String sql = null;
1142
1143 if (orderByComparator != null) {
1144 query = new StringBundler(2 +
1145 (orderByComparator.getOrderByFields().length * 3));
1146
1147 query.append(_SQL_SELECT_USERTRACKERPATH);
1148
1149 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1150 orderByComparator);
1151
1152 sql = query.toString();
1153 }
1154 else {
1155 sql = _SQL_SELECT_USERTRACKERPATH;
1156
1157 if (pagination) {
1158 sql = sql.concat(UserTrackerPathModelImpl.ORDER_BY_JPQL);
1159 }
1160 }
1161
1162 Session session = null;
1163
1164 try {
1165 session = openSession();
1166
1167 Query q = session.createQuery(sql);
1168
1169 if (!pagination) {
1170 list = (List<UserTrackerPath>)QueryUtil.list(q,
1171 getDialect(), start, end, false);
1172
1173 Collections.sort(list);
1174
1175 list = Collections.unmodifiableList(list);
1176 }
1177 else {
1178 list = (List<UserTrackerPath>)QueryUtil.list(q,
1179 getDialect(), start, end);
1180 }
1181
1182 cacheResult(list);
1183
1184 finderCache.putResult(finderPath, finderArgs, list);
1185 }
1186 catch (Exception e) {
1187 finderCache.removeResult(finderPath, finderArgs);
1188
1189 throw processException(e);
1190 }
1191 finally {
1192 closeSession(session);
1193 }
1194 }
1195
1196 return list;
1197 }
1198
1199
1203 @Override
1204 public void removeAll() {
1205 for (UserTrackerPath userTrackerPath : findAll()) {
1206 remove(userTrackerPath);
1207 }
1208 }
1209
1210
1215 @Override
1216 public int countAll() {
1217 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
1218 FINDER_ARGS_EMPTY, this);
1219
1220 if (count == null) {
1221 Session session = null;
1222
1223 try {
1224 session = openSession();
1225
1226 Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
1227
1228 count = (Long)q.uniqueResult();
1229
1230 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
1231 count);
1232 }
1233 catch (Exception e) {
1234 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
1235 FINDER_ARGS_EMPTY);
1236
1237 throw processException(e);
1238 }
1239 finally {
1240 closeSession(session);
1241 }
1242 }
1243
1244 return count.intValue();
1245 }
1246
1247 @Override
1248 public Set<String> getBadColumnNames() {
1249 return _badColumnNames;
1250 }
1251
1252 @Override
1253 protected Map<String, Integer> getTableColumnsMap() {
1254 return UserTrackerPathModelImpl.TABLE_COLUMNS_MAP;
1255 }
1256
1257
1260 public void afterPropertiesSet() {
1261 }
1262
1263 public void destroy() {
1264 entityCache.removeCache(UserTrackerPathImpl.class.getName());
1265 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1266 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1267 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1268 }
1269
1270 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1271 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1272 private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1273 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE userTrackerPathId IN (";
1274 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1275 private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1276 private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1277 private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1278 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1279 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1280 private static final Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1281 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1282 "path"
1283 });
1284 private static final UserTrackerPath _nullUserTrackerPath = new UserTrackerPathImpl() {
1285 @Override
1286 public Object clone() {
1287 return this;
1288 }
1289
1290 @Override
1291 public CacheModel<UserTrackerPath> toCacheModel() {
1292 return _nullUserTrackerPathCacheModel;
1293 }
1294 };
1295
1296 private static final CacheModel<UserTrackerPath> _nullUserTrackerPathCacheModel =
1297 new NullCacheModel();
1298
1299 private static class NullCacheModel implements CacheModel<UserTrackerPath>,
1300 MVCCModel {
1301 @Override
1302 public long getMvccVersion() {
1303 return -1;
1304 }
1305
1306 @Override
1307 public void setMvccVersion(long mvccVersion) {
1308 }
1309
1310 @Override
1311 public UserTrackerPath toEntityModel() {
1312 return _nullUserTrackerPath;
1313 }
1314 }
1315 }