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 @Override
210 public void clearCache(List<UserTracker> userTrackers) {
211 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
212 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
213
214 for (UserTracker userTracker : userTrackers) {
215 EntityCacheUtil.removeResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
216 UserTrackerImpl.class, userTracker.getPrimaryKey());
217 }
218 }
219
220
226 public UserTracker create(long userTrackerId) {
227 UserTracker userTracker = new UserTrackerImpl();
228
229 userTracker.setNew(true);
230 userTracker.setPrimaryKey(userTrackerId);
231
232 return userTracker;
233 }
234
235
243 public UserTracker remove(long userTrackerId)
244 throws NoSuchUserTrackerException, SystemException {
245 return remove(Long.valueOf(userTrackerId));
246 }
247
248
256 @Override
257 public UserTracker remove(Serializable primaryKey)
258 throws NoSuchUserTrackerException, SystemException {
259 Session session = null;
260
261 try {
262 session = openSession();
263
264 UserTracker userTracker = (UserTracker)session.get(UserTrackerImpl.class,
265 primaryKey);
266
267 if (userTracker == null) {
268 if (_log.isWarnEnabled()) {
269 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
270 }
271
272 throw new NoSuchUserTrackerException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
273 primaryKey);
274 }
275
276 return remove(userTracker);
277 }
278 catch (NoSuchUserTrackerException nsee) {
279 throw nsee;
280 }
281 catch (Exception e) {
282 throw processException(e);
283 }
284 finally {
285 closeSession(session);
286 }
287 }
288
289 @Override
290 protected UserTracker removeImpl(UserTracker userTracker)
291 throws SystemException {
292 userTracker = toUnwrappedModel(userTracker);
293
294 Session session = null;
295
296 try {
297 session = openSession();
298
299 BatchSessionUtil.delete(session, userTracker);
300 }
301 catch (Exception e) {
302 throw processException(e);
303 }
304 finally {
305 closeSession(session);
306 }
307
308 clearCache(userTracker);
309
310 return userTracker;
311 }
312
313 @Override
314 public UserTracker updateImpl(
315 com.liferay.portal.model.UserTracker userTracker, boolean merge)
316 throws SystemException {
317 userTracker = toUnwrappedModel(userTracker);
318
319 boolean isNew = userTracker.isNew();
320
321 UserTrackerModelImpl userTrackerModelImpl = (UserTrackerModelImpl)userTracker;
322
323 Session session = null;
324
325 try {
326 session = openSession();
327
328 BatchSessionUtil.update(session, userTracker, merge);
329
330 userTracker.setNew(false);
331 }
332 catch (Exception e) {
333 throw processException(e);
334 }
335 finally {
336 closeSession(session);
337 }
338
339 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
340
341 if (isNew || !UserTrackerModelImpl.COLUMN_BITMASK_ENABLED) {
342 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
343 }
344
345 else {
346 if ((userTrackerModelImpl.getColumnBitmask() &
347 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
348 Object[] args = new Object[] {
349 Long.valueOf(userTrackerModelImpl.getOriginalCompanyId())
350 };
351
352 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
353 args);
354 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
355 args);
356
357 args = new Object[] {
358 Long.valueOf(userTrackerModelImpl.getCompanyId())
359 };
360
361 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
362 args);
363 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
364 args);
365 }
366
367 if ((userTrackerModelImpl.getColumnBitmask() &
368 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
369 Object[] args = new Object[] {
370 Long.valueOf(userTrackerModelImpl.getOriginalUserId())
371 };
372
373 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
374 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
375 args);
376
377 args = new Object[] {
378 Long.valueOf(userTrackerModelImpl.getUserId())
379 };
380
381 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
382 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
383 args);
384 }
385
386 if ((userTrackerModelImpl.getColumnBitmask() &
387 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SESSIONID.getColumnBitmask()) != 0) {
388 Object[] args = new Object[] {
389 userTrackerModelImpl.getOriginalSessionId()
390 };
391
392 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SESSIONID,
393 args);
394 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SESSIONID,
395 args);
396
397 args = new Object[] { userTrackerModelImpl.getSessionId() };
398
399 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SESSIONID,
400 args);
401 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SESSIONID,
402 args);
403 }
404 }
405
406 EntityCacheUtil.putResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
407 UserTrackerImpl.class, userTracker.getPrimaryKey(), userTracker);
408
409 return userTracker;
410 }
411
412 protected UserTracker toUnwrappedModel(UserTracker userTracker) {
413 if (userTracker instanceof UserTrackerImpl) {
414 return userTracker;
415 }
416
417 UserTrackerImpl userTrackerImpl = new UserTrackerImpl();
418
419 userTrackerImpl.setNew(userTracker.isNew());
420 userTrackerImpl.setPrimaryKey(userTracker.getPrimaryKey());
421
422 userTrackerImpl.setUserTrackerId(userTracker.getUserTrackerId());
423 userTrackerImpl.setCompanyId(userTracker.getCompanyId());
424 userTrackerImpl.setUserId(userTracker.getUserId());
425 userTrackerImpl.setModifiedDate(userTracker.getModifiedDate());
426 userTrackerImpl.setSessionId(userTracker.getSessionId());
427 userTrackerImpl.setRemoteAddr(userTracker.getRemoteAddr());
428 userTrackerImpl.setRemoteHost(userTracker.getRemoteHost());
429 userTrackerImpl.setUserAgent(userTracker.getUserAgent());
430
431 return userTrackerImpl;
432 }
433
434
442 @Override
443 public UserTracker findByPrimaryKey(Serializable primaryKey)
444 throws NoSuchModelException, SystemException {
445 return findByPrimaryKey(((Long)primaryKey).longValue());
446 }
447
448
456 public UserTracker findByPrimaryKey(long userTrackerId)
457 throws NoSuchUserTrackerException, SystemException {
458 UserTracker userTracker = fetchByPrimaryKey(userTrackerId);
459
460 if (userTracker == null) {
461 if (_log.isWarnEnabled()) {
462 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userTrackerId);
463 }
464
465 throw new NoSuchUserTrackerException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
466 userTrackerId);
467 }
468
469 return userTracker;
470 }
471
472
479 @Override
480 public UserTracker fetchByPrimaryKey(Serializable primaryKey)
481 throws SystemException {
482 return fetchByPrimaryKey(((Long)primaryKey).longValue());
483 }
484
485
492 public UserTracker fetchByPrimaryKey(long userTrackerId)
493 throws SystemException {
494 UserTracker userTracker = (UserTracker)EntityCacheUtil.getResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
495 UserTrackerImpl.class, userTrackerId);
496
497 if (userTracker == _nullUserTracker) {
498 return null;
499 }
500
501 if (userTracker == null) {
502 Session session = null;
503
504 boolean hasException = false;
505
506 try {
507 session = openSession();
508
509 userTracker = (UserTracker)session.get(UserTrackerImpl.class,
510 Long.valueOf(userTrackerId));
511 }
512 catch (Exception e) {
513 hasException = true;
514
515 throw processException(e);
516 }
517 finally {
518 if (userTracker != null) {
519 cacheResult(userTracker);
520 }
521 else if (!hasException) {
522 EntityCacheUtil.putResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
523 UserTrackerImpl.class, userTrackerId, _nullUserTracker);
524 }
525
526 closeSession(session);
527 }
528 }
529
530 return userTracker;
531 }
532
533
540 public List<UserTracker> findByCompanyId(long companyId)
541 throws SystemException {
542 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
543 null);
544 }
545
546
559 public List<UserTracker> findByCompanyId(long companyId, int start, int end)
560 throws SystemException {
561 return findByCompanyId(companyId, start, end, null);
562 }
563
564
578 public List<UserTracker> findByCompanyId(long companyId, int start,
579 int end, OrderByComparator orderByComparator) throws SystemException {
580 FinderPath finderPath = null;
581 Object[] finderArgs = null;
582
583 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
584 (orderByComparator == null)) {
585 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
586 finderArgs = new Object[] { companyId };
587 }
588 else {
589 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
590 finderArgs = new Object[] { companyId, start, end, orderByComparator };
591 }
592
593 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(finderPath,
594 finderArgs, this);
595
596 if (list == null) {
597 StringBundler query = null;
598
599 if (orderByComparator != null) {
600 query = new StringBundler(3 +
601 (orderByComparator.getOrderByFields().length * 3));
602 }
603 else {
604 query = new StringBundler(2);
605 }
606
607 query.append(_SQL_SELECT_USERTRACKER_WHERE);
608
609 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
610
611 if (orderByComparator != null) {
612 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
613 orderByComparator);
614 }
615
616 String sql = query.toString();
617
618 Session session = null;
619
620 try {
621 session = openSession();
622
623 Query q = session.createQuery(sql);
624
625 QueryPos qPos = QueryPos.getInstance(q);
626
627 qPos.add(companyId);
628
629 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
630 start, end);
631 }
632 catch (Exception e) {
633 throw processException(e);
634 }
635 finally {
636 if (list == null) {
637 FinderCacheUtil.removeResult(finderPath, finderArgs);
638 }
639 else {
640 cacheResult(list);
641
642 FinderCacheUtil.putResult(finderPath, finderArgs, list);
643 }
644
645 closeSession(session);
646 }
647 }
648
649 return list;
650 }
651
652
665 public UserTracker findByCompanyId_First(long companyId,
666 OrderByComparator orderByComparator)
667 throws NoSuchUserTrackerException, SystemException {
668 List<UserTracker> list = findByCompanyId(companyId, 0, 1,
669 orderByComparator);
670
671 if (list.isEmpty()) {
672 StringBundler msg = new StringBundler(4);
673
674 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
675
676 msg.append("companyId=");
677 msg.append(companyId);
678
679 msg.append(StringPool.CLOSE_CURLY_BRACE);
680
681 throw new NoSuchUserTrackerException(msg.toString());
682 }
683 else {
684 return list.get(0);
685 }
686 }
687
688
701 public UserTracker findByCompanyId_Last(long companyId,
702 OrderByComparator orderByComparator)
703 throws NoSuchUserTrackerException, SystemException {
704 int count = countByCompanyId(companyId);
705
706 List<UserTracker> list = findByCompanyId(companyId, count - 1, count,
707 orderByComparator);
708
709 if (list.isEmpty()) {
710 StringBundler msg = new StringBundler(4);
711
712 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
713
714 msg.append("companyId=");
715 msg.append(companyId);
716
717 msg.append(StringPool.CLOSE_CURLY_BRACE);
718
719 throw new NoSuchUserTrackerException(msg.toString());
720 }
721 else {
722 return list.get(0);
723 }
724 }
725
726
740 public UserTracker[] findByCompanyId_PrevAndNext(long userTrackerId,
741 long companyId, OrderByComparator orderByComparator)
742 throws NoSuchUserTrackerException, SystemException {
743 UserTracker userTracker = findByPrimaryKey(userTrackerId);
744
745 Session session = null;
746
747 try {
748 session = openSession();
749
750 UserTracker[] array = new UserTrackerImpl[3];
751
752 array[0] = getByCompanyId_PrevAndNext(session, userTracker,
753 companyId, orderByComparator, true);
754
755 array[1] = userTracker;
756
757 array[2] = getByCompanyId_PrevAndNext(session, userTracker,
758 companyId, orderByComparator, false);
759
760 return array;
761 }
762 catch (Exception e) {
763 throw processException(e);
764 }
765 finally {
766 closeSession(session);
767 }
768 }
769
770 protected UserTracker getByCompanyId_PrevAndNext(Session session,
771 UserTracker userTracker, long companyId,
772 OrderByComparator orderByComparator, boolean previous) {
773 StringBundler query = null;
774
775 if (orderByComparator != null) {
776 query = new StringBundler(6 +
777 (orderByComparator.getOrderByFields().length * 6));
778 }
779 else {
780 query = new StringBundler(3);
781 }
782
783 query.append(_SQL_SELECT_USERTRACKER_WHERE);
784
785 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
786
787 if (orderByComparator != null) {
788 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
789
790 if (orderByConditionFields.length > 0) {
791 query.append(WHERE_AND);
792 }
793
794 for (int i = 0; i < orderByConditionFields.length; i++) {
795 query.append(_ORDER_BY_ENTITY_ALIAS);
796 query.append(orderByConditionFields[i]);
797
798 if ((i + 1) < orderByConditionFields.length) {
799 if (orderByComparator.isAscending() ^ previous) {
800 query.append(WHERE_GREATER_THAN_HAS_NEXT);
801 }
802 else {
803 query.append(WHERE_LESSER_THAN_HAS_NEXT);
804 }
805 }
806 else {
807 if (orderByComparator.isAscending() ^ previous) {
808 query.append(WHERE_GREATER_THAN);
809 }
810 else {
811 query.append(WHERE_LESSER_THAN);
812 }
813 }
814 }
815
816 query.append(ORDER_BY_CLAUSE);
817
818 String[] orderByFields = orderByComparator.getOrderByFields();
819
820 for (int i = 0; i < orderByFields.length; i++) {
821 query.append(_ORDER_BY_ENTITY_ALIAS);
822 query.append(orderByFields[i]);
823
824 if ((i + 1) < orderByFields.length) {
825 if (orderByComparator.isAscending() ^ previous) {
826 query.append(ORDER_BY_ASC_HAS_NEXT);
827 }
828 else {
829 query.append(ORDER_BY_DESC_HAS_NEXT);
830 }
831 }
832 else {
833 if (orderByComparator.isAscending() ^ previous) {
834 query.append(ORDER_BY_ASC);
835 }
836 else {
837 query.append(ORDER_BY_DESC);
838 }
839 }
840 }
841 }
842
843 String sql = query.toString();
844
845 Query q = session.createQuery(sql);
846
847 q.setFirstResult(0);
848 q.setMaxResults(2);
849
850 QueryPos qPos = QueryPos.getInstance(q);
851
852 qPos.add(companyId);
853
854 if (orderByComparator != null) {
855 Object[] values = orderByComparator.getOrderByConditionValues(userTracker);
856
857 for (Object value : values) {
858 qPos.add(value);
859 }
860 }
861
862 List<UserTracker> list = q.list();
863
864 if (list.size() == 2) {
865 return list.get(1);
866 }
867 else {
868 return null;
869 }
870 }
871
872
879 public List<UserTracker> findByUserId(long userId)
880 throws SystemException {
881 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
882 }
883
884
897 public List<UserTracker> findByUserId(long userId, int start, int end)
898 throws SystemException {
899 return findByUserId(userId, start, end, null);
900 }
901
902
916 public List<UserTracker> findByUserId(long userId, int start, int end,
917 OrderByComparator orderByComparator) throws SystemException {
918 FinderPath finderPath = null;
919 Object[] finderArgs = null;
920
921 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
922 (orderByComparator == null)) {
923 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
924 finderArgs = new Object[] { userId };
925 }
926 else {
927 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
928 finderArgs = new Object[] { userId, start, end, orderByComparator };
929 }
930
931 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(finderPath,
932 finderArgs, this);
933
934 if (list == null) {
935 StringBundler query = null;
936
937 if (orderByComparator != null) {
938 query = new StringBundler(3 +
939 (orderByComparator.getOrderByFields().length * 3));
940 }
941 else {
942 query = new StringBundler(2);
943 }
944
945 query.append(_SQL_SELECT_USERTRACKER_WHERE);
946
947 query.append(_FINDER_COLUMN_USERID_USERID_2);
948
949 if (orderByComparator != null) {
950 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
951 orderByComparator);
952 }
953
954 String sql = query.toString();
955
956 Session session = null;
957
958 try {
959 session = openSession();
960
961 Query q = session.createQuery(sql);
962
963 QueryPos qPos = QueryPos.getInstance(q);
964
965 qPos.add(userId);
966
967 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
968 start, end);
969 }
970 catch (Exception e) {
971 throw processException(e);
972 }
973 finally {
974 if (list == null) {
975 FinderCacheUtil.removeResult(finderPath, finderArgs);
976 }
977 else {
978 cacheResult(list);
979
980 FinderCacheUtil.putResult(finderPath, finderArgs, list);
981 }
982
983 closeSession(session);
984 }
985 }
986
987 return list;
988 }
989
990
1003 public UserTracker findByUserId_First(long userId,
1004 OrderByComparator orderByComparator)
1005 throws NoSuchUserTrackerException, SystemException {
1006 List<UserTracker> list = findByUserId(userId, 0, 1, orderByComparator);
1007
1008 if (list.isEmpty()) {
1009 StringBundler msg = new StringBundler(4);
1010
1011 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1012
1013 msg.append("userId=");
1014 msg.append(userId);
1015
1016 msg.append(StringPool.CLOSE_CURLY_BRACE);
1017
1018 throw new NoSuchUserTrackerException(msg.toString());
1019 }
1020 else {
1021 return list.get(0);
1022 }
1023 }
1024
1025
1038 public UserTracker findByUserId_Last(long userId,
1039 OrderByComparator orderByComparator)
1040 throws NoSuchUserTrackerException, SystemException {
1041 int count = countByUserId(userId);
1042
1043 List<UserTracker> list = findByUserId(userId, count - 1, count,
1044 orderByComparator);
1045
1046 if (list.isEmpty()) {
1047 StringBundler msg = new StringBundler(4);
1048
1049 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1050
1051 msg.append("userId=");
1052 msg.append(userId);
1053
1054 msg.append(StringPool.CLOSE_CURLY_BRACE);
1055
1056 throw new NoSuchUserTrackerException(msg.toString());
1057 }
1058 else {
1059 return list.get(0);
1060 }
1061 }
1062
1063
1077 public UserTracker[] findByUserId_PrevAndNext(long userTrackerId,
1078 long userId, OrderByComparator orderByComparator)
1079 throws NoSuchUserTrackerException, SystemException {
1080 UserTracker userTracker = findByPrimaryKey(userTrackerId);
1081
1082 Session session = null;
1083
1084 try {
1085 session = openSession();
1086
1087 UserTracker[] array = new UserTrackerImpl[3];
1088
1089 array[0] = getByUserId_PrevAndNext(session, userTracker, userId,
1090 orderByComparator, true);
1091
1092 array[1] = userTracker;
1093
1094 array[2] = getByUserId_PrevAndNext(session, userTracker, userId,
1095 orderByComparator, false);
1096
1097 return array;
1098 }
1099 catch (Exception e) {
1100 throw processException(e);
1101 }
1102 finally {
1103 closeSession(session);
1104 }
1105 }
1106
1107 protected UserTracker getByUserId_PrevAndNext(Session session,
1108 UserTracker userTracker, long userId,
1109 OrderByComparator orderByComparator, boolean previous) {
1110 StringBundler query = null;
1111
1112 if (orderByComparator != null) {
1113 query = new StringBundler(6 +
1114 (orderByComparator.getOrderByFields().length * 6));
1115 }
1116 else {
1117 query = new StringBundler(3);
1118 }
1119
1120 query.append(_SQL_SELECT_USERTRACKER_WHERE);
1121
1122 query.append(_FINDER_COLUMN_USERID_USERID_2);
1123
1124 if (orderByComparator != null) {
1125 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1126
1127 if (orderByConditionFields.length > 0) {
1128 query.append(WHERE_AND);
1129 }
1130
1131 for (int i = 0; i < orderByConditionFields.length; i++) {
1132 query.append(_ORDER_BY_ENTITY_ALIAS);
1133 query.append(orderByConditionFields[i]);
1134
1135 if ((i + 1) < orderByConditionFields.length) {
1136 if (orderByComparator.isAscending() ^ previous) {
1137 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1138 }
1139 else {
1140 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1141 }
1142 }
1143 else {
1144 if (orderByComparator.isAscending() ^ previous) {
1145 query.append(WHERE_GREATER_THAN);
1146 }
1147 else {
1148 query.append(WHERE_LESSER_THAN);
1149 }
1150 }
1151 }
1152
1153 query.append(ORDER_BY_CLAUSE);
1154
1155 String[] orderByFields = orderByComparator.getOrderByFields();
1156
1157 for (int i = 0; i < orderByFields.length; i++) {
1158 query.append(_ORDER_BY_ENTITY_ALIAS);
1159 query.append(orderByFields[i]);
1160
1161 if ((i + 1) < orderByFields.length) {
1162 if (orderByComparator.isAscending() ^ previous) {
1163 query.append(ORDER_BY_ASC_HAS_NEXT);
1164 }
1165 else {
1166 query.append(ORDER_BY_DESC_HAS_NEXT);
1167 }
1168 }
1169 else {
1170 if (orderByComparator.isAscending() ^ previous) {
1171 query.append(ORDER_BY_ASC);
1172 }
1173 else {
1174 query.append(ORDER_BY_DESC);
1175 }
1176 }
1177 }
1178 }
1179
1180 String sql = query.toString();
1181
1182 Query q = session.createQuery(sql);
1183
1184 q.setFirstResult(0);
1185 q.setMaxResults(2);
1186
1187 QueryPos qPos = QueryPos.getInstance(q);
1188
1189 qPos.add(userId);
1190
1191 if (orderByComparator != null) {
1192 Object[] values = orderByComparator.getOrderByConditionValues(userTracker);
1193
1194 for (Object value : values) {
1195 qPos.add(value);
1196 }
1197 }
1198
1199 List<UserTracker> list = q.list();
1200
1201 if (list.size() == 2) {
1202 return list.get(1);
1203 }
1204 else {
1205 return null;
1206 }
1207 }
1208
1209
1216 public List<UserTracker> findBySessionId(String sessionId)
1217 throws SystemException {
1218 return findBySessionId(sessionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1219 null);
1220 }
1221
1222
1235 public List<UserTracker> findBySessionId(String sessionId, int start,
1236 int end) throws SystemException {
1237 return findBySessionId(sessionId, start, end, null);
1238 }
1239
1240
1254 public List<UserTracker> findBySessionId(String sessionId, int start,
1255 int end, OrderByComparator orderByComparator) throws SystemException {
1256 FinderPath finderPath = null;
1257 Object[] finderArgs = null;
1258
1259 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1260 (orderByComparator == null)) {
1261 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SESSIONID;
1262 finderArgs = new Object[] { sessionId };
1263 }
1264 else {
1265 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SESSIONID;
1266 finderArgs = new Object[] { sessionId, start, end, orderByComparator };
1267 }
1268
1269 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(finderPath,
1270 finderArgs, this);
1271
1272 if (list == null) {
1273 StringBundler query = null;
1274
1275 if (orderByComparator != null) {
1276 query = new StringBundler(3 +
1277 (orderByComparator.getOrderByFields().length * 3));
1278 }
1279 else {
1280 query = new StringBundler(2);
1281 }
1282
1283 query.append(_SQL_SELECT_USERTRACKER_WHERE);
1284
1285 if (sessionId == null) {
1286 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_1);
1287 }
1288 else {
1289 if (sessionId.equals(StringPool.BLANK)) {
1290 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_3);
1291 }
1292 else {
1293 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_2);
1294 }
1295 }
1296
1297 if (orderByComparator != null) {
1298 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1299 orderByComparator);
1300 }
1301
1302 String sql = query.toString();
1303
1304 Session session = null;
1305
1306 try {
1307 session = openSession();
1308
1309 Query q = session.createQuery(sql);
1310
1311 QueryPos qPos = QueryPos.getInstance(q);
1312
1313 if (sessionId != null) {
1314 qPos.add(sessionId);
1315 }
1316
1317 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
1318 start, end);
1319 }
1320 catch (Exception e) {
1321 throw processException(e);
1322 }
1323 finally {
1324 if (list == null) {
1325 FinderCacheUtil.removeResult(finderPath, finderArgs);
1326 }
1327 else {
1328 cacheResult(list);
1329
1330 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1331 }
1332
1333 closeSession(session);
1334 }
1335 }
1336
1337 return list;
1338 }
1339
1340
1353 public UserTracker findBySessionId_First(String sessionId,
1354 OrderByComparator orderByComparator)
1355 throws NoSuchUserTrackerException, SystemException {
1356 List<UserTracker> list = findBySessionId(sessionId, 0, 1,
1357 orderByComparator);
1358
1359 if (list.isEmpty()) {
1360 StringBundler msg = new StringBundler(4);
1361
1362 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1363
1364 msg.append("sessionId=");
1365 msg.append(sessionId);
1366
1367 msg.append(StringPool.CLOSE_CURLY_BRACE);
1368
1369 throw new NoSuchUserTrackerException(msg.toString());
1370 }
1371 else {
1372 return list.get(0);
1373 }
1374 }
1375
1376
1389 public UserTracker findBySessionId_Last(String sessionId,
1390 OrderByComparator orderByComparator)
1391 throws NoSuchUserTrackerException, SystemException {
1392 int count = countBySessionId(sessionId);
1393
1394 List<UserTracker> list = findBySessionId(sessionId, count - 1, count,
1395 orderByComparator);
1396
1397 if (list.isEmpty()) {
1398 StringBundler msg = new StringBundler(4);
1399
1400 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1401
1402 msg.append("sessionId=");
1403 msg.append(sessionId);
1404
1405 msg.append(StringPool.CLOSE_CURLY_BRACE);
1406
1407 throw new NoSuchUserTrackerException(msg.toString());
1408 }
1409 else {
1410 return list.get(0);
1411 }
1412 }
1413
1414
1428 public UserTracker[] findBySessionId_PrevAndNext(long userTrackerId,
1429 String sessionId, OrderByComparator orderByComparator)
1430 throws NoSuchUserTrackerException, SystemException {
1431 UserTracker userTracker = findByPrimaryKey(userTrackerId);
1432
1433 Session session = null;
1434
1435 try {
1436 session = openSession();
1437
1438 UserTracker[] array = new UserTrackerImpl[3];
1439
1440 array[0] = getBySessionId_PrevAndNext(session, userTracker,
1441 sessionId, orderByComparator, true);
1442
1443 array[1] = userTracker;
1444
1445 array[2] = getBySessionId_PrevAndNext(session, userTracker,
1446 sessionId, orderByComparator, false);
1447
1448 return array;
1449 }
1450 catch (Exception e) {
1451 throw processException(e);
1452 }
1453 finally {
1454 closeSession(session);
1455 }
1456 }
1457
1458 protected UserTracker getBySessionId_PrevAndNext(Session session,
1459 UserTracker userTracker, String sessionId,
1460 OrderByComparator orderByComparator, boolean previous) {
1461 StringBundler query = null;
1462
1463 if (orderByComparator != null) {
1464 query = new StringBundler(6 +
1465 (orderByComparator.getOrderByFields().length * 6));
1466 }
1467 else {
1468 query = new StringBundler(3);
1469 }
1470
1471 query.append(_SQL_SELECT_USERTRACKER_WHERE);
1472
1473 if (sessionId == null) {
1474 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_1);
1475 }
1476 else {
1477 if (sessionId.equals(StringPool.BLANK)) {
1478 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_3);
1479 }
1480 else {
1481 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_2);
1482 }
1483 }
1484
1485 if (orderByComparator != null) {
1486 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1487
1488 if (orderByConditionFields.length > 0) {
1489 query.append(WHERE_AND);
1490 }
1491
1492 for (int i = 0; i < orderByConditionFields.length; i++) {
1493 query.append(_ORDER_BY_ENTITY_ALIAS);
1494 query.append(orderByConditionFields[i]);
1495
1496 if ((i + 1) < orderByConditionFields.length) {
1497 if (orderByComparator.isAscending() ^ previous) {
1498 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1499 }
1500 else {
1501 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1502 }
1503 }
1504 else {
1505 if (orderByComparator.isAscending() ^ previous) {
1506 query.append(WHERE_GREATER_THAN);
1507 }
1508 else {
1509 query.append(WHERE_LESSER_THAN);
1510 }
1511 }
1512 }
1513
1514 query.append(ORDER_BY_CLAUSE);
1515
1516 String[] orderByFields = orderByComparator.getOrderByFields();
1517
1518 for (int i = 0; i < orderByFields.length; i++) {
1519 query.append(_ORDER_BY_ENTITY_ALIAS);
1520 query.append(orderByFields[i]);
1521
1522 if ((i + 1) < orderByFields.length) {
1523 if (orderByComparator.isAscending() ^ previous) {
1524 query.append(ORDER_BY_ASC_HAS_NEXT);
1525 }
1526 else {
1527 query.append(ORDER_BY_DESC_HAS_NEXT);
1528 }
1529 }
1530 else {
1531 if (orderByComparator.isAscending() ^ previous) {
1532 query.append(ORDER_BY_ASC);
1533 }
1534 else {
1535 query.append(ORDER_BY_DESC);
1536 }
1537 }
1538 }
1539 }
1540
1541 String sql = query.toString();
1542
1543 Query q = session.createQuery(sql);
1544
1545 q.setFirstResult(0);
1546 q.setMaxResults(2);
1547
1548 QueryPos qPos = QueryPos.getInstance(q);
1549
1550 if (sessionId != null) {
1551 qPos.add(sessionId);
1552 }
1553
1554 if (orderByComparator != null) {
1555 Object[] values = orderByComparator.getOrderByConditionValues(userTracker);
1556
1557 for (Object value : values) {
1558 qPos.add(value);
1559 }
1560 }
1561
1562 List<UserTracker> list = q.list();
1563
1564 if (list.size() == 2) {
1565 return list.get(1);
1566 }
1567 else {
1568 return null;
1569 }
1570 }
1571
1572
1578 public List<UserTracker> findAll() throws SystemException {
1579 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1580 }
1581
1582
1594 public List<UserTracker> findAll(int start, int end)
1595 throws SystemException {
1596 return findAll(start, end, null);
1597 }
1598
1599
1612 public List<UserTracker> findAll(int start, int end,
1613 OrderByComparator orderByComparator) throws SystemException {
1614 FinderPath finderPath = null;
1615 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1616
1617 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1618 (orderByComparator == null)) {
1619 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1620 finderArgs = FINDER_ARGS_EMPTY;
1621 }
1622 else {
1623 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1624 finderArgs = new Object[] { start, end, orderByComparator };
1625 }
1626
1627 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(finderPath,
1628 finderArgs, this);
1629
1630 if (list == null) {
1631 StringBundler query = null;
1632 String sql = null;
1633
1634 if (orderByComparator != null) {
1635 query = new StringBundler(2 +
1636 (orderByComparator.getOrderByFields().length * 3));
1637
1638 query.append(_SQL_SELECT_USERTRACKER);
1639
1640 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1641 orderByComparator);
1642
1643 sql = query.toString();
1644 }
1645 else {
1646 sql = _SQL_SELECT_USERTRACKER;
1647 }
1648
1649 Session session = null;
1650
1651 try {
1652 session = openSession();
1653
1654 Query q = session.createQuery(sql);
1655
1656 if (orderByComparator == null) {
1657 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
1658 start, end, false);
1659
1660 Collections.sort(list);
1661 }
1662 else {
1663 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
1664 start, end);
1665 }
1666 }
1667 catch (Exception e) {
1668 throw processException(e);
1669 }
1670 finally {
1671 if (list == null) {
1672 FinderCacheUtil.removeResult(finderPath, finderArgs);
1673 }
1674 else {
1675 cacheResult(list);
1676
1677 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1678 }
1679
1680 closeSession(session);
1681 }
1682 }
1683
1684 return list;
1685 }
1686
1687
1693 public void removeByCompanyId(long companyId) throws SystemException {
1694 for (UserTracker userTracker : findByCompanyId(companyId)) {
1695 remove(userTracker);
1696 }
1697 }
1698
1699
1705 public void removeByUserId(long userId) throws SystemException {
1706 for (UserTracker userTracker : findByUserId(userId)) {
1707 remove(userTracker);
1708 }
1709 }
1710
1711
1717 public void removeBySessionId(String sessionId) throws SystemException {
1718 for (UserTracker userTracker : findBySessionId(sessionId)) {
1719 remove(userTracker);
1720 }
1721 }
1722
1723
1728 public void removeAll() throws SystemException {
1729 for (UserTracker userTracker : findAll()) {
1730 remove(userTracker);
1731 }
1732 }
1733
1734
1741 public int countByCompanyId(long companyId) throws SystemException {
1742 Object[] finderArgs = new Object[] { companyId };
1743
1744 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1745 finderArgs, this);
1746
1747 if (count == null) {
1748 StringBundler query = new StringBundler(2);
1749
1750 query.append(_SQL_COUNT_USERTRACKER_WHERE);
1751
1752 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1753
1754 String sql = query.toString();
1755
1756 Session session = null;
1757
1758 try {
1759 session = openSession();
1760
1761 Query q = session.createQuery(sql);
1762
1763 QueryPos qPos = QueryPos.getInstance(q);
1764
1765 qPos.add(companyId);
1766
1767 count = (Long)q.uniqueResult();
1768 }
1769 catch (Exception e) {
1770 throw processException(e);
1771 }
1772 finally {
1773 if (count == null) {
1774 count = Long.valueOf(0);
1775 }
1776
1777 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1778 finderArgs, count);
1779
1780 closeSession(session);
1781 }
1782 }
1783
1784 return count.intValue();
1785 }
1786
1787
1794 public int countByUserId(long userId) throws SystemException {
1795 Object[] finderArgs = new Object[] { userId };
1796
1797 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1798 finderArgs, this);
1799
1800 if (count == null) {
1801 StringBundler query = new StringBundler(2);
1802
1803 query.append(_SQL_COUNT_USERTRACKER_WHERE);
1804
1805 query.append(_FINDER_COLUMN_USERID_USERID_2);
1806
1807 String sql = query.toString();
1808
1809 Session session = null;
1810
1811 try {
1812 session = openSession();
1813
1814 Query q = session.createQuery(sql);
1815
1816 QueryPos qPos = QueryPos.getInstance(q);
1817
1818 qPos.add(userId);
1819
1820 count = (Long)q.uniqueResult();
1821 }
1822 catch (Exception e) {
1823 throw processException(e);
1824 }
1825 finally {
1826 if (count == null) {
1827 count = Long.valueOf(0);
1828 }
1829
1830 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1831 finderArgs, count);
1832
1833 closeSession(session);
1834 }
1835 }
1836
1837 return count.intValue();
1838 }
1839
1840
1847 public int countBySessionId(String sessionId) throws SystemException {
1848 Object[] finderArgs = new Object[] { sessionId };
1849
1850 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SESSIONID,
1851 finderArgs, this);
1852
1853 if (count == null) {
1854 StringBundler query = new StringBundler(2);
1855
1856 query.append(_SQL_COUNT_USERTRACKER_WHERE);
1857
1858 if (sessionId == null) {
1859 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_1);
1860 }
1861 else {
1862 if (sessionId.equals(StringPool.BLANK)) {
1863 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_3);
1864 }
1865 else {
1866 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_2);
1867 }
1868 }
1869
1870 String sql = query.toString();
1871
1872 Session session = null;
1873
1874 try {
1875 session = openSession();
1876
1877 Query q = session.createQuery(sql);
1878
1879 QueryPos qPos = QueryPos.getInstance(q);
1880
1881 if (sessionId != null) {
1882 qPos.add(sessionId);
1883 }
1884
1885 count = (Long)q.uniqueResult();
1886 }
1887 catch (Exception e) {
1888 throw processException(e);
1889 }
1890 finally {
1891 if (count == null) {
1892 count = Long.valueOf(0);
1893 }
1894
1895 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SESSIONID,
1896 finderArgs, count);
1897
1898 closeSession(session);
1899 }
1900 }
1901
1902 return count.intValue();
1903 }
1904
1905
1911 public int countAll() throws SystemException {
1912 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1913 FINDER_ARGS_EMPTY, this);
1914
1915 if (count == null) {
1916 Session session = null;
1917
1918 try {
1919 session = openSession();
1920
1921 Query q = session.createQuery(_SQL_COUNT_USERTRACKER);
1922
1923 count = (Long)q.uniqueResult();
1924 }
1925 catch (Exception e) {
1926 throw processException(e);
1927 }
1928 finally {
1929 if (count == null) {
1930 count = Long.valueOf(0);
1931 }
1932
1933 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1934 FINDER_ARGS_EMPTY, count);
1935
1936 closeSession(session);
1937 }
1938 }
1939
1940 return count.intValue();
1941 }
1942
1943
1946 public void afterPropertiesSet() {
1947 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1948 com.liferay.portal.util.PropsUtil.get(
1949 "value.object.listener.com.liferay.portal.model.UserTracker")));
1950
1951 if (listenerClassNames.length > 0) {
1952 try {
1953 List<ModelListener<UserTracker>> listenersList = new ArrayList<ModelListener<UserTracker>>();
1954
1955 for (String listenerClassName : listenerClassNames) {
1956 listenersList.add((ModelListener<UserTracker>)InstanceFactory.newInstance(
1957 listenerClassName));
1958 }
1959
1960 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1961 }
1962 catch (Exception e) {
1963 _log.error(e);
1964 }
1965 }
1966 }
1967
1968 public void destroy() {
1969 EntityCacheUtil.removeCache(UserTrackerImpl.class.getName());
1970 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1971 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1972 }
1973
1974 @BeanReference(type = AccountPersistence.class)
1975 protected AccountPersistence accountPersistence;
1976 @BeanReference(type = AddressPersistence.class)
1977 protected AddressPersistence addressPersistence;
1978 @BeanReference(type = BrowserTrackerPersistence.class)
1979 protected BrowserTrackerPersistence browserTrackerPersistence;
1980 @BeanReference(type = ClassNamePersistence.class)
1981 protected ClassNamePersistence classNamePersistence;
1982 @BeanReference(type = ClusterGroupPersistence.class)
1983 protected ClusterGroupPersistence clusterGroupPersistence;
1984 @BeanReference(type = CompanyPersistence.class)
1985 protected CompanyPersistence companyPersistence;
1986 @BeanReference(type = ContactPersistence.class)
1987 protected ContactPersistence contactPersistence;
1988 @BeanReference(type = CountryPersistence.class)
1989 protected CountryPersistence countryPersistence;
1990 @BeanReference(type = EmailAddressPersistence.class)
1991 protected EmailAddressPersistence emailAddressPersistence;
1992 @BeanReference(type = GroupPersistence.class)
1993 protected GroupPersistence groupPersistence;
1994 @BeanReference(type = ImagePersistence.class)
1995 protected ImagePersistence imagePersistence;
1996 @BeanReference(type = LayoutPersistence.class)
1997 protected LayoutPersistence layoutPersistence;
1998 @BeanReference(type = LayoutBranchPersistence.class)
1999 protected LayoutBranchPersistence layoutBranchPersistence;
2000 @BeanReference(type = LayoutPrototypePersistence.class)
2001 protected LayoutPrototypePersistence layoutPrototypePersistence;
2002 @BeanReference(type = LayoutRevisionPersistence.class)
2003 protected LayoutRevisionPersistence layoutRevisionPersistence;
2004 @BeanReference(type = LayoutSetPersistence.class)
2005 protected LayoutSetPersistence layoutSetPersistence;
2006 @BeanReference(type = LayoutSetBranchPersistence.class)
2007 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2008 @BeanReference(type = LayoutSetPrototypePersistence.class)
2009 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2010 @BeanReference(type = ListTypePersistence.class)
2011 protected ListTypePersistence listTypePersistence;
2012 @BeanReference(type = LockPersistence.class)
2013 protected LockPersistence lockPersistence;
2014 @BeanReference(type = MembershipRequestPersistence.class)
2015 protected MembershipRequestPersistence membershipRequestPersistence;
2016 @BeanReference(type = OrganizationPersistence.class)
2017 protected OrganizationPersistence organizationPersistence;
2018 @BeanReference(type = OrgGroupPermissionPersistence.class)
2019 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2020 @BeanReference(type = OrgGroupRolePersistence.class)
2021 protected OrgGroupRolePersistence orgGroupRolePersistence;
2022 @BeanReference(type = OrgLaborPersistence.class)
2023 protected OrgLaborPersistence orgLaborPersistence;
2024 @BeanReference(type = PasswordPolicyPersistence.class)
2025 protected PasswordPolicyPersistence passwordPolicyPersistence;
2026 @BeanReference(type = PasswordPolicyRelPersistence.class)
2027 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2028 @BeanReference(type = PasswordTrackerPersistence.class)
2029 protected PasswordTrackerPersistence passwordTrackerPersistence;
2030 @BeanReference(type = PermissionPersistence.class)
2031 protected PermissionPersistence permissionPersistence;
2032 @BeanReference(type = PhonePersistence.class)
2033 protected PhonePersistence phonePersistence;
2034 @BeanReference(type = PluginSettingPersistence.class)
2035 protected PluginSettingPersistence pluginSettingPersistence;
2036 @BeanReference(type = PortalPreferencesPersistence.class)
2037 protected PortalPreferencesPersistence portalPreferencesPersistence;
2038 @BeanReference(type = PortletPersistence.class)
2039 protected PortletPersistence portletPersistence;
2040 @BeanReference(type = PortletItemPersistence.class)
2041 protected PortletItemPersistence portletItemPersistence;
2042 @BeanReference(type = PortletPreferencesPersistence.class)
2043 protected PortletPreferencesPersistence portletPreferencesPersistence;
2044 @BeanReference(type = RegionPersistence.class)
2045 protected RegionPersistence regionPersistence;
2046 @BeanReference(type = ReleasePersistence.class)
2047 protected ReleasePersistence releasePersistence;
2048 @BeanReference(type = RepositoryPersistence.class)
2049 protected RepositoryPersistence repositoryPersistence;
2050 @BeanReference(type = RepositoryEntryPersistence.class)
2051 protected RepositoryEntryPersistence repositoryEntryPersistence;
2052 @BeanReference(type = ResourcePersistence.class)
2053 protected ResourcePersistence resourcePersistence;
2054 @BeanReference(type = ResourceActionPersistence.class)
2055 protected ResourceActionPersistence resourceActionPersistence;
2056 @BeanReference(type = ResourceBlockPersistence.class)
2057 protected ResourceBlockPersistence resourceBlockPersistence;
2058 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2059 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2060 @BeanReference(type = ResourceCodePersistence.class)
2061 protected ResourceCodePersistence resourceCodePersistence;
2062 @BeanReference(type = ResourcePermissionPersistence.class)
2063 protected ResourcePermissionPersistence resourcePermissionPersistence;
2064 @BeanReference(type = ResourceTypePermissionPersistence.class)
2065 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2066 @BeanReference(type = RolePersistence.class)
2067 protected RolePersistence rolePersistence;
2068 @BeanReference(type = ServiceComponentPersistence.class)
2069 protected ServiceComponentPersistence serviceComponentPersistence;
2070 @BeanReference(type = ShardPersistence.class)
2071 protected ShardPersistence shardPersistence;
2072 @BeanReference(type = SubscriptionPersistence.class)
2073 protected SubscriptionPersistence subscriptionPersistence;
2074 @BeanReference(type = TeamPersistence.class)
2075 protected TeamPersistence teamPersistence;
2076 @BeanReference(type = TicketPersistence.class)
2077 protected TicketPersistence ticketPersistence;
2078 @BeanReference(type = UserPersistence.class)
2079 protected UserPersistence userPersistence;
2080 @BeanReference(type = UserGroupPersistence.class)
2081 protected UserGroupPersistence userGroupPersistence;
2082 @BeanReference(type = UserGroupGroupRolePersistence.class)
2083 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2084 @BeanReference(type = UserGroupRolePersistence.class)
2085 protected UserGroupRolePersistence userGroupRolePersistence;
2086 @BeanReference(type = UserIdMapperPersistence.class)
2087 protected UserIdMapperPersistence userIdMapperPersistence;
2088 @BeanReference(type = UserNotificationEventPersistence.class)
2089 protected UserNotificationEventPersistence userNotificationEventPersistence;
2090 @BeanReference(type = UserTrackerPersistence.class)
2091 protected UserTrackerPersistence userTrackerPersistence;
2092 @BeanReference(type = UserTrackerPathPersistence.class)
2093 protected UserTrackerPathPersistence userTrackerPathPersistence;
2094 @BeanReference(type = VirtualHostPersistence.class)
2095 protected VirtualHostPersistence virtualHostPersistence;
2096 @BeanReference(type = WebDAVPropsPersistence.class)
2097 protected WebDAVPropsPersistence webDAVPropsPersistence;
2098 @BeanReference(type = WebsitePersistence.class)
2099 protected WebsitePersistence websitePersistence;
2100 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2101 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2102 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2103 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2104 private static final String _SQL_SELECT_USERTRACKER = "SELECT userTracker FROM UserTracker userTracker";
2105 private static final String _SQL_SELECT_USERTRACKER_WHERE = "SELECT userTracker FROM UserTracker userTracker WHERE ";
2106 private static final String _SQL_COUNT_USERTRACKER = "SELECT COUNT(userTracker) FROM UserTracker userTracker";
2107 private static final String _SQL_COUNT_USERTRACKER_WHERE = "SELECT COUNT(userTracker) FROM UserTracker userTracker WHERE ";
2108 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "userTracker.companyId = ?";
2109 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userTracker.userId = ?";
2110 private static final String _FINDER_COLUMN_SESSIONID_SESSIONID_1 = "userTracker.sessionId IS NULL";
2111 private static final String _FINDER_COLUMN_SESSIONID_SESSIONID_2 = "userTracker.sessionId = ?";
2112 private static final String _FINDER_COLUMN_SESSIONID_SESSIONID_3 = "(userTracker.sessionId IS NULL OR userTracker.sessionId = ?)";
2113 private static final String _ORDER_BY_ENTITY_ALIAS = "userTracker.";
2114 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTracker exists with the primary key ";
2115 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTracker exists with the key {";
2116 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2117 private static Log _log = LogFactoryUtil.getLog(UserTrackerPersistenceImpl.class);
2118 private static UserTracker _nullUserTracker = new UserTrackerImpl() {
2119 @Override
2120 public Object clone() {
2121 return this;
2122 }
2123
2124 @Override
2125 public CacheModel<UserTracker> toCacheModel() {
2126 return _nullUserTrackerCacheModel;
2127 }
2128 };
2129
2130 private static CacheModel<UserTracker> _nullUserTrackerCacheModel = new CacheModel<UserTracker>() {
2131 public UserTracker toEntityModel() {
2132 return _nullUserTracker;
2133 }
2134 };
2135 }