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