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.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.OrderByComparator;
030 import com.liferay.portal.kernel.util.SetUtil;
031 import com.liferay.portal.kernel.util.StringBundler;
032 import com.liferay.portal.kernel.util.StringPool;
033 import com.liferay.portal.model.CacheModel;
034 import com.liferay.portal.model.MVCCModel;
035 import com.liferay.portal.model.UserTrackerPath;
036 import com.liferay.portal.model.impl.UserTrackerPathImpl;
037 import com.liferay.portal.model.impl.UserTrackerPathModelImpl;
038 import com.liferay.portal.service.persistence.UserTrackerPathPersistence;
039
040 import java.io.Serializable;
041
042 import java.util.Collections;
043 import java.util.HashMap;
044 import java.util.HashSet;
045 import java.util.Iterator;
046 import java.util.List;
047 import java.util.Map;
048 import java.util.Set;
049
050
062 @ProviderType
063 public class UserTrackerPathPersistenceImpl extends BasePersistenceImpl<UserTrackerPath>
064 implements UserTrackerPathPersistence {
065
070 public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerPathImpl.class.getName();
071 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List1";
073 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List2";
075 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
076 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
077 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
078 "findAll", new String[0]);
079 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
080 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
081 UserTrackerPathImpl.class,
082 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
083 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
084 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
085 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
086 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID =
087 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
088 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
089 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
090 "findByUserTrackerId",
091 new String[] {
092 Long.class.getName(),
093
094 Integer.class.getName(), Integer.class.getName(),
095 OrderByComparator.class.getName()
096 });
097 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID =
098 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
099 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
100 UserTrackerPathImpl.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserTrackerId",
102 new String[] { Long.class.getName() },
103 UserTrackerPathModelImpl.USERTRACKERID_COLUMN_BITMASK);
104 public static final FinderPath FINDER_PATH_COUNT_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
105 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserTrackerId",
107 new String[] { Long.class.getName() });
108
109
115 @Override
116 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId) {
117 return findByUserTrackerId(userTrackerId, QueryUtil.ALL_POS,
118 QueryUtil.ALL_POS, null);
119 }
120
121
133 @Override
134 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
135 int start, int end) {
136 return findByUserTrackerId(userTrackerId, start, end, null);
137 }
138
139
152 @Override
153 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
154 int start, int end, OrderByComparator<UserTrackerPath> orderByComparator) {
155 boolean pagination = true;
156 FinderPath finderPath = null;
157 Object[] finderArgs = null;
158
159 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
160 (orderByComparator == null)) {
161 pagination = false;
162 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID;
163 finderArgs = new Object[] { userTrackerId };
164 }
165 else {
166 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID;
167 finderArgs = new Object[] {
168 userTrackerId,
169
170 start, end, orderByComparator
171 };
172 }
173
174 List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(finderPath,
175 finderArgs, this);
176
177 if ((list != null) && !list.isEmpty()) {
178 for (UserTrackerPath userTrackerPath : list) {
179 if ((userTrackerId != userTrackerPath.getUserTrackerId())) {
180 list = null;
181
182 break;
183 }
184 }
185 }
186
187 if (list == null) {
188 StringBundler query = null;
189
190 if (orderByComparator != null) {
191 query = new StringBundler(3 +
192 (orderByComparator.getOrderByFields().length * 3));
193 }
194 else {
195 query = new StringBundler(3);
196 }
197
198 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
199
200 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
201
202 if (orderByComparator != null) {
203 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
204 orderByComparator);
205 }
206 else
207 if (pagination) {
208 query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
209 }
210
211 String sql = query.toString();
212
213 Session session = null;
214
215 try {
216 session = openSession();
217
218 Query q = session.createQuery(sql);
219
220 QueryPos qPos = QueryPos.getInstance(q);
221
222 qPos.add(userTrackerId);
223
224 if (!pagination) {
225 list = (List<UserTrackerPath>)QueryUtil.list(q,
226 getDialect(), start, end, false);
227
228 Collections.sort(list);
229
230 list = Collections.unmodifiableList(list);
231 }
232 else {
233 list = (List<UserTrackerPath>)QueryUtil.list(q,
234 getDialect(), start, end);
235 }
236
237 cacheResult(list);
238
239 FinderCacheUtil.putResult(finderPath, finderArgs, list);
240 }
241 catch (Exception e) {
242 FinderCacheUtil.removeResult(finderPath, finderArgs);
243
244 throw processException(e);
245 }
246 finally {
247 closeSession(session);
248 }
249 }
250
251 return list;
252 }
253
254
262 @Override
263 public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
264 OrderByComparator<UserTrackerPath> orderByComparator)
265 throws NoSuchUserTrackerPathException {
266 UserTrackerPath userTrackerPath = fetchByUserTrackerId_First(userTrackerId,
267 orderByComparator);
268
269 if (userTrackerPath != null) {
270 return userTrackerPath;
271 }
272
273 StringBundler msg = new StringBundler(4);
274
275 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
276
277 msg.append("userTrackerId=");
278 msg.append(userTrackerId);
279
280 msg.append(StringPool.CLOSE_CURLY_BRACE);
281
282 throw new NoSuchUserTrackerPathException(msg.toString());
283 }
284
285
292 @Override
293 public UserTrackerPath fetchByUserTrackerId_First(long userTrackerId,
294 OrderByComparator<UserTrackerPath> orderByComparator) {
295 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId, 0, 1,
296 orderByComparator);
297
298 if (!list.isEmpty()) {
299 return list.get(0);
300 }
301
302 return null;
303 }
304
305
313 @Override
314 public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
315 OrderByComparator<UserTrackerPath> orderByComparator)
316 throws NoSuchUserTrackerPathException {
317 UserTrackerPath userTrackerPath = fetchByUserTrackerId_Last(userTrackerId,
318 orderByComparator);
319
320 if (userTrackerPath != null) {
321 return userTrackerPath;
322 }
323
324 StringBundler msg = new StringBundler(4);
325
326 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
327
328 msg.append("userTrackerId=");
329 msg.append(userTrackerId);
330
331 msg.append(StringPool.CLOSE_CURLY_BRACE);
332
333 throw new NoSuchUserTrackerPathException(msg.toString());
334 }
335
336
343 @Override
344 public UserTrackerPath fetchByUserTrackerId_Last(long userTrackerId,
345 OrderByComparator<UserTrackerPath> orderByComparator) {
346 int count = countByUserTrackerId(userTrackerId);
347
348 if (count == 0) {
349 return null;
350 }
351
352 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
353 count - 1, count, orderByComparator);
354
355 if (!list.isEmpty()) {
356 return list.get(0);
357 }
358
359 return null;
360 }
361
362
371 @Override
372 public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
373 long userTrackerPathId, long userTrackerId,
374 OrderByComparator<UserTrackerPath> orderByComparator)
375 throws NoSuchUserTrackerPathException {
376 UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
377
378 Session session = null;
379
380 try {
381 session = openSession();
382
383 UserTrackerPath[] array = new UserTrackerPathImpl[3];
384
385 array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
386 userTrackerId, orderByComparator, true);
387
388 array[1] = userTrackerPath;
389
390 array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
391 userTrackerId, orderByComparator, false);
392
393 return array;
394 }
395 catch (Exception e) {
396 throw processException(e);
397 }
398 finally {
399 closeSession(session);
400 }
401 }
402
403 protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
404 UserTrackerPath userTrackerPath, long userTrackerId,
405 OrderByComparator<UserTrackerPath> orderByComparator, boolean previous) {
406 StringBundler query = null;
407
408 if (orderByComparator != null) {
409 query = new StringBundler(6 +
410 (orderByComparator.getOrderByFields().length * 6));
411 }
412 else {
413 query = new StringBundler(3);
414 }
415
416 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
417
418 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
419
420 if (orderByComparator != null) {
421 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
422
423 if (orderByConditionFields.length > 0) {
424 query.append(WHERE_AND);
425 }
426
427 for (int i = 0; i < orderByConditionFields.length; i++) {
428 query.append(_ORDER_BY_ENTITY_ALIAS);
429 query.append(orderByConditionFields[i]);
430
431 if ((i + 1) < orderByConditionFields.length) {
432 if (orderByComparator.isAscending() ^ previous) {
433 query.append(WHERE_GREATER_THAN_HAS_NEXT);
434 }
435 else {
436 query.append(WHERE_LESSER_THAN_HAS_NEXT);
437 }
438 }
439 else {
440 if (orderByComparator.isAscending() ^ previous) {
441 query.append(WHERE_GREATER_THAN);
442 }
443 else {
444 query.append(WHERE_LESSER_THAN);
445 }
446 }
447 }
448
449 query.append(ORDER_BY_CLAUSE);
450
451 String[] orderByFields = orderByComparator.getOrderByFields();
452
453 for (int i = 0; i < orderByFields.length; i++) {
454 query.append(_ORDER_BY_ENTITY_ALIAS);
455 query.append(orderByFields[i]);
456
457 if ((i + 1) < orderByFields.length) {
458 if (orderByComparator.isAscending() ^ previous) {
459 query.append(ORDER_BY_ASC_HAS_NEXT);
460 }
461 else {
462 query.append(ORDER_BY_DESC_HAS_NEXT);
463 }
464 }
465 else {
466 if (orderByComparator.isAscending() ^ previous) {
467 query.append(ORDER_BY_ASC);
468 }
469 else {
470 query.append(ORDER_BY_DESC);
471 }
472 }
473 }
474 }
475 else {
476 query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
477 }
478
479 String sql = query.toString();
480
481 Query q = session.createQuery(sql);
482
483 q.setFirstResult(0);
484 q.setMaxResults(2);
485
486 QueryPos qPos = QueryPos.getInstance(q);
487
488 qPos.add(userTrackerId);
489
490 if (orderByComparator != null) {
491 Object[] values = orderByComparator.getOrderByConditionValues(userTrackerPath);
492
493 for (Object value : values) {
494 qPos.add(value);
495 }
496 }
497
498 List<UserTrackerPath> list = q.list();
499
500 if (list.size() == 2) {
501 return list.get(1);
502 }
503 else {
504 return null;
505 }
506 }
507
508
513 @Override
514 public void removeByUserTrackerId(long userTrackerId) {
515 for (UserTrackerPath userTrackerPath : findByUserTrackerId(
516 userTrackerId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
517 remove(userTrackerPath);
518 }
519 }
520
521
527 @Override
528 public int countByUserTrackerId(long userTrackerId) {
529 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERTRACKERID;
530
531 Object[] finderArgs = new Object[] { userTrackerId };
532
533 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
534 this);
535
536 if (count == null) {
537 StringBundler query = new StringBundler(2);
538
539 query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
540
541 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
542
543 String sql = query.toString();
544
545 Session session = null;
546
547 try {
548 session = openSession();
549
550 Query q = session.createQuery(sql);
551
552 QueryPos qPos = QueryPos.getInstance(q);
553
554 qPos.add(userTrackerId);
555
556 count = (Long)q.uniqueResult();
557
558 FinderCacheUtil.putResult(finderPath, finderArgs, count);
559 }
560 catch (Exception e) {
561 FinderCacheUtil.removeResult(finderPath, finderArgs);
562
563 throw processException(e);
564 }
565 finally {
566 closeSession(session);
567 }
568 }
569
570 return count.intValue();
571 }
572
573 private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
574
575 public UserTrackerPathPersistenceImpl() {
576 setModelClass(UserTrackerPath.class);
577 }
578
579
584 @Override
585 public void cacheResult(UserTrackerPath userTrackerPath) {
586 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
587 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
588 userTrackerPath);
589
590 userTrackerPath.resetOriginalValues();
591 }
592
593
598 @Override
599 public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
600 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
601 if (EntityCacheUtil.getResult(
602 UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
603 UserTrackerPathImpl.class,
604 userTrackerPath.getPrimaryKey()) == null) {
605 cacheResult(userTrackerPath);
606 }
607 else {
608 userTrackerPath.resetOriginalValues();
609 }
610 }
611 }
612
613
620 @Override
621 public void clearCache() {
622 EntityCacheUtil.clearCache(UserTrackerPathImpl.class);
623
624 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
625 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
626 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
627 }
628
629
636 @Override
637 public void clearCache(UserTrackerPath userTrackerPath) {
638 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
639 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
640
641 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
642 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
643 }
644
645 @Override
646 public void clearCache(List<UserTrackerPath> userTrackerPaths) {
647 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
648 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
649
650 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
651 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
652 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
653 }
654 }
655
656
662 @Override
663 public UserTrackerPath create(long userTrackerPathId) {
664 UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
665
666 userTrackerPath.setNew(true);
667 userTrackerPath.setPrimaryKey(userTrackerPathId);
668
669 return userTrackerPath;
670 }
671
672
679 @Override
680 public UserTrackerPath remove(long userTrackerPathId)
681 throws NoSuchUserTrackerPathException {
682 return remove((Serializable)userTrackerPathId);
683 }
684
685
692 @Override
693 public UserTrackerPath remove(Serializable primaryKey)
694 throws NoSuchUserTrackerPathException {
695 Session session = null;
696
697 try {
698 session = openSession();
699
700 UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
701 primaryKey);
702
703 if (userTrackerPath == null) {
704 if (_log.isWarnEnabled()) {
705 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
706 }
707
708 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
709 primaryKey);
710 }
711
712 return remove(userTrackerPath);
713 }
714 catch (NoSuchUserTrackerPathException nsee) {
715 throw nsee;
716 }
717 catch (Exception e) {
718 throw processException(e);
719 }
720 finally {
721 closeSession(session);
722 }
723 }
724
725 @Override
726 protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath) {
727 userTrackerPath = toUnwrappedModel(userTrackerPath);
728
729 Session session = null;
730
731 try {
732 session = openSession();
733
734 if (!session.contains(userTrackerPath)) {
735 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
736 userTrackerPath.getPrimaryKeyObj());
737 }
738
739 if (userTrackerPath != null) {
740 session.delete(userTrackerPath);
741 }
742 }
743 catch (Exception e) {
744 throw processException(e);
745 }
746 finally {
747 closeSession(session);
748 }
749
750 if (userTrackerPath != null) {
751 clearCache(userTrackerPath);
752 }
753
754 return userTrackerPath;
755 }
756
757 @Override
758 public UserTrackerPath updateImpl(UserTrackerPath userTrackerPath) {
759 userTrackerPath = toUnwrappedModel(userTrackerPath);
760
761 boolean isNew = userTrackerPath.isNew();
762
763 UserTrackerPathModelImpl userTrackerPathModelImpl = (UserTrackerPathModelImpl)userTrackerPath;
764
765 Session session = null;
766
767 try {
768 session = openSession();
769
770 if (userTrackerPath.isNew()) {
771 session.save(userTrackerPath);
772
773 userTrackerPath.setNew(false);
774 }
775 else {
776 session.merge(userTrackerPath);
777 }
778 }
779 catch (Exception e) {
780 throw processException(e);
781 }
782 finally {
783 closeSession(session);
784 }
785
786 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
787
788 if (isNew || !UserTrackerPathModelImpl.COLUMN_BITMASK_ENABLED) {
789 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
790 }
791
792 else {
793 if ((userTrackerPathModelImpl.getColumnBitmask() &
794 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID.getColumnBitmask()) != 0) {
795 Object[] args = new Object[] {
796 userTrackerPathModelImpl.getOriginalUserTrackerId()
797 };
798
799 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
800 args);
801 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
802 args);
803
804 args = new Object[] { userTrackerPathModelImpl.getUserTrackerId() };
805
806 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
807 args);
808 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
809 args);
810 }
811 }
812
813 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
814 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
815 userTrackerPath, false);
816
817 userTrackerPath.resetOriginalValues();
818
819 return userTrackerPath;
820 }
821
822 protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
823 if (userTrackerPath instanceof UserTrackerPathImpl) {
824 return userTrackerPath;
825 }
826
827 UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
828
829 userTrackerPathImpl.setNew(userTrackerPath.isNew());
830 userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
831
832 userTrackerPathImpl.setMvccVersion(userTrackerPath.getMvccVersion());
833 userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
834 userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
835 userTrackerPathImpl.setPath(userTrackerPath.getPath());
836 userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
837
838 return userTrackerPathImpl;
839 }
840
841
848 @Override
849 public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
850 throws NoSuchUserTrackerPathException {
851 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
852
853 if (userTrackerPath == null) {
854 if (_log.isWarnEnabled()) {
855 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
856 }
857
858 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
859 primaryKey);
860 }
861
862 return userTrackerPath;
863 }
864
865
872 @Override
873 public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
874 throws NoSuchUserTrackerPathException {
875 return findByPrimaryKey((Serializable)userTrackerPathId);
876 }
877
878
884 @Override
885 public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey) {
886 UserTrackerPath userTrackerPath = (UserTrackerPath)EntityCacheUtil.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
887 UserTrackerPathImpl.class, primaryKey);
888
889 if (userTrackerPath == _nullUserTrackerPath) {
890 return null;
891 }
892
893 if (userTrackerPath == null) {
894 Session session = null;
895
896 try {
897 session = openSession();
898
899 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
900 primaryKey);
901
902 if (userTrackerPath != null) {
903 cacheResult(userTrackerPath);
904 }
905 else {
906 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
907 UserTrackerPathImpl.class, primaryKey,
908 _nullUserTrackerPath);
909 }
910 }
911 catch (Exception e) {
912 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
913 UserTrackerPathImpl.class, primaryKey);
914
915 throw processException(e);
916 }
917 finally {
918 closeSession(session);
919 }
920 }
921
922 return userTrackerPath;
923 }
924
925
931 @Override
932 public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId) {
933 return fetchByPrimaryKey((Serializable)userTrackerPathId);
934 }
935
936 @Override
937 public Map<Serializable, UserTrackerPath> fetchByPrimaryKeys(
938 Set<Serializable> primaryKeys) {
939 if (primaryKeys.isEmpty()) {
940 return Collections.emptyMap();
941 }
942
943 Map<Serializable, UserTrackerPath> map = new HashMap<Serializable, UserTrackerPath>();
944
945 if (primaryKeys.size() == 1) {
946 Iterator<Serializable> iterator = primaryKeys.iterator();
947
948 Serializable primaryKey = iterator.next();
949
950 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
951
952 if (userTrackerPath != null) {
953 map.put(primaryKey, userTrackerPath);
954 }
955
956 return map;
957 }
958
959 Set<Serializable> uncachedPrimaryKeys = null;
960
961 for (Serializable primaryKey : primaryKeys) {
962 UserTrackerPath userTrackerPath = (UserTrackerPath)EntityCacheUtil.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
963 UserTrackerPathImpl.class, primaryKey);
964
965 if (userTrackerPath == null) {
966 if (uncachedPrimaryKeys == null) {
967 uncachedPrimaryKeys = new HashSet<Serializable>();
968 }
969
970 uncachedPrimaryKeys.add(primaryKey);
971 }
972 else {
973 map.put(primaryKey, userTrackerPath);
974 }
975 }
976
977 if (uncachedPrimaryKeys == null) {
978 return map;
979 }
980
981 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
982 1);
983
984 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN);
985
986 for (Serializable primaryKey : uncachedPrimaryKeys) {
987 query.append(String.valueOf(primaryKey));
988
989 query.append(StringPool.COMMA);
990 }
991
992 query.setIndex(query.index() - 1);
993
994 query.append(StringPool.CLOSE_PARENTHESIS);
995
996 String sql = query.toString();
997
998 Session session = null;
999
1000 try {
1001 session = openSession();
1002
1003 Query q = session.createQuery(sql);
1004
1005 for (UserTrackerPath userTrackerPath : (List<UserTrackerPath>)q.list()) {
1006 map.put(userTrackerPath.getPrimaryKeyObj(), userTrackerPath);
1007
1008 cacheResult(userTrackerPath);
1009
1010 uncachedPrimaryKeys.remove(userTrackerPath.getPrimaryKeyObj());
1011 }
1012
1013 for (Serializable primaryKey : uncachedPrimaryKeys) {
1014 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
1015 UserTrackerPathImpl.class, primaryKey, _nullUserTrackerPath);
1016 }
1017 }
1018 catch (Exception e) {
1019 throw processException(e);
1020 }
1021 finally {
1022 closeSession(session);
1023 }
1024
1025 return map;
1026 }
1027
1028
1033 @Override
1034 public List<UserTrackerPath> findAll() {
1035 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1036 }
1037
1038
1049 @Override
1050 public List<UserTrackerPath> findAll(int start, int end) {
1051 return findAll(start, end, null);
1052 }
1053
1054
1066 @Override
1067 public List<UserTrackerPath> findAll(int start, int end,
1068 OrderByComparator<UserTrackerPath> orderByComparator) {
1069 boolean pagination = true;
1070 FinderPath finderPath = null;
1071 Object[] finderArgs = null;
1072
1073 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1074 (orderByComparator == null)) {
1075 pagination = false;
1076 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1077 finderArgs = FINDER_ARGS_EMPTY;
1078 }
1079 else {
1080 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1081 finderArgs = new Object[] { start, end, orderByComparator };
1082 }
1083
1084 List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(finderPath,
1085 finderArgs, this);
1086
1087 if (list == null) {
1088 StringBundler query = null;
1089 String sql = null;
1090
1091 if (orderByComparator != null) {
1092 query = new StringBundler(2 +
1093 (orderByComparator.getOrderByFields().length * 3));
1094
1095 query.append(_SQL_SELECT_USERTRACKERPATH);
1096
1097 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1098 orderByComparator);
1099
1100 sql = query.toString();
1101 }
1102 else {
1103 sql = _SQL_SELECT_USERTRACKERPATH;
1104
1105 if (pagination) {
1106 sql = sql.concat(UserTrackerPathModelImpl.ORDER_BY_JPQL);
1107 }
1108 }
1109
1110 Session session = null;
1111
1112 try {
1113 session = openSession();
1114
1115 Query q = session.createQuery(sql);
1116
1117 if (!pagination) {
1118 list = (List<UserTrackerPath>)QueryUtil.list(q,
1119 getDialect(), start, end, false);
1120
1121 Collections.sort(list);
1122
1123 list = Collections.unmodifiableList(list);
1124 }
1125 else {
1126 list = (List<UserTrackerPath>)QueryUtil.list(q,
1127 getDialect(), start, end);
1128 }
1129
1130 cacheResult(list);
1131
1132 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1133 }
1134 catch (Exception e) {
1135 FinderCacheUtil.removeResult(finderPath, finderArgs);
1136
1137 throw processException(e);
1138 }
1139 finally {
1140 closeSession(session);
1141 }
1142 }
1143
1144 return list;
1145 }
1146
1147
1151 @Override
1152 public void removeAll() {
1153 for (UserTrackerPath userTrackerPath : findAll()) {
1154 remove(userTrackerPath);
1155 }
1156 }
1157
1158
1163 @Override
1164 public int countAll() {
1165 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1166 FINDER_ARGS_EMPTY, this);
1167
1168 if (count == null) {
1169 Session session = null;
1170
1171 try {
1172 session = openSession();
1173
1174 Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
1175
1176 count = (Long)q.uniqueResult();
1177
1178 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1179 FINDER_ARGS_EMPTY, count);
1180 }
1181 catch (Exception e) {
1182 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
1183 FINDER_ARGS_EMPTY);
1184
1185 throw processException(e);
1186 }
1187 finally {
1188 closeSession(session);
1189 }
1190 }
1191
1192 return count.intValue();
1193 }
1194
1195 @Override
1196 protected Set<String> getBadColumnNames() {
1197 return _badColumnNames;
1198 }
1199
1200
1203 public void afterPropertiesSet() {
1204 }
1205
1206 public void destroy() {
1207 EntityCacheUtil.removeCache(UserTrackerPathImpl.class.getName());
1208 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1209 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1210 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1211 }
1212
1213 private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1214 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE userTrackerPathId IN (";
1215 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1216 private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1217 private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1218 private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1219 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1220 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1221 private static final Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1222 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1223 "path"
1224 });
1225 private static final UserTrackerPath _nullUserTrackerPath = new UserTrackerPathImpl() {
1226 @Override
1227 public Object clone() {
1228 return this;
1229 }
1230
1231 @Override
1232 public CacheModel<UserTrackerPath> toCacheModel() {
1233 return _nullUserTrackerPathCacheModel;
1234 }
1235 };
1236
1237 private static final CacheModel<UserTrackerPath> _nullUserTrackerPathCacheModel =
1238 new NullCacheModel();
1239
1240 private static class NullCacheModel implements CacheModel<UserTrackerPath>,
1241 MVCCModel {
1242 @Override
1243 public long getMvccVersion() {
1244 return -1;
1245 }
1246
1247 @Override
1248 public void setMvccVersion(long mvccVersion) {
1249 }
1250
1251 @Override
1252 public UserTrackerPath toEntityModel() {
1253 return _nullUserTrackerPath;
1254 }
1255 }
1256 }