001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchUserTrackerException;
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.UserTracker;
040 import com.liferay.portal.model.impl.UserTrackerImpl;
041 import com.liferay.portal.model.impl.UserTrackerModelImpl;
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 UserTrackerPersistenceImpl extends BasePersistenceImpl<UserTracker>
063 implements UserTrackerPersistence {
064
069 public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerImpl.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_COMPANYID =
075 new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
076 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
077 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
078 new String[] {
079 Long.class.getName(),
080
081 "java.lang.Integer", "java.lang.Integer",
082 "com.liferay.portal.kernel.util.OrderByComparator"
083 });
084 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
085 new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
086 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
088 new String[] { Long.class.getName() },
089 UserTrackerModelImpl.COMPANYID_COLUMN_BITMASK);
090 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
091 UserTrackerModelImpl.FINDER_CACHE_ENABLED, Long.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
093 new String[] { Long.class.getName() });
094 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
095 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
096 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
097 new String[] {
098 Long.class.getName(),
099
100 "java.lang.Integer", "java.lang.Integer",
101 "com.liferay.portal.kernel.util.OrderByComparator"
102 });
103 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
104 new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
105 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
107 new String[] { Long.class.getName() },
108 UserTrackerModelImpl.USERID_COLUMN_BITMASK);
109 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
110 UserTrackerModelImpl.FINDER_CACHE_ENABLED, Long.class,
111 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
112 new String[] { Long.class.getName() });
113 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SESSIONID =
114 new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
115 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
116 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findBySessionId",
117 new String[] {
118 String.class.getName(),
119
120 "java.lang.Integer", "java.lang.Integer",
121 "com.liferay.portal.kernel.util.OrderByComparator"
122 });
123 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SESSIONID =
124 new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
125 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
126 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySessionId",
127 new String[] { String.class.getName() },
128 UserTrackerModelImpl.SESSIONID_COLUMN_BITMASK);
129 public static final FinderPath FINDER_PATH_COUNT_BY_SESSIONID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
130 UserTrackerModelImpl.FINDER_CACHE_ENABLED, Long.class,
131 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySessionId",
132 new String[] { String.class.getName() });
133 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
134 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
135 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
136 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
137 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
138 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
139 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
140 UserTrackerModelImpl.FINDER_CACHE_ENABLED, Long.class,
141 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
142
143
148 public void cacheResult(UserTracker userTracker) {
149 EntityCacheUtil.putResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
150 UserTrackerImpl.class, userTracker.getPrimaryKey(), userTracker);
151
152 userTracker.resetOriginalValues();
153 }
154
155
160 public void cacheResult(List<UserTracker> userTrackers) {
161 for (UserTracker userTracker : userTrackers) {
162 if (EntityCacheUtil.getResult(
163 UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
164 UserTrackerImpl.class, userTracker.getPrimaryKey()) == null) {
165 cacheResult(userTracker);
166 }
167 else {
168 userTracker.resetOriginalValues();
169 }
170 }
171 }
172
173
180 @Override
181 public void clearCache() {
182 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
183 CacheRegistryUtil.clear(UserTrackerImpl.class.getName());
184 }
185
186 EntityCacheUtil.clearCache(UserTrackerImpl.class.getName());
187
188 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
189 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
190 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
191 }
192
193
200 @Override
201 public void clearCache(UserTracker userTracker) {
202 EntityCacheUtil.removeResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
203 UserTrackerImpl.class, userTracker.getPrimaryKey());
204
205 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
206 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
207 }
208
209
215 public UserTracker create(long userTrackerId) {
216 UserTracker userTracker = new UserTrackerImpl();
217
218 userTracker.setNew(true);
219 userTracker.setPrimaryKey(userTrackerId);
220
221 return userTracker;
222 }
223
224
232 @Override
233 public UserTracker remove(Serializable primaryKey)
234 throws NoSuchModelException, SystemException {
235 return remove(((Long)primaryKey).longValue());
236 }
237
238
246 public UserTracker remove(long userTrackerId)
247 throws NoSuchUserTrackerException, SystemException {
248 Session session = null;
249
250 try {
251 session = openSession();
252
253 UserTracker userTracker = (UserTracker)session.get(UserTrackerImpl.class,
254 Long.valueOf(userTrackerId));
255
256 if (userTracker == null) {
257 if (_log.isWarnEnabled()) {
258 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userTrackerId);
259 }
260
261 throw new NoSuchUserTrackerException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
262 userTrackerId);
263 }
264
265 return userTrackerPersistence.remove(userTracker);
266 }
267 catch (NoSuchUserTrackerException nsee) {
268 throw nsee;
269 }
270 catch (Exception e) {
271 throw processException(e);
272 }
273 finally {
274 closeSession(session);
275 }
276 }
277
278
285 @Override
286 public UserTracker remove(UserTracker userTracker)
287 throws SystemException {
288 return super.remove(userTracker);
289 }
290
291 @Override
292 protected UserTracker removeImpl(UserTracker userTracker)
293 throws SystemException {
294 userTracker = toUnwrappedModel(userTracker);
295
296 Session session = null;
297
298 try {
299 session = openSession();
300
301 BatchSessionUtil.delete(session, userTracker);
302 }
303 catch (Exception e) {
304 throw processException(e);
305 }
306 finally {
307 closeSession(session);
308 }
309
310 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
311 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
312
313 EntityCacheUtil.removeResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
314 UserTrackerImpl.class, userTracker.getPrimaryKey());
315
316 return userTracker;
317 }
318
319 @Override
320 public UserTracker updateImpl(
321 com.liferay.portal.model.UserTracker userTracker, boolean merge)
322 throws SystemException {
323 userTracker = toUnwrappedModel(userTracker);
324
325 boolean isNew = userTracker.isNew();
326
327 UserTrackerModelImpl userTrackerModelImpl = (UserTrackerModelImpl)userTracker;
328
329 Session session = null;
330
331 try {
332 session = openSession();
333
334 BatchSessionUtil.update(session, userTracker, merge);
335
336 userTracker.setNew(false);
337 }
338 catch (Exception e) {
339 throw processException(e);
340 }
341 finally {
342 closeSession(session);
343 }
344
345 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
346
347 if (isNew || !UserTrackerModelImpl.COLUMN_BITMASK_ENABLED) {
348 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
349 }
350
351 else {
352 if ((userTrackerModelImpl.getColumnBitmask() &
353 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
354 Object[] args = new Object[] {
355 Long.valueOf(userTrackerModelImpl.getOriginalCompanyId())
356 };
357
358 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
359 args);
360 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
361 args);
362
363 args = new Object[] {
364 Long.valueOf(userTrackerModelImpl.getCompanyId())
365 };
366
367 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
368 args);
369 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
370 args);
371 }
372
373 if ((userTrackerModelImpl.getColumnBitmask() &
374 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
375 Object[] args = new Object[] {
376 Long.valueOf(userTrackerModelImpl.getOriginalUserId())
377 };
378
379 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
380 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
381 args);
382
383 args = new Object[] {
384 Long.valueOf(userTrackerModelImpl.getUserId())
385 };
386
387 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
388 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
389 args);
390 }
391
392 if ((userTrackerModelImpl.getColumnBitmask() &
393 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SESSIONID.getColumnBitmask()) != 0) {
394 Object[] args = new Object[] {
395 userTrackerModelImpl.getOriginalSessionId()
396 };
397
398 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SESSIONID,
399 args);
400 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SESSIONID,
401 args);
402
403 args = new Object[] { userTrackerModelImpl.getSessionId() };
404
405 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SESSIONID,
406 args);
407 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SESSIONID,
408 args);
409 }
410 }
411
412 EntityCacheUtil.putResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
413 UserTrackerImpl.class, userTracker.getPrimaryKey(), userTracker);
414
415 return userTracker;
416 }
417
418 protected UserTracker toUnwrappedModel(UserTracker userTracker) {
419 if (userTracker instanceof UserTrackerImpl) {
420 return userTracker;
421 }
422
423 UserTrackerImpl userTrackerImpl = new UserTrackerImpl();
424
425 userTrackerImpl.setNew(userTracker.isNew());
426 userTrackerImpl.setPrimaryKey(userTracker.getPrimaryKey());
427
428 userTrackerImpl.setUserTrackerId(userTracker.getUserTrackerId());
429 userTrackerImpl.setCompanyId(userTracker.getCompanyId());
430 userTrackerImpl.setUserId(userTracker.getUserId());
431 userTrackerImpl.setModifiedDate(userTracker.getModifiedDate());
432 userTrackerImpl.setSessionId(userTracker.getSessionId());
433 userTrackerImpl.setRemoteAddr(userTracker.getRemoteAddr());
434 userTrackerImpl.setRemoteHost(userTracker.getRemoteHost());
435 userTrackerImpl.setUserAgent(userTracker.getUserAgent());
436
437 return userTrackerImpl;
438 }
439
440
448 @Override
449 public UserTracker findByPrimaryKey(Serializable primaryKey)
450 throws NoSuchModelException, SystemException {
451 return findByPrimaryKey(((Long)primaryKey).longValue());
452 }
453
454
462 public UserTracker findByPrimaryKey(long userTrackerId)
463 throws NoSuchUserTrackerException, SystemException {
464 UserTracker userTracker = fetchByPrimaryKey(userTrackerId);
465
466 if (userTracker == null) {
467 if (_log.isWarnEnabled()) {
468 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userTrackerId);
469 }
470
471 throw new NoSuchUserTrackerException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
472 userTrackerId);
473 }
474
475 return userTracker;
476 }
477
478
485 @Override
486 public UserTracker fetchByPrimaryKey(Serializable primaryKey)
487 throws SystemException {
488 return fetchByPrimaryKey(((Long)primaryKey).longValue());
489 }
490
491
498 public UserTracker fetchByPrimaryKey(long userTrackerId)
499 throws SystemException {
500 UserTracker userTracker = (UserTracker)EntityCacheUtil.getResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
501 UserTrackerImpl.class, userTrackerId);
502
503 if (userTracker == _nullUserTracker) {
504 return null;
505 }
506
507 if (userTracker == null) {
508 Session session = null;
509
510 boolean hasException = false;
511
512 try {
513 session = openSession();
514
515 userTracker = (UserTracker)session.get(UserTrackerImpl.class,
516 Long.valueOf(userTrackerId));
517 }
518 catch (Exception e) {
519 hasException = true;
520
521 throw processException(e);
522 }
523 finally {
524 if (userTracker != null) {
525 cacheResult(userTracker);
526 }
527 else if (!hasException) {
528 EntityCacheUtil.putResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
529 UserTrackerImpl.class, userTrackerId, _nullUserTracker);
530 }
531
532 closeSession(session);
533 }
534 }
535
536 return userTracker;
537 }
538
539
546 public List<UserTracker> findByCompanyId(long companyId)
547 throws SystemException {
548 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
549 null);
550 }
551
552
565 public List<UserTracker> findByCompanyId(long companyId, int start, int end)
566 throws SystemException {
567 return findByCompanyId(companyId, start, end, null);
568 }
569
570
584 public List<UserTracker> findByCompanyId(long companyId, int start,
585 int end, OrderByComparator orderByComparator) throws SystemException {
586 FinderPath finderPath = null;
587 Object[] finderArgs = null;
588
589 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
590 (orderByComparator == null)) {
591 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
592 finderArgs = new Object[] { companyId };
593 }
594 else {
595 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
596 finderArgs = new Object[] { companyId, start, end, orderByComparator };
597 }
598
599 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(finderPath,
600 finderArgs, this);
601
602 if (list == null) {
603 StringBundler query = null;
604
605 if (orderByComparator != null) {
606 query = new StringBundler(3 +
607 (orderByComparator.getOrderByFields().length * 3));
608 }
609 else {
610 query = new StringBundler(2);
611 }
612
613 query.append(_SQL_SELECT_USERTRACKER_WHERE);
614
615 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
616
617 if (orderByComparator != null) {
618 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
619 orderByComparator);
620 }
621
622 String sql = query.toString();
623
624 Session session = null;
625
626 try {
627 session = openSession();
628
629 Query q = session.createQuery(sql);
630
631 QueryPos qPos = QueryPos.getInstance(q);
632
633 qPos.add(companyId);
634
635 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
636 start, end);
637 }
638 catch (Exception e) {
639 throw processException(e);
640 }
641 finally {
642 if (list == null) {
643 FinderCacheUtil.removeResult(finderPath, finderArgs);
644 }
645 else {
646 cacheResult(list);
647
648 FinderCacheUtil.putResult(finderPath, finderArgs, list);
649 }
650
651 closeSession(session);
652 }
653 }
654
655 return list;
656 }
657
658
671 public UserTracker findByCompanyId_First(long companyId,
672 OrderByComparator orderByComparator)
673 throws NoSuchUserTrackerException, SystemException {
674 List<UserTracker> list = findByCompanyId(companyId, 0, 1,
675 orderByComparator);
676
677 if (list.isEmpty()) {
678 StringBundler msg = new StringBundler(4);
679
680 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
681
682 msg.append("companyId=");
683 msg.append(companyId);
684
685 msg.append(StringPool.CLOSE_CURLY_BRACE);
686
687 throw new NoSuchUserTrackerException(msg.toString());
688 }
689 else {
690 return list.get(0);
691 }
692 }
693
694
707 public UserTracker findByCompanyId_Last(long companyId,
708 OrderByComparator orderByComparator)
709 throws NoSuchUserTrackerException, SystemException {
710 int count = countByCompanyId(companyId);
711
712 List<UserTracker> list = findByCompanyId(companyId, count - 1, count,
713 orderByComparator);
714
715 if (list.isEmpty()) {
716 StringBundler msg = new StringBundler(4);
717
718 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
719
720 msg.append("companyId=");
721 msg.append(companyId);
722
723 msg.append(StringPool.CLOSE_CURLY_BRACE);
724
725 throw new NoSuchUserTrackerException(msg.toString());
726 }
727 else {
728 return list.get(0);
729 }
730 }
731
732
746 public UserTracker[] findByCompanyId_PrevAndNext(long userTrackerId,
747 long companyId, OrderByComparator orderByComparator)
748 throws NoSuchUserTrackerException, SystemException {
749 UserTracker userTracker = findByPrimaryKey(userTrackerId);
750
751 Session session = null;
752
753 try {
754 session = openSession();
755
756 UserTracker[] array = new UserTrackerImpl[3];
757
758 array[0] = getByCompanyId_PrevAndNext(session, userTracker,
759 companyId, orderByComparator, true);
760
761 array[1] = userTracker;
762
763 array[2] = getByCompanyId_PrevAndNext(session, userTracker,
764 companyId, orderByComparator, false);
765
766 return array;
767 }
768 catch (Exception e) {
769 throw processException(e);
770 }
771 finally {
772 closeSession(session);
773 }
774 }
775
776 protected UserTracker getByCompanyId_PrevAndNext(Session session,
777 UserTracker userTracker, long companyId,
778 OrderByComparator orderByComparator, boolean previous) {
779 StringBundler query = null;
780
781 if (orderByComparator != null) {
782 query = new StringBundler(6 +
783 (orderByComparator.getOrderByFields().length * 6));
784 }
785 else {
786 query = new StringBundler(3);
787 }
788
789 query.append(_SQL_SELECT_USERTRACKER_WHERE);
790
791 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
792
793 if (orderByComparator != null) {
794 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
795
796 if (orderByConditionFields.length > 0) {
797 query.append(WHERE_AND);
798 }
799
800 for (int i = 0; i < orderByConditionFields.length; i++) {
801 query.append(_ORDER_BY_ENTITY_ALIAS);
802 query.append(orderByConditionFields[i]);
803
804 if ((i + 1) < orderByConditionFields.length) {
805 if (orderByComparator.isAscending() ^ previous) {
806 query.append(WHERE_GREATER_THAN_HAS_NEXT);
807 }
808 else {
809 query.append(WHERE_LESSER_THAN_HAS_NEXT);
810 }
811 }
812 else {
813 if (orderByComparator.isAscending() ^ previous) {
814 query.append(WHERE_GREATER_THAN);
815 }
816 else {
817 query.append(WHERE_LESSER_THAN);
818 }
819 }
820 }
821
822 query.append(ORDER_BY_CLAUSE);
823
824 String[] orderByFields = orderByComparator.getOrderByFields();
825
826 for (int i = 0; i < orderByFields.length; i++) {
827 query.append(_ORDER_BY_ENTITY_ALIAS);
828 query.append(orderByFields[i]);
829
830 if ((i + 1) < orderByFields.length) {
831 if (orderByComparator.isAscending() ^ previous) {
832 query.append(ORDER_BY_ASC_HAS_NEXT);
833 }
834 else {
835 query.append(ORDER_BY_DESC_HAS_NEXT);
836 }
837 }
838 else {
839 if (orderByComparator.isAscending() ^ previous) {
840 query.append(ORDER_BY_ASC);
841 }
842 else {
843 query.append(ORDER_BY_DESC);
844 }
845 }
846 }
847 }
848
849 String sql = query.toString();
850
851 Query q = session.createQuery(sql);
852
853 q.setFirstResult(0);
854 q.setMaxResults(2);
855
856 QueryPos qPos = QueryPos.getInstance(q);
857
858 qPos.add(companyId);
859
860 if (orderByComparator != null) {
861 Object[] values = orderByComparator.getOrderByConditionValues(userTracker);
862
863 for (Object value : values) {
864 qPos.add(value);
865 }
866 }
867
868 List<UserTracker> list = q.list();
869
870 if (list.size() == 2) {
871 return list.get(1);
872 }
873 else {
874 return null;
875 }
876 }
877
878
885 public List<UserTracker> findByUserId(long userId)
886 throws SystemException {
887 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
888 }
889
890
903 public List<UserTracker> findByUserId(long userId, int start, int end)
904 throws SystemException {
905 return findByUserId(userId, start, end, null);
906 }
907
908
922 public List<UserTracker> findByUserId(long userId, int start, int end,
923 OrderByComparator orderByComparator) throws SystemException {
924 FinderPath finderPath = null;
925 Object[] finderArgs = null;
926
927 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
928 (orderByComparator == null)) {
929 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
930 finderArgs = new Object[] { userId };
931 }
932 else {
933 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
934 finderArgs = new Object[] { userId, start, end, orderByComparator };
935 }
936
937 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(finderPath,
938 finderArgs, this);
939
940 if (list == null) {
941 StringBundler query = null;
942
943 if (orderByComparator != null) {
944 query = new StringBundler(3 +
945 (orderByComparator.getOrderByFields().length * 3));
946 }
947 else {
948 query = new StringBundler(2);
949 }
950
951 query.append(_SQL_SELECT_USERTRACKER_WHERE);
952
953 query.append(_FINDER_COLUMN_USERID_USERID_2);
954
955 if (orderByComparator != null) {
956 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
957 orderByComparator);
958 }
959
960 String sql = query.toString();
961
962 Session session = null;
963
964 try {
965 session = openSession();
966
967 Query q = session.createQuery(sql);
968
969 QueryPos qPos = QueryPos.getInstance(q);
970
971 qPos.add(userId);
972
973 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
974 start, end);
975 }
976 catch (Exception e) {
977 throw processException(e);
978 }
979 finally {
980 if (list == null) {
981 FinderCacheUtil.removeResult(finderPath, finderArgs);
982 }
983 else {
984 cacheResult(list);
985
986 FinderCacheUtil.putResult(finderPath, finderArgs, list);
987 }
988
989 closeSession(session);
990 }
991 }
992
993 return list;
994 }
995
996
1009 public UserTracker findByUserId_First(long userId,
1010 OrderByComparator orderByComparator)
1011 throws NoSuchUserTrackerException, SystemException {
1012 List<UserTracker> list = findByUserId(userId, 0, 1, orderByComparator);
1013
1014 if (list.isEmpty()) {
1015 StringBundler msg = new StringBundler(4);
1016
1017 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1018
1019 msg.append("userId=");
1020 msg.append(userId);
1021
1022 msg.append(StringPool.CLOSE_CURLY_BRACE);
1023
1024 throw new NoSuchUserTrackerException(msg.toString());
1025 }
1026 else {
1027 return list.get(0);
1028 }
1029 }
1030
1031
1044 public UserTracker findByUserId_Last(long userId,
1045 OrderByComparator orderByComparator)
1046 throws NoSuchUserTrackerException, SystemException {
1047 int count = countByUserId(userId);
1048
1049 List<UserTracker> list = findByUserId(userId, count - 1, count,
1050 orderByComparator);
1051
1052 if (list.isEmpty()) {
1053 StringBundler msg = new StringBundler(4);
1054
1055 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1056
1057 msg.append("userId=");
1058 msg.append(userId);
1059
1060 msg.append(StringPool.CLOSE_CURLY_BRACE);
1061
1062 throw new NoSuchUserTrackerException(msg.toString());
1063 }
1064 else {
1065 return list.get(0);
1066 }
1067 }
1068
1069
1083 public UserTracker[] findByUserId_PrevAndNext(long userTrackerId,
1084 long userId, OrderByComparator orderByComparator)
1085 throws NoSuchUserTrackerException, SystemException {
1086 UserTracker userTracker = findByPrimaryKey(userTrackerId);
1087
1088 Session session = null;
1089
1090 try {
1091 session = openSession();
1092
1093 UserTracker[] array = new UserTrackerImpl[3];
1094
1095 array[0] = getByUserId_PrevAndNext(session, userTracker, userId,
1096 orderByComparator, true);
1097
1098 array[1] = userTracker;
1099
1100 array[2] = getByUserId_PrevAndNext(session, userTracker, userId,
1101 orderByComparator, false);
1102
1103 return array;
1104 }
1105 catch (Exception e) {
1106 throw processException(e);
1107 }
1108 finally {
1109 closeSession(session);
1110 }
1111 }
1112
1113 protected UserTracker getByUserId_PrevAndNext(Session session,
1114 UserTracker userTracker, long userId,
1115 OrderByComparator orderByComparator, boolean previous) {
1116 StringBundler query = null;
1117
1118 if (orderByComparator != null) {
1119 query = new StringBundler(6 +
1120 (orderByComparator.getOrderByFields().length * 6));
1121 }
1122 else {
1123 query = new StringBundler(3);
1124 }
1125
1126 query.append(_SQL_SELECT_USERTRACKER_WHERE);
1127
1128 query.append(_FINDER_COLUMN_USERID_USERID_2);
1129
1130 if (orderByComparator != null) {
1131 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1132
1133 if (orderByConditionFields.length > 0) {
1134 query.append(WHERE_AND);
1135 }
1136
1137 for (int i = 0; i < orderByConditionFields.length; i++) {
1138 query.append(_ORDER_BY_ENTITY_ALIAS);
1139 query.append(orderByConditionFields[i]);
1140
1141 if ((i + 1) < orderByConditionFields.length) {
1142 if (orderByComparator.isAscending() ^ previous) {
1143 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1144 }
1145 else {
1146 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1147 }
1148 }
1149 else {
1150 if (orderByComparator.isAscending() ^ previous) {
1151 query.append(WHERE_GREATER_THAN);
1152 }
1153 else {
1154 query.append(WHERE_LESSER_THAN);
1155 }
1156 }
1157 }
1158
1159 query.append(ORDER_BY_CLAUSE);
1160
1161 String[] orderByFields = orderByComparator.getOrderByFields();
1162
1163 for (int i = 0; i < orderByFields.length; i++) {
1164 query.append(_ORDER_BY_ENTITY_ALIAS);
1165 query.append(orderByFields[i]);
1166
1167 if ((i + 1) < orderByFields.length) {
1168 if (orderByComparator.isAscending() ^ previous) {
1169 query.append(ORDER_BY_ASC_HAS_NEXT);
1170 }
1171 else {
1172 query.append(ORDER_BY_DESC_HAS_NEXT);
1173 }
1174 }
1175 else {
1176 if (orderByComparator.isAscending() ^ previous) {
1177 query.append(ORDER_BY_ASC);
1178 }
1179 else {
1180 query.append(ORDER_BY_DESC);
1181 }
1182 }
1183 }
1184 }
1185
1186 String sql = query.toString();
1187
1188 Query q = session.createQuery(sql);
1189
1190 q.setFirstResult(0);
1191 q.setMaxResults(2);
1192
1193 QueryPos qPos = QueryPos.getInstance(q);
1194
1195 qPos.add(userId);
1196
1197 if (orderByComparator != null) {
1198 Object[] values = orderByComparator.getOrderByConditionValues(userTracker);
1199
1200 for (Object value : values) {
1201 qPos.add(value);
1202 }
1203 }
1204
1205 List<UserTracker> list = q.list();
1206
1207 if (list.size() == 2) {
1208 return list.get(1);
1209 }
1210 else {
1211 return null;
1212 }
1213 }
1214
1215
1222 public List<UserTracker> findBySessionId(String sessionId)
1223 throws SystemException {
1224 return findBySessionId(sessionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1225 null);
1226 }
1227
1228
1241 public List<UserTracker> findBySessionId(String sessionId, int start,
1242 int end) throws SystemException {
1243 return findBySessionId(sessionId, start, end, null);
1244 }
1245
1246
1260 public List<UserTracker> findBySessionId(String sessionId, int start,
1261 int end, OrderByComparator orderByComparator) throws SystemException {
1262 FinderPath finderPath = null;
1263 Object[] finderArgs = null;
1264
1265 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1266 (orderByComparator == null)) {
1267 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SESSIONID;
1268 finderArgs = new Object[] { sessionId };
1269 }
1270 else {
1271 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SESSIONID;
1272 finderArgs = new Object[] { sessionId, start, end, orderByComparator };
1273 }
1274
1275 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(finderPath,
1276 finderArgs, this);
1277
1278 if (list == null) {
1279 StringBundler query = null;
1280
1281 if (orderByComparator != null) {
1282 query = new StringBundler(3 +
1283 (orderByComparator.getOrderByFields().length * 3));
1284 }
1285 else {
1286 query = new StringBundler(2);
1287 }
1288
1289 query.append(_SQL_SELECT_USERTRACKER_WHERE);
1290
1291 if (sessionId == null) {
1292 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_1);
1293 }
1294 else {
1295 if (sessionId.equals(StringPool.BLANK)) {
1296 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_3);
1297 }
1298 else {
1299 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_2);
1300 }
1301 }
1302
1303 if (orderByComparator != null) {
1304 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1305 orderByComparator);
1306 }
1307
1308 String sql = query.toString();
1309
1310 Session session = null;
1311
1312 try {
1313 session = openSession();
1314
1315 Query q = session.createQuery(sql);
1316
1317 QueryPos qPos = QueryPos.getInstance(q);
1318
1319 if (sessionId != null) {
1320 qPos.add(sessionId);
1321 }
1322
1323 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
1324 start, end);
1325 }
1326 catch (Exception e) {
1327 throw processException(e);
1328 }
1329 finally {
1330 if (list == null) {
1331 FinderCacheUtil.removeResult(finderPath, finderArgs);
1332 }
1333 else {
1334 cacheResult(list);
1335
1336 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1337 }
1338
1339 closeSession(session);
1340 }
1341 }
1342
1343 return list;
1344 }
1345
1346
1359 public UserTracker findBySessionId_First(String sessionId,
1360 OrderByComparator orderByComparator)
1361 throws NoSuchUserTrackerException, SystemException {
1362 List<UserTracker> list = findBySessionId(sessionId, 0, 1,
1363 orderByComparator);
1364
1365 if (list.isEmpty()) {
1366 StringBundler msg = new StringBundler(4);
1367
1368 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1369
1370 msg.append("sessionId=");
1371 msg.append(sessionId);
1372
1373 msg.append(StringPool.CLOSE_CURLY_BRACE);
1374
1375 throw new NoSuchUserTrackerException(msg.toString());
1376 }
1377 else {
1378 return list.get(0);
1379 }
1380 }
1381
1382
1395 public UserTracker findBySessionId_Last(String sessionId,
1396 OrderByComparator orderByComparator)
1397 throws NoSuchUserTrackerException, SystemException {
1398 int count = countBySessionId(sessionId);
1399
1400 List<UserTracker> list = findBySessionId(sessionId, count - 1, count,
1401 orderByComparator);
1402
1403 if (list.isEmpty()) {
1404 StringBundler msg = new StringBundler(4);
1405
1406 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1407
1408 msg.append("sessionId=");
1409 msg.append(sessionId);
1410
1411 msg.append(StringPool.CLOSE_CURLY_BRACE);
1412
1413 throw new NoSuchUserTrackerException(msg.toString());
1414 }
1415 else {
1416 return list.get(0);
1417 }
1418 }
1419
1420
1434 public UserTracker[] findBySessionId_PrevAndNext(long userTrackerId,
1435 String sessionId, OrderByComparator orderByComparator)
1436 throws NoSuchUserTrackerException, SystemException {
1437 UserTracker userTracker = findByPrimaryKey(userTrackerId);
1438
1439 Session session = null;
1440
1441 try {
1442 session = openSession();
1443
1444 UserTracker[] array = new UserTrackerImpl[3];
1445
1446 array[0] = getBySessionId_PrevAndNext(session, userTracker,
1447 sessionId, orderByComparator, true);
1448
1449 array[1] = userTracker;
1450
1451 array[2] = getBySessionId_PrevAndNext(session, userTracker,
1452 sessionId, orderByComparator, false);
1453
1454 return array;
1455 }
1456 catch (Exception e) {
1457 throw processException(e);
1458 }
1459 finally {
1460 closeSession(session);
1461 }
1462 }
1463
1464 protected UserTracker getBySessionId_PrevAndNext(Session session,
1465 UserTracker userTracker, String sessionId,
1466 OrderByComparator orderByComparator, boolean previous) {
1467 StringBundler query = null;
1468
1469 if (orderByComparator != null) {
1470 query = new StringBundler(6 +
1471 (orderByComparator.getOrderByFields().length * 6));
1472 }
1473 else {
1474 query = new StringBundler(3);
1475 }
1476
1477 query.append(_SQL_SELECT_USERTRACKER_WHERE);
1478
1479 if (sessionId == null) {
1480 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_1);
1481 }
1482 else {
1483 if (sessionId.equals(StringPool.BLANK)) {
1484 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_3);
1485 }
1486 else {
1487 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_2);
1488 }
1489 }
1490
1491 if (orderByComparator != null) {
1492 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1493
1494 if (orderByConditionFields.length > 0) {
1495 query.append(WHERE_AND);
1496 }
1497
1498 for (int i = 0; i < orderByConditionFields.length; i++) {
1499 query.append(_ORDER_BY_ENTITY_ALIAS);
1500 query.append(orderByConditionFields[i]);
1501
1502 if ((i + 1) < orderByConditionFields.length) {
1503 if (orderByComparator.isAscending() ^ previous) {
1504 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1505 }
1506 else {
1507 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1508 }
1509 }
1510 else {
1511 if (orderByComparator.isAscending() ^ previous) {
1512 query.append(WHERE_GREATER_THAN);
1513 }
1514 else {
1515 query.append(WHERE_LESSER_THAN);
1516 }
1517 }
1518 }
1519
1520 query.append(ORDER_BY_CLAUSE);
1521
1522 String[] orderByFields = orderByComparator.getOrderByFields();
1523
1524 for (int i = 0; i < orderByFields.length; i++) {
1525 query.append(_ORDER_BY_ENTITY_ALIAS);
1526 query.append(orderByFields[i]);
1527
1528 if ((i + 1) < orderByFields.length) {
1529 if (orderByComparator.isAscending() ^ previous) {
1530 query.append(ORDER_BY_ASC_HAS_NEXT);
1531 }
1532 else {
1533 query.append(ORDER_BY_DESC_HAS_NEXT);
1534 }
1535 }
1536 else {
1537 if (orderByComparator.isAscending() ^ previous) {
1538 query.append(ORDER_BY_ASC);
1539 }
1540 else {
1541 query.append(ORDER_BY_DESC);
1542 }
1543 }
1544 }
1545 }
1546
1547 String sql = query.toString();
1548
1549 Query q = session.createQuery(sql);
1550
1551 q.setFirstResult(0);
1552 q.setMaxResults(2);
1553
1554 QueryPos qPos = QueryPos.getInstance(q);
1555
1556 if (sessionId != null) {
1557 qPos.add(sessionId);
1558 }
1559
1560 if (orderByComparator != null) {
1561 Object[] values = orderByComparator.getOrderByConditionValues(userTracker);
1562
1563 for (Object value : values) {
1564 qPos.add(value);
1565 }
1566 }
1567
1568 List<UserTracker> list = q.list();
1569
1570 if (list.size() == 2) {
1571 return list.get(1);
1572 }
1573 else {
1574 return null;
1575 }
1576 }
1577
1578
1584 public List<UserTracker> findAll() throws SystemException {
1585 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1586 }
1587
1588
1600 public List<UserTracker> findAll(int start, int end)
1601 throws SystemException {
1602 return findAll(start, end, null);
1603 }
1604
1605
1618 public List<UserTracker> findAll(int start, int end,
1619 OrderByComparator orderByComparator) throws SystemException {
1620 FinderPath finderPath = null;
1621 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1622
1623 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1624 (orderByComparator == null)) {
1625 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1626 finderArgs = FINDER_ARGS_EMPTY;
1627 }
1628 else {
1629 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1630 finderArgs = new Object[] { start, end, orderByComparator };
1631 }
1632
1633 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(finderPath,
1634 finderArgs, this);
1635
1636 if (list == null) {
1637 StringBundler query = null;
1638 String sql = null;
1639
1640 if (orderByComparator != null) {
1641 query = new StringBundler(2 +
1642 (orderByComparator.getOrderByFields().length * 3));
1643
1644 query.append(_SQL_SELECT_USERTRACKER);
1645
1646 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1647 orderByComparator);
1648
1649 sql = query.toString();
1650 }
1651 else {
1652 sql = _SQL_SELECT_USERTRACKER;
1653 }
1654
1655 Session session = null;
1656
1657 try {
1658 session = openSession();
1659
1660 Query q = session.createQuery(sql);
1661
1662 if (orderByComparator == null) {
1663 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
1664 start, end, false);
1665
1666 Collections.sort(list);
1667 }
1668 else {
1669 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
1670 start, end);
1671 }
1672 }
1673 catch (Exception e) {
1674 throw processException(e);
1675 }
1676 finally {
1677 if (list == null) {
1678 FinderCacheUtil.removeResult(finderPath, finderArgs);
1679 }
1680 else {
1681 cacheResult(list);
1682
1683 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1684 }
1685
1686 closeSession(session);
1687 }
1688 }
1689
1690 return list;
1691 }
1692
1693
1699 public void removeByCompanyId(long companyId) throws SystemException {
1700 for (UserTracker userTracker : findByCompanyId(companyId)) {
1701 userTrackerPersistence.remove(userTracker);
1702 }
1703 }
1704
1705
1711 public void removeByUserId(long userId) throws SystemException {
1712 for (UserTracker userTracker : findByUserId(userId)) {
1713 userTrackerPersistence.remove(userTracker);
1714 }
1715 }
1716
1717
1723 public void removeBySessionId(String sessionId) throws SystemException {
1724 for (UserTracker userTracker : findBySessionId(sessionId)) {
1725 userTrackerPersistence.remove(userTracker);
1726 }
1727 }
1728
1729
1734 public void removeAll() throws SystemException {
1735 for (UserTracker userTracker : findAll()) {
1736 userTrackerPersistence.remove(userTracker);
1737 }
1738 }
1739
1740
1747 public int countByCompanyId(long companyId) throws SystemException {
1748 Object[] finderArgs = new Object[] { companyId };
1749
1750 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1751 finderArgs, this);
1752
1753 if (count == null) {
1754 StringBundler query = new StringBundler(2);
1755
1756 query.append(_SQL_COUNT_USERTRACKER_WHERE);
1757
1758 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1759
1760 String sql = query.toString();
1761
1762 Session session = null;
1763
1764 try {
1765 session = openSession();
1766
1767 Query q = session.createQuery(sql);
1768
1769 QueryPos qPos = QueryPos.getInstance(q);
1770
1771 qPos.add(companyId);
1772
1773 count = (Long)q.uniqueResult();
1774 }
1775 catch (Exception e) {
1776 throw processException(e);
1777 }
1778 finally {
1779 if (count == null) {
1780 count = Long.valueOf(0);
1781 }
1782
1783 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1784 finderArgs, count);
1785
1786 closeSession(session);
1787 }
1788 }
1789
1790 return count.intValue();
1791 }
1792
1793
1800 public int countByUserId(long userId) throws SystemException {
1801 Object[] finderArgs = new Object[] { userId };
1802
1803 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1804 finderArgs, this);
1805
1806 if (count == null) {
1807 StringBundler query = new StringBundler(2);
1808
1809 query.append(_SQL_COUNT_USERTRACKER_WHERE);
1810
1811 query.append(_FINDER_COLUMN_USERID_USERID_2);
1812
1813 String sql = query.toString();
1814
1815 Session session = null;
1816
1817 try {
1818 session = openSession();
1819
1820 Query q = session.createQuery(sql);
1821
1822 QueryPos qPos = QueryPos.getInstance(q);
1823
1824 qPos.add(userId);
1825
1826 count = (Long)q.uniqueResult();
1827 }
1828 catch (Exception e) {
1829 throw processException(e);
1830 }
1831 finally {
1832 if (count == null) {
1833 count = Long.valueOf(0);
1834 }
1835
1836 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1837 finderArgs, count);
1838
1839 closeSession(session);
1840 }
1841 }
1842
1843 return count.intValue();
1844 }
1845
1846
1853 public int countBySessionId(String sessionId) throws SystemException {
1854 Object[] finderArgs = new Object[] { sessionId };
1855
1856 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SESSIONID,
1857 finderArgs, this);
1858
1859 if (count == null) {
1860 StringBundler query = new StringBundler(2);
1861
1862 query.append(_SQL_COUNT_USERTRACKER_WHERE);
1863
1864 if (sessionId == null) {
1865 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_1);
1866 }
1867 else {
1868 if (sessionId.equals(StringPool.BLANK)) {
1869 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_3);
1870 }
1871 else {
1872 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_2);
1873 }
1874 }
1875
1876 String sql = query.toString();
1877
1878 Session session = null;
1879
1880 try {
1881 session = openSession();
1882
1883 Query q = session.createQuery(sql);
1884
1885 QueryPos qPos = QueryPos.getInstance(q);
1886
1887 if (sessionId != null) {
1888 qPos.add(sessionId);
1889 }
1890
1891 count = (Long)q.uniqueResult();
1892 }
1893 catch (Exception e) {
1894 throw processException(e);
1895 }
1896 finally {
1897 if (count == null) {
1898 count = Long.valueOf(0);
1899 }
1900
1901 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SESSIONID,
1902 finderArgs, count);
1903
1904 closeSession(session);
1905 }
1906 }
1907
1908 return count.intValue();
1909 }
1910
1911
1917 public int countAll() throws SystemException {
1918 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1919 FINDER_ARGS_EMPTY, this);
1920
1921 if (count == null) {
1922 Session session = null;
1923
1924 try {
1925 session = openSession();
1926
1927 Query q = session.createQuery(_SQL_COUNT_USERTRACKER);
1928
1929 count = (Long)q.uniqueResult();
1930 }
1931 catch (Exception e) {
1932 throw processException(e);
1933 }
1934 finally {
1935 if (count == null) {
1936 count = Long.valueOf(0);
1937 }
1938
1939 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1940 FINDER_ARGS_EMPTY, count);
1941
1942 closeSession(session);
1943 }
1944 }
1945
1946 return count.intValue();
1947 }
1948
1949
1952 public void afterPropertiesSet() {
1953 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1954 com.liferay.portal.util.PropsUtil.get(
1955 "value.object.listener.com.liferay.portal.model.UserTracker")));
1956
1957 if (listenerClassNames.length > 0) {
1958 try {
1959 List<ModelListener<UserTracker>> listenersList = new ArrayList<ModelListener<UserTracker>>();
1960
1961 for (String listenerClassName : listenerClassNames) {
1962 listenersList.add((ModelListener<UserTracker>)InstanceFactory.newInstance(
1963 listenerClassName));
1964 }
1965
1966 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1967 }
1968 catch (Exception e) {
1969 _log.error(e);
1970 }
1971 }
1972 }
1973
1974 public void destroy() {
1975 EntityCacheUtil.removeCache(UserTrackerImpl.class.getName());
1976 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1977 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1978 }
1979
1980 @BeanReference(type = AccountPersistence.class)
1981 protected AccountPersistence accountPersistence;
1982 @BeanReference(type = AddressPersistence.class)
1983 protected AddressPersistence addressPersistence;
1984 @BeanReference(type = BrowserTrackerPersistence.class)
1985 protected BrowserTrackerPersistence browserTrackerPersistence;
1986 @BeanReference(type = ClassNamePersistence.class)
1987 protected ClassNamePersistence classNamePersistence;
1988 @BeanReference(type = ClusterGroupPersistence.class)
1989 protected ClusterGroupPersistence clusterGroupPersistence;
1990 @BeanReference(type = CompanyPersistence.class)
1991 protected CompanyPersistence companyPersistence;
1992 @BeanReference(type = ContactPersistence.class)
1993 protected ContactPersistence contactPersistence;
1994 @BeanReference(type = CountryPersistence.class)
1995 protected CountryPersistence countryPersistence;
1996 @BeanReference(type = EmailAddressPersistence.class)
1997 protected EmailAddressPersistence emailAddressPersistence;
1998 @BeanReference(type = GroupPersistence.class)
1999 protected GroupPersistence groupPersistence;
2000 @BeanReference(type = ImagePersistence.class)
2001 protected ImagePersistence imagePersistence;
2002 @BeanReference(type = LayoutPersistence.class)
2003 protected LayoutPersistence layoutPersistence;
2004 @BeanReference(type = LayoutBranchPersistence.class)
2005 protected LayoutBranchPersistence layoutBranchPersistence;
2006 @BeanReference(type = LayoutPrototypePersistence.class)
2007 protected LayoutPrototypePersistence layoutPrototypePersistence;
2008 @BeanReference(type = LayoutRevisionPersistence.class)
2009 protected LayoutRevisionPersistence layoutRevisionPersistence;
2010 @BeanReference(type = LayoutSetPersistence.class)
2011 protected LayoutSetPersistence layoutSetPersistence;
2012 @BeanReference(type = LayoutSetBranchPersistence.class)
2013 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2014 @BeanReference(type = LayoutSetPrototypePersistence.class)
2015 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2016 @BeanReference(type = ListTypePersistence.class)
2017 protected ListTypePersistence listTypePersistence;
2018 @BeanReference(type = LockPersistence.class)
2019 protected LockPersistence lockPersistence;
2020 @BeanReference(type = MembershipRequestPersistence.class)
2021 protected MembershipRequestPersistence membershipRequestPersistence;
2022 @BeanReference(type = OrganizationPersistence.class)
2023 protected OrganizationPersistence organizationPersistence;
2024 @BeanReference(type = OrgGroupPermissionPersistence.class)
2025 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2026 @BeanReference(type = OrgGroupRolePersistence.class)
2027 protected OrgGroupRolePersistence orgGroupRolePersistence;
2028 @BeanReference(type = OrgLaborPersistence.class)
2029 protected OrgLaborPersistence orgLaborPersistence;
2030 @BeanReference(type = PasswordPolicyPersistence.class)
2031 protected PasswordPolicyPersistence passwordPolicyPersistence;
2032 @BeanReference(type = PasswordPolicyRelPersistence.class)
2033 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2034 @BeanReference(type = PasswordTrackerPersistence.class)
2035 protected PasswordTrackerPersistence passwordTrackerPersistence;
2036 @BeanReference(type = PermissionPersistence.class)
2037 protected PermissionPersistence permissionPersistence;
2038 @BeanReference(type = PhonePersistence.class)
2039 protected PhonePersistence phonePersistence;
2040 @BeanReference(type = PluginSettingPersistence.class)
2041 protected PluginSettingPersistence pluginSettingPersistence;
2042 @BeanReference(type = PortalPreferencesPersistence.class)
2043 protected PortalPreferencesPersistence portalPreferencesPersistence;
2044 @BeanReference(type = PortletPersistence.class)
2045 protected PortletPersistence portletPersistence;
2046 @BeanReference(type = PortletItemPersistence.class)
2047 protected PortletItemPersistence portletItemPersistence;
2048 @BeanReference(type = PortletPreferencesPersistence.class)
2049 protected PortletPreferencesPersistence portletPreferencesPersistence;
2050 @BeanReference(type = RegionPersistence.class)
2051 protected RegionPersistence regionPersistence;
2052 @BeanReference(type = ReleasePersistence.class)
2053 protected ReleasePersistence releasePersistence;
2054 @BeanReference(type = RepositoryPersistence.class)
2055 protected RepositoryPersistence repositoryPersistence;
2056 @BeanReference(type = RepositoryEntryPersistence.class)
2057 protected RepositoryEntryPersistence repositoryEntryPersistence;
2058 @BeanReference(type = ResourcePersistence.class)
2059 protected ResourcePersistence resourcePersistence;
2060 @BeanReference(type = ResourceActionPersistence.class)
2061 protected ResourceActionPersistence resourceActionPersistence;
2062 @BeanReference(type = ResourceBlockPersistence.class)
2063 protected ResourceBlockPersistence resourceBlockPersistence;
2064 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2065 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2066 @BeanReference(type = ResourceCodePersistence.class)
2067 protected ResourceCodePersistence resourceCodePersistence;
2068 @BeanReference(type = ResourcePermissionPersistence.class)
2069 protected ResourcePermissionPersistence resourcePermissionPersistence;
2070 @BeanReference(type = ResourceTypePermissionPersistence.class)
2071 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2072 @BeanReference(type = RolePersistence.class)
2073 protected RolePersistence rolePersistence;
2074 @BeanReference(type = ServiceComponentPersistence.class)
2075 protected ServiceComponentPersistence serviceComponentPersistence;
2076 @BeanReference(type = ShardPersistence.class)
2077 protected ShardPersistence shardPersistence;
2078 @BeanReference(type = SubscriptionPersistence.class)
2079 protected SubscriptionPersistence subscriptionPersistence;
2080 @BeanReference(type = TeamPersistence.class)
2081 protected TeamPersistence teamPersistence;
2082 @BeanReference(type = TicketPersistence.class)
2083 protected TicketPersistence ticketPersistence;
2084 @BeanReference(type = UserPersistence.class)
2085 protected UserPersistence userPersistence;
2086 @BeanReference(type = UserGroupPersistence.class)
2087 protected UserGroupPersistence userGroupPersistence;
2088 @BeanReference(type = UserGroupGroupRolePersistence.class)
2089 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2090 @BeanReference(type = UserGroupRolePersistence.class)
2091 protected UserGroupRolePersistence userGroupRolePersistence;
2092 @BeanReference(type = UserIdMapperPersistence.class)
2093 protected UserIdMapperPersistence userIdMapperPersistence;
2094 @BeanReference(type = UserNotificationEventPersistence.class)
2095 protected UserNotificationEventPersistence userNotificationEventPersistence;
2096 @BeanReference(type = UserTrackerPersistence.class)
2097 protected UserTrackerPersistence userTrackerPersistence;
2098 @BeanReference(type = UserTrackerPathPersistence.class)
2099 protected UserTrackerPathPersistence userTrackerPathPersistence;
2100 @BeanReference(type = VirtualHostPersistence.class)
2101 protected VirtualHostPersistence virtualHostPersistence;
2102 @BeanReference(type = WebDAVPropsPersistence.class)
2103 protected WebDAVPropsPersistence webDAVPropsPersistence;
2104 @BeanReference(type = WebsitePersistence.class)
2105 protected WebsitePersistence websitePersistence;
2106 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2107 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2108 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2109 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2110 private static final String _SQL_SELECT_USERTRACKER = "SELECT userTracker FROM UserTracker userTracker";
2111 private static final String _SQL_SELECT_USERTRACKER_WHERE = "SELECT userTracker FROM UserTracker userTracker WHERE ";
2112 private static final String _SQL_COUNT_USERTRACKER = "SELECT COUNT(userTracker) FROM UserTracker userTracker";
2113 private static final String _SQL_COUNT_USERTRACKER_WHERE = "SELECT COUNT(userTracker) FROM UserTracker userTracker WHERE ";
2114 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "userTracker.companyId = ?";
2115 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userTracker.userId = ?";
2116 private static final String _FINDER_COLUMN_SESSIONID_SESSIONID_1 = "userTracker.sessionId IS NULL";
2117 private static final String _FINDER_COLUMN_SESSIONID_SESSIONID_2 = "userTracker.sessionId = ?";
2118 private static final String _FINDER_COLUMN_SESSIONID_SESSIONID_3 = "(userTracker.sessionId IS NULL OR userTracker.sessionId = ?)";
2119 private static final String _ORDER_BY_ENTITY_ALIAS = "userTracker.";
2120 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTracker exists with the primary key ";
2121 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTracker exists with the key {";
2122 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2123 private static Log _log = LogFactoryUtil.getLog(UserTrackerPersistenceImpl.class);
2124 private static UserTracker _nullUserTracker = new UserTrackerImpl() {
2125 @Override
2126 public Object clone() {
2127 return this;
2128 }
2129
2130 @Override
2131 public CacheModel<UserTracker> toCacheModel() {
2132 return _nullUserTrackerCacheModel;
2133 }
2134 };
2135
2136 private static CacheModel<UserTracker> _nullUserTrackerCacheModel = new CacheModel<UserTracker>() {
2137 public UserTracker toEntityModel() {
2138 return _nullUserTracker;
2139 }
2140 };
2141 }