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.setCompanyId(userTrackerPath.getCompanyId());
863 userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
864 userTrackerPathImpl.setPath(userTrackerPath.getPath());
865 userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
866
867 return userTrackerPathImpl;
868 }
869
870
877 @Override
878 public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
879 throws NoSuchUserTrackerPathException {
880 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
881
882 if (userTrackerPath == null) {
883 if (_log.isWarnEnabled()) {
884 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
885 }
886
887 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
888 primaryKey);
889 }
890
891 return userTrackerPath;
892 }
893
894
901 @Override
902 public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
903 throws NoSuchUserTrackerPathException {
904 return findByPrimaryKey((Serializable)userTrackerPathId);
905 }
906
907
913 @Override
914 public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey) {
915 UserTrackerPath userTrackerPath = (UserTrackerPath)entityCache.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
916 UserTrackerPathImpl.class, primaryKey);
917
918 if (userTrackerPath == _nullUserTrackerPath) {
919 return null;
920 }
921
922 if (userTrackerPath == null) {
923 Session session = null;
924
925 try {
926 session = openSession();
927
928 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
929 primaryKey);
930
931 if (userTrackerPath != null) {
932 cacheResult(userTrackerPath);
933 }
934 else {
935 entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
936 UserTrackerPathImpl.class, primaryKey,
937 _nullUserTrackerPath);
938 }
939 }
940 catch (Exception e) {
941 entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
942 UserTrackerPathImpl.class, primaryKey);
943
944 throw processException(e);
945 }
946 finally {
947 closeSession(session);
948 }
949 }
950
951 return userTrackerPath;
952 }
953
954
960 @Override
961 public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId) {
962 return fetchByPrimaryKey((Serializable)userTrackerPathId);
963 }
964
965 @Override
966 public Map<Serializable, UserTrackerPath> fetchByPrimaryKeys(
967 Set<Serializable> primaryKeys) {
968 if (primaryKeys.isEmpty()) {
969 return Collections.emptyMap();
970 }
971
972 Map<Serializable, UserTrackerPath> map = new HashMap<Serializable, UserTrackerPath>();
973
974 if (primaryKeys.size() == 1) {
975 Iterator<Serializable> iterator = primaryKeys.iterator();
976
977 Serializable primaryKey = iterator.next();
978
979 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
980
981 if (userTrackerPath != null) {
982 map.put(primaryKey, userTrackerPath);
983 }
984
985 return map;
986 }
987
988 Set<Serializable> uncachedPrimaryKeys = null;
989
990 for (Serializable primaryKey : primaryKeys) {
991 UserTrackerPath userTrackerPath = (UserTrackerPath)entityCache.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
992 UserTrackerPathImpl.class, primaryKey);
993
994 if (userTrackerPath == null) {
995 if (uncachedPrimaryKeys == null) {
996 uncachedPrimaryKeys = new HashSet<Serializable>();
997 }
998
999 uncachedPrimaryKeys.add(primaryKey);
1000 }
1001 else {
1002 map.put(primaryKey, userTrackerPath);
1003 }
1004 }
1005
1006 if (uncachedPrimaryKeys == null) {
1007 return map;
1008 }
1009
1010 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1011 1);
1012
1013 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN);
1014
1015 for (Serializable primaryKey : uncachedPrimaryKeys) {
1016 query.append(String.valueOf(primaryKey));
1017
1018 query.append(StringPool.COMMA);
1019 }
1020
1021 query.setIndex(query.index() - 1);
1022
1023 query.append(StringPool.CLOSE_PARENTHESIS);
1024
1025 String sql = query.toString();
1026
1027 Session session = null;
1028
1029 try {
1030 session = openSession();
1031
1032 Query q = session.createQuery(sql);
1033
1034 for (UserTrackerPath userTrackerPath : (List<UserTrackerPath>)q.list()) {
1035 map.put(userTrackerPath.getPrimaryKeyObj(), userTrackerPath);
1036
1037 cacheResult(userTrackerPath);
1038
1039 uncachedPrimaryKeys.remove(userTrackerPath.getPrimaryKeyObj());
1040 }
1041
1042 for (Serializable primaryKey : uncachedPrimaryKeys) {
1043 entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
1044 UserTrackerPathImpl.class, primaryKey, _nullUserTrackerPath);
1045 }
1046 }
1047 catch (Exception e) {
1048 throw processException(e);
1049 }
1050 finally {
1051 closeSession(session);
1052 }
1053
1054 return map;
1055 }
1056
1057
1062 @Override
1063 public List<UserTrackerPath> findAll() {
1064 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1065 }
1066
1067
1078 @Override
1079 public List<UserTrackerPath> findAll(int start, int end) {
1080 return findAll(start, end, null);
1081 }
1082
1083
1095 @Override
1096 public List<UserTrackerPath> findAll(int start, int end,
1097 OrderByComparator<UserTrackerPath> orderByComparator) {
1098 return findAll(start, end, orderByComparator, true);
1099 }
1100
1101
1114 @Override
1115 public List<UserTrackerPath> findAll(int start, int end,
1116 OrderByComparator<UserTrackerPath> orderByComparator,
1117 boolean retrieveFromCache) {
1118 boolean pagination = true;
1119 FinderPath finderPath = null;
1120 Object[] finderArgs = null;
1121
1122 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1123 (orderByComparator == null)) {
1124 pagination = false;
1125 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1126 finderArgs = FINDER_ARGS_EMPTY;
1127 }
1128 else {
1129 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1130 finderArgs = new Object[] { start, end, orderByComparator };
1131 }
1132
1133 List<UserTrackerPath> list = null;
1134
1135 if (retrieveFromCache) {
1136 list = (List<UserTrackerPath>)finderCache.getResult(finderPath,
1137 finderArgs, this);
1138 }
1139
1140 if (list == null) {
1141 StringBundler query = null;
1142 String sql = null;
1143
1144 if (orderByComparator != null) {
1145 query = new StringBundler(2 +
1146 (orderByComparator.getOrderByFields().length * 3));
1147
1148 query.append(_SQL_SELECT_USERTRACKERPATH);
1149
1150 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1151 orderByComparator);
1152
1153 sql = query.toString();
1154 }
1155 else {
1156 sql = _SQL_SELECT_USERTRACKERPATH;
1157
1158 if (pagination) {
1159 sql = sql.concat(UserTrackerPathModelImpl.ORDER_BY_JPQL);
1160 }
1161 }
1162
1163 Session session = null;
1164
1165 try {
1166 session = openSession();
1167
1168 Query q = session.createQuery(sql);
1169
1170 if (!pagination) {
1171 list = (List<UserTrackerPath>)QueryUtil.list(q,
1172 getDialect(), start, end, false);
1173
1174 Collections.sort(list);
1175
1176 list = Collections.unmodifiableList(list);
1177 }
1178 else {
1179 list = (List<UserTrackerPath>)QueryUtil.list(q,
1180 getDialect(), start, end);
1181 }
1182
1183 cacheResult(list);
1184
1185 finderCache.putResult(finderPath, finderArgs, list);
1186 }
1187 catch (Exception e) {
1188 finderCache.removeResult(finderPath, finderArgs);
1189
1190 throw processException(e);
1191 }
1192 finally {
1193 closeSession(session);
1194 }
1195 }
1196
1197 return list;
1198 }
1199
1200
1204 @Override
1205 public void removeAll() {
1206 for (UserTrackerPath userTrackerPath : findAll()) {
1207 remove(userTrackerPath);
1208 }
1209 }
1210
1211
1216 @Override
1217 public int countAll() {
1218 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
1219 FINDER_ARGS_EMPTY, this);
1220
1221 if (count == null) {
1222 Session session = null;
1223
1224 try {
1225 session = openSession();
1226
1227 Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
1228
1229 count = (Long)q.uniqueResult();
1230
1231 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
1232 count);
1233 }
1234 catch (Exception e) {
1235 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
1236 FINDER_ARGS_EMPTY);
1237
1238 throw processException(e);
1239 }
1240 finally {
1241 closeSession(session);
1242 }
1243 }
1244
1245 return count.intValue();
1246 }
1247
1248 @Override
1249 public Set<String> getBadColumnNames() {
1250 return _badColumnNames;
1251 }
1252
1253 @Override
1254 protected Map<String, Integer> getTableColumnsMap() {
1255 return UserTrackerPathModelImpl.TABLE_COLUMNS_MAP;
1256 }
1257
1258
1261 public void afterPropertiesSet() {
1262 }
1263
1264 public void destroy() {
1265 entityCache.removeCache(UserTrackerPathImpl.class.getName());
1266 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1267 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1268 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1269 }
1270
1271 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1272 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1273 private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1274 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE userTrackerPathId IN (";
1275 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1276 private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1277 private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1278 private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1279 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1280 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1281 private static final Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1282 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1283 "path"
1284 });
1285 private static final UserTrackerPath _nullUserTrackerPath = new UserTrackerPathImpl() {
1286 @Override
1287 public Object clone() {
1288 return this;
1289 }
1290
1291 @Override
1292 public CacheModel<UserTrackerPath> toCacheModel() {
1293 return _nullUserTrackerPathCacheModel;
1294 }
1295 };
1296
1297 private static final CacheModel<UserTrackerPath> _nullUserTrackerPathCacheModel =
1298 new NullCacheModel();
1299
1300 private static class NullCacheModel implements CacheModel<UserTrackerPath>,
1301 MVCCModel {
1302 @Override
1303 public long getMvccVersion() {
1304 return -1;
1305 }
1306
1307 @Override
1308 public void setMvccVersion(long mvccVersion) {
1309 }
1310
1311 @Override
1312 public UserTrackerPath toEntityModel() {
1313 return _nullUserTrackerPath;
1314 }
1315 }
1316 }