001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchUserTrackerPathException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.UserTrackerPath;
040 import com.liferay.portal.model.impl.UserTrackerPathImpl;
041 import com.liferay.portal.model.impl.UserTrackerPathModelImpl;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import java.io.Serializable;
045
046 import java.util.ArrayList;
047 import java.util.Collections;
048 import java.util.List;
049
050
062 public class UserTrackerPathPersistenceImpl extends BasePersistenceImpl<UserTrackerPath>
063 implements UserTrackerPathPersistence {
064
069 public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerPathImpl.class.getName();
070 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071 ".List1";
072 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List2";
074 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID =
075 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
076 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
077 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
078 "findByUserTrackerId",
079 new String[] {
080 Long.class.getName(),
081
082 "java.lang.Integer", "java.lang.Integer",
083 "com.liferay.portal.kernel.util.OrderByComparator"
084 });
085 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID =
086 new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
087 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
088 UserTrackerPathImpl.class,
089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserTrackerId",
090 new String[] { Long.class.getName() },
091 UserTrackerPathModelImpl.USERTRACKERID_COLUMN_BITMASK);
092 public static final FinderPath FINDER_PATH_COUNT_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
093 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserTrackerId",
095 new String[] { Long.class.getName() });
096 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
097 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
098 UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
099 "findAll", new String[0]);
100 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
101 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
102 UserTrackerPathImpl.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
104 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
105 UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
107
108
113 public void cacheResult(UserTrackerPath userTrackerPath) {
114 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
115 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
116 userTrackerPath);
117
118 userTrackerPath.resetOriginalValues();
119 }
120
121
126 public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
127 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
128 if (EntityCacheUtil.getResult(
129 UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
130 UserTrackerPathImpl.class,
131 userTrackerPath.getPrimaryKey()) == null) {
132 cacheResult(userTrackerPath);
133 }
134 else {
135 userTrackerPath.resetOriginalValues();
136 }
137 }
138 }
139
140
147 @Override
148 public void clearCache() {
149 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
150 CacheRegistryUtil.clear(UserTrackerPathImpl.class.getName());
151 }
152
153 EntityCacheUtil.clearCache(UserTrackerPathImpl.class.getName());
154
155 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
156 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
157 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
158 }
159
160
167 @Override
168 public void clearCache(UserTrackerPath userTrackerPath) {
169 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
170 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
171
172 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
173 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
174 }
175
176 @Override
177 public void clearCache(List<UserTrackerPath> userTrackerPaths) {
178 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
179 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
180
181 for (UserTrackerPath userTrackerPath : userTrackerPaths) {
182 EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
183 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
184 }
185 }
186
187
193 public UserTrackerPath create(long userTrackerPathId) {
194 UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
195
196 userTrackerPath.setNew(true);
197 userTrackerPath.setPrimaryKey(userTrackerPathId);
198
199 return userTrackerPath;
200 }
201
202
210 public UserTrackerPath remove(long userTrackerPathId)
211 throws NoSuchUserTrackerPathException, SystemException {
212 return remove(Long.valueOf(userTrackerPathId));
213 }
214
215
223 @Override
224 public UserTrackerPath remove(Serializable primaryKey)
225 throws NoSuchUserTrackerPathException, SystemException {
226 Session session = null;
227
228 try {
229 session = openSession();
230
231 UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
232 primaryKey);
233
234 if (userTrackerPath == null) {
235 if (_log.isWarnEnabled()) {
236 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
237 }
238
239 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
240 primaryKey);
241 }
242
243 return remove(userTrackerPath);
244 }
245 catch (NoSuchUserTrackerPathException nsee) {
246 throw nsee;
247 }
248 catch (Exception e) {
249 throw processException(e);
250 }
251 finally {
252 closeSession(session);
253 }
254 }
255
256 @Override
257 protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath)
258 throws SystemException {
259 userTrackerPath = toUnwrappedModel(userTrackerPath);
260
261 Session session = null;
262
263 try {
264 session = openSession();
265
266 if (userTrackerPath.isCachedModel()) {
267 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
268 userTrackerPath.getPrimaryKeyObj());
269 }
270
271 session.delete(userTrackerPath);
272 }
273 catch (Exception e) {
274 throw processException(e);
275 }
276 finally {
277 closeSession(session);
278 }
279
280 clearCache(userTrackerPath);
281
282 return userTrackerPath;
283 }
284
285 @Override
286 public UserTrackerPath updateImpl(
287 com.liferay.portal.model.UserTrackerPath userTrackerPath)
288 throws SystemException {
289 userTrackerPath = toUnwrappedModel(userTrackerPath);
290
291 boolean isNew = userTrackerPath.isNew();
292
293 UserTrackerPathModelImpl userTrackerPathModelImpl = (UserTrackerPathModelImpl)userTrackerPath;
294
295 Session session = null;
296
297 try {
298 session = openSession();
299
300 if (userTrackerPath.isNew()) {
301 session.save(userTrackerPath);
302
303 userTrackerPath.setNew(false);
304 }
305 else {
306 session.merge(userTrackerPath);
307 }
308 }
309 catch (Exception e) {
310 throw processException(e);
311 }
312 finally {
313 closeSession(session);
314 }
315
316 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
317
318 if (isNew || !UserTrackerPathModelImpl.COLUMN_BITMASK_ENABLED) {
319 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
320 }
321
322 else {
323 if ((userTrackerPathModelImpl.getColumnBitmask() &
324 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID.getColumnBitmask()) != 0) {
325 Object[] args = new Object[] {
326 Long.valueOf(userTrackerPathModelImpl.getOriginalUserTrackerId())
327 };
328
329 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
330 args);
331 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
332 args);
333
334 args = new Object[] {
335 Long.valueOf(userTrackerPathModelImpl.getUserTrackerId())
336 };
337
338 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
339 args);
340 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
341 args);
342 }
343 }
344
345 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
346 UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
347 userTrackerPath);
348
349 return userTrackerPath;
350 }
351
352 protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
353 if (userTrackerPath instanceof UserTrackerPathImpl) {
354 return userTrackerPath;
355 }
356
357 UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
358
359 userTrackerPathImpl.setNew(userTrackerPath.isNew());
360 userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
361
362 userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
363 userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
364 userTrackerPathImpl.setPath(userTrackerPath.getPath());
365 userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
366
367 return userTrackerPathImpl;
368 }
369
370
378 @Override
379 public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
380 throws NoSuchModelException, SystemException {
381 return findByPrimaryKey(((Long)primaryKey).longValue());
382 }
383
384
392 public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
393 throws NoSuchUserTrackerPathException, SystemException {
394 UserTrackerPath userTrackerPath = fetchByPrimaryKey(userTrackerPathId);
395
396 if (userTrackerPath == null) {
397 if (_log.isWarnEnabled()) {
398 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userTrackerPathId);
399 }
400
401 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
402 userTrackerPathId);
403 }
404
405 return userTrackerPath;
406 }
407
408
415 @Override
416 public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey)
417 throws SystemException {
418 return fetchByPrimaryKey(((Long)primaryKey).longValue());
419 }
420
421
428 public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId)
429 throws SystemException {
430 UserTrackerPath userTrackerPath = (UserTrackerPath)EntityCacheUtil.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
431 UserTrackerPathImpl.class, userTrackerPathId);
432
433 if (userTrackerPath == _nullUserTrackerPath) {
434 return null;
435 }
436
437 if (userTrackerPath == null) {
438 Session session = null;
439
440 boolean hasException = false;
441
442 try {
443 session = openSession();
444
445 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
446 Long.valueOf(userTrackerPathId));
447 }
448 catch (Exception e) {
449 hasException = true;
450
451 throw processException(e);
452 }
453 finally {
454 if (userTrackerPath != null) {
455 cacheResult(userTrackerPath);
456 }
457 else if (!hasException) {
458 EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
459 UserTrackerPathImpl.class, userTrackerPathId,
460 _nullUserTrackerPath);
461 }
462
463 closeSession(session);
464 }
465 }
466
467 return userTrackerPath;
468 }
469
470
477 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId)
478 throws SystemException {
479 return findByUserTrackerId(userTrackerId, QueryUtil.ALL_POS,
480 QueryUtil.ALL_POS, null);
481 }
482
483
496 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
497 int start, int end) throws SystemException {
498 return findByUserTrackerId(userTrackerId, start, end, null);
499 }
500
501
515 public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
516 int start, int end, OrderByComparator orderByComparator)
517 throws SystemException {
518 FinderPath finderPath = null;
519 Object[] finderArgs = null;
520
521 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
522 (orderByComparator == null)) {
523 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID;
524 finderArgs = new Object[] { userTrackerId };
525 }
526 else {
527 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID;
528 finderArgs = new Object[] {
529 userTrackerId,
530
531 start, end, orderByComparator
532 };
533 }
534
535 List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(finderPath,
536 finderArgs, this);
537
538 if ((list != null) && !list.isEmpty()) {
539 for (UserTrackerPath userTrackerPath : list) {
540 if ((userTrackerId != userTrackerPath.getUserTrackerId())) {
541 list = null;
542
543 break;
544 }
545 }
546 }
547
548 if (list == null) {
549 StringBundler query = null;
550
551 if (orderByComparator != null) {
552 query = new StringBundler(3 +
553 (orderByComparator.getOrderByFields().length * 3));
554 }
555 else {
556 query = new StringBundler(2);
557 }
558
559 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
560
561 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
562
563 if (orderByComparator != null) {
564 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
565 orderByComparator);
566 }
567
568 String sql = query.toString();
569
570 Session session = null;
571
572 try {
573 session = openSession();
574
575 Query q = session.createQuery(sql);
576
577 QueryPos qPos = QueryPos.getInstance(q);
578
579 qPos.add(userTrackerId);
580
581 list = (List<UserTrackerPath>)QueryUtil.list(q, getDialect(),
582 start, end);
583 }
584 catch (Exception e) {
585 throw processException(e);
586 }
587 finally {
588 if (list == null) {
589 FinderCacheUtil.removeResult(finderPath, finderArgs);
590 }
591 else {
592 cacheResult(list);
593
594 FinderCacheUtil.putResult(finderPath, finderArgs, list);
595 }
596
597 closeSession(session);
598 }
599 }
600
601 return list;
602 }
603
604
613 public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
614 OrderByComparator orderByComparator)
615 throws NoSuchUserTrackerPathException, SystemException {
616 UserTrackerPath userTrackerPath = fetchByUserTrackerId_First(userTrackerId,
617 orderByComparator);
618
619 if (userTrackerPath != null) {
620 return userTrackerPath;
621 }
622
623 StringBundler msg = new StringBundler(4);
624
625 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
626
627 msg.append("userTrackerId=");
628 msg.append(userTrackerId);
629
630 msg.append(StringPool.CLOSE_CURLY_BRACE);
631
632 throw new NoSuchUserTrackerPathException(msg.toString());
633 }
634
635
643 public UserTrackerPath fetchByUserTrackerId_First(long userTrackerId,
644 OrderByComparator orderByComparator) throws SystemException {
645 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId, 0, 1,
646 orderByComparator);
647
648 if (!list.isEmpty()) {
649 return list.get(0);
650 }
651
652 return null;
653 }
654
655
664 public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
665 OrderByComparator orderByComparator)
666 throws NoSuchUserTrackerPathException, SystemException {
667 UserTrackerPath userTrackerPath = fetchByUserTrackerId_Last(userTrackerId,
668 orderByComparator);
669
670 if (userTrackerPath != null) {
671 return userTrackerPath;
672 }
673
674 StringBundler msg = new StringBundler(4);
675
676 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
677
678 msg.append("userTrackerId=");
679 msg.append(userTrackerId);
680
681 msg.append(StringPool.CLOSE_CURLY_BRACE);
682
683 throw new NoSuchUserTrackerPathException(msg.toString());
684 }
685
686
694 public UserTrackerPath fetchByUserTrackerId_Last(long userTrackerId,
695 OrderByComparator orderByComparator) throws SystemException {
696 int count = countByUserTrackerId(userTrackerId);
697
698 List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
699 count - 1, count, orderByComparator);
700
701 if (!list.isEmpty()) {
702 return list.get(0);
703 }
704
705 return null;
706 }
707
708
718 public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
719 long userTrackerPathId, long userTrackerId,
720 OrderByComparator orderByComparator)
721 throws NoSuchUserTrackerPathException, SystemException {
722 UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
723
724 Session session = null;
725
726 try {
727 session = openSession();
728
729 UserTrackerPath[] array = new UserTrackerPathImpl[3];
730
731 array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
732 userTrackerId, orderByComparator, true);
733
734 array[1] = userTrackerPath;
735
736 array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
737 userTrackerId, orderByComparator, false);
738
739 return array;
740 }
741 catch (Exception e) {
742 throw processException(e);
743 }
744 finally {
745 closeSession(session);
746 }
747 }
748
749 protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
750 UserTrackerPath userTrackerPath, long userTrackerId,
751 OrderByComparator orderByComparator, boolean previous) {
752 StringBundler query = null;
753
754 if (orderByComparator != null) {
755 query = new StringBundler(6 +
756 (orderByComparator.getOrderByFields().length * 6));
757 }
758 else {
759 query = new StringBundler(3);
760 }
761
762 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
763
764 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
765
766 if (orderByComparator != null) {
767 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
768
769 if (orderByConditionFields.length > 0) {
770 query.append(WHERE_AND);
771 }
772
773 for (int i = 0; i < orderByConditionFields.length; i++) {
774 query.append(_ORDER_BY_ENTITY_ALIAS);
775 query.append(orderByConditionFields[i]);
776
777 if ((i + 1) < orderByConditionFields.length) {
778 if (orderByComparator.isAscending() ^ previous) {
779 query.append(WHERE_GREATER_THAN_HAS_NEXT);
780 }
781 else {
782 query.append(WHERE_LESSER_THAN_HAS_NEXT);
783 }
784 }
785 else {
786 if (orderByComparator.isAscending() ^ previous) {
787 query.append(WHERE_GREATER_THAN);
788 }
789 else {
790 query.append(WHERE_LESSER_THAN);
791 }
792 }
793 }
794
795 query.append(ORDER_BY_CLAUSE);
796
797 String[] orderByFields = orderByComparator.getOrderByFields();
798
799 for (int i = 0; i < orderByFields.length; i++) {
800 query.append(_ORDER_BY_ENTITY_ALIAS);
801 query.append(orderByFields[i]);
802
803 if ((i + 1) < orderByFields.length) {
804 if (orderByComparator.isAscending() ^ previous) {
805 query.append(ORDER_BY_ASC_HAS_NEXT);
806 }
807 else {
808 query.append(ORDER_BY_DESC_HAS_NEXT);
809 }
810 }
811 else {
812 if (orderByComparator.isAscending() ^ previous) {
813 query.append(ORDER_BY_ASC);
814 }
815 else {
816 query.append(ORDER_BY_DESC);
817 }
818 }
819 }
820 }
821
822 String sql = query.toString();
823
824 Query q = session.createQuery(sql);
825
826 q.setFirstResult(0);
827 q.setMaxResults(2);
828
829 QueryPos qPos = QueryPos.getInstance(q);
830
831 qPos.add(userTrackerId);
832
833 if (orderByComparator != null) {
834 Object[] values = orderByComparator.getOrderByConditionValues(userTrackerPath);
835
836 for (Object value : values) {
837 qPos.add(value);
838 }
839 }
840
841 List<UserTrackerPath> list = q.list();
842
843 if (list.size() == 2) {
844 return list.get(1);
845 }
846 else {
847 return null;
848 }
849 }
850
851
857 public List<UserTrackerPath> findAll() throws SystemException {
858 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
859 }
860
861
873 public List<UserTrackerPath> findAll(int start, int end)
874 throws SystemException {
875 return findAll(start, end, null);
876 }
877
878
891 public List<UserTrackerPath> findAll(int start, int end,
892 OrderByComparator orderByComparator) throws SystemException {
893 FinderPath finderPath = null;
894 Object[] finderArgs = new Object[] { start, end, orderByComparator };
895
896 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
897 (orderByComparator == null)) {
898 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
899 finderArgs = FINDER_ARGS_EMPTY;
900 }
901 else {
902 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
903 finderArgs = new Object[] { start, end, orderByComparator };
904 }
905
906 List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(finderPath,
907 finderArgs, this);
908
909 if (list == null) {
910 StringBundler query = null;
911 String sql = null;
912
913 if (orderByComparator != null) {
914 query = new StringBundler(2 +
915 (orderByComparator.getOrderByFields().length * 3));
916
917 query.append(_SQL_SELECT_USERTRACKERPATH);
918
919 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
920 orderByComparator);
921
922 sql = query.toString();
923 }
924 else {
925 sql = _SQL_SELECT_USERTRACKERPATH;
926 }
927
928 Session session = null;
929
930 try {
931 session = openSession();
932
933 Query q = session.createQuery(sql);
934
935 if (orderByComparator == null) {
936 list = (List<UserTrackerPath>)QueryUtil.list(q,
937 getDialect(), start, end, false);
938
939 Collections.sort(list);
940 }
941 else {
942 list = (List<UserTrackerPath>)QueryUtil.list(q,
943 getDialect(), start, end);
944 }
945 }
946 catch (Exception e) {
947 throw processException(e);
948 }
949 finally {
950 if (list == null) {
951 FinderCacheUtil.removeResult(finderPath, finderArgs);
952 }
953 else {
954 cacheResult(list);
955
956 FinderCacheUtil.putResult(finderPath, finderArgs, list);
957 }
958
959 closeSession(session);
960 }
961 }
962
963 return list;
964 }
965
966
972 public void removeByUserTrackerId(long userTrackerId)
973 throws SystemException {
974 for (UserTrackerPath userTrackerPath : findByUserTrackerId(
975 userTrackerId)) {
976 remove(userTrackerPath);
977 }
978 }
979
980
985 public void removeAll() throws SystemException {
986 for (UserTrackerPath userTrackerPath : findAll()) {
987 remove(userTrackerPath);
988 }
989 }
990
991
998 public int countByUserTrackerId(long userTrackerId)
999 throws SystemException {
1000 Object[] finderArgs = new Object[] { userTrackerId };
1001
1002 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
1003 finderArgs, this);
1004
1005 if (count == null) {
1006 StringBundler query = new StringBundler(2);
1007
1008 query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
1009
1010 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
1011
1012 String sql = query.toString();
1013
1014 Session session = null;
1015
1016 try {
1017 session = openSession();
1018
1019 Query q = session.createQuery(sql);
1020
1021 QueryPos qPos = QueryPos.getInstance(q);
1022
1023 qPos.add(userTrackerId);
1024
1025 count = (Long)q.uniqueResult();
1026 }
1027 catch (Exception e) {
1028 throw processException(e);
1029 }
1030 finally {
1031 if (count == null) {
1032 count = Long.valueOf(0);
1033 }
1034
1035 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
1036 finderArgs, count);
1037
1038 closeSession(session);
1039 }
1040 }
1041
1042 return count.intValue();
1043 }
1044
1045
1051 public int countAll() throws SystemException {
1052 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1053 FINDER_ARGS_EMPTY, this);
1054
1055 if (count == null) {
1056 Session session = null;
1057
1058 try {
1059 session = openSession();
1060
1061 Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
1062
1063 count = (Long)q.uniqueResult();
1064 }
1065 catch (Exception e) {
1066 throw processException(e);
1067 }
1068 finally {
1069 if (count == null) {
1070 count = Long.valueOf(0);
1071 }
1072
1073 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1074 FINDER_ARGS_EMPTY, count);
1075
1076 closeSession(session);
1077 }
1078 }
1079
1080 return count.intValue();
1081 }
1082
1083
1086 public void afterPropertiesSet() {
1087 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1088 com.liferay.portal.util.PropsUtil.get(
1089 "value.object.listener.com.liferay.portal.model.UserTrackerPath")));
1090
1091 if (listenerClassNames.length > 0) {
1092 try {
1093 List<ModelListener<UserTrackerPath>> listenersList = new ArrayList<ModelListener<UserTrackerPath>>();
1094
1095 for (String listenerClassName : listenerClassNames) {
1096 listenersList.add((ModelListener<UserTrackerPath>)InstanceFactory.newInstance(
1097 listenerClassName));
1098 }
1099
1100 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1101 }
1102 catch (Exception e) {
1103 _log.error(e);
1104 }
1105 }
1106 }
1107
1108 public void destroy() {
1109 EntityCacheUtil.removeCache(UserTrackerPathImpl.class.getName());
1110 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1111 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1112 }
1113
1114 @BeanReference(type = AccountPersistence.class)
1115 protected AccountPersistence accountPersistence;
1116 @BeanReference(type = AddressPersistence.class)
1117 protected AddressPersistence addressPersistence;
1118 @BeanReference(type = BrowserTrackerPersistence.class)
1119 protected BrowserTrackerPersistence browserTrackerPersistence;
1120 @BeanReference(type = ClassNamePersistence.class)
1121 protected ClassNamePersistence classNamePersistence;
1122 @BeanReference(type = ClusterGroupPersistence.class)
1123 protected ClusterGroupPersistence clusterGroupPersistence;
1124 @BeanReference(type = CompanyPersistence.class)
1125 protected CompanyPersistence companyPersistence;
1126 @BeanReference(type = ContactPersistence.class)
1127 protected ContactPersistence contactPersistence;
1128 @BeanReference(type = CountryPersistence.class)
1129 protected CountryPersistence countryPersistence;
1130 @BeanReference(type = EmailAddressPersistence.class)
1131 protected EmailAddressPersistence emailAddressPersistence;
1132 @BeanReference(type = GroupPersistence.class)
1133 protected GroupPersistence groupPersistence;
1134 @BeanReference(type = ImagePersistence.class)
1135 protected ImagePersistence imagePersistence;
1136 @BeanReference(type = LayoutPersistence.class)
1137 protected LayoutPersistence layoutPersistence;
1138 @BeanReference(type = LayoutBranchPersistence.class)
1139 protected LayoutBranchPersistence layoutBranchPersistence;
1140 @BeanReference(type = LayoutPrototypePersistence.class)
1141 protected LayoutPrototypePersistence layoutPrototypePersistence;
1142 @BeanReference(type = LayoutRevisionPersistence.class)
1143 protected LayoutRevisionPersistence layoutRevisionPersistence;
1144 @BeanReference(type = LayoutSetPersistence.class)
1145 protected LayoutSetPersistence layoutSetPersistence;
1146 @BeanReference(type = LayoutSetBranchPersistence.class)
1147 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1148 @BeanReference(type = LayoutSetPrototypePersistence.class)
1149 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1150 @BeanReference(type = ListTypePersistence.class)
1151 protected ListTypePersistence listTypePersistence;
1152 @BeanReference(type = LockPersistence.class)
1153 protected LockPersistence lockPersistence;
1154 @BeanReference(type = MembershipRequestPersistence.class)
1155 protected MembershipRequestPersistence membershipRequestPersistence;
1156 @BeanReference(type = OrganizationPersistence.class)
1157 protected OrganizationPersistence organizationPersistence;
1158 @BeanReference(type = OrgGroupRolePersistence.class)
1159 protected OrgGroupRolePersistence orgGroupRolePersistence;
1160 @BeanReference(type = OrgLaborPersistence.class)
1161 protected OrgLaborPersistence orgLaborPersistence;
1162 @BeanReference(type = PasswordPolicyPersistence.class)
1163 protected PasswordPolicyPersistence passwordPolicyPersistence;
1164 @BeanReference(type = PasswordPolicyRelPersistence.class)
1165 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1166 @BeanReference(type = PasswordTrackerPersistence.class)
1167 protected PasswordTrackerPersistence passwordTrackerPersistence;
1168 @BeanReference(type = PhonePersistence.class)
1169 protected PhonePersistence phonePersistence;
1170 @BeanReference(type = PluginSettingPersistence.class)
1171 protected PluginSettingPersistence pluginSettingPersistence;
1172 @BeanReference(type = PortalPreferencesPersistence.class)
1173 protected PortalPreferencesPersistence portalPreferencesPersistence;
1174 @BeanReference(type = PortletPersistence.class)
1175 protected PortletPersistence portletPersistence;
1176 @BeanReference(type = PortletItemPersistence.class)
1177 protected PortletItemPersistence portletItemPersistence;
1178 @BeanReference(type = PortletPreferencesPersistence.class)
1179 protected PortletPreferencesPersistence portletPreferencesPersistence;
1180 @BeanReference(type = RegionPersistence.class)
1181 protected RegionPersistence regionPersistence;
1182 @BeanReference(type = ReleasePersistence.class)
1183 protected ReleasePersistence releasePersistence;
1184 @BeanReference(type = RepositoryPersistence.class)
1185 protected RepositoryPersistence repositoryPersistence;
1186 @BeanReference(type = RepositoryEntryPersistence.class)
1187 protected RepositoryEntryPersistence repositoryEntryPersistence;
1188 @BeanReference(type = ResourceActionPersistence.class)
1189 protected ResourceActionPersistence resourceActionPersistence;
1190 @BeanReference(type = ResourceBlockPersistence.class)
1191 protected ResourceBlockPersistence resourceBlockPersistence;
1192 @BeanReference(type = ResourceBlockPermissionPersistence.class)
1193 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1194 @BeanReference(type = ResourcePermissionPersistence.class)
1195 protected ResourcePermissionPersistence resourcePermissionPersistence;
1196 @BeanReference(type = ResourceTypePermissionPersistence.class)
1197 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1198 @BeanReference(type = RolePersistence.class)
1199 protected RolePersistence rolePersistence;
1200 @BeanReference(type = ServiceComponentPersistence.class)
1201 protected ServiceComponentPersistence serviceComponentPersistence;
1202 @BeanReference(type = ShardPersistence.class)
1203 protected ShardPersistence shardPersistence;
1204 @BeanReference(type = SubscriptionPersistence.class)
1205 protected SubscriptionPersistence subscriptionPersistence;
1206 @BeanReference(type = TeamPersistence.class)
1207 protected TeamPersistence teamPersistence;
1208 @BeanReference(type = TicketPersistence.class)
1209 protected TicketPersistence ticketPersistence;
1210 @BeanReference(type = UserPersistence.class)
1211 protected UserPersistence userPersistence;
1212 @BeanReference(type = UserGroupPersistence.class)
1213 protected UserGroupPersistence userGroupPersistence;
1214 @BeanReference(type = UserGroupGroupRolePersistence.class)
1215 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1216 @BeanReference(type = UserGroupRolePersistence.class)
1217 protected UserGroupRolePersistence userGroupRolePersistence;
1218 @BeanReference(type = UserIdMapperPersistence.class)
1219 protected UserIdMapperPersistence userIdMapperPersistence;
1220 @BeanReference(type = UserNotificationEventPersistence.class)
1221 protected UserNotificationEventPersistence userNotificationEventPersistence;
1222 @BeanReference(type = UserTrackerPersistence.class)
1223 protected UserTrackerPersistence userTrackerPersistence;
1224 @BeanReference(type = UserTrackerPathPersistence.class)
1225 protected UserTrackerPathPersistence userTrackerPathPersistence;
1226 @BeanReference(type = VirtualHostPersistence.class)
1227 protected VirtualHostPersistence virtualHostPersistence;
1228 @BeanReference(type = WebDAVPropsPersistence.class)
1229 protected WebDAVPropsPersistence webDAVPropsPersistence;
1230 @BeanReference(type = WebsitePersistence.class)
1231 protected WebsitePersistence websitePersistence;
1232 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1233 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1234 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1235 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1236 private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1237 private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1238 private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1239 private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1240 private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
1241 private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1242 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1243 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1244 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1245 private static Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1246 private static UserTrackerPath _nullUserTrackerPath = new UserTrackerPathImpl() {
1247 @Override
1248 public Object clone() {
1249 return this;
1250 }
1251
1252 @Override
1253 public CacheModel<UserTrackerPath> toCacheModel() {
1254 return _nullUserTrackerPathCacheModel;
1255 }
1256 };
1257
1258 private static CacheModel<UserTrackerPath> _nullUserTrackerPathCacheModel = new CacheModel<UserTrackerPath>() {
1259 public UserTrackerPath toEntityModel() {
1260 return _nullUserTrackerPath;
1261 }
1262 };
1263 }