1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchUserTrackerException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.annotation.BeanReference;
28 import com.liferay.portal.kernel.cache.CacheRegistry;
29 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
30 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32 import com.liferay.portal.kernel.dao.orm.FinderPath;
33 import com.liferay.portal.kernel.dao.orm.Query;
34 import com.liferay.portal.kernel.dao.orm.QueryPos;
35 import com.liferay.portal.kernel.dao.orm.QueryUtil;
36 import com.liferay.portal.kernel.dao.orm.Session;
37 import com.liferay.portal.kernel.log.Log;
38 import com.liferay.portal.kernel.log.LogFactoryUtil;
39 import com.liferay.portal.kernel.util.GetterUtil;
40 import com.liferay.portal.kernel.util.OrderByComparator;
41 import com.liferay.portal.kernel.util.StringPool;
42 import com.liferay.portal.kernel.util.StringUtil;
43 import com.liferay.portal.model.ModelListener;
44 import com.liferay.portal.model.UserTracker;
45 import com.liferay.portal.model.impl.UserTrackerImpl;
46 import com.liferay.portal.model.impl.UserTrackerModelImpl;
47 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
48
49 import java.util.ArrayList;
50 import java.util.Collections;
51 import java.util.List;
52
53
59 public class UserTrackerPersistenceImpl extends BasePersistenceImpl
60 implements UserTrackerPersistence {
61 public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerImpl.class.getName();
62 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
63 ".List";
64 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
65 UserTrackerModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
66 "findByCompanyId", new String[] { Long.class.getName() });
67 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
68 UserTrackerModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
69 "findByCompanyId",
70 new String[] {
71 Long.class.getName(),
72
73 "java.lang.Integer", "java.lang.Integer",
74 "com.liferay.portal.kernel.util.OrderByComparator"
75 });
76 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
77 UserTrackerModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
78 "countByCompanyId", new String[] { Long.class.getName() });
79 public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
80 UserTrackerModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
81 "findByUserId", new String[] { Long.class.getName() });
82 public static final FinderPath FINDER_PATH_FIND_BY_OBC_USERID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
83 UserTrackerModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
84 "findByUserId",
85 new String[] {
86 Long.class.getName(),
87
88 "java.lang.Integer", "java.lang.Integer",
89 "com.liferay.portal.kernel.util.OrderByComparator"
90 });
91 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
92 UserTrackerModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
93 "countByUserId", new String[] { Long.class.getName() });
94 public static final FinderPath FINDER_PATH_FIND_BY_SESSIONID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
95 UserTrackerModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96 "findBySessionId", new String[] { String.class.getName() });
97 public static final FinderPath FINDER_PATH_FIND_BY_OBC_SESSIONID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
98 UserTrackerModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
99 "findBySessionId",
100 new String[] {
101 String.class.getName(),
102
103 "java.lang.Integer", "java.lang.Integer",
104 "com.liferay.portal.kernel.util.OrderByComparator"
105 });
106 public static final FinderPath FINDER_PATH_COUNT_BY_SESSIONID = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
107 UserTrackerModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108 "countBySessionId", new String[] { String.class.getName() });
109 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
110 UserTrackerModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111 "findAll", new String[0]);
112 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
113 UserTrackerModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
114 "countAll", new String[0]);
115
116 public void cacheResult(UserTracker userTracker) {
117 EntityCacheUtil.putResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
118 UserTrackerImpl.class, userTracker.getPrimaryKey(), userTracker);
119 }
120
121 public void cacheResult(List<UserTracker> userTrackers) {
122 for (UserTracker userTracker : userTrackers) {
123 if (EntityCacheUtil.getResult(
124 UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
125 UserTrackerImpl.class, userTracker.getPrimaryKey(), this) == null) {
126 cacheResult(userTracker);
127 }
128 }
129 }
130
131 public void clearCache() {
132 CacheRegistry.clear(UserTrackerImpl.class.getName());
133 EntityCacheUtil.clearCache(UserTrackerImpl.class.getName());
134 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
135 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
136 }
137
138 public UserTracker create(long userTrackerId) {
139 UserTracker userTracker = new UserTrackerImpl();
140
141 userTracker.setNew(true);
142 userTracker.setPrimaryKey(userTrackerId);
143
144 return userTracker;
145 }
146
147 public UserTracker remove(long userTrackerId)
148 throws NoSuchUserTrackerException, SystemException {
149 Session session = null;
150
151 try {
152 session = openSession();
153
154 UserTracker userTracker = (UserTracker)session.get(UserTrackerImpl.class,
155 new Long(userTrackerId));
156
157 if (userTracker == null) {
158 if (_log.isWarnEnabled()) {
159 _log.warn("No UserTracker exists with the primary key " +
160 userTrackerId);
161 }
162
163 throw new NoSuchUserTrackerException(
164 "No UserTracker exists with the primary key " +
165 userTrackerId);
166 }
167
168 return remove(userTracker);
169 }
170 catch (NoSuchUserTrackerException nsee) {
171 throw nsee;
172 }
173 catch (Exception e) {
174 throw processException(e);
175 }
176 finally {
177 closeSession(session);
178 }
179 }
180
181 public UserTracker remove(UserTracker userTracker)
182 throws SystemException {
183 for (ModelListener<UserTracker> listener : listeners) {
184 listener.onBeforeRemove(userTracker);
185 }
186
187 userTracker = removeImpl(userTracker);
188
189 for (ModelListener<UserTracker> listener : listeners) {
190 listener.onAfterRemove(userTracker);
191 }
192
193 return userTracker;
194 }
195
196 protected UserTracker removeImpl(UserTracker userTracker)
197 throws SystemException {
198 Session session = null;
199
200 try {
201 session = openSession();
202
203 if (userTracker.isCachedModel() || BatchSessionUtil.isEnabled()) {
204 Object staleObject = session.get(UserTrackerImpl.class,
205 userTracker.getPrimaryKeyObj());
206
207 if (staleObject != null) {
208 session.evict(staleObject);
209 }
210 }
211
212 session.delete(userTracker);
213
214 session.flush();
215 }
216 catch (Exception e) {
217 throw processException(e);
218 }
219 finally {
220 closeSession(session);
221 }
222
223 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
224
225 EntityCacheUtil.removeResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
226 UserTrackerImpl.class, userTracker.getPrimaryKey());
227
228 return userTracker;
229 }
230
231
234 public UserTracker update(UserTracker userTracker)
235 throws SystemException {
236 if (_log.isWarnEnabled()) {
237 _log.warn(
238 "Using the deprecated update(UserTracker userTracker) method. Use update(UserTracker userTracker, boolean merge) instead.");
239 }
240
241 return update(userTracker, false);
242 }
243
244
257 public UserTracker update(UserTracker userTracker, boolean merge)
258 throws SystemException {
259 boolean isNew = userTracker.isNew();
260
261 for (ModelListener<UserTracker> listener : listeners) {
262 if (isNew) {
263 listener.onBeforeCreate(userTracker);
264 }
265 else {
266 listener.onBeforeUpdate(userTracker);
267 }
268 }
269
270 userTracker = updateImpl(userTracker, merge);
271
272 for (ModelListener<UserTracker> listener : listeners) {
273 if (isNew) {
274 listener.onAfterCreate(userTracker);
275 }
276 else {
277 listener.onAfterUpdate(userTracker);
278 }
279 }
280
281 return userTracker;
282 }
283
284 public UserTracker updateImpl(
285 com.liferay.portal.model.UserTracker userTracker, boolean merge)
286 throws SystemException {
287 Session session = null;
288
289 try {
290 session = openSession();
291
292 BatchSessionUtil.update(session, userTracker, merge);
293
294 userTracker.setNew(false);
295 }
296 catch (Exception e) {
297 throw processException(e);
298 }
299 finally {
300 closeSession(session);
301 }
302
303 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
304
305 EntityCacheUtil.putResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
306 UserTrackerImpl.class, userTracker.getPrimaryKey(), userTracker);
307
308 return userTracker;
309 }
310
311 public UserTracker findByPrimaryKey(long userTrackerId)
312 throws NoSuchUserTrackerException, SystemException {
313 UserTracker userTracker = fetchByPrimaryKey(userTrackerId);
314
315 if (userTracker == null) {
316 if (_log.isWarnEnabled()) {
317 _log.warn("No UserTracker exists with the primary key " +
318 userTrackerId);
319 }
320
321 throw new NoSuchUserTrackerException(
322 "No UserTracker exists with the primary key " + userTrackerId);
323 }
324
325 return userTracker;
326 }
327
328 public UserTracker fetchByPrimaryKey(long userTrackerId)
329 throws SystemException {
330 UserTracker userTracker = (UserTracker)EntityCacheUtil.getResult(UserTrackerModelImpl.ENTITY_CACHE_ENABLED,
331 UserTrackerImpl.class, userTrackerId, this);
332
333 if (userTracker == null) {
334 Session session = null;
335
336 try {
337 session = openSession();
338
339 userTracker = (UserTracker)session.get(UserTrackerImpl.class,
340 new Long(userTrackerId));
341 }
342 catch (Exception e) {
343 throw processException(e);
344 }
345 finally {
346 if (userTracker != null) {
347 cacheResult(userTracker);
348 }
349
350 closeSession(session);
351 }
352 }
353
354 return userTracker;
355 }
356
357 public List<UserTracker> findByCompanyId(long companyId)
358 throws SystemException {
359 Object[] finderArgs = new Object[] { new Long(companyId) };
360
361 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
362 finderArgs, this);
363
364 if (list == null) {
365 Session session = null;
366
367 try {
368 session = openSession();
369
370 StringBuilder query = new StringBuilder();
371
372 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
373
374 query.append("companyId = ?");
375
376 query.append(" ");
377
378 Query q = session.createQuery(query.toString());
379
380 QueryPos qPos = QueryPos.getInstance(q);
381
382 qPos.add(companyId);
383
384 list = q.list();
385 }
386 catch (Exception e) {
387 throw processException(e);
388 }
389 finally {
390 if (list == null) {
391 list = new ArrayList<UserTracker>();
392 }
393
394 cacheResult(list);
395
396 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
397 finderArgs, list);
398
399 closeSession(session);
400 }
401 }
402
403 return list;
404 }
405
406 public List<UserTracker> findByCompanyId(long companyId, int start, int end)
407 throws SystemException {
408 return findByCompanyId(companyId, start, end, null);
409 }
410
411 public List<UserTracker> findByCompanyId(long companyId, int start,
412 int end, OrderByComparator obc) throws SystemException {
413 Object[] finderArgs = new Object[] {
414 new Long(companyId),
415
416 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
417 };
418
419 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
420 finderArgs, this);
421
422 if (list == null) {
423 Session session = null;
424
425 try {
426 session = openSession();
427
428 StringBuilder query = new StringBuilder();
429
430 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
431
432 query.append("companyId = ?");
433
434 query.append(" ");
435
436 if (obc != null) {
437 query.append("ORDER BY ");
438 query.append(obc.getOrderBy());
439 }
440
441 Query q = session.createQuery(query.toString());
442
443 QueryPos qPos = QueryPos.getInstance(q);
444
445 qPos.add(companyId);
446
447 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
448 start, end);
449 }
450 catch (Exception e) {
451 throw processException(e);
452 }
453 finally {
454 if (list == null) {
455 list = new ArrayList<UserTracker>();
456 }
457
458 cacheResult(list);
459
460 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
461 finderArgs, list);
462
463 closeSession(session);
464 }
465 }
466
467 return list;
468 }
469
470 public UserTracker findByCompanyId_First(long companyId,
471 OrderByComparator obc)
472 throws NoSuchUserTrackerException, SystemException {
473 List<UserTracker> list = findByCompanyId(companyId, 0, 1, obc);
474
475 if (list.isEmpty()) {
476 StringBuilder msg = new StringBuilder();
477
478 msg.append("No UserTracker exists with the key {");
479
480 msg.append("companyId=" + companyId);
481
482 msg.append(StringPool.CLOSE_CURLY_BRACE);
483
484 throw new NoSuchUserTrackerException(msg.toString());
485 }
486 else {
487 return list.get(0);
488 }
489 }
490
491 public UserTracker findByCompanyId_Last(long companyId,
492 OrderByComparator obc)
493 throws NoSuchUserTrackerException, SystemException {
494 int count = countByCompanyId(companyId);
495
496 List<UserTracker> list = findByCompanyId(companyId, count - 1, count,
497 obc);
498
499 if (list.isEmpty()) {
500 StringBuilder msg = new StringBuilder();
501
502 msg.append("No UserTracker exists with the key {");
503
504 msg.append("companyId=" + companyId);
505
506 msg.append(StringPool.CLOSE_CURLY_BRACE);
507
508 throw new NoSuchUserTrackerException(msg.toString());
509 }
510 else {
511 return list.get(0);
512 }
513 }
514
515 public UserTracker[] findByCompanyId_PrevAndNext(long userTrackerId,
516 long companyId, OrderByComparator obc)
517 throws NoSuchUserTrackerException, SystemException {
518 UserTracker userTracker = findByPrimaryKey(userTrackerId);
519
520 int count = countByCompanyId(companyId);
521
522 Session session = null;
523
524 try {
525 session = openSession();
526
527 StringBuilder query = new StringBuilder();
528
529 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
530
531 query.append("companyId = ?");
532
533 query.append(" ");
534
535 if (obc != null) {
536 query.append("ORDER BY ");
537 query.append(obc.getOrderBy());
538 }
539
540 Query q = session.createQuery(query.toString());
541
542 QueryPos qPos = QueryPos.getInstance(q);
543
544 qPos.add(companyId);
545
546 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
547 userTracker);
548
549 UserTracker[] array = new UserTrackerImpl[3];
550
551 array[0] = (UserTracker)objArray[0];
552 array[1] = (UserTracker)objArray[1];
553 array[2] = (UserTracker)objArray[2];
554
555 return array;
556 }
557 catch (Exception e) {
558 throw processException(e);
559 }
560 finally {
561 closeSession(session);
562 }
563 }
564
565 public List<UserTracker> findByUserId(long userId)
566 throws SystemException {
567 Object[] finderArgs = new Object[] { new Long(userId) };
568
569 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
570 finderArgs, this);
571
572 if (list == null) {
573 Session session = null;
574
575 try {
576 session = openSession();
577
578 StringBuilder query = new StringBuilder();
579
580 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
581
582 query.append("userId = ?");
583
584 query.append(" ");
585
586 Query q = session.createQuery(query.toString());
587
588 QueryPos qPos = QueryPos.getInstance(q);
589
590 qPos.add(userId);
591
592 list = q.list();
593 }
594 catch (Exception e) {
595 throw processException(e);
596 }
597 finally {
598 if (list == null) {
599 list = new ArrayList<UserTracker>();
600 }
601
602 cacheResult(list);
603
604 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
605 finderArgs, list);
606
607 closeSession(session);
608 }
609 }
610
611 return list;
612 }
613
614 public List<UserTracker> findByUserId(long userId, int start, int end)
615 throws SystemException {
616 return findByUserId(userId, start, end, null);
617 }
618
619 public List<UserTracker> findByUserId(long userId, int start, int end,
620 OrderByComparator obc) throws SystemException {
621 Object[] finderArgs = new Object[] {
622 new Long(userId),
623
624 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
625 };
626
627 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_USERID,
628 finderArgs, this);
629
630 if (list == null) {
631 Session session = null;
632
633 try {
634 session = openSession();
635
636 StringBuilder query = new StringBuilder();
637
638 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
639
640 query.append("userId = ?");
641
642 query.append(" ");
643
644 if (obc != null) {
645 query.append("ORDER BY ");
646 query.append(obc.getOrderBy());
647 }
648
649 Query q = session.createQuery(query.toString());
650
651 QueryPos qPos = QueryPos.getInstance(q);
652
653 qPos.add(userId);
654
655 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
656 start, end);
657 }
658 catch (Exception e) {
659 throw processException(e);
660 }
661 finally {
662 if (list == null) {
663 list = new ArrayList<UserTracker>();
664 }
665
666 cacheResult(list);
667
668 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_USERID,
669 finderArgs, list);
670
671 closeSession(session);
672 }
673 }
674
675 return list;
676 }
677
678 public UserTracker findByUserId_First(long userId, OrderByComparator obc)
679 throws NoSuchUserTrackerException, SystemException {
680 List<UserTracker> list = findByUserId(userId, 0, 1, obc);
681
682 if (list.isEmpty()) {
683 StringBuilder msg = new StringBuilder();
684
685 msg.append("No UserTracker exists with the key {");
686
687 msg.append("userId=" + userId);
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 public UserTracker findByUserId_Last(long userId, OrderByComparator obc)
699 throws NoSuchUserTrackerException, SystemException {
700 int count = countByUserId(userId);
701
702 List<UserTracker> list = findByUserId(userId, count - 1, count, obc);
703
704 if (list.isEmpty()) {
705 StringBuilder msg = new StringBuilder();
706
707 msg.append("No UserTracker exists with the key {");
708
709 msg.append("userId=" + userId);
710
711 msg.append(StringPool.CLOSE_CURLY_BRACE);
712
713 throw new NoSuchUserTrackerException(msg.toString());
714 }
715 else {
716 return list.get(0);
717 }
718 }
719
720 public UserTracker[] findByUserId_PrevAndNext(long userTrackerId,
721 long userId, OrderByComparator obc)
722 throws NoSuchUserTrackerException, SystemException {
723 UserTracker userTracker = findByPrimaryKey(userTrackerId);
724
725 int count = countByUserId(userId);
726
727 Session session = null;
728
729 try {
730 session = openSession();
731
732 StringBuilder query = new StringBuilder();
733
734 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
735
736 query.append("userId = ?");
737
738 query.append(" ");
739
740 if (obc != null) {
741 query.append("ORDER BY ");
742 query.append(obc.getOrderBy());
743 }
744
745 Query q = session.createQuery(query.toString());
746
747 QueryPos qPos = QueryPos.getInstance(q);
748
749 qPos.add(userId);
750
751 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
752 userTracker);
753
754 UserTracker[] array = new UserTrackerImpl[3];
755
756 array[0] = (UserTracker)objArray[0];
757 array[1] = (UserTracker)objArray[1];
758 array[2] = (UserTracker)objArray[2];
759
760 return array;
761 }
762 catch (Exception e) {
763 throw processException(e);
764 }
765 finally {
766 closeSession(session);
767 }
768 }
769
770 public List<UserTracker> findBySessionId(String sessionId)
771 throws SystemException {
772 Object[] finderArgs = new Object[] { sessionId };
773
774 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_SESSIONID,
775 finderArgs, this);
776
777 if (list == null) {
778 Session session = null;
779
780 try {
781 session = openSession();
782
783 StringBuilder query = new StringBuilder();
784
785 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
786
787 if (sessionId == null) {
788 query.append("sessionId IS NULL");
789 }
790 else {
791 query.append("sessionId = ?");
792 }
793
794 query.append(" ");
795
796 Query q = session.createQuery(query.toString());
797
798 QueryPos qPos = QueryPos.getInstance(q);
799
800 if (sessionId != null) {
801 qPos.add(sessionId);
802 }
803
804 list = q.list();
805 }
806 catch (Exception e) {
807 throw processException(e);
808 }
809 finally {
810 if (list == null) {
811 list = new ArrayList<UserTracker>();
812 }
813
814 cacheResult(list);
815
816 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_SESSIONID,
817 finderArgs, list);
818
819 closeSession(session);
820 }
821 }
822
823 return list;
824 }
825
826 public List<UserTracker> findBySessionId(String sessionId, int start,
827 int end) throws SystemException {
828 return findBySessionId(sessionId, start, end, null);
829 }
830
831 public List<UserTracker> findBySessionId(String sessionId, int start,
832 int end, OrderByComparator obc) throws SystemException {
833 Object[] finderArgs = new Object[] {
834 sessionId,
835
836 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
837 };
838
839 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_SESSIONID,
840 finderArgs, this);
841
842 if (list == null) {
843 Session session = null;
844
845 try {
846 session = openSession();
847
848 StringBuilder query = new StringBuilder();
849
850 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
851
852 if (sessionId == null) {
853 query.append("sessionId IS NULL");
854 }
855 else {
856 query.append("sessionId = ?");
857 }
858
859 query.append(" ");
860
861 if (obc != null) {
862 query.append("ORDER BY ");
863 query.append(obc.getOrderBy());
864 }
865
866 Query q = session.createQuery(query.toString());
867
868 QueryPos qPos = QueryPos.getInstance(q);
869
870 if (sessionId != null) {
871 qPos.add(sessionId);
872 }
873
874 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
875 start, end);
876 }
877 catch (Exception e) {
878 throw processException(e);
879 }
880 finally {
881 if (list == null) {
882 list = new ArrayList<UserTracker>();
883 }
884
885 cacheResult(list);
886
887 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_SESSIONID,
888 finderArgs, list);
889
890 closeSession(session);
891 }
892 }
893
894 return list;
895 }
896
897 public UserTracker findBySessionId_First(String sessionId,
898 OrderByComparator obc)
899 throws NoSuchUserTrackerException, SystemException {
900 List<UserTracker> list = findBySessionId(sessionId, 0, 1, obc);
901
902 if (list.isEmpty()) {
903 StringBuilder msg = new StringBuilder();
904
905 msg.append("No UserTracker exists with the key {");
906
907 msg.append("sessionId=" + sessionId);
908
909 msg.append(StringPool.CLOSE_CURLY_BRACE);
910
911 throw new NoSuchUserTrackerException(msg.toString());
912 }
913 else {
914 return list.get(0);
915 }
916 }
917
918 public UserTracker findBySessionId_Last(String sessionId,
919 OrderByComparator obc)
920 throws NoSuchUserTrackerException, SystemException {
921 int count = countBySessionId(sessionId);
922
923 List<UserTracker> list = findBySessionId(sessionId, count - 1, count,
924 obc);
925
926 if (list.isEmpty()) {
927 StringBuilder msg = new StringBuilder();
928
929 msg.append("No UserTracker exists with the key {");
930
931 msg.append("sessionId=" + sessionId);
932
933 msg.append(StringPool.CLOSE_CURLY_BRACE);
934
935 throw new NoSuchUserTrackerException(msg.toString());
936 }
937 else {
938 return list.get(0);
939 }
940 }
941
942 public UserTracker[] findBySessionId_PrevAndNext(long userTrackerId,
943 String sessionId, OrderByComparator obc)
944 throws NoSuchUserTrackerException, SystemException {
945 UserTracker userTracker = findByPrimaryKey(userTrackerId);
946
947 int count = countBySessionId(sessionId);
948
949 Session session = null;
950
951 try {
952 session = openSession();
953
954 StringBuilder query = new StringBuilder();
955
956 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
957
958 if (sessionId == null) {
959 query.append("sessionId IS NULL");
960 }
961 else {
962 query.append("sessionId = ?");
963 }
964
965 query.append(" ");
966
967 if (obc != null) {
968 query.append("ORDER BY ");
969 query.append(obc.getOrderBy());
970 }
971
972 Query q = session.createQuery(query.toString());
973
974 QueryPos qPos = QueryPos.getInstance(q);
975
976 if (sessionId != null) {
977 qPos.add(sessionId);
978 }
979
980 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
981 userTracker);
982
983 UserTracker[] array = new UserTrackerImpl[3];
984
985 array[0] = (UserTracker)objArray[0];
986 array[1] = (UserTracker)objArray[1];
987 array[2] = (UserTracker)objArray[2];
988
989 return array;
990 }
991 catch (Exception e) {
992 throw processException(e);
993 }
994 finally {
995 closeSession(session);
996 }
997 }
998
999 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1000 throws SystemException {
1001 Session session = null;
1002
1003 try {
1004 session = openSession();
1005
1006 dynamicQuery.compile(session);
1007
1008 return dynamicQuery.list();
1009 }
1010 catch (Exception e) {
1011 throw processException(e);
1012 }
1013 finally {
1014 closeSession(session);
1015 }
1016 }
1017
1018 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1019 int start, int end) throws SystemException {
1020 Session session = null;
1021
1022 try {
1023 session = openSession();
1024
1025 dynamicQuery.setLimit(start, end);
1026
1027 dynamicQuery.compile(session);
1028
1029 return dynamicQuery.list();
1030 }
1031 catch (Exception e) {
1032 throw processException(e);
1033 }
1034 finally {
1035 closeSession(session);
1036 }
1037 }
1038
1039 public List<UserTracker> findAll() throws SystemException {
1040 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1041 }
1042
1043 public List<UserTracker> findAll(int start, int end)
1044 throws SystemException {
1045 return findAll(start, end, null);
1046 }
1047
1048 public List<UserTracker> findAll(int start, int end, OrderByComparator obc)
1049 throws SystemException {
1050 Object[] finderArgs = new Object[] {
1051 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1052 };
1053
1054 List<UserTracker> list = (List<UserTracker>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1055 finderArgs, this);
1056
1057 if (list == null) {
1058 Session session = null;
1059
1060 try {
1061 session = openSession();
1062
1063 StringBuilder query = new StringBuilder();
1064
1065 query.append("FROM com.liferay.portal.model.UserTracker ");
1066
1067 if (obc != null) {
1068 query.append("ORDER BY ");
1069 query.append(obc.getOrderBy());
1070 }
1071
1072 Query q = session.createQuery(query.toString());
1073
1074 if (obc == null) {
1075 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
1076 start, end, false);
1077
1078 Collections.sort(list);
1079 }
1080 else {
1081 list = (List<UserTracker>)QueryUtil.list(q, getDialect(),
1082 start, end);
1083 }
1084 }
1085 catch (Exception e) {
1086 throw processException(e);
1087 }
1088 finally {
1089 if (list == null) {
1090 list = new ArrayList<UserTracker>();
1091 }
1092
1093 cacheResult(list);
1094
1095 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1096
1097 closeSession(session);
1098 }
1099 }
1100
1101 return list;
1102 }
1103
1104 public void removeByCompanyId(long companyId) throws SystemException {
1105 for (UserTracker userTracker : findByCompanyId(companyId)) {
1106 remove(userTracker);
1107 }
1108 }
1109
1110 public void removeByUserId(long userId) throws SystemException {
1111 for (UserTracker userTracker : findByUserId(userId)) {
1112 remove(userTracker);
1113 }
1114 }
1115
1116 public void removeBySessionId(String sessionId) throws SystemException {
1117 for (UserTracker userTracker : findBySessionId(sessionId)) {
1118 remove(userTracker);
1119 }
1120 }
1121
1122 public void removeAll() throws SystemException {
1123 for (UserTracker userTracker : findAll()) {
1124 remove(userTracker);
1125 }
1126 }
1127
1128 public int countByCompanyId(long companyId) throws SystemException {
1129 Object[] finderArgs = new Object[] { new Long(companyId) };
1130
1131 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1132 finderArgs, this);
1133
1134 if (count == null) {
1135 Session session = null;
1136
1137 try {
1138 session = openSession();
1139
1140 StringBuilder query = new StringBuilder();
1141
1142 query.append("SELECT COUNT(*) ");
1143 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
1144
1145 query.append("companyId = ?");
1146
1147 query.append(" ");
1148
1149 Query q = session.createQuery(query.toString());
1150
1151 QueryPos qPos = QueryPos.getInstance(q);
1152
1153 qPos.add(companyId);
1154
1155 count = (Long)q.uniqueResult();
1156 }
1157 catch (Exception e) {
1158 throw processException(e);
1159 }
1160 finally {
1161 if (count == null) {
1162 count = Long.valueOf(0);
1163 }
1164
1165 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1166 finderArgs, count);
1167
1168 closeSession(session);
1169 }
1170 }
1171
1172 return count.intValue();
1173 }
1174
1175 public int countByUserId(long userId) throws SystemException {
1176 Object[] finderArgs = new Object[] { new Long(userId) };
1177
1178 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
1179 finderArgs, this);
1180
1181 if (count == null) {
1182 Session session = null;
1183
1184 try {
1185 session = openSession();
1186
1187 StringBuilder query = new StringBuilder();
1188
1189 query.append("SELECT COUNT(*) ");
1190 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
1191
1192 query.append("userId = ?");
1193
1194 query.append(" ");
1195
1196 Query q = session.createQuery(query.toString());
1197
1198 QueryPos qPos = QueryPos.getInstance(q);
1199
1200 qPos.add(userId);
1201
1202 count = (Long)q.uniqueResult();
1203 }
1204 catch (Exception e) {
1205 throw processException(e);
1206 }
1207 finally {
1208 if (count == null) {
1209 count = Long.valueOf(0);
1210 }
1211
1212 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
1213 finderArgs, count);
1214
1215 closeSession(session);
1216 }
1217 }
1218
1219 return count.intValue();
1220 }
1221
1222 public int countBySessionId(String sessionId) throws SystemException {
1223 Object[] finderArgs = new Object[] { sessionId };
1224
1225 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SESSIONID,
1226 finderArgs, this);
1227
1228 if (count == null) {
1229 Session session = null;
1230
1231 try {
1232 session = openSession();
1233
1234 StringBuilder query = new StringBuilder();
1235
1236 query.append("SELECT COUNT(*) ");
1237 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
1238
1239 if (sessionId == null) {
1240 query.append("sessionId IS NULL");
1241 }
1242 else {
1243 query.append("sessionId = ?");
1244 }
1245
1246 query.append(" ");
1247
1248 Query q = session.createQuery(query.toString());
1249
1250 QueryPos qPos = QueryPos.getInstance(q);
1251
1252 if (sessionId != null) {
1253 qPos.add(sessionId);
1254 }
1255
1256 count = (Long)q.uniqueResult();
1257 }
1258 catch (Exception e) {
1259 throw processException(e);
1260 }
1261 finally {
1262 if (count == null) {
1263 count = Long.valueOf(0);
1264 }
1265
1266 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SESSIONID,
1267 finderArgs, count);
1268
1269 closeSession(session);
1270 }
1271 }
1272
1273 return count.intValue();
1274 }
1275
1276 public int countAll() throws SystemException {
1277 Object[] finderArgs = new Object[0];
1278
1279 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1280 finderArgs, this);
1281
1282 if (count == null) {
1283 Session session = null;
1284
1285 try {
1286 session = openSession();
1287
1288 Query q = session.createQuery(
1289 "SELECT COUNT(*) FROM com.liferay.portal.model.UserTracker");
1290
1291 count = (Long)q.uniqueResult();
1292 }
1293 catch (Exception e) {
1294 throw processException(e);
1295 }
1296 finally {
1297 if (count == null) {
1298 count = Long.valueOf(0);
1299 }
1300
1301 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1302 count);
1303
1304 closeSession(session);
1305 }
1306 }
1307
1308 return count.intValue();
1309 }
1310
1311 public void afterPropertiesSet() {
1312 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1313 com.liferay.portal.util.PropsUtil.get(
1314 "value.object.listener.com.liferay.portal.model.UserTracker")));
1315
1316 if (listenerClassNames.length > 0) {
1317 try {
1318 List<ModelListener<UserTracker>> listenersList = new ArrayList<ModelListener<UserTracker>>();
1319
1320 for (String listenerClassName : listenerClassNames) {
1321 listenersList.add((ModelListener<UserTracker>)Class.forName(
1322 listenerClassName).newInstance());
1323 }
1324
1325 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1326 }
1327 catch (Exception e) {
1328 _log.error(e);
1329 }
1330 }
1331 }
1332
1333 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
1334 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
1335 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
1336 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
1337 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
1338 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
1339 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
1340 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
1341 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
1342 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1343 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
1344 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
1345 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
1346 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
1347 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
1348 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
1349 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
1350 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1351 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
1352 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1353 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
1354 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1355 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
1356 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
1357 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
1358 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
1359 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
1360 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
1361 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
1362 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
1363 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
1364 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1365 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
1366 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
1367 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
1368 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
1369 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
1370 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
1371 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
1372 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1373 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
1374 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
1375 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
1376 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
1377 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
1378 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
1379 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
1380 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
1381 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
1382 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
1383 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
1384 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
1385 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
1386 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
1387 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
1388 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
1389 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
1390 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
1391 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1392 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1393 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
1394 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
1395 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
1396 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1397 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
1398 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
1399 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
1400 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1401 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
1402 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1403 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
1404 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
1405 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
1406 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1407 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1408 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1409 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
1410 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1411 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
1412 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1413 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
1414 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1415 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
1416 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1417 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
1418 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1419 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
1420 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1421 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
1422 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1423 private static Log _log = LogFactoryUtil.getLog(UserTrackerPersistenceImpl.class);
1424}