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.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.OrderByComparator;
031 import com.liferay.portal.kernel.util.SetUtil;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.model.CacheModel;
035 import com.liferay.portal.model.MVCCModel;
036 import com.liferay.portal.model.UserTrackerPath;
037 import com.liferay.portal.model.impl.UserTrackerPathImpl;
038 import com.liferay.portal.model.impl.UserTrackerPathModelImpl;
039 import com.liferay.portal.service.persistence.UserTrackerPathPersistence;
040
041 import java.io.Serializable;
042
043 import java.util.Collections;
044 import java.util.HashMap;
045 import java.util.HashSet;
046 import java.util.Iterator;
047 import java.util.List;
048 import java.util.Map;
049 import java.util.Set;
050
051
063 @ProviderType
064 public class UserTrackerPathPersistenceImpl extends BasePersistenceImpl<UserTrackerPath>
065 implements UserTrackerPathPersistence {
066
071 public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerPathImpl.class.getName();
072 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List1";
074 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List2";
076 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
077 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
078 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
079 "findAll", new String[0]);
080 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
081 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
082 UserTrackerPathImpl.class,
083 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
084 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
085 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID =
088 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
089 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
090 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
091 "findByUserTrackerId",
092 new String[] {
093 Long.class.getName(),
094
095 Integer.class.getName(), Integer.class.getName(),
096 OrderByComparator.class.getName()
097 });
098 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID =
099 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
100 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
101 UserTrackerPathImpl.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserTrackerId",
103 new String[] { Long.class.getName() },
104 UserTrackerPathModelImpl.USERTRACKERID_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
106 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserTrackerId",
108 new String[] { Long.class.getName() });
109
110
116 @Override
117 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId) {
118 return findByUserTrackerId(userTrackerId, QueryUtil.ALL_POS,
119 QueryUtil.ALL_POS, null);
120 }
121
122
134 @Override
135 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
136 int start, int end) {
137 return findByUserTrackerId(userTrackerId, start, end, null);
138 }
139
140
153 @Override
154 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
155 int start, int end, OrderByComparator<UserTrackerPath> orderByComparator) {
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 = Collections.unmodifiableList(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
263 @Override
264 public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
265 OrderByComparator<UserTrackerPath> orderByComparator)
266 throws NoSuchUserTrackerPathException {
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
293 @Override
294 public UserTrackerPath fetchByUserTrackerId_First(long userTrackerId,
295 OrderByComparator<UserTrackerPath> orderByComparator) {
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
314 @Override
315 public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
316 OrderByComparator<UserTrackerPath> orderByComparator)
317 throws NoSuchUserTrackerPathException {
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
344 @Override
345 public UserTrackerPath fetchByUserTrackerId_Last(long userTrackerId,
346 OrderByComparator<UserTrackerPath> orderByComparator) {
347 int count = countByUserTrackerId(userTrackerId);
348
349 if (count == 0) {
350 return null;
351 }
352
353 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
354 count - 1, count, orderByComparator);
355
356 if (!list.isEmpty()) {
357 return list.get(0);
358 }
359
360 return null;
361 }
362
363
372 @Override
373 public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
374 long userTrackerPathId, long userTrackerId,
375 OrderByComparator<UserTrackerPath> orderByComparator)
376 throws NoSuchUserTrackerPathException {
377 UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
378
379 Session session = null;
380
381 try {
382 session = openSession();
383
384 UserTrackerPath[] array = new UserTrackerPathImpl[3];
385
386 array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
387 userTrackerId, orderByComparator, true);
388
389 array[1] = userTrackerPath;
390
391 array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
392 userTrackerId, orderByComparator, false);
393
394 return array;
395 }
396 catch (Exception e) {
397 throw processException(e);
398 }
399 finally {
400 closeSession(session);
401 }
402 }
403
404 protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
405 UserTrackerPath userTrackerPath, long userTrackerId,
406 OrderByComparator<UserTrackerPath> orderByComparator, boolean previous) {
407 StringBundler query = null;
408
409 if (orderByComparator != null) {
410 query = new StringBundler(6 +
411 (orderByComparator.getOrderByFields().length * 6));
412 }
413 else {
414 query = new StringBundler(3);
415 }
416
417 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
418
419 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
420
421 if (orderByComparator != null) {
422 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
423
424 if (orderByConditionFields.length > 0) {
425 query.append(WHERE_AND);
426 }
427
428 for (int i = 0; i < orderByConditionFields.length; i++) {
429 query.append(_ORDER_BY_ENTITY_ALIAS);
430 query.append(orderByConditionFields[i]);
431
432 if ((i + 1) < orderByConditionFields.length) {
433 if (orderByComparator.isAscending() ^ previous) {
434 query.append(WHERE_GREATER_THAN_HAS_NEXT);
435 }
436 else {
437 query.append(WHERE_LESSER_THAN_HAS_NEXT);
438 }
439 }
440 else {
441 if (orderByComparator.isAscending() ^ previous) {
442 query.append(WHERE_GREATER_THAN);
443 }
444 else {
445 query.append(WHERE_LESSER_THAN);
446 }
447 }
448 }
449
450 query.append(ORDER_BY_CLAUSE);
451
452 String[] orderByFields = orderByComparator.getOrderByFields();
453
454 for (int i = 0; i < orderByFields.length; i++) {
455 query.append(_ORDER_BY_ENTITY_ALIAS);
456 query.append(orderByFields[i]);
457
458 if ((i + 1) < orderByFields.length) {
459 if (orderByComparator.isAscending() ^ previous) {
460 query.append(ORDER_BY_ASC_HAS_NEXT);
461 }
462 else {
463 query.append(ORDER_BY_DESC_HAS_NEXT);
464 }
465 }
466 else {
467 if (orderByComparator.isAscending() ^ previous) {
468 query.append(ORDER_BY_ASC);
469 }
470 else {
471 query.append(ORDER_BY_DESC);
472 }
473 }
474 }
475 }
476 else {
477 query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
478 }
479
480 String sql = query.toString();
481
482 Query q = session.createQuery(sql);
483
484 q.setFirstResult(0);
485 q.setMaxResults(2);
486
487 QueryPos qPos = QueryPos.getInstance(q);
488
489 qPos.add(userTrackerId);
490
491 if (orderByComparator != null) {
492 Object[] values = orderByComparator.getOrderByConditionValues(userTrackerPath);
493
494 for (Object value : values) {
495 qPos.add(value);
496 }
497 }
498
499 List<UserTrackerPath> list = q.list();
500
501 if (list.size() == 2) {
502 return list.get(1);
503 }
504 else {
505 return null;
506 }
507 }
508
509
514 @Override
515 public void removeByUserTrackerId(long userTrackerId) {
516 for (UserTrackerPath userTrackerPath : findByUserTrackerId(
517 userTrackerId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
518 remove(userTrackerPath);
519 }
520 }
521
522
528 @Override
529 public int countByUserTrackerId(long userTrackerId) {
530 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERTRACKERID;
531
532 Object[] finderArgs = new Object[] { userTrackerId };
533
534 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
535 this);
536
537 if (count == null) {
538 StringBundler query = new StringBundler(2);
539
540 query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
541
542 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
543
544 String sql = query.toString();
545
546 Session session = null;
547
548 try {
549 session = openSession();
550
551 Query q = session.createQuery(sql);
552
553 QueryPos qPos = QueryPos.getInstance(q);
554
555 qPos.add(userTrackerId);
556
557 count = (Long)q.uniqueResult();
558
559 FinderCacheUtil.putResult(finderPath, finderArgs, count);
560 }
561 catch (Exception e) {
562 FinderCacheUtil.removeResult(finderPath, finderArgs);
563
564 throw processException(e);
565 }
566 finally {
567 closeSession(session);
568 }
569 }
570
571 return count.intValue();
572 }
573
574 private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
575
576 public UserTrackerPathPersistenceImpl() {
577 setModelClass(UserTrackerPath.class);
578 }
579
580
585 @Override
586 public void cacheResult(UserTrackerPath userTrackerPath) {
587 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
588 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
589 userTrackerPath);
590
591 userTrackerPath.resetOriginalValues();
592 }
593
594
599 @Override
600 public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
601 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
602 if (EntityCacheUtil.getResult(
603 UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
604 UserTrackerPathImpl.class,
605 userTrackerPath.getPrimaryKey()) == null) {
606 cacheResult(userTrackerPath);
607 }
608 else {
609 userTrackerPath.resetOriginalValues();
610 }
611 }
612 }
613
614
621 @Override
622 public void clearCache() {
623 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
624 CacheRegistryUtil.clear(UserTrackerPathImpl.class.getName());
625 }
626
627 EntityCacheUtil.clearCache(UserTrackerPathImpl.class);
628
629 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
630 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
631 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
632 }
633
634
641 @Override
642 public void clearCache(UserTrackerPath userTrackerPath) {
643 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
644 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
645
646 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
647 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
648 }
649
650 @Override
651 public void clearCache(List<UserTrackerPath> userTrackerPaths) {
652 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
653 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
654
655 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
656 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
657 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
658 }
659 }
660
661
667 @Override
668 public UserTrackerPath create(long userTrackerPathId) {
669 UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
670
671 userTrackerPath.setNew(true);
672 userTrackerPath.setPrimaryKey(userTrackerPathId);
673
674 return userTrackerPath;
675 }
676
677
684 @Override
685 public UserTrackerPath remove(long userTrackerPathId)
686 throws NoSuchUserTrackerPathException {
687 return remove((Serializable)userTrackerPathId);
688 }
689
690
697 @Override
698 public UserTrackerPath remove(Serializable primaryKey)
699 throws NoSuchUserTrackerPathException {
700 Session session = null;
701
702 try {
703 session = openSession();
704
705 UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
706 primaryKey);
707
708 if (userTrackerPath == null) {
709 if (_log.isWarnEnabled()) {
710 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
711 }
712
713 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
714 primaryKey);
715 }
716
717 return remove(userTrackerPath);
718 }
719 catch (NoSuchUserTrackerPathException nsee) {
720 throw nsee;
721 }
722 catch (Exception e) {
723 throw processException(e);
724 }
725 finally {
726 closeSession(session);
727 }
728 }
729
730 @Override
731 protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath) {
732 userTrackerPath = toUnwrappedModel(userTrackerPath);
733
734 Session session = null;
735
736 try {
737 session = openSession();
738
739 if (!session.contains(userTrackerPath)) {
740 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
741 userTrackerPath.getPrimaryKeyObj());
742 }
743
744 if (userTrackerPath != null) {
745 session.delete(userTrackerPath);
746 }
747 }
748 catch (Exception e) {
749 throw processException(e);
750 }
751 finally {
752 closeSession(session);
753 }
754
755 if (userTrackerPath != null) {
756 clearCache(userTrackerPath);
757 }
758
759 return userTrackerPath;
760 }
761
762 @Override
763 public UserTrackerPath updateImpl(
764 com.liferay.portal.model.UserTrackerPath userTrackerPath) {
765 userTrackerPath = toUnwrappedModel(userTrackerPath);
766
767 boolean isNew = userTrackerPath.isNew();
768
769 UserTrackerPathModelImpl userTrackerPathModelImpl = (UserTrackerPathModelImpl)userTrackerPath;
770
771 Session session = null;
772
773 try {
774 session = openSession();
775
776 if (userTrackerPath.isNew()) {
777 session.save(userTrackerPath);
778
779 userTrackerPath.setNew(false);
780 }
781 else {
782 session.merge(userTrackerPath);
783 }
784 }
785 catch (Exception e) {
786 throw processException(e);
787 }
788 finally {
789 closeSession(session);
790 }
791
792 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
793
794 if (isNew || !UserTrackerPathModelImpl.COLUMN_BITMASK_ENABLED) {
795 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
796 }
797
798 else {
799 if ((userTrackerPathModelImpl.getColumnBitmask() &
800 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID.getColumnBitmask()) != 0) {
801 Object[] args = new Object[] {
802 userTrackerPathModelImpl.getOriginalUserTrackerId()
803 };
804
805 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
806 args);
807 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
808 args);
809
810 args = new Object[] { userTrackerPathModelImpl.getUserTrackerId() };
811
812 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
813 args);
814 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
815 args);
816 }
817 }
818
819 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
820 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
821 userTrackerPath, false);
822
823 userTrackerPath.resetOriginalValues();
824
825 return userTrackerPath;
826 }
827
828 protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
829 if (userTrackerPath instanceof UserTrackerPathImpl) {
830 return userTrackerPath;
831 }
832
833 UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
834
835 userTrackerPathImpl.setNew(userTrackerPath.isNew());
836 userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
837
838 userTrackerPathImpl.setMvccVersion(userTrackerPath.getMvccVersion());
839 userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
840 userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
841 userTrackerPathImpl.setPath(userTrackerPath.getPath());
842 userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
843
844 return userTrackerPathImpl;
845 }
846
847
854 @Override
855 public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
856 throws NoSuchUserTrackerPathException {
857 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
858
859 if (userTrackerPath == null) {
860 if (_log.isWarnEnabled()) {
861 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
862 }
863
864 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
865 primaryKey);
866 }
867
868 return userTrackerPath;
869 }
870
871
878 @Override
879 public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
880 throws NoSuchUserTrackerPathException {
881 return findByPrimaryKey((Serializable)userTrackerPathId);
882 }
883
884
890 @Override
891 public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey) {
892 UserTrackerPath userTrackerPath = (UserTrackerPath)EntityCacheUtil.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
893 UserTrackerPathImpl.class, primaryKey);
894
895 if (userTrackerPath == _nullUserTrackerPath) {
896 return null;
897 }
898
899 if (userTrackerPath == null) {
900 Session session = null;
901
902 try {
903 session = openSession();
904
905 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
906 primaryKey);
907
908 if (userTrackerPath != null) {
909 cacheResult(userTrackerPath);
910 }
911 else {
912 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
913 UserTrackerPathImpl.class, primaryKey,
914 _nullUserTrackerPath);
915 }
916 }
917 catch (Exception e) {
918 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
919 UserTrackerPathImpl.class, primaryKey);
920
921 throw processException(e);
922 }
923 finally {
924 closeSession(session);
925 }
926 }
927
928 return userTrackerPath;
929 }
930
931
937 @Override
938 public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId) {
939 return fetchByPrimaryKey((Serializable)userTrackerPathId);
940 }
941
942 @Override
943 public Map<Serializable, UserTrackerPath> fetchByPrimaryKeys(
944 Set<Serializable> primaryKeys) {
945 if (primaryKeys.isEmpty()) {
946 return Collections.emptyMap();
947 }
948
949 Map<Serializable, UserTrackerPath> map = new HashMap<Serializable, UserTrackerPath>();
950
951 if (primaryKeys.size() == 1) {
952 Iterator<Serializable> iterator = primaryKeys.iterator();
953
954 Serializable primaryKey = iterator.next();
955
956 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
957
958 if (userTrackerPath != null) {
959 map.put(primaryKey, userTrackerPath);
960 }
961
962 return map;
963 }
964
965 Set<Serializable> uncachedPrimaryKeys = null;
966
967 for (Serializable primaryKey : primaryKeys) {
968 UserTrackerPath userTrackerPath = (UserTrackerPath)EntityCacheUtil.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
969 UserTrackerPathImpl.class, primaryKey);
970
971 if (userTrackerPath == null) {
972 if (uncachedPrimaryKeys == null) {
973 uncachedPrimaryKeys = new HashSet<Serializable>();
974 }
975
976 uncachedPrimaryKeys.add(primaryKey);
977 }
978 else {
979 map.put(primaryKey, userTrackerPath);
980 }
981 }
982
983 if (uncachedPrimaryKeys == null) {
984 return map;
985 }
986
987 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
988 1);
989
990 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN);
991
992 for (Serializable primaryKey : uncachedPrimaryKeys) {
993 query.append(String.valueOf(primaryKey));
994
995 query.append(StringPool.COMMA);
996 }
997
998 query.setIndex(query.index() - 1);
999
1000 query.append(StringPool.CLOSE_PARENTHESIS);
1001
1002 String sql = query.toString();
1003
1004 Session session = null;
1005
1006 try {
1007 session = openSession();
1008
1009 Query q = session.createQuery(sql);
1010
1011 for (UserTrackerPath userTrackerPath : (List<UserTrackerPath>)q.list()) {
1012 map.put(userTrackerPath.getPrimaryKeyObj(), userTrackerPath);
1013
1014 cacheResult(userTrackerPath);
1015
1016 uncachedPrimaryKeys.remove(userTrackerPath.getPrimaryKeyObj());
1017 }
1018
1019 for (Serializable primaryKey : uncachedPrimaryKeys) {
1020 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
1021 UserTrackerPathImpl.class, primaryKey, _nullUserTrackerPath);
1022 }
1023 }
1024 catch (Exception e) {
1025 throw processException(e);
1026 }
1027 finally {
1028 closeSession(session);
1029 }
1030
1031 return map;
1032 }
1033
1034
1039 @Override
1040 public List<UserTrackerPath> findAll() {
1041 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1042 }
1043
1044
1055 @Override
1056 public List<UserTrackerPath> findAll(int start, int end) {
1057 return findAll(start, end, null);
1058 }
1059
1060
1072 @Override
1073 public List<UserTrackerPath> findAll(int start, int end,
1074 OrderByComparator<UserTrackerPath> orderByComparator) {
1075 boolean pagination = true;
1076 FinderPath finderPath = null;
1077 Object[] finderArgs = null;
1078
1079 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1080 (orderByComparator == null)) {
1081 pagination = false;
1082 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1083 finderArgs = FINDER_ARGS_EMPTY;
1084 }
1085 else {
1086 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1087 finderArgs = new Object[] { start, end, orderByComparator };
1088 }
1089
1090 List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(finderPath,
1091 finderArgs, this);
1092
1093 if (list == null) {
1094 StringBundler query = null;
1095 String sql = null;
1096
1097 if (orderByComparator != null) {
1098 query = new StringBundler(2 +
1099 (orderByComparator.getOrderByFields().length * 3));
1100
1101 query.append(_SQL_SELECT_USERTRACKERPATH);
1102
1103 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1104 orderByComparator);
1105
1106 sql = query.toString();
1107 }
1108 else {
1109 sql = _SQL_SELECT_USERTRACKERPATH;
1110
1111 if (pagination) {
1112 sql = sql.concat(UserTrackerPathModelImpl.ORDER_BY_JPQL);
1113 }
1114 }
1115
1116 Session session = null;
1117
1118 try {
1119 session = openSession();
1120
1121 Query q = session.createQuery(sql);
1122
1123 if (!pagination) {
1124 list = (List<UserTrackerPath>)QueryUtil.list(q,
1125 getDialect(), start, end, false);
1126
1127 Collections.sort(list);
1128
1129 list = Collections.unmodifiableList(list);
1130 }
1131 else {
1132 list = (List<UserTrackerPath>)QueryUtil.list(q,
1133 getDialect(), start, end);
1134 }
1135
1136 cacheResult(list);
1137
1138 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1139 }
1140 catch (Exception e) {
1141 FinderCacheUtil.removeResult(finderPath, finderArgs);
1142
1143 throw processException(e);
1144 }
1145 finally {
1146 closeSession(session);
1147 }
1148 }
1149
1150 return list;
1151 }
1152
1153
1157 @Override
1158 public void removeAll() {
1159 for (UserTrackerPath userTrackerPath : findAll()) {
1160 remove(userTrackerPath);
1161 }
1162 }
1163
1164
1169 @Override
1170 public int countAll() {
1171 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1172 FINDER_ARGS_EMPTY, this);
1173
1174 if (count == null) {
1175 Session session = null;
1176
1177 try {
1178 session = openSession();
1179
1180 Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
1181
1182 count = (Long)q.uniqueResult();
1183
1184 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1185 FINDER_ARGS_EMPTY, count);
1186 }
1187 catch (Exception e) {
1188 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1189 FINDER_ARGS_EMPTY);
1190
1191 throw processException(e);
1192 }
1193 finally {
1194 closeSession(session);
1195 }
1196 }
1197
1198 return count.intValue();
1199 }
1200
1201 @Override
1202 protected Set<String> getBadColumnNames() {
1203 return _badColumnNames;
1204 }
1205
1206
1209 public void afterPropertiesSet() {
1210 }
1211
1212 public void destroy() {
1213 EntityCacheUtil.removeCache(UserTrackerPathImpl.class.getName());
1214 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1215 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1216 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1217 }
1218
1219 private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1220 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE userTrackerPathId IN (";
1221 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1222 private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1223 private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1224 private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1225 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1226 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1227 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1228 private static final Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1229 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1230 "path"
1231 });
1232 private static final UserTrackerPath _nullUserTrackerPath = new UserTrackerPathImpl() {
1233 @Override
1234 public Object clone() {
1235 return this;
1236 }
1237
1238 @Override
1239 public CacheModel<UserTrackerPath> toCacheModel() {
1240 return _nullUserTrackerPathCacheModel;
1241 }
1242 };
1243
1244 private static final CacheModel<UserTrackerPath> _nullUserTrackerPathCacheModel =
1245 new NullCacheModel();
1246
1247 private static class NullCacheModel implements CacheModel<UserTrackerPath>,
1248 MVCCModel {
1249 @Override
1250 public long getMvccVersion() {
1251 return -1;
1252 }
1253
1254 @Override
1255 public void setMvccVersion(long mvccVersion) {
1256 }
1257
1258 @Override
1259 public UserTrackerPath toEntityModel() {
1260 return _nullUserTrackerPath;
1261 }
1262 }
1263 }