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.dao.DynamicQuery;
28 import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
29 import com.liferay.portal.kernel.util.OrderByComparator;
30 import com.liferay.portal.kernel.util.StringMaker;
31 import com.liferay.portal.kernel.util.StringPool;
32 import com.liferay.portal.model.UserTracker;
33 import com.liferay.portal.model.impl.UserTrackerImpl;
34 import com.liferay.portal.service.persistence.BasePersistence;
35 import com.liferay.portal.spring.hibernate.FinderCache;
36 import com.liferay.portal.spring.hibernate.HibernateUtil;
37
38 import com.liferay.util.dao.hibernate.QueryUtil;
39
40 import org.apache.commons.logging.Log;
41 import org.apache.commons.logging.LogFactory;
42
43 import org.hibernate.Query;
44 import org.hibernate.Session;
45
46 import java.util.Collections;
47 import java.util.Iterator;
48 import java.util.List;
49
50
56 public class UserTrackerPersistenceImpl extends BasePersistence
57 implements UserTrackerPersistence {
58 public UserTracker create(long userTrackerId) {
59 UserTracker userTracker = new UserTrackerImpl();
60 userTracker.setNew(true);
61 userTracker.setPrimaryKey(userTrackerId);
62
63 return userTracker;
64 }
65
66 public UserTracker remove(long userTrackerId)
67 throws NoSuchUserTrackerException, SystemException {
68 Session session = null;
69
70 try {
71 session = openSession();
72
73 UserTracker userTracker = (UserTracker)session.get(UserTrackerImpl.class,
74 new Long(userTrackerId));
75
76 if (userTracker == null) {
77 if (_log.isWarnEnabled()) {
78 _log.warn("No UserTracker exists with the primary key " +
79 userTrackerId);
80 }
81
82 throw new NoSuchUserTrackerException(
83 "No UserTracker exists with the primary key " +
84 userTrackerId);
85 }
86
87 return remove(userTracker);
88 }
89 catch (NoSuchUserTrackerException nsee) {
90 throw nsee;
91 }
92 catch (Exception e) {
93 throw HibernateUtil.processException(e);
94 }
95 finally {
96 closeSession(session);
97 }
98 }
99
100 public UserTracker remove(UserTracker userTracker)
101 throws SystemException {
102 Session session = null;
103
104 try {
105 session = openSession();
106 session.delete(userTracker);
107 session.flush();
108
109 return userTracker;
110 }
111 catch (Exception e) {
112 throw HibernateUtil.processException(e);
113 }
114 finally {
115 closeSession(session);
116 FinderCache.clearCache(UserTracker.class.getName());
117 }
118 }
119
120 public UserTracker update(com.liferay.portal.model.UserTracker userTracker)
121 throws SystemException {
122 return update(userTracker, false);
123 }
124
125 public UserTracker update(
126 com.liferay.portal.model.UserTracker userTracker, boolean merge)
127 throws SystemException {
128 Session session = null;
129
130 try {
131 session = openSession();
132
133 if (merge) {
134 session.merge(userTracker);
135 }
136 else {
137 if (userTracker.isNew()) {
138 session.save(userTracker);
139 }
140 }
141
142 session.flush();
143 userTracker.setNew(false);
144
145 return userTracker;
146 }
147 catch (Exception e) {
148 throw HibernateUtil.processException(e);
149 }
150 finally {
151 closeSession(session);
152 FinderCache.clearCache(UserTracker.class.getName());
153 }
154 }
155
156 public UserTracker findByPrimaryKey(long userTrackerId)
157 throws NoSuchUserTrackerException, SystemException {
158 UserTracker userTracker = fetchByPrimaryKey(userTrackerId);
159
160 if (userTracker == null) {
161 if (_log.isWarnEnabled()) {
162 _log.warn("No UserTracker exists with the primary key " +
163 userTrackerId);
164 }
165
166 throw new NoSuchUserTrackerException(
167 "No UserTracker exists with the primary key " + userTrackerId);
168 }
169
170 return userTracker;
171 }
172
173 public UserTracker fetchByPrimaryKey(long userTrackerId)
174 throws SystemException {
175 Session session = null;
176
177 try {
178 session = openSession();
179
180 return (UserTracker)session.get(UserTrackerImpl.class,
181 new Long(userTrackerId));
182 }
183 catch (Exception e) {
184 throw HibernateUtil.processException(e);
185 }
186 finally {
187 closeSession(session);
188 }
189 }
190
191 public List findByCompanyId(long companyId) throws SystemException {
192 String finderClassName = UserTracker.class.getName();
193 String finderMethodName = "findByCompanyId";
194 String[] finderParams = new String[] { Long.class.getName() };
195 Object[] finderArgs = new Object[] { new Long(companyId) };
196 Object result = FinderCache.getResult(finderClassName,
197 finderMethodName, finderParams, finderArgs, getSessionFactory());
198
199 if (result == null) {
200 Session session = null;
201
202 try {
203 session = openSession();
204
205 StringMaker query = new StringMaker();
206 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
207 query.append("companyId = ?");
208 query.append(" ");
209
210 Query q = session.createQuery(query.toString());
211 int queryPos = 0;
212 q.setLong(queryPos++, companyId);
213
214 List list = q.list();
215 FinderCache.putResult(finderClassName, finderMethodName,
216 finderParams, finderArgs, list);
217
218 return list;
219 }
220 catch (Exception e) {
221 throw HibernateUtil.processException(e);
222 }
223 finally {
224 closeSession(session);
225 }
226 }
227 else {
228 return (List)result;
229 }
230 }
231
232 public List findByCompanyId(long companyId, int begin, int end)
233 throws SystemException {
234 return findByCompanyId(companyId, begin, end, null);
235 }
236
237 public List findByCompanyId(long companyId, int begin, int end,
238 OrderByComparator obc) throws SystemException {
239 String finderClassName = UserTracker.class.getName();
240 String finderMethodName = "findByCompanyId";
241 String[] finderParams = new String[] {
242 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
243 "com.liferay.portal.kernel.util.OrderByComparator"
244 };
245 Object[] finderArgs = new Object[] {
246 new Long(companyId), String.valueOf(begin), String.valueOf(end),
247 String.valueOf(obc)
248 };
249 Object result = FinderCache.getResult(finderClassName,
250 finderMethodName, finderParams, finderArgs, getSessionFactory());
251
252 if (result == null) {
253 Session session = null;
254
255 try {
256 session = openSession();
257
258 StringMaker query = new StringMaker();
259 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
260 query.append("companyId = ?");
261 query.append(" ");
262
263 if (obc != null) {
264 query.append("ORDER BY ");
265 query.append(obc.getOrderBy());
266 }
267
268 Query q = session.createQuery(query.toString());
269 int queryPos = 0;
270 q.setLong(queryPos++, companyId);
271
272 List list = QueryUtil.list(q, getDialect(), begin, end);
273 FinderCache.putResult(finderClassName, finderMethodName,
274 finderParams, finderArgs, list);
275
276 return list;
277 }
278 catch (Exception e) {
279 throw HibernateUtil.processException(e);
280 }
281 finally {
282 closeSession(session);
283 }
284 }
285 else {
286 return (List)result;
287 }
288 }
289
290 public UserTracker findByCompanyId_First(long companyId,
291 OrderByComparator obc)
292 throws NoSuchUserTrackerException, SystemException {
293 List list = findByCompanyId(companyId, 0, 1, obc);
294
295 if (list.size() == 0) {
296 StringMaker msg = new StringMaker();
297 msg.append("No UserTracker exists with the key ");
298 msg.append(StringPool.OPEN_CURLY_BRACE);
299 msg.append("companyId=");
300 msg.append(companyId);
301 msg.append(StringPool.CLOSE_CURLY_BRACE);
302 throw new NoSuchUserTrackerException(msg.toString());
303 }
304 else {
305 return (UserTracker)list.get(0);
306 }
307 }
308
309 public UserTracker findByCompanyId_Last(long companyId,
310 OrderByComparator obc)
311 throws NoSuchUserTrackerException, SystemException {
312 int count = countByCompanyId(companyId);
313 List list = findByCompanyId(companyId, count - 1, count, obc);
314
315 if (list.size() == 0) {
316 StringMaker msg = new StringMaker();
317 msg.append("No UserTracker exists with the key ");
318 msg.append(StringPool.OPEN_CURLY_BRACE);
319 msg.append("companyId=");
320 msg.append(companyId);
321 msg.append(StringPool.CLOSE_CURLY_BRACE);
322 throw new NoSuchUserTrackerException(msg.toString());
323 }
324 else {
325 return (UserTracker)list.get(0);
326 }
327 }
328
329 public UserTracker[] findByCompanyId_PrevAndNext(long userTrackerId,
330 long companyId, OrderByComparator obc)
331 throws NoSuchUserTrackerException, SystemException {
332 UserTracker userTracker = findByPrimaryKey(userTrackerId);
333 int count = countByCompanyId(companyId);
334 Session session = null;
335
336 try {
337 session = openSession();
338
339 StringMaker query = new StringMaker();
340 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
341 query.append("companyId = ?");
342 query.append(" ");
343
344 if (obc != null) {
345 query.append("ORDER BY ");
346 query.append(obc.getOrderBy());
347 }
348
349 Query q = session.createQuery(query.toString());
350 int queryPos = 0;
351 q.setLong(queryPos++, companyId);
352
353 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
354 userTracker);
355 UserTracker[] array = new UserTrackerImpl[3];
356 array[0] = (UserTracker)objArray[0];
357 array[1] = (UserTracker)objArray[1];
358 array[2] = (UserTracker)objArray[2];
359
360 return array;
361 }
362 catch (Exception e) {
363 throw HibernateUtil.processException(e);
364 }
365 finally {
366 closeSession(session);
367 }
368 }
369
370 public List findByUserId(long userId) throws SystemException {
371 String finderClassName = UserTracker.class.getName();
372 String finderMethodName = "findByUserId";
373 String[] finderParams = new String[] { Long.class.getName() };
374 Object[] finderArgs = new Object[] { new Long(userId) };
375 Object result = FinderCache.getResult(finderClassName,
376 finderMethodName, finderParams, finderArgs, getSessionFactory());
377
378 if (result == null) {
379 Session session = null;
380
381 try {
382 session = openSession();
383
384 StringMaker query = new StringMaker();
385 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
386 query.append("userId = ?");
387 query.append(" ");
388
389 Query q = session.createQuery(query.toString());
390 int queryPos = 0;
391 q.setLong(queryPos++, userId);
392
393 List list = q.list();
394 FinderCache.putResult(finderClassName, finderMethodName,
395 finderParams, finderArgs, list);
396
397 return list;
398 }
399 catch (Exception e) {
400 throw HibernateUtil.processException(e);
401 }
402 finally {
403 closeSession(session);
404 }
405 }
406 else {
407 return (List)result;
408 }
409 }
410
411 public List findByUserId(long userId, int begin, int end)
412 throws SystemException {
413 return findByUserId(userId, begin, end, null);
414 }
415
416 public List findByUserId(long userId, int begin, int end,
417 OrderByComparator obc) throws SystemException {
418 String finderClassName = UserTracker.class.getName();
419 String finderMethodName = "findByUserId";
420 String[] finderParams = new String[] {
421 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
422 "com.liferay.portal.kernel.util.OrderByComparator"
423 };
424 Object[] finderArgs = new Object[] {
425 new Long(userId), String.valueOf(begin), String.valueOf(end),
426 String.valueOf(obc)
427 };
428 Object result = FinderCache.getResult(finderClassName,
429 finderMethodName, finderParams, finderArgs, getSessionFactory());
430
431 if (result == null) {
432 Session session = null;
433
434 try {
435 session = openSession();
436
437 StringMaker query = new StringMaker();
438 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
439 query.append("userId = ?");
440 query.append(" ");
441
442 if (obc != null) {
443 query.append("ORDER BY ");
444 query.append(obc.getOrderBy());
445 }
446
447 Query q = session.createQuery(query.toString());
448 int queryPos = 0;
449 q.setLong(queryPos++, userId);
450
451 List list = QueryUtil.list(q, getDialect(), begin, end);
452 FinderCache.putResult(finderClassName, finderMethodName,
453 finderParams, finderArgs, list);
454
455 return list;
456 }
457 catch (Exception e) {
458 throw HibernateUtil.processException(e);
459 }
460 finally {
461 closeSession(session);
462 }
463 }
464 else {
465 return (List)result;
466 }
467 }
468
469 public UserTracker findByUserId_First(long userId, OrderByComparator obc)
470 throws NoSuchUserTrackerException, SystemException {
471 List list = findByUserId(userId, 0, 1, obc);
472
473 if (list.size() == 0) {
474 StringMaker msg = new StringMaker();
475 msg.append("No UserTracker exists with the key ");
476 msg.append(StringPool.OPEN_CURLY_BRACE);
477 msg.append("userId=");
478 msg.append(userId);
479 msg.append(StringPool.CLOSE_CURLY_BRACE);
480 throw new NoSuchUserTrackerException(msg.toString());
481 }
482 else {
483 return (UserTracker)list.get(0);
484 }
485 }
486
487 public UserTracker findByUserId_Last(long userId, OrderByComparator obc)
488 throws NoSuchUserTrackerException, SystemException {
489 int count = countByUserId(userId);
490 List list = findByUserId(userId, count - 1, count, obc);
491
492 if (list.size() == 0) {
493 StringMaker msg = new StringMaker();
494 msg.append("No UserTracker exists with the key ");
495 msg.append(StringPool.OPEN_CURLY_BRACE);
496 msg.append("userId=");
497 msg.append(userId);
498 msg.append(StringPool.CLOSE_CURLY_BRACE);
499 throw new NoSuchUserTrackerException(msg.toString());
500 }
501 else {
502 return (UserTracker)list.get(0);
503 }
504 }
505
506 public UserTracker[] findByUserId_PrevAndNext(long userTrackerId,
507 long userId, OrderByComparator obc)
508 throws NoSuchUserTrackerException, SystemException {
509 UserTracker userTracker = findByPrimaryKey(userTrackerId);
510 int count = countByUserId(userId);
511 Session session = null;
512
513 try {
514 session = openSession();
515
516 StringMaker query = new StringMaker();
517 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
518 query.append("userId = ?");
519 query.append(" ");
520
521 if (obc != null) {
522 query.append("ORDER BY ");
523 query.append(obc.getOrderBy());
524 }
525
526 Query q = session.createQuery(query.toString());
527 int queryPos = 0;
528 q.setLong(queryPos++, userId);
529
530 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
531 userTracker);
532 UserTracker[] array = new UserTrackerImpl[3];
533 array[0] = (UserTracker)objArray[0];
534 array[1] = (UserTracker)objArray[1];
535 array[2] = (UserTracker)objArray[2];
536
537 return array;
538 }
539 catch (Exception e) {
540 throw HibernateUtil.processException(e);
541 }
542 finally {
543 closeSession(session);
544 }
545 }
546
547 public List findBySessionId(String sessionId) throws SystemException {
548 String finderClassName = UserTracker.class.getName();
549 String finderMethodName = "findBySessionId";
550 String[] finderParams = new String[] { String.class.getName() };
551 Object[] finderArgs = new Object[] { sessionId };
552 Object result = FinderCache.getResult(finderClassName,
553 finderMethodName, finderParams, finderArgs, getSessionFactory());
554
555 if (result == null) {
556 Session session = null;
557
558 try {
559 session = openSession();
560
561 StringMaker query = new StringMaker();
562 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
563
564 if (sessionId == null) {
565 query.append("sessionId IS NULL");
566 }
567 else {
568 query.append("sessionId = ?");
569 }
570
571 query.append(" ");
572
573 Query q = session.createQuery(query.toString());
574 int queryPos = 0;
575
576 if (sessionId != null) {
577 q.setString(queryPos++, sessionId);
578 }
579
580 List list = q.list();
581 FinderCache.putResult(finderClassName, finderMethodName,
582 finderParams, finderArgs, list);
583
584 return list;
585 }
586 catch (Exception e) {
587 throw HibernateUtil.processException(e);
588 }
589 finally {
590 closeSession(session);
591 }
592 }
593 else {
594 return (List)result;
595 }
596 }
597
598 public List findBySessionId(String sessionId, int begin, int end)
599 throws SystemException {
600 return findBySessionId(sessionId, begin, end, null);
601 }
602
603 public List findBySessionId(String sessionId, int begin, int end,
604 OrderByComparator obc) throws SystemException {
605 String finderClassName = UserTracker.class.getName();
606 String finderMethodName = "findBySessionId";
607 String[] finderParams = new String[] {
608 String.class.getName(), "java.lang.Integer", "java.lang.Integer",
609 "com.liferay.portal.kernel.util.OrderByComparator"
610 };
611 Object[] finderArgs = new Object[] {
612 sessionId, String.valueOf(begin), String.valueOf(end),
613 String.valueOf(obc)
614 };
615 Object result = FinderCache.getResult(finderClassName,
616 finderMethodName, finderParams, finderArgs, getSessionFactory());
617
618 if (result == null) {
619 Session session = null;
620
621 try {
622 session = openSession();
623
624 StringMaker query = new StringMaker();
625 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
626
627 if (sessionId == null) {
628 query.append("sessionId IS NULL");
629 }
630 else {
631 query.append("sessionId = ?");
632 }
633
634 query.append(" ");
635
636 if (obc != null) {
637 query.append("ORDER BY ");
638 query.append(obc.getOrderBy());
639 }
640
641 Query q = session.createQuery(query.toString());
642 int queryPos = 0;
643
644 if (sessionId != null) {
645 q.setString(queryPos++, sessionId);
646 }
647
648 List list = QueryUtil.list(q, getDialect(), begin, end);
649 FinderCache.putResult(finderClassName, finderMethodName,
650 finderParams, finderArgs, list);
651
652 return list;
653 }
654 catch (Exception e) {
655 throw HibernateUtil.processException(e);
656 }
657 finally {
658 closeSession(session);
659 }
660 }
661 else {
662 return (List)result;
663 }
664 }
665
666 public UserTracker findBySessionId_First(String sessionId,
667 OrderByComparator obc)
668 throws NoSuchUserTrackerException, SystemException {
669 List list = findBySessionId(sessionId, 0, 1, obc);
670
671 if (list.size() == 0) {
672 StringMaker msg = new StringMaker();
673 msg.append("No UserTracker exists with the key ");
674 msg.append(StringPool.OPEN_CURLY_BRACE);
675 msg.append("sessionId=");
676 msg.append(sessionId);
677 msg.append(StringPool.CLOSE_CURLY_BRACE);
678 throw new NoSuchUserTrackerException(msg.toString());
679 }
680 else {
681 return (UserTracker)list.get(0);
682 }
683 }
684
685 public UserTracker findBySessionId_Last(String sessionId,
686 OrderByComparator obc)
687 throws NoSuchUserTrackerException, SystemException {
688 int count = countBySessionId(sessionId);
689 List list = findBySessionId(sessionId, count - 1, count, obc);
690
691 if (list.size() == 0) {
692 StringMaker msg = new StringMaker();
693 msg.append("No UserTracker exists with the key ");
694 msg.append(StringPool.OPEN_CURLY_BRACE);
695 msg.append("sessionId=");
696 msg.append(sessionId);
697 msg.append(StringPool.CLOSE_CURLY_BRACE);
698 throw new NoSuchUserTrackerException(msg.toString());
699 }
700 else {
701 return (UserTracker)list.get(0);
702 }
703 }
704
705 public UserTracker[] findBySessionId_PrevAndNext(long userTrackerId,
706 String sessionId, OrderByComparator obc)
707 throws NoSuchUserTrackerException, SystemException {
708 UserTracker userTracker = findByPrimaryKey(userTrackerId);
709 int count = countBySessionId(sessionId);
710 Session session = null;
711
712 try {
713 session = openSession();
714
715 StringMaker query = new StringMaker();
716 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
717
718 if (sessionId == null) {
719 query.append("sessionId IS NULL");
720 }
721 else {
722 query.append("sessionId = ?");
723 }
724
725 query.append(" ");
726
727 if (obc != null) {
728 query.append("ORDER BY ");
729 query.append(obc.getOrderBy());
730 }
731
732 Query q = session.createQuery(query.toString());
733 int queryPos = 0;
734
735 if (sessionId != null) {
736 q.setString(queryPos++, sessionId);
737 }
738
739 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
740 userTracker);
741 UserTracker[] array = new UserTrackerImpl[3];
742 array[0] = (UserTracker)objArray[0];
743 array[1] = (UserTracker)objArray[1];
744 array[2] = (UserTracker)objArray[2];
745
746 return array;
747 }
748 catch (Exception e) {
749 throw HibernateUtil.processException(e);
750 }
751 finally {
752 closeSession(session);
753 }
754 }
755
756 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
757 throws SystemException {
758 Session session = null;
759
760 try {
761 session = openSession();
762
763 DynamicQuery query = queryInitializer.initialize(session);
764
765 return query.list();
766 }
767 catch (Exception e) {
768 throw HibernateUtil.processException(e);
769 }
770 finally {
771 closeSession(session);
772 }
773 }
774
775 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
776 int begin, int end) throws SystemException {
777 Session session = null;
778
779 try {
780 session = openSession();
781
782 DynamicQuery query = queryInitializer.initialize(session);
783 query.setLimit(begin, end);
784
785 return query.list();
786 }
787 catch (Exception e) {
788 throw HibernateUtil.processException(e);
789 }
790 finally {
791 closeSession(session);
792 }
793 }
794
795 public List findAll() throws SystemException {
796 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
797 }
798
799 public List findAll(int begin, int end) throws SystemException {
800 return findAll(begin, end, null);
801 }
802
803 public List findAll(int begin, int end, OrderByComparator obc)
804 throws SystemException {
805 String finderClassName = UserTracker.class.getName();
806 String finderMethodName = "findAll";
807 String[] finderParams = new String[] {
808 "java.lang.Integer", "java.lang.Integer",
809 "com.liferay.portal.kernel.util.OrderByComparator"
810 };
811 Object[] finderArgs = new Object[] {
812 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
813 };
814 Object result = FinderCache.getResult(finderClassName,
815 finderMethodName, finderParams, finderArgs, getSessionFactory());
816
817 if (result == null) {
818 Session session = null;
819
820 try {
821 session = openSession();
822
823 StringMaker query = new StringMaker();
824 query.append("FROM com.liferay.portal.model.UserTracker ");
825
826 if (obc != null) {
827 query.append("ORDER BY ");
828 query.append(obc.getOrderBy());
829 }
830
831 Query q = session.createQuery(query.toString());
832 List list = QueryUtil.list(q, getDialect(), begin, end);
833
834 if (obc == null) {
835 Collections.sort(list);
836 }
837
838 FinderCache.putResult(finderClassName, finderMethodName,
839 finderParams, finderArgs, list);
840
841 return list;
842 }
843 catch (Exception e) {
844 throw HibernateUtil.processException(e);
845 }
846 finally {
847 closeSession(session);
848 }
849 }
850 else {
851 return (List)result;
852 }
853 }
854
855 public void removeByCompanyId(long companyId) throws SystemException {
856 Iterator itr = findByCompanyId(companyId).iterator();
857
858 while (itr.hasNext()) {
859 UserTracker userTracker = (UserTracker)itr.next();
860 remove(userTracker);
861 }
862 }
863
864 public void removeByUserId(long userId) throws SystemException {
865 Iterator itr = findByUserId(userId).iterator();
866
867 while (itr.hasNext()) {
868 UserTracker userTracker = (UserTracker)itr.next();
869 remove(userTracker);
870 }
871 }
872
873 public void removeBySessionId(String sessionId) throws SystemException {
874 Iterator itr = findBySessionId(sessionId).iterator();
875
876 while (itr.hasNext()) {
877 UserTracker userTracker = (UserTracker)itr.next();
878 remove(userTracker);
879 }
880 }
881
882 public void removeAll() throws SystemException {
883 Iterator itr = findAll().iterator();
884
885 while (itr.hasNext()) {
886 remove((UserTracker)itr.next());
887 }
888 }
889
890 public int countByCompanyId(long companyId) throws SystemException {
891 String finderClassName = UserTracker.class.getName();
892 String finderMethodName = "countByCompanyId";
893 String[] finderParams = new String[] { Long.class.getName() };
894 Object[] finderArgs = new Object[] { new Long(companyId) };
895 Object result = FinderCache.getResult(finderClassName,
896 finderMethodName, finderParams, finderArgs, getSessionFactory());
897
898 if (result == null) {
899 Session session = null;
900
901 try {
902 session = openSession();
903
904 StringMaker query = new StringMaker();
905 query.append("SELECT COUNT(*) ");
906 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
907 query.append("companyId = ?");
908 query.append(" ");
909
910 Query q = session.createQuery(query.toString());
911 int queryPos = 0;
912 q.setLong(queryPos++, companyId);
913
914 Long count = null;
915 Iterator itr = q.list().iterator();
916
917 if (itr.hasNext()) {
918 count = (Long)itr.next();
919 }
920
921 if (count == null) {
922 count = new Long(0);
923 }
924
925 FinderCache.putResult(finderClassName, finderMethodName,
926 finderParams, finderArgs, count);
927
928 return count.intValue();
929 }
930 catch (Exception e) {
931 throw HibernateUtil.processException(e);
932 }
933 finally {
934 closeSession(session);
935 }
936 }
937 else {
938 return ((Long)result).intValue();
939 }
940 }
941
942 public int countByUserId(long userId) throws SystemException {
943 String finderClassName = UserTracker.class.getName();
944 String finderMethodName = "countByUserId";
945 String[] finderParams = new String[] { Long.class.getName() };
946 Object[] finderArgs = new Object[] { new Long(userId) };
947 Object result = FinderCache.getResult(finderClassName,
948 finderMethodName, finderParams, finderArgs, getSessionFactory());
949
950 if (result == null) {
951 Session session = null;
952
953 try {
954 session = openSession();
955
956 StringMaker query = new StringMaker();
957 query.append("SELECT COUNT(*) ");
958 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
959 query.append("userId = ?");
960 query.append(" ");
961
962 Query q = session.createQuery(query.toString());
963 int queryPos = 0;
964 q.setLong(queryPos++, userId);
965
966 Long count = null;
967 Iterator itr = q.list().iterator();
968
969 if (itr.hasNext()) {
970 count = (Long)itr.next();
971 }
972
973 if (count == null) {
974 count = new Long(0);
975 }
976
977 FinderCache.putResult(finderClassName, finderMethodName,
978 finderParams, finderArgs, count);
979
980 return count.intValue();
981 }
982 catch (Exception e) {
983 throw HibernateUtil.processException(e);
984 }
985 finally {
986 closeSession(session);
987 }
988 }
989 else {
990 return ((Long)result).intValue();
991 }
992 }
993
994 public int countBySessionId(String sessionId) throws SystemException {
995 String finderClassName = UserTracker.class.getName();
996 String finderMethodName = "countBySessionId";
997 String[] finderParams = new String[] { String.class.getName() };
998 Object[] finderArgs = new Object[] { sessionId };
999 Object result = FinderCache.getResult(finderClassName,
1000 finderMethodName, finderParams, finderArgs, getSessionFactory());
1001
1002 if (result == null) {
1003 Session session = null;
1004
1005 try {
1006 session = openSession();
1007
1008 StringMaker query = new StringMaker();
1009 query.append("SELECT COUNT(*) ");
1010 query.append("FROM com.liferay.portal.model.UserTracker WHERE ");
1011
1012 if (sessionId == null) {
1013 query.append("sessionId IS NULL");
1014 }
1015 else {
1016 query.append("sessionId = ?");
1017 }
1018
1019 query.append(" ");
1020
1021 Query q = session.createQuery(query.toString());
1022 int queryPos = 0;
1023
1024 if (sessionId != null) {
1025 q.setString(queryPos++, sessionId);
1026 }
1027
1028 Long count = null;
1029 Iterator itr = q.list().iterator();
1030
1031 if (itr.hasNext()) {
1032 count = (Long)itr.next();
1033 }
1034
1035 if (count == null) {
1036 count = new Long(0);
1037 }
1038
1039 FinderCache.putResult(finderClassName, finderMethodName,
1040 finderParams, finderArgs, count);
1041
1042 return count.intValue();
1043 }
1044 catch (Exception e) {
1045 throw HibernateUtil.processException(e);
1046 }
1047 finally {
1048 closeSession(session);
1049 }
1050 }
1051 else {
1052 return ((Long)result).intValue();
1053 }
1054 }
1055
1056 public int countAll() throws SystemException {
1057 String finderClassName = UserTracker.class.getName();
1058 String finderMethodName = "countAll";
1059 String[] finderParams = new String[] { };
1060 Object[] finderArgs = new Object[] { };
1061 Object result = FinderCache.getResult(finderClassName,
1062 finderMethodName, finderParams, finderArgs, getSessionFactory());
1063
1064 if (result == null) {
1065 Session session = null;
1066
1067 try {
1068 session = openSession();
1069
1070 StringMaker query = new StringMaker();
1071 query.append("SELECT COUNT(*) ");
1072 query.append("FROM com.liferay.portal.model.UserTracker");
1073
1074 Query q = session.createQuery(query.toString());
1075 Long count = null;
1076 Iterator itr = q.list().iterator();
1077
1078 if (itr.hasNext()) {
1079 count = (Long)itr.next();
1080 }
1081
1082 if (count == null) {
1083 count = new Long(0);
1084 }
1085
1086 FinderCache.putResult(finderClassName, finderMethodName,
1087 finderParams, finderArgs, count);
1088
1089 return count.intValue();
1090 }
1091 catch (Exception e) {
1092 throw HibernateUtil.processException(e);
1093 }
1094 finally {
1095 closeSession(session);
1096 }
1097 }
1098 else {
1099 return ((Long)result).intValue();
1100 }
1101 }
1102
1103 protected void initDao() {
1104 }
1105
1106 private static Log _log = LogFactory.getLog(UserTrackerPersistenceImpl.class);
1107}