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.kernel.util.Validator;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.model.UserTracker;
041 import com.liferay.portal.model.impl.UserTrackerImpl;
042 import com.liferay.portal.model.impl.UserTrackerModelImpl;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import java.io.Serializable;
046
047 import java.util.ArrayList;
048 import java.util.Collections;
049 import java.util.List;
050
051
063 public class UserTrackerPersistenceImpl extends BasePersistenceImpl<UserTracker>
064 implements UserTrackerPersistence {
065
070 public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerImpl.class.getName();
071 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List1";
073 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List2";
075 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
076 new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
077 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
078 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
079 new String[] {
080 Long.class.getName(),
081
082 "java.lang.Integer", "java.lang.Integer",
083 "com.liferay.portal.kernel.util.OrderByComparator"
084 });
085 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
086 new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
087 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
089 new String[] { Long.class.getName() },
090 UserTrackerModelImpl.COMPANYID_COLUMN_BITMASK);
091 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
092 UserTrackerModelImpl.FINDER_CACHE_ENABLED, Long.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
094 new String[] { Long.class.getName() });
095 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
096 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
097 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
098 new String[] {
099 Long.class.getName(),
100
101 "java.lang.Integer", "java.lang.Integer",
102 "com.liferay.portal.kernel.util.OrderByComparator"
103 });
104 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
105 new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
106 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
108 new String[] { Long.class.getName() },
109 UserTrackerModelImpl.USERID_COLUMN_BITMASK);
110 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
111 UserTrackerModelImpl.FINDER_CACHE_ENABLED, Long.class,
112 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
113 new String[] { Long.class.getName() });
114 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SESSIONID =
115 new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
116 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
117 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findBySessionId",
118 new String[] {
119 String.class.getName(),
120
121 "java.lang.Integer", "java.lang.Integer",
122 "com.liferay.portal.kernel.util.OrderByComparator"
123 });
124 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SESSIONID =
125 new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
126 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySessionId",
128 new String[] { String.class.getName() },
129 UserTrackerModelImpl.SESSIONID_COLUMN_BITMASK);
130 public static final FinderPath FINDER_PATH_COUNT_BY_SESSIONID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
131 UserTrackerModelImpl.FINDER_CACHE_ENABLED, Long.class,
132 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySessionId",
133 new String[] { String.class.getName() });
134 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
135 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
136 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
137 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
138 UserTrackerModelImpl.FINDER_CACHE_ENABLED, UserTrackerImpl.class,
139 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
140 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
141 UserTrackerModelImpl.FINDER_CACHE_ENABLED, Long.class,
142 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
143
144
149 public void cacheResult(UserTracker userTracker) {
150 EntityCacheUtil.putResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
151 UserTrackerImpl.class, userTracker.getPrimaryKey(), userTracker);
152
153 userTracker.resetOriginalValues();
154 }
155
156
161 public void cacheResult(List<UserTracker> userTrackers) {
162 for (UserTracker userTracker : userTrackers) {
163 if (EntityCacheUtil.getResult(
164 UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
165 UserTrackerImpl.class, userTracker.getPrimaryKey()) == null) {
166 cacheResult(userTracker);
167 }
168 else {
169 userTracker.resetOriginalValues();
170 }
171 }
172 }
173
174
181 @Override
182 public void clearCache() {
183 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
184 CacheRegistryUtil.clear(UserTrackerImpl.class.getName());
185 }
186
187 EntityCacheUtil.clearCache(UserTrackerImpl.class.getName());
188
189 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
190 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
191 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
192 }
193
194
201 @Override
202 public void clearCache(UserTracker userTracker) {
203 EntityCacheUtil.removeResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
204 UserTrackerImpl.class, userTracker.getPrimaryKey());
205
206 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
207 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
208 }
209
210 @Override
211 public void clearCache(List<UserTracker> userTrackers) {
212 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
213 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
214
215 for (UserTracker userTracker : userTrackers) {
216 EntityCacheUtil.removeResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
217 UserTrackerImpl.class, userTracker.getPrimaryKey());
218 }
219 }
220
221
227 public UserTracker create(long userTrackerId) {
228 UserTracker userTracker = new UserTrackerImpl();
229
230 userTracker.setNew(true);
231 userTracker.setPrimaryKey(userTrackerId);
232
233 return userTracker;
234 }
235
236
244 public UserTracker remove(long userTrackerId)
245 throws NoSuchUserTrackerException, SystemException {
246 return remove(Long.valueOf(userTrackerId));
247 }
248
249
257 @Override
258 public UserTracker remove(Serializable primaryKey)
259 throws NoSuchUserTrackerException, SystemException {
260 Session session = null;
261
262 try {
263 session = openSession();
264
265 UserTracker userTracker = (UserTracker)session.get(UserTrackerImpl.class,
266 primaryKey);
267
268 if (userTracker == null) {
269 if (_log.isWarnEnabled()) {
270 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
271 }
272
273 throw new NoSuchUserTrackerException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
274 primaryKey);
275 }
276
277 return remove(userTracker);
278 }
279 catch (NoSuchUserTrackerException nsee) {
280 throw nsee;
281 }
282 catch (Exception e) {
283 throw processException(e);
284 }
285 finally {
286 closeSession(session);
287 }
288 }
289
290 @Override
291 protected UserTracker removeImpl(UserTracker userTracker)
292 throws SystemException {
293 userTracker = toUnwrappedModel(userTracker);
294
295 Session session = null;
296
297 try {
298 session = openSession();
299
300 BatchSessionUtil.delete(session, userTracker);
301 }
302 catch (Exception e) {
303 throw processException(e);
304 }
305 finally {
306 closeSession(session);
307 }
308
309 clearCache(userTracker);
310
311 return userTracker;
312 }
313
314 @Override
315 public UserTracker updateImpl(
316 com.liferay.portal.model.UserTracker userTracker, boolean merge)
317 throws SystemException {
318 userTracker = toUnwrappedModel(userTracker);
319
320 boolean isNew = userTracker.isNew();
321
322 UserTrackerModelImpl userTrackerModelImpl = (UserTrackerModelImpl)userTracker;
323
324 Session session = null;
325
326 try {
327 session = openSession();
328
329 BatchSessionUtil.update(session, userTracker, merge);
330
331 userTracker.setNew(false);
332 }
333 catch (Exception e) {
334 throw processException(e);
335 }
336 finally {
337 closeSession(session);
338 }
339
340 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
341
342 if (isNew || !UserTrackerModelImpl.COLUMN_BITMASK_ENABLED) {
343 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
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) && !list.isEmpty()) {
597 for (UserTracker userTracker : list) {
598 if ((companyId != userTracker.getCompanyId())) {
599 list = null;
600
601 break;
602 }
603 }
604 }
605
606 if (list == null) {
607 StringBundler query = null;
608
609 if (orderByComparator != null) {
610 query = new StringBundler(3 +
611 (orderByComparator.getOrderByFields().length * 3));
612 }
613 else {
614 query = new StringBundler(2);
615 }
616
617 query.append(_SQL_SELECT_USERTRACKER_WHERE);
618
619 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
620
621 if (orderByComparator != null) {
622 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
623 orderByComparator);
624 }
625
626 String sql = query.toString();
627
628 Session session = null;
629
630 try {
631 session = openSession();
632
633 Query q = session.createQuery(sql);
634
635 QueryPos qPos = QueryPos.getInstance(q);
636
637 qPos.add(companyId);
638
639 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
640 start, end);
641 }
642 catch (Exception e) {
643 throw processException(e);
644 }
645 finally {
646 if (list == null) {
647 FinderCacheUtil.removeResult(finderPath, finderArgs);
648 }
649 else {
650 cacheResult(list);
651
652 FinderCacheUtil.putResult(finderPath, finderArgs, list);
653 }
654
655 closeSession(session);
656 }
657 }
658
659 return list;
660 }
661
662
675 public UserTracker findByCompanyId_First(long companyId,
676 OrderByComparator orderByComparator)
677 throws NoSuchUserTrackerException, SystemException {
678 List<UserTracker> list = findByCompanyId(companyId, 0, 1,
679 orderByComparator);
680
681 if (list.isEmpty()) {
682 StringBundler msg = new StringBundler(4);
683
684 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
685
686 msg.append("companyId=");
687 msg.append(companyId);
688
689 msg.append(StringPool.CLOSE_CURLY_BRACE);
690
691 throw new NoSuchUserTrackerException(msg.toString());
692 }
693 else {
694 return list.get(0);
695 }
696 }
697
698
711 public UserTracker findByCompanyId_Last(long companyId,
712 OrderByComparator orderByComparator)
713 throws NoSuchUserTrackerException, SystemException {
714 int count = countByCompanyId(companyId);
715
716 List<UserTracker> list = findByCompanyId(companyId, count - 1, count,
717 orderByComparator);
718
719 if (list.isEmpty()) {
720 StringBundler msg = new StringBundler(4);
721
722 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
723
724 msg.append("companyId=");
725 msg.append(companyId);
726
727 msg.append(StringPool.CLOSE_CURLY_BRACE);
728
729 throw new NoSuchUserTrackerException(msg.toString());
730 }
731 else {
732 return list.get(0);
733 }
734 }
735
736
750 public UserTracker[] findByCompanyId_PrevAndNext(long userTrackerId,
751 long companyId, OrderByComparator orderByComparator)
752 throws NoSuchUserTrackerException, SystemException {
753 UserTracker userTracker = findByPrimaryKey(userTrackerId);
754
755 Session session = null;
756
757 try {
758 session = openSession();
759
760 UserTracker[] array = new UserTrackerImpl[3];
761
762 array[0] = getByCompanyId_PrevAndNext(session, userTracker,
763 companyId, orderByComparator, true);
764
765 array[1] = userTracker;
766
767 array[2] = getByCompanyId_PrevAndNext(session, userTracker,
768 companyId, orderByComparator, false);
769
770 return array;
771 }
772 catch (Exception e) {
773 throw processException(e);
774 }
775 finally {
776 closeSession(session);
777 }
778 }
779
780 protected UserTracker getByCompanyId_PrevAndNext(Session session,
781 UserTracker userTracker, long companyId,
782 OrderByComparator orderByComparator, boolean previous) {
783 StringBundler query = null;
784
785 if (orderByComparator != null) {
786 query = new StringBundler(6 +
787 (orderByComparator.getOrderByFields().length * 6));
788 }
789 else {
790 query = new StringBundler(3);
791 }
792
793 query.append(_SQL_SELECT_USERTRACKER_WHERE);
794
795 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
796
797 if (orderByComparator != null) {
798 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
799
800 if (orderByConditionFields.length > 0) {
801 query.append(WHERE_AND);
802 }
803
804 for (int i = 0; i < orderByConditionFields.length; i++) {
805 query.append(_ORDER_BY_ENTITY_ALIAS);
806 query.append(orderByConditionFields[i]);
807
808 if ((i + 1) < orderByConditionFields.length) {
809 if (orderByComparator.isAscending() ^ previous) {
810 query.append(WHERE_GREATER_THAN_HAS_NEXT);
811 }
812 else {
813 query.append(WHERE_LESSER_THAN_HAS_NEXT);
814 }
815 }
816 else {
817 if (orderByComparator.isAscending() ^ previous) {
818 query.append(WHERE_GREATER_THAN);
819 }
820 else {
821 query.append(WHERE_LESSER_THAN);
822 }
823 }
824 }
825
826 query.append(ORDER_BY_CLAUSE);
827
828 String[] orderByFields = orderByComparator.getOrderByFields();
829
830 for (int i = 0; i < orderByFields.length; i++) {
831 query.append(_ORDER_BY_ENTITY_ALIAS);
832 query.append(orderByFields[i]);
833
834 if ((i + 1) < orderByFields.length) {
835 if (orderByComparator.isAscending() ^ previous) {
836 query.append(ORDER_BY_ASC_HAS_NEXT);
837 }
838 else {
839 query.append(ORDER_BY_DESC_HAS_NEXT);
840 }
841 }
842 else {
843 if (orderByComparator.isAscending() ^ previous) {
844 query.append(ORDER_BY_ASC);
845 }
846 else {
847 query.append(ORDER_BY_DESC);
848 }
849 }
850 }
851 }
852
853 String sql = query.toString();
854
855 Query q = session.createQuery(sql);
856
857 q.setFirstResult(0);
858 q.setMaxResults(2);
859
860 QueryPos qPos = QueryPos.getInstance(q);
861
862 qPos.add(companyId);
863
864 if (orderByComparator != null) {
865 Object[] values = orderByComparator.getOrderByConditionValues(userTracker);
866
867 for (Object value : values) {
868 qPos.add(value);
869 }
870 }
871
872 List<UserTracker> list = q.list();
873
874 if (list.size() == 2) {
875 return list.get(1);
876 }
877 else {
878 return null;
879 }
880 }
881
882
889 public List<UserTracker> findByUserId(long userId)
890 throws SystemException {
891 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
892 }
893
894
907 public List<UserTracker> findByUserId(long userId, int start, int end)
908 throws SystemException {
909 return findByUserId(userId, start, end, null);
910 }
911
912
926 public List<UserTracker> findByUserId(long userId, int start, int end,
927 OrderByComparator orderByComparator) throws SystemException {
928 FinderPath finderPath = null;
929 Object[] finderArgs = null;
930
931 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
932 (orderByComparator == null)) {
933 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
934 finderArgs = new Object[] { userId };
935 }
936 else {
937 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
938 finderArgs = new Object[] { userId, start, end, orderByComparator };
939 }
940
941 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(finderPath,
942 finderArgs, this);
943
944 if ((list != null) && !list.isEmpty()) {
945 for (UserTracker userTracker : list) {
946 if ((userId != userTracker.getUserId())) {
947 list = null;
948
949 break;
950 }
951 }
952 }
953
954 if (list == null) {
955 StringBundler query = null;
956
957 if (orderByComparator != null) {
958 query = new StringBundler(3 +
959 (orderByComparator.getOrderByFields().length * 3));
960 }
961 else {
962 query = new StringBundler(2);
963 }
964
965 query.append(_SQL_SELECT_USERTRACKER_WHERE);
966
967 query.append(_FINDER_COLUMN_USERID_USERID_2);
968
969 if (orderByComparator != null) {
970 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
971 orderByComparator);
972 }
973
974 String sql = query.toString();
975
976 Session session = null;
977
978 try {
979 session = openSession();
980
981 Query q = session.createQuery(sql);
982
983 QueryPos qPos = QueryPos.getInstance(q);
984
985 qPos.add(userId);
986
987 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
988 start, end);
989 }
990 catch (Exception e) {
991 throw processException(e);
992 }
993 finally {
994 if (list == null) {
995 FinderCacheUtil.removeResult(finderPath, finderArgs);
996 }
997 else {
998 cacheResult(list);
999
1000 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1001 }
1002
1003 closeSession(session);
1004 }
1005 }
1006
1007 return list;
1008 }
1009
1010
1023 public UserTracker findByUserId_First(long userId,
1024 OrderByComparator orderByComparator)
1025 throws NoSuchUserTrackerException, SystemException {
1026 List<UserTracker> list = findByUserId(userId, 0, 1, orderByComparator);
1027
1028 if (list.isEmpty()) {
1029 StringBundler msg = new StringBundler(4);
1030
1031 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1032
1033 msg.append("userId=");
1034 msg.append(userId);
1035
1036 msg.append(StringPool.CLOSE_CURLY_BRACE);
1037
1038 throw new NoSuchUserTrackerException(msg.toString());
1039 }
1040 else {
1041 return list.get(0);
1042 }
1043 }
1044
1045
1058 public UserTracker findByUserId_Last(long userId,
1059 OrderByComparator orderByComparator)
1060 throws NoSuchUserTrackerException, SystemException {
1061 int count = countByUserId(userId);
1062
1063 List<UserTracker> list = findByUserId(userId, count - 1, count,
1064 orderByComparator);
1065
1066 if (list.isEmpty()) {
1067 StringBundler msg = new StringBundler(4);
1068
1069 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1070
1071 msg.append("userId=");
1072 msg.append(userId);
1073
1074 msg.append(StringPool.CLOSE_CURLY_BRACE);
1075
1076 throw new NoSuchUserTrackerException(msg.toString());
1077 }
1078 else {
1079 return list.get(0);
1080 }
1081 }
1082
1083
1097 public UserTracker[] findByUserId_PrevAndNext(long userTrackerId,
1098 long userId, OrderByComparator orderByComparator)
1099 throws NoSuchUserTrackerException, SystemException {
1100 UserTracker userTracker = findByPrimaryKey(userTrackerId);
1101
1102 Session session = null;
1103
1104 try {
1105 session = openSession();
1106
1107 UserTracker[] array = new UserTrackerImpl[3];
1108
1109 array[0] = getByUserId_PrevAndNext(session, userTracker, userId,
1110 orderByComparator, true);
1111
1112 array[1] = userTracker;
1113
1114 array[2] = getByUserId_PrevAndNext(session, userTracker, userId,
1115 orderByComparator, false);
1116
1117 return array;
1118 }
1119 catch (Exception e) {
1120 throw processException(e);
1121 }
1122 finally {
1123 closeSession(session);
1124 }
1125 }
1126
1127 protected UserTracker getByUserId_PrevAndNext(Session session,
1128 UserTracker userTracker, long userId,
1129 OrderByComparator orderByComparator, boolean previous) {
1130 StringBundler query = null;
1131
1132 if (orderByComparator != null) {
1133 query = new StringBundler(6 +
1134 (orderByComparator.getOrderByFields().length * 6));
1135 }
1136 else {
1137 query = new StringBundler(3);
1138 }
1139
1140 query.append(_SQL_SELECT_USERTRACKER_WHERE);
1141
1142 query.append(_FINDER_COLUMN_USERID_USERID_2);
1143
1144 if (orderByComparator != null) {
1145 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1146
1147 if (orderByConditionFields.length > 0) {
1148 query.append(WHERE_AND);
1149 }
1150
1151 for (int i = 0; i < orderByConditionFields.length; i++) {
1152 query.append(_ORDER_BY_ENTITY_ALIAS);
1153 query.append(orderByConditionFields[i]);
1154
1155 if ((i + 1) < orderByConditionFields.length) {
1156 if (orderByComparator.isAscending() ^ previous) {
1157 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1158 }
1159 else {
1160 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1161 }
1162 }
1163 else {
1164 if (orderByComparator.isAscending() ^ previous) {
1165 query.append(WHERE_GREATER_THAN);
1166 }
1167 else {
1168 query.append(WHERE_LESSER_THAN);
1169 }
1170 }
1171 }
1172
1173 query.append(ORDER_BY_CLAUSE);
1174
1175 String[] orderByFields = orderByComparator.getOrderByFields();
1176
1177 for (int i = 0; i < orderByFields.length; i++) {
1178 query.append(_ORDER_BY_ENTITY_ALIAS);
1179 query.append(orderByFields[i]);
1180
1181 if ((i + 1) < orderByFields.length) {
1182 if (orderByComparator.isAscending() ^ previous) {
1183 query.append(ORDER_BY_ASC_HAS_NEXT);
1184 }
1185 else {
1186 query.append(ORDER_BY_DESC_HAS_NEXT);
1187 }
1188 }
1189 else {
1190 if (orderByComparator.isAscending() ^ previous) {
1191 query.append(ORDER_BY_ASC);
1192 }
1193 else {
1194 query.append(ORDER_BY_DESC);
1195 }
1196 }
1197 }
1198 }
1199
1200 String sql = query.toString();
1201
1202 Query q = session.createQuery(sql);
1203
1204 q.setFirstResult(0);
1205 q.setMaxResults(2);
1206
1207 QueryPos qPos = QueryPos.getInstance(q);
1208
1209 qPos.add(userId);
1210
1211 if (orderByComparator != null) {
1212 Object[] values = orderByComparator.getOrderByConditionValues(userTracker);
1213
1214 for (Object value : values) {
1215 qPos.add(value);
1216 }
1217 }
1218
1219 List<UserTracker> list = q.list();
1220
1221 if (list.size() == 2) {
1222 return list.get(1);
1223 }
1224 else {
1225 return null;
1226 }
1227 }
1228
1229
1236 public List<UserTracker> findBySessionId(String sessionId)
1237 throws SystemException {
1238 return findBySessionId(sessionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1239 null);
1240 }
1241
1242
1255 public List<UserTracker> findBySessionId(String sessionId, int start,
1256 int end) throws SystemException {
1257 return findBySessionId(sessionId, start, end, null);
1258 }
1259
1260
1274 public List<UserTracker> findBySessionId(String sessionId, int start,
1275 int end, OrderByComparator orderByComparator) throws SystemException {
1276 FinderPath finderPath = null;
1277 Object[] finderArgs = null;
1278
1279 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1280 (orderByComparator == null)) {
1281 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SESSIONID;
1282 finderArgs = new Object[] { sessionId };
1283 }
1284 else {
1285 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SESSIONID;
1286 finderArgs = new Object[] { sessionId, start, end, orderByComparator };
1287 }
1288
1289 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(finderPath,
1290 finderArgs, this);
1291
1292 if ((list != null) && !list.isEmpty()) {
1293 for (UserTracker userTracker : list) {
1294 if (!Validator.equals(sessionId, userTracker.getSessionId())) {
1295 list = null;
1296
1297 break;
1298 }
1299 }
1300 }
1301
1302 if (list == null) {
1303 StringBundler query = null;
1304
1305 if (orderByComparator != null) {
1306 query = new StringBundler(3 +
1307 (orderByComparator.getOrderByFields().length * 3));
1308 }
1309 else {
1310 query = new StringBundler(2);
1311 }
1312
1313 query.append(_SQL_SELECT_USERTRACKER_WHERE);
1314
1315 if (sessionId == null) {
1316 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_1);
1317 }
1318 else {
1319 if (sessionId.equals(StringPool.BLANK)) {
1320 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_3);
1321 }
1322 else {
1323 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_2);
1324 }
1325 }
1326
1327 if (orderByComparator != null) {
1328 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1329 orderByComparator);
1330 }
1331
1332 String sql = query.toString();
1333
1334 Session session = null;
1335
1336 try {
1337 session = openSession();
1338
1339 Query q = session.createQuery(sql);
1340
1341 QueryPos qPos = QueryPos.getInstance(q);
1342
1343 if (sessionId != null) {
1344 qPos.add(sessionId);
1345 }
1346
1347 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
1348 start, end);
1349 }
1350 catch (Exception e) {
1351 throw processException(e);
1352 }
1353 finally {
1354 if (list == null) {
1355 FinderCacheUtil.removeResult(finderPath, finderArgs);
1356 }
1357 else {
1358 cacheResult(list);
1359
1360 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1361 }
1362
1363 closeSession(session);
1364 }
1365 }
1366
1367 return list;
1368 }
1369
1370
1383 public UserTracker findBySessionId_First(String sessionId,
1384 OrderByComparator orderByComparator)
1385 throws NoSuchUserTrackerException, SystemException {
1386 List<UserTracker> list = findBySessionId(sessionId, 0, 1,
1387 orderByComparator);
1388
1389 if (list.isEmpty()) {
1390 StringBundler msg = new StringBundler(4);
1391
1392 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1393
1394 msg.append("sessionId=");
1395 msg.append(sessionId);
1396
1397 msg.append(StringPool.CLOSE_CURLY_BRACE);
1398
1399 throw new NoSuchUserTrackerException(msg.toString());
1400 }
1401 else {
1402 return list.get(0);
1403 }
1404 }
1405
1406
1419 public UserTracker findBySessionId_Last(String sessionId,
1420 OrderByComparator orderByComparator)
1421 throws NoSuchUserTrackerException, SystemException {
1422 int count = countBySessionId(sessionId);
1423
1424 List<UserTracker> list = findBySessionId(sessionId, count - 1, count,
1425 orderByComparator);
1426
1427 if (list.isEmpty()) {
1428 StringBundler msg = new StringBundler(4);
1429
1430 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1431
1432 msg.append("sessionId=");
1433 msg.append(sessionId);
1434
1435 msg.append(StringPool.CLOSE_CURLY_BRACE);
1436
1437 throw new NoSuchUserTrackerException(msg.toString());
1438 }
1439 else {
1440 return list.get(0);
1441 }
1442 }
1443
1444
1458 public UserTracker[] findBySessionId_PrevAndNext(long userTrackerId,
1459 String sessionId, OrderByComparator orderByComparator)
1460 throws NoSuchUserTrackerException, SystemException {
1461 UserTracker userTracker = findByPrimaryKey(userTrackerId);
1462
1463 Session session = null;
1464
1465 try {
1466 session = openSession();
1467
1468 UserTracker[] array = new UserTrackerImpl[3];
1469
1470 array[0] = getBySessionId_PrevAndNext(session, userTracker,
1471 sessionId, orderByComparator, true);
1472
1473 array[1] = userTracker;
1474
1475 array[2] = getBySessionId_PrevAndNext(session, userTracker,
1476 sessionId, orderByComparator, false);
1477
1478 return array;
1479 }
1480 catch (Exception e) {
1481 throw processException(e);
1482 }
1483 finally {
1484 closeSession(session);
1485 }
1486 }
1487
1488 protected UserTracker getBySessionId_PrevAndNext(Session session,
1489 UserTracker userTracker, String sessionId,
1490 OrderByComparator orderByComparator, boolean previous) {
1491 StringBundler query = null;
1492
1493 if (orderByComparator != null) {
1494 query = new StringBundler(6 +
1495 (orderByComparator.getOrderByFields().length * 6));
1496 }
1497 else {
1498 query = new StringBundler(3);
1499 }
1500
1501 query.append(_SQL_SELECT_USERTRACKER_WHERE);
1502
1503 if (sessionId == null) {
1504 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_1);
1505 }
1506 else {
1507 if (sessionId.equals(StringPool.BLANK)) {
1508 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_3);
1509 }
1510 else {
1511 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_2);
1512 }
1513 }
1514
1515 if (orderByComparator != null) {
1516 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1517
1518 if (orderByConditionFields.length > 0) {
1519 query.append(WHERE_AND);
1520 }
1521
1522 for (int i = 0; i < orderByConditionFields.length; i++) {
1523 query.append(_ORDER_BY_ENTITY_ALIAS);
1524 query.append(orderByConditionFields[i]);
1525
1526 if ((i + 1) < orderByConditionFields.length) {
1527 if (orderByComparator.isAscending() ^ previous) {
1528 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1529 }
1530 else {
1531 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1532 }
1533 }
1534 else {
1535 if (orderByComparator.isAscending() ^ previous) {
1536 query.append(WHERE_GREATER_THAN);
1537 }
1538 else {
1539 query.append(WHERE_LESSER_THAN);
1540 }
1541 }
1542 }
1543
1544 query.append(ORDER_BY_CLAUSE);
1545
1546 String[] orderByFields = orderByComparator.getOrderByFields();
1547
1548 for (int i = 0; i < orderByFields.length; i++) {
1549 query.append(_ORDER_BY_ENTITY_ALIAS);
1550 query.append(orderByFields[i]);
1551
1552 if ((i + 1) < orderByFields.length) {
1553 if (orderByComparator.isAscending() ^ previous) {
1554 query.append(ORDER_BY_ASC_HAS_NEXT);
1555 }
1556 else {
1557 query.append(ORDER_BY_DESC_HAS_NEXT);
1558 }
1559 }
1560 else {
1561 if (orderByComparator.isAscending() ^ previous) {
1562 query.append(ORDER_BY_ASC);
1563 }
1564 else {
1565 query.append(ORDER_BY_DESC);
1566 }
1567 }
1568 }
1569 }
1570
1571 String sql = query.toString();
1572
1573 Query q = session.createQuery(sql);
1574
1575 q.setFirstResult(0);
1576 q.setMaxResults(2);
1577
1578 QueryPos qPos = QueryPos.getInstance(q);
1579
1580 if (sessionId != null) {
1581 qPos.add(sessionId);
1582 }
1583
1584 if (orderByComparator != null) {
1585 Object[] values = orderByComparator.getOrderByConditionValues(userTracker);
1586
1587 for (Object value : values) {
1588 qPos.add(value);
1589 }
1590 }
1591
1592 List<UserTracker> list = q.list();
1593
1594 if (list.size() == 2) {
1595 return list.get(1);
1596 }
1597 else {
1598 return null;
1599 }
1600 }
1601
1602
1608 public List<UserTracker> findAll() throws SystemException {
1609 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1610 }
1611
1612
1624 public List<UserTracker> findAll(int start, int end)
1625 throws SystemException {
1626 return findAll(start, end, null);
1627 }
1628
1629
1642 public List<UserTracker> findAll(int start, int end,
1643 OrderByComparator orderByComparator) throws SystemException {
1644 FinderPath finderPath = null;
1645 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1646
1647 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1648 (orderByComparator == null)) {
1649 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1650 finderArgs = FINDER_ARGS_EMPTY;
1651 }
1652 else {
1653 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1654 finderArgs = new Object[] { start, end, orderByComparator };
1655 }
1656
1657 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(finderPath,
1658 finderArgs, this);
1659
1660 if (list == null) {
1661 StringBundler query = null;
1662 String sql = null;
1663
1664 if (orderByComparator != null) {
1665 query = new StringBundler(2 +
1666 (orderByComparator.getOrderByFields().length * 3));
1667
1668 query.append(_SQL_SELECT_USERTRACKER);
1669
1670 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1671 orderByComparator);
1672
1673 sql = query.toString();
1674 }
1675 else {
1676 sql = _SQL_SELECT_USERTRACKER;
1677 }
1678
1679 Session session = null;
1680
1681 try {
1682 session = openSession();
1683
1684 Query q = session.createQuery(sql);
1685
1686 if (orderByComparator == null) {
1687 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
1688 start, end, false);
1689
1690 Collections.sort(list);
1691 }
1692 else {
1693 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
1694 start, end);
1695 }
1696 }
1697 catch (Exception e) {
1698 throw processException(e);
1699 }
1700 finally {
1701 if (list == null) {
1702 FinderCacheUtil.removeResult(finderPath, finderArgs);
1703 }
1704 else {
1705 cacheResult(list);
1706
1707 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1708 }
1709
1710 closeSession(session);
1711 }
1712 }
1713
1714 return list;
1715 }
1716
1717
1723 public void removeByCompanyId(long companyId) throws SystemException {
1724 for (UserTracker userTracker : findByCompanyId(companyId)) {
1725 remove(userTracker);
1726 }
1727 }
1728
1729
1735 public void removeByUserId(long userId) throws SystemException {
1736 for (UserTracker userTracker : findByUserId(userId)) {
1737 remove(userTracker);
1738 }
1739 }
1740
1741
1747 public void removeBySessionId(String sessionId) throws SystemException {
1748 for (UserTracker userTracker : findBySessionId(sessionId)) {
1749 remove(userTracker);
1750 }
1751 }
1752
1753
1758 public void removeAll() throws SystemException {
1759 for (UserTracker userTracker : findAll()) {
1760 remove(userTracker);
1761 }
1762 }
1763
1764
1771 public int countByCompanyId(long companyId) throws SystemException {
1772 Object[] finderArgs = new Object[] { companyId };
1773
1774 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1775 finderArgs, this);
1776
1777 if (count == null) {
1778 StringBundler query = new StringBundler(2);
1779
1780 query.append(_SQL_COUNT_USERTRACKER_WHERE);
1781
1782 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1783
1784 String sql = query.toString();
1785
1786 Session session = null;
1787
1788 try {
1789 session = openSession();
1790
1791 Query q = session.createQuery(sql);
1792
1793 QueryPos qPos = QueryPos.getInstance(q);
1794
1795 qPos.add(companyId);
1796
1797 count = (Long)q.uniqueResult();
1798 }
1799 catch (Exception e) {
1800 throw processException(e);
1801 }
1802 finally {
1803 if (count == null) {
1804 count = Long.valueOf(0);
1805 }
1806
1807 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1808 finderArgs, count);
1809
1810 closeSession(session);
1811 }
1812 }
1813
1814 return count.intValue();
1815 }
1816
1817
1824 public int countByUserId(long userId) throws SystemException {
1825 Object[] finderArgs = new Object[] { userId };
1826
1827 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1828 finderArgs, this);
1829
1830 if (count == null) {
1831 StringBundler query = new StringBundler(2);
1832
1833 query.append(_SQL_COUNT_USERTRACKER_WHERE);
1834
1835 query.append(_FINDER_COLUMN_USERID_USERID_2);
1836
1837 String sql = query.toString();
1838
1839 Session session = null;
1840
1841 try {
1842 session = openSession();
1843
1844 Query q = session.createQuery(sql);
1845
1846 QueryPos qPos = QueryPos.getInstance(q);
1847
1848 qPos.add(userId);
1849
1850 count = (Long)q.uniqueResult();
1851 }
1852 catch (Exception e) {
1853 throw processException(e);
1854 }
1855 finally {
1856 if (count == null) {
1857 count = Long.valueOf(0);
1858 }
1859
1860 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1861 finderArgs, count);
1862
1863 closeSession(session);
1864 }
1865 }
1866
1867 return count.intValue();
1868 }
1869
1870
1877 public int countBySessionId(String sessionId) throws SystemException {
1878 Object[] finderArgs = new Object[] { sessionId };
1879
1880 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SESSIONID,
1881 finderArgs, this);
1882
1883 if (count == null) {
1884 StringBundler query = new StringBundler(2);
1885
1886 query.append(_SQL_COUNT_USERTRACKER_WHERE);
1887
1888 if (sessionId == null) {
1889 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_1);
1890 }
1891 else {
1892 if (sessionId.equals(StringPool.BLANK)) {
1893 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_3);
1894 }
1895 else {
1896 query.append(_FINDER_COLUMN_SESSIONID_SESSIONID_2);
1897 }
1898 }
1899
1900 String sql = query.toString();
1901
1902 Session session = null;
1903
1904 try {
1905 session = openSession();
1906
1907 Query q = session.createQuery(sql);
1908
1909 QueryPos qPos = QueryPos.getInstance(q);
1910
1911 if (sessionId != null) {
1912 qPos.add(sessionId);
1913 }
1914
1915 count = (Long)q.uniqueResult();
1916 }
1917 catch (Exception e) {
1918 throw processException(e);
1919 }
1920 finally {
1921 if (count == null) {
1922 count = Long.valueOf(0);
1923 }
1924
1925 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SESSIONID,
1926 finderArgs, count);
1927
1928 closeSession(session);
1929 }
1930 }
1931
1932 return count.intValue();
1933 }
1934
1935
1941 public int countAll() throws SystemException {
1942 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1943 FINDER_ARGS_EMPTY, this);
1944
1945 if (count == null) {
1946 Session session = null;
1947
1948 try {
1949 session = openSession();
1950
1951 Query q = session.createQuery(_SQL_COUNT_USERTRACKER);
1952
1953 count = (Long)q.uniqueResult();
1954 }
1955 catch (Exception e) {
1956 throw processException(e);
1957 }
1958 finally {
1959 if (count == null) {
1960 count = Long.valueOf(0);
1961 }
1962
1963 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1964 FINDER_ARGS_EMPTY, count);
1965
1966 closeSession(session);
1967 }
1968 }
1969
1970 return count.intValue();
1971 }
1972
1973
1976 public void afterPropertiesSet() {
1977 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1978 com.liferay.portal.util.PropsUtil.get(
1979 "value.object.listener.com.liferay.portal.model.UserTracker")));
1980
1981 if (listenerClassNames.length > 0) {
1982 try {
1983 List<ModelListener<UserTracker>> listenersList = new ArrayList<ModelListener<UserTracker>>();
1984
1985 for (String listenerClassName : listenerClassNames) {
1986 listenersList.add((ModelListener<UserTracker>)InstanceFactory.newInstance(
1987 listenerClassName));
1988 }
1989
1990 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1991 }
1992 catch (Exception e) {
1993 _log.error(e);
1994 }
1995 }
1996 }
1997
1998 public void destroy() {
1999 EntityCacheUtil.removeCache(UserTrackerImpl.class.getName());
2000 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2001 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2002 }
2003
2004 @BeanReference(type = AccountPersistence.class)
2005 protected AccountPersistence accountPersistence;
2006 @BeanReference(type = AddressPersistence.class)
2007 protected AddressPersistence addressPersistence;
2008 @BeanReference(type = BrowserTrackerPersistence.class)
2009 protected BrowserTrackerPersistence browserTrackerPersistence;
2010 @BeanReference(type = ClassNamePersistence.class)
2011 protected ClassNamePersistence classNamePersistence;
2012 @BeanReference(type = ClusterGroupPersistence.class)
2013 protected ClusterGroupPersistence clusterGroupPersistence;
2014 @BeanReference(type = CompanyPersistence.class)
2015 protected CompanyPersistence companyPersistence;
2016 @BeanReference(type = ContactPersistence.class)
2017 protected ContactPersistence contactPersistence;
2018 @BeanReference(type = CountryPersistence.class)
2019 protected CountryPersistence countryPersistence;
2020 @BeanReference(type = EmailAddressPersistence.class)
2021 protected EmailAddressPersistence emailAddressPersistence;
2022 @BeanReference(type = GroupPersistence.class)
2023 protected GroupPersistence groupPersistence;
2024 @BeanReference(type = ImagePersistence.class)
2025 protected ImagePersistence imagePersistence;
2026 @BeanReference(type = LayoutPersistence.class)
2027 protected LayoutPersistence layoutPersistence;
2028 @BeanReference(type = LayoutBranchPersistence.class)
2029 protected LayoutBranchPersistence layoutBranchPersistence;
2030 @BeanReference(type = LayoutPrototypePersistence.class)
2031 protected LayoutPrototypePersistence layoutPrototypePersistence;
2032 @BeanReference(type = LayoutRevisionPersistence.class)
2033 protected LayoutRevisionPersistence layoutRevisionPersistence;
2034 @BeanReference(type = LayoutSetPersistence.class)
2035 protected LayoutSetPersistence layoutSetPersistence;
2036 @BeanReference(type = LayoutSetBranchPersistence.class)
2037 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2038 @BeanReference(type = LayoutSetPrototypePersistence.class)
2039 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2040 @BeanReference(type = ListTypePersistence.class)
2041 protected ListTypePersistence listTypePersistence;
2042 @BeanReference(type = LockPersistence.class)
2043 protected LockPersistence lockPersistence;
2044 @BeanReference(type = MembershipRequestPersistence.class)
2045 protected MembershipRequestPersistence membershipRequestPersistence;
2046 @BeanReference(type = OrganizationPersistence.class)
2047 protected OrganizationPersistence organizationPersistence;
2048 @BeanReference(type = OrgGroupPermissionPersistence.class)
2049 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2050 @BeanReference(type = OrgGroupRolePersistence.class)
2051 protected OrgGroupRolePersistence orgGroupRolePersistence;
2052 @BeanReference(type = OrgLaborPersistence.class)
2053 protected OrgLaborPersistence orgLaborPersistence;
2054 @BeanReference(type = PasswordPolicyPersistence.class)
2055 protected PasswordPolicyPersistence passwordPolicyPersistence;
2056 @BeanReference(type = PasswordPolicyRelPersistence.class)
2057 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2058 @BeanReference(type = PasswordTrackerPersistence.class)
2059 protected PasswordTrackerPersistence passwordTrackerPersistence;
2060 @BeanReference(type = PermissionPersistence.class)
2061 protected PermissionPersistence permissionPersistence;
2062 @BeanReference(type = PhonePersistence.class)
2063 protected PhonePersistence phonePersistence;
2064 @BeanReference(type = PluginSettingPersistence.class)
2065 protected PluginSettingPersistence pluginSettingPersistence;
2066 @BeanReference(type = PortalPreferencesPersistence.class)
2067 protected PortalPreferencesPersistence portalPreferencesPersistence;
2068 @BeanReference(type = PortletPersistence.class)
2069 protected PortletPersistence portletPersistence;
2070 @BeanReference(type = PortletItemPersistence.class)
2071 protected PortletItemPersistence portletItemPersistence;
2072 @BeanReference(type = PortletPreferencesPersistence.class)
2073 protected PortletPreferencesPersistence portletPreferencesPersistence;
2074 @BeanReference(type = RegionPersistence.class)
2075 protected RegionPersistence regionPersistence;
2076 @BeanReference(type = ReleasePersistence.class)
2077 protected ReleasePersistence releasePersistence;
2078 @BeanReference(type = RepositoryPersistence.class)
2079 protected RepositoryPersistence repositoryPersistence;
2080 @BeanReference(type = RepositoryEntryPersistence.class)
2081 protected RepositoryEntryPersistence repositoryEntryPersistence;
2082 @BeanReference(type = ResourcePersistence.class)
2083 protected ResourcePersistence resourcePersistence;
2084 @BeanReference(type = ResourceActionPersistence.class)
2085 protected ResourceActionPersistence resourceActionPersistence;
2086 @BeanReference(type = ResourceBlockPersistence.class)
2087 protected ResourceBlockPersistence resourceBlockPersistence;
2088 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2089 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2090 @BeanReference(type = ResourceCodePersistence.class)
2091 protected ResourceCodePersistence resourceCodePersistence;
2092 @BeanReference(type = ResourcePermissionPersistence.class)
2093 protected ResourcePermissionPersistence resourcePermissionPersistence;
2094 @BeanReference(type = ResourceTypePermissionPersistence.class)
2095 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2096 @BeanReference(type = RolePersistence.class)
2097 protected RolePersistence rolePersistence;
2098 @BeanReference(type = ServiceComponentPersistence.class)
2099 protected ServiceComponentPersistence serviceComponentPersistence;
2100 @BeanReference(type = ShardPersistence.class)
2101 protected ShardPersistence shardPersistence;
2102 @BeanReference(type = SubscriptionPersistence.class)
2103 protected SubscriptionPersistence subscriptionPersistence;
2104 @BeanReference(type = TeamPersistence.class)
2105 protected TeamPersistence teamPersistence;
2106 @BeanReference(type = TicketPersistence.class)
2107 protected TicketPersistence ticketPersistence;
2108 @BeanReference(type = UserPersistence.class)
2109 protected UserPersistence userPersistence;
2110 @BeanReference(type = UserGroupPersistence.class)
2111 protected UserGroupPersistence userGroupPersistence;
2112 @BeanReference(type = UserGroupGroupRolePersistence.class)
2113 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2114 @BeanReference(type = UserGroupRolePersistence.class)
2115 protected UserGroupRolePersistence userGroupRolePersistence;
2116 @BeanReference(type = UserIdMapperPersistence.class)
2117 protected UserIdMapperPersistence userIdMapperPersistence;
2118 @BeanReference(type = UserNotificationEventPersistence.class)
2119 protected UserNotificationEventPersistence userNotificationEventPersistence;
2120 @BeanReference(type = UserTrackerPersistence.class)
2121 protected UserTrackerPersistence userTrackerPersistence;
2122 @BeanReference(type = UserTrackerPathPersistence.class)
2123 protected UserTrackerPathPersistence userTrackerPathPersistence;
2124 @BeanReference(type = VirtualHostPersistence.class)
2125 protected VirtualHostPersistence virtualHostPersistence;
2126 @BeanReference(type = WebDAVPropsPersistence.class)
2127 protected WebDAVPropsPersistence webDAVPropsPersistence;
2128 @BeanReference(type = WebsitePersistence.class)
2129 protected WebsitePersistence websitePersistence;
2130 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2131 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2132 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2133 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2134 private static final String _SQL_SELECT_USERTRACKER = "SELECT userTracker FROM UserTracker userTracker";
2135 private static final String _SQL_SELECT_USERTRACKER_WHERE = "SELECT userTracker FROM UserTracker userTracker WHERE ";
2136 private static final String _SQL_COUNT_USERTRACKER = "SELECT COUNT(userTracker) FROM UserTracker userTracker";
2137 private static final String _SQL_COUNT_USERTRACKER_WHERE = "SELECT COUNT(userTracker) FROM UserTracker userTracker WHERE ";
2138 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "userTracker.companyId = ?";
2139 private static final String _FINDER_COLUMN_USERID_USERID_2 = "userTracker.userId = ?";
2140 private static final String _FINDER_COLUMN_SESSIONID_SESSIONID_1 = "userTracker.sessionId IS NULL";
2141 private static final String _FINDER_COLUMN_SESSIONID_SESSIONID_2 = "userTracker.sessionId = ?";
2142 private static final String _FINDER_COLUMN_SESSIONID_SESSIONID_3 = "(userTracker.sessionId IS NULL OR userTracker.sessionId = ?)";
2143 private static final String _ORDER_BY_ENTITY_ALIAS = "userTracker.";
2144 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTracker exists with the primary key ";
2145 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTracker exists with the key {";
2146 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2147 private static Log _log = LogFactoryUtil.getLog(UserTrackerPersistenceImpl.class);
2148 private static UserTracker _nullUserTracker = new UserTrackerImpl() {
2149 @Override
2150 public Object clone() {
2151 return this;
2152 }
2153
2154 @Override
2155 public CacheModel<UserTracker> toCacheModel() {
2156 return _nullUserTrackerCacheModel;
2157 }
2158 };
2159
2160 private static CacheModel<UserTracker> _nullUserTrackerCacheModel = new CacheModel<UserTracker>() {
2161 public UserTracker toEntityModel() {
2162 return _nullUserTracker;
2163 }
2164 };
2165 }