001
014
015 package com.liferay.portal.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.bean.BeanReference;
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.exception.NoSuchUserTrackerPathException;
030 import com.liferay.portal.kernel.log.Log;
031 import com.liferay.portal.kernel.log.LogFactoryUtil;
032 import com.liferay.portal.kernel.model.CacheModel;
033 import com.liferay.portal.kernel.model.MVCCModel;
034 import com.liferay.portal.kernel.model.UserTrackerPath;
035 import com.liferay.portal.kernel.service.persistence.CompanyProvider;
036 import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
037 import com.liferay.portal.kernel.service.persistence.UserTrackerPathPersistence;
038 import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.model.impl.UserTrackerPathImpl;
044 import com.liferay.portal.model.impl.UserTrackerPathModelImpl;
045
046 import java.io.Serializable;
047
048 import java.util.Collections;
049 import java.util.HashMap;
050 import java.util.HashSet;
051 import java.util.Iterator;
052 import java.util.List;
053 import java.util.Map;
054 import java.util.Set;
055
056
068 @ProviderType
069 public class UserTrackerPathPersistenceImpl extends BasePersistenceImpl<UserTrackerPath>
070 implements UserTrackerPathPersistence {
071
076 public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerPathImpl.class.getName();
077 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List1";
079 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List2";
081 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
082 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
083 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
084 "findAll", new String[0]);
085 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
086 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
087 UserTrackerPathImpl.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
089 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
090 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
091 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
092 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID =
093 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
094 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
095 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
096 "findByUserTrackerId",
097 new String[] {
098 Long.class.getName(),
099
100 Integer.class.getName(), Integer.class.getName(),
101 OrderByComparator.class.getName()
102 });
103 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID =
104 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
105 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
106 UserTrackerPathImpl.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserTrackerId",
108 new String[] { Long.class.getName() },
109 UserTrackerPathModelImpl.USERTRACKERID_COLUMN_BITMASK);
110 public static final FinderPath FINDER_PATH_COUNT_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
111 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
112 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserTrackerId",
113 new String[] { Long.class.getName() });
114
115
121 @Override
122 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId) {
123 return findByUserTrackerId(userTrackerId, QueryUtil.ALL_POS,
124 QueryUtil.ALL_POS, null);
125 }
126
127
139 @Override
140 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
141 int start, int end) {
142 return findByUserTrackerId(userTrackerId, start, end, null);
143 }
144
145
158 @Override
159 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
160 int start, int end, OrderByComparator<UserTrackerPath> orderByComparator) {
161 return findByUserTrackerId(userTrackerId, start, end,
162 orderByComparator, true);
163 }
164
165
179 @Override
180 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
181 int start, int end,
182 OrderByComparator<UserTrackerPath> orderByComparator,
183 boolean retrieveFromCache) {
184 boolean pagination = true;
185 FinderPath finderPath = null;
186 Object[] finderArgs = null;
187
188 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
189 (orderByComparator == null)) {
190 pagination = false;
191 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID;
192 finderArgs = new Object[] { userTrackerId };
193 }
194 else {
195 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID;
196 finderArgs = new Object[] {
197 userTrackerId,
198
199 start, end, orderByComparator
200 };
201 }
202
203 List<UserTrackerPath> list = null;
204
205 if (retrieveFromCache) {
206 list = (List<UserTrackerPath>)finderCache.getResult(finderPath,
207 finderArgs, this);
208
209 if ((list != null) && !list.isEmpty()) {
210 for (UserTrackerPath userTrackerPath : list) {
211 if ((userTrackerId != userTrackerPath.getUserTrackerId())) {
212 list = null;
213
214 break;
215 }
216 }
217 }
218 }
219
220 if (list == null) {
221 StringBundler query = null;
222
223 if (orderByComparator != null) {
224 query = new StringBundler(3 +
225 (orderByComparator.getOrderByFields().length * 2));
226 }
227 else {
228 query = new StringBundler(3);
229 }
230
231 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
232
233 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
234
235 if (orderByComparator != null) {
236 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
237 orderByComparator);
238 }
239 else
240 if (pagination) {
241 query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
242 }
243
244 String sql = query.toString();
245
246 Session session = null;
247
248 try {
249 session = openSession();
250
251 Query q = session.createQuery(sql);
252
253 QueryPos qPos = QueryPos.getInstance(q);
254
255 qPos.add(userTrackerId);
256
257 if (!pagination) {
258 list = (List<UserTrackerPath>)QueryUtil.list(q,
259 getDialect(), start, end, false);
260
261 Collections.sort(list);
262
263 list = Collections.unmodifiableList(list);
264 }
265 else {
266 list = (List<UserTrackerPath>)QueryUtil.list(q,
267 getDialect(), start, end);
268 }
269
270 cacheResult(list);
271
272 finderCache.putResult(finderPath, finderArgs, list);
273 }
274 catch (Exception e) {
275 finderCache.removeResult(finderPath, finderArgs);
276
277 throw processException(e);
278 }
279 finally {
280 closeSession(session);
281 }
282 }
283
284 return list;
285 }
286
287
295 @Override
296 public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
297 OrderByComparator<UserTrackerPath> orderByComparator)
298 throws NoSuchUserTrackerPathException {
299 UserTrackerPath userTrackerPath = fetchByUserTrackerId_First(userTrackerId,
300 orderByComparator);
301
302 if (userTrackerPath != null) {
303 return userTrackerPath;
304 }
305
306 StringBundler msg = new StringBundler(4);
307
308 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
309
310 msg.append("userTrackerId=");
311 msg.append(userTrackerId);
312
313 msg.append(StringPool.CLOSE_CURLY_BRACE);
314
315 throw new NoSuchUserTrackerPathException(msg.toString());
316 }
317
318
325 @Override
326 public UserTrackerPath fetchByUserTrackerId_First(long userTrackerId,
327 OrderByComparator<UserTrackerPath> orderByComparator) {
328 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId, 0, 1,
329 orderByComparator);
330
331 if (!list.isEmpty()) {
332 return list.get(0);
333 }
334
335 return null;
336 }
337
338
346 @Override
347 public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
348 OrderByComparator<UserTrackerPath> orderByComparator)
349 throws NoSuchUserTrackerPathException {
350 UserTrackerPath userTrackerPath = fetchByUserTrackerId_Last(userTrackerId,
351 orderByComparator);
352
353 if (userTrackerPath != null) {
354 return userTrackerPath;
355 }
356
357 StringBundler msg = new StringBundler(4);
358
359 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
360
361 msg.append("userTrackerId=");
362 msg.append(userTrackerId);
363
364 msg.append(StringPool.CLOSE_CURLY_BRACE);
365
366 throw new NoSuchUserTrackerPathException(msg.toString());
367 }
368
369
376 @Override
377 public UserTrackerPath fetchByUserTrackerId_Last(long userTrackerId,
378 OrderByComparator<UserTrackerPath> orderByComparator) {
379 int count = countByUserTrackerId(userTrackerId);
380
381 if (count == 0) {
382 return null;
383 }
384
385 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
386 count - 1, count, orderByComparator);
387
388 if (!list.isEmpty()) {
389 return list.get(0);
390 }
391
392 return null;
393 }
394
395
404 @Override
405 public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
406 long userTrackerPathId, long userTrackerId,
407 OrderByComparator<UserTrackerPath> orderByComparator)
408 throws NoSuchUserTrackerPathException {
409 UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
410
411 Session session = null;
412
413 try {
414 session = openSession();
415
416 UserTrackerPath[] array = new UserTrackerPathImpl[3];
417
418 array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
419 userTrackerId, orderByComparator, true);
420
421 array[1] = userTrackerPath;
422
423 array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
424 userTrackerId, orderByComparator, false);
425
426 return array;
427 }
428 catch (Exception e) {
429 throw processException(e);
430 }
431 finally {
432 closeSession(session);
433 }
434 }
435
436 protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
437 UserTrackerPath userTrackerPath, long userTrackerId,
438 OrderByComparator<UserTrackerPath> orderByComparator, boolean previous) {
439 StringBundler query = null;
440
441 if (orderByComparator != null) {
442 query = new StringBundler(4 +
443 (orderByComparator.getOrderByConditionFields().length * 3) +
444 (orderByComparator.getOrderByFields().length * 3));
445 }
446 else {
447 query = new StringBundler(3);
448 }
449
450 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
451
452 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
453
454 if (orderByComparator != null) {
455 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
456
457 if (orderByConditionFields.length > 0) {
458 query.append(WHERE_AND);
459 }
460
461 for (int i = 0; i < orderByConditionFields.length; i++) {
462 query.append(_ORDER_BY_ENTITY_ALIAS);
463 query.append(orderByConditionFields[i]);
464
465 if ((i + 1) < orderByConditionFields.length) {
466 if (orderByComparator.isAscending() ^ previous) {
467 query.append(WHERE_GREATER_THAN_HAS_NEXT);
468 }
469 else {
470 query.append(WHERE_LESSER_THAN_HAS_NEXT);
471 }
472 }
473 else {
474 if (orderByComparator.isAscending() ^ previous) {
475 query.append(WHERE_GREATER_THAN);
476 }
477 else {
478 query.append(WHERE_LESSER_THAN);
479 }
480 }
481 }
482
483 query.append(ORDER_BY_CLAUSE);
484
485 String[] orderByFields = orderByComparator.getOrderByFields();
486
487 for (int i = 0; i < orderByFields.length; i++) {
488 query.append(_ORDER_BY_ENTITY_ALIAS);
489 query.append(orderByFields[i]);
490
491 if ((i + 1) < orderByFields.length) {
492 if (orderByComparator.isAscending() ^ previous) {
493 query.append(ORDER_BY_ASC_HAS_NEXT);
494 }
495 else {
496 query.append(ORDER_BY_DESC_HAS_NEXT);
497 }
498 }
499 else {
500 if (orderByComparator.isAscending() ^ previous) {
501 query.append(ORDER_BY_ASC);
502 }
503 else {
504 query.append(ORDER_BY_DESC);
505 }
506 }
507 }
508 }
509 else {
510 query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
511 }
512
513 String sql = query.toString();
514
515 Query q = session.createQuery(sql);
516
517 q.setFirstResult(0);
518 q.setMaxResults(2);
519
520 QueryPos qPos = QueryPos.getInstance(q);
521
522 qPos.add(userTrackerId);
523
524 if (orderByComparator != null) {
525 Object[] values = orderByComparator.getOrderByConditionValues(userTrackerPath);
526
527 for (Object value : values) {
528 qPos.add(value);
529 }
530 }
531
532 List<UserTrackerPath> list = q.list();
533
534 if (list.size() == 2) {
535 return list.get(1);
536 }
537 else {
538 return null;
539 }
540 }
541
542
547 @Override
548 public void removeByUserTrackerId(long userTrackerId) {
549 for (UserTrackerPath userTrackerPath : findByUserTrackerId(
550 userTrackerId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
551 remove(userTrackerPath);
552 }
553 }
554
555
561 @Override
562 public int countByUserTrackerId(long userTrackerId) {
563 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERTRACKERID;
564
565 Object[] finderArgs = new Object[] { userTrackerId };
566
567 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
568
569 if (count == null) {
570 StringBundler query = new StringBundler(2);
571
572 query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
573
574 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
575
576 String sql = query.toString();
577
578 Session session = null;
579
580 try {
581 session = openSession();
582
583 Query q = session.createQuery(sql);
584
585 QueryPos qPos = QueryPos.getInstance(q);
586
587 qPos.add(userTrackerId);
588
589 count = (Long)q.uniqueResult();
590
591 finderCache.putResult(finderPath, finderArgs, count);
592 }
593 catch (Exception e) {
594 finderCache.removeResult(finderPath, finderArgs);
595
596 throw processException(e);
597 }
598 finally {
599 closeSession(session);
600 }
601 }
602
603 return count.intValue();
604 }
605
606 private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
607
608 public UserTrackerPathPersistenceImpl() {
609 setModelClass(UserTrackerPath.class);
610 }
611
612
617 @Override
618 public void cacheResult(UserTrackerPath userTrackerPath) {
619 entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
620 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
621 userTrackerPath);
622
623 userTrackerPath.resetOriginalValues();
624 }
625
626
631 @Override
632 public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
633 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
634 if (entityCache.getResult(
635 UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
636 UserTrackerPathImpl.class,
637 userTrackerPath.getPrimaryKey()) == null) {
638 cacheResult(userTrackerPath);
639 }
640 else {
641 userTrackerPath.resetOriginalValues();
642 }
643 }
644 }
645
646
653 @Override
654 public void clearCache() {
655 entityCache.clearCache(UserTrackerPathImpl.class);
656
657 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
658 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
659 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
660 }
661
662
669 @Override
670 public void clearCache(UserTrackerPath userTrackerPath) {
671 entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
672 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
673
674 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
675 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
676 }
677
678 @Override
679 public void clearCache(List<UserTrackerPath> userTrackerPaths) {
680 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
681 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
682
683 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
684 entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
685 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
686 }
687 }
688
689
695 @Override
696 public UserTrackerPath create(long userTrackerPathId) {
697 UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
698
699 userTrackerPath.setNew(true);
700 userTrackerPath.setPrimaryKey(userTrackerPathId);
701
702 userTrackerPath.setCompanyId(companyProvider.getCompanyId());
703
704 return userTrackerPath;
705 }
706
707
714 @Override
715 public UserTrackerPath remove(long userTrackerPathId)
716 throws NoSuchUserTrackerPathException {
717 return remove((Serializable)userTrackerPathId);
718 }
719
720
727 @Override
728 public UserTrackerPath remove(Serializable primaryKey)
729 throws NoSuchUserTrackerPathException {
730 Session session = null;
731
732 try {
733 session = openSession();
734
735 UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
736 primaryKey);
737
738 if (userTrackerPath == null) {
739 if (_log.isWarnEnabled()) {
740 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
741 }
742
743 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
744 primaryKey);
745 }
746
747 return remove(userTrackerPath);
748 }
749 catch (NoSuchUserTrackerPathException nsee) {
750 throw nsee;
751 }
752 catch (Exception e) {
753 throw processException(e);
754 }
755 finally {
756 closeSession(session);
757 }
758 }
759
760 @Override
761 protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath) {
762 userTrackerPath = toUnwrappedModel(userTrackerPath);
763
764 Session session = null;
765
766 try {
767 session = openSession();
768
769 if (!session.contains(userTrackerPath)) {
770 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
771 userTrackerPath.getPrimaryKeyObj());
772 }
773
774 if (userTrackerPath != null) {
775 session.delete(userTrackerPath);
776 }
777 }
778 catch (Exception e) {
779 throw processException(e);
780 }
781 finally {
782 closeSession(session);
783 }
784
785 if (userTrackerPath != null) {
786 clearCache(userTrackerPath);
787 }
788
789 return userTrackerPath;
790 }
791
792 @Override
793 public UserTrackerPath updateImpl(UserTrackerPath userTrackerPath) {
794 userTrackerPath = toUnwrappedModel(userTrackerPath);
795
796 boolean isNew = userTrackerPath.isNew();
797
798 UserTrackerPathModelImpl userTrackerPathModelImpl = (UserTrackerPathModelImpl)userTrackerPath;
799
800 Session session = null;
801
802 try {
803 session = openSession();
804
805 if (userTrackerPath.isNew()) {
806 session.save(userTrackerPath);
807
808 userTrackerPath.setNew(false);
809 }
810 else {
811 userTrackerPath = (UserTrackerPath)session.merge(userTrackerPath);
812 }
813 }
814 catch (Exception e) {
815 throw processException(e);
816 }
817 finally {
818 closeSession(session);
819 }
820
821 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
822
823 if (isNew || !UserTrackerPathModelImpl.COLUMN_BITMASK_ENABLED) {
824 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
825 }
826
827 else {
828 if ((userTrackerPathModelImpl.getColumnBitmask() &
829 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID.getColumnBitmask()) != 0) {
830 Object[] args = new Object[] {
831 userTrackerPathModelImpl.getOriginalUserTrackerId()
832 };
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 args = new Object[] { userTrackerPathModelImpl.getUserTrackerId() };
840
841 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
842 args);
843 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
844 args);
845 }
846 }
847
848 entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
849 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
850 userTrackerPath, false);
851
852 userTrackerPath.resetOriginalValues();
853
854 return userTrackerPath;
855 }
856
857 protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
858 if (userTrackerPath instanceof UserTrackerPathImpl) {
859 return userTrackerPath;
860 }
861
862 UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
863
864 userTrackerPathImpl.setNew(userTrackerPath.isNew());
865 userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
866
867 userTrackerPathImpl.setMvccVersion(userTrackerPath.getMvccVersion());
868 userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
869 userTrackerPathImpl.setCompanyId(userTrackerPath.getCompanyId());
870 userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
871 userTrackerPathImpl.setPath(userTrackerPath.getPath());
872 userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
873
874 return userTrackerPathImpl;
875 }
876
877
884 @Override
885 public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
886 throws NoSuchUserTrackerPathException {
887 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
888
889 if (userTrackerPath == null) {
890 if (_log.isWarnEnabled()) {
891 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
892 }
893
894 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
895 primaryKey);
896 }
897
898 return userTrackerPath;
899 }
900
901
908 @Override
909 public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
910 throws NoSuchUserTrackerPathException {
911 return findByPrimaryKey((Serializable)userTrackerPathId);
912 }
913
914
920 @Override
921 public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey) {
922 UserTrackerPath userTrackerPath = (UserTrackerPath)entityCache.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
923 UserTrackerPathImpl.class, primaryKey);
924
925 if (userTrackerPath == _nullUserTrackerPath) {
926 return null;
927 }
928
929 if (userTrackerPath == null) {
930 Session session = null;
931
932 try {
933 session = openSession();
934
935 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
936 primaryKey);
937
938 if (userTrackerPath != null) {
939 cacheResult(userTrackerPath);
940 }
941 else {
942 entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
943 UserTrackerPathImpl.class, primaryKey,
944 _nullUserTrackerPath);
945 }
946 }
947 catch (Exception e) {
948 entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
949 UserTrackerPathImpl.class, primaryKey);
950
951 throw processException(e);
952 }
953 finally {
954 closeSession(session);
955 }
956 }
957
958 return userTrackerPath;
959 }
960
961
967 @Override
968 public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId) {
969 return fetchByPrimaryKey((Serializable)userTrackerPathId);
970 }
971
972 @Override
973 public Map<Serializable, UserTrackerPath> fetchByPrimaryKeys(
974 Set<Serializable> primaryKeys) {
975 if (primaryKeys.isEmpty()) {
976 return Collections.emptyMap();
977 }
978
979 Map<Serializable, UserTrackerPath> map = new HashMap<Serializable, UserTrackerPath>();
980
981 if (primaryKeys.size() == 1) {
982 Iterator<Serializable> iterator = primaryKeys.iterator();
983
984 Serializable primaryKey = iterator.next();
985
986 UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
987
988 if (userTrackerPath != null) {
989 map.put(primaryKey, userTrackerPath);
990 }
991
992 return map;
993 }
994
995 Set<Serializable> uncachedPrimaryKeys = null;
996
997 for (Serializable primaryKey : primaryKeys) {
998 UserTrackerPath userTrackerPath = (UserTrackerPath)entityCache.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
999 UserTrackerPathImpl.class, primaryKey);
1000
1001 if (userTrackerPath == null) {
1002 if (uncachedPrimaryKeys == null) {
1003 uncachedPrimaryKeys = new HashSet<Serializable>();
1004 }
1005
1006 uncachedPrimaryKeys.add(primaryKey);
1007 }
1008 else {
1009 map.put(primaryKey, userTrackerPath);
1010 }
1011 }
1012
1013 if (uncachedPrimaryKeys == null) {
1014 return map;
1015 }
1016
1017 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1018 1);
1019
1020 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN);
1021
1022 for (Serializable primaryKey : uncachedPrimaryKeys) {
1023 query.append(String.valueOf(primaryKey));
1024
1025 query.append(StringPool.COMMA);
1026 }
1027
1028 query.setIndex(query.index() - 1);
1029
1030 query.append(StringPool.CLOSE_PARENTHESIS);
1031
1032 String sql = query.toString();
1033
1034 Session session = null;
1035
1036 try {
1037 session = openSession();
1038
1039 Query q = session.createQuery(sql);
1040
1041 for (UserTrackerPath userTrackerPath : (List<UserTrackerPath>)q.list()) {
1042 map.put(userTrackerPath.getPrimaryKeyObj(), userTrackerPath);
1043
1044 cacheResult(userTrackerPath);
1045
1046 uncachedPrimaryKeys.remove(userTrackerPath.getPrimaryKeyObj());
1047 }
1048
1049 for (Serializable primaryKey : uncachedPrimaryKeys) {
1050 entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
1051 UserTrackerPathImpl.class, primaryKey, _nullUserTrackerPath);
1052 }
1053 }
1054 catch (Exception e) {
1055 throw processException(e);
1056 }
1057 finally {
1058 closeSession(session);
1059 }
1060
1061 return map;
1062 }
1063
1064
1069 @Override
1070 public List<UserTrackerPath> findAll() {
1071 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1072 }
1073
1074
1085 @Override
1086 public List<UserTrackerPath> findAll(int start, int end) {
1087 return findAll(start, end, null);
1088 }
1089
1090
1102 @Override
1103 public List<UserTrackerPath> findAll(int start, int end,
1104 OrderByComparator<UserTrackerPath> orderByComparator) {
1105 return findAll(start, end, orderByComparator, true);
1106 }
1107
1108
1121 @Override
1122 public List<UserTrackerPath> findAll(int start, int end,
1123 OrderByComparator<UserTrackerPath> orderByComparator,
1124 boolean retrieveFromCache) {
1125 boolean pagination = true;
1126 FinderPath finderPath = null;
1127 Object[] finderArgs = null;
1128
1129 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1130 (orderByComparator == null)) {
1131 pagination = false;
1132 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1133 finderArgs = FINDER_ARGS_EMPTY;
1134 }
1135 else {
1136 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1137 finderArgs = new Object[] { start, end, orderByComparator };
1138 }
1139
1140 List<UserTrackerPath> list = null;
1141
1142 if (retrieveFromCache) {
1143 list = (List<UserTrackerPath>)finderCache.getResult(finderPath,
1144 finderArgs, this);
1145 }
1146
1147 if (list == null) {
1148 StringBundler query = null;
1149 String sql = null;
1150
1151 if (orderByComparator != null) {
1152 query = new StringBundler(2 +
1153 (orderByComparator.getOrderByFields().length * 2));
1154
1155 query.append(_SQL_SELECT_USERTRACKERPATH);
1156
1157 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1158 orderByComparator);
1159
1160 sql = query.toString();
1161 }
1162 else {
1163 sql = _SQL_SELECT_USERTRACKERPATH;
1164
1165 if (pagination) {
1166 sql = sql.concat(UserTrackerPathModelImpl.ORDER_BY_JPQL);
1167 }
1168 }
1169
1170 Session session = null;
1171
1172 try {
1173 session = openSession();
1174
1175 Query q = session.createQuery(sql);
1176
1177 if (!pagination) {
1178 list = (List<UserTrackerPath>)QueryUtil.list(q,
1179 getDialect(), start, end, false);
1180
1181 Collections.sort(list);
1182
1183 list = Collections.unmodifiableList(list);
1184 }
1185 else {
1186 list = (List<UserTrackerPath>)QueryUtil.list(q,
1187 getDialect(), start, end);
1188 }
1189
1190 cacheResult(list);
1191
1192 finderCache.putResult(finderPath, finderArgs, list);
1193 }
1194 catch (Exception e) {
1195 finderCache.removeResult(finderPath, finderArgs);
1196
1197 throw processException(e);
1198 }
1199 finally {
1200 closeSession(session);
1201 }
1202 }
1203
1204 return list;
1205 }
1206
1207
1211 @Override
1212 public void removeAll() {
1213 for (UserTrackerPath userTrackerPath : findAll()) {
1214 remove(userTrackerPath);
1215 }
1216 }
1217
1218
1223 @Override
1224 public int countAll() {
1225 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
1226 FINDER_ARGS_EMPTY, this);
1227
1228 if (count == null) {
1229 Session session = null;
1230
1231 try {
1232 session = openSession();
1233
1234 Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
1235
1236 count = (Long)q.uniqueResult();
1237
1238 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
1239 count);
1240 }
1241 catch (Exception e) {
1242 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
1243 FINDER_ARGS_EMPTY);
1244
1245 throw processException(e);
1246 }
1247 finally {
1248 closeSession(session);
1249 }
1250 }
1251
1252 return count.intValue();
1253 }
1254
1255 @Override
1256 public Set<String> getBadColumnNames() {
1257 return _badColumnNames;
1258 }
1259
1260 @Override
1261 protected Map<String, Integer> getTableColumnsMap() {
1262 return UserTrackerPathModelImpl.TABLE_COLUMNS_MAP;
1263 }
1264
1265
1268 public void afterPropertiesSet() {
1269 }
1270
1271 public void destroy() {
1272 entityCache.removeCache(UserTrackerPathImpl.class.getName());
1273 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1274 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1275 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1276 }
1277
1278 @BeanReference(type = CompanyProviderWrapper.class)
1279 protected CompanyProvider companyProvider;
1280 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1281 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1282 private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1283 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE userTrackerPathId IN (";
1284 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1285 private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1286 private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1287 private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1288 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1289 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1290 private static final Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1291 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1292 "path"
1293 });
1294 private static final UserTrackerPath _nullUserTrackerPath = new UserTrackerPathImpl() {
1295 @Override
1296 public Object clone() {
1297 return this;
1298 }
1299
1300 @Override
1301 public CacheModel<UserTrackerPath> toCacheModel() {
1302 return _nullUserTrackerPathCacheModel;
1303 }
1304 };
1305
1306 private static final CacheModel<UserTrackerPath> _nullUserTrackerPathCacheModel =
1307 new NullCacheModel();
1308
1309 private static class NullCacheModel implements CacheModel<UserTrackerPath>,
1310 MVCCModel {
1311 @Override
1312 public long getMvccVersion() {
1313 return -1;
1314 }
1315
1316 @Override
1317 public void setMvccVersion(long mvccVersion) {
1318 }
1319
1320 @Override
1321 public UserTrackerPath toEntityModel() {
1322 return _nullUserTrackerPath;
1323 }
1324 }
1325 }