1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.NoSuchUserTrackerPathException;
19  import com.liferay.portal.kernel.annotation.BeanReference;
20  import com.liferay.portal.kernel.cache.CacheRegistry;
21  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderPath;
24  import com.liferay.portal.kernel.dao.orm.Query;
25  import com.liferay.portal.kernel.dao.orm.QueryPos;
26  import com.liferay.portal.kernel.dao.orm.QueryUtil;
27  import com.liferay.portal.kernel.dao.orm.Session;
28  import com.liferay.portal.kernel.exception.SystemException;
29  import com.liferay.portal.kernel.log.Log;
30  import com.liferay.portal.kernel.log.LogFactoryUtil;
31  import com.liferay.portal.kernel.util.GetterUtil;
32  import com.liferay.portal.kernel.util.InstanceFactory;
33  import com.liferay.portal.kernel.util.OrderByComparator;
34  import com.liferay.portal.kernel.util.StringBundler;
35  import com.liferay.portal.kernel.util.StringPool;
36  import com.liferay.portal.kernel.util.StringUtil;
37  import com.liferay.portal.model.ModelListener;
38  import com.liferay.portal.model.UserTrackerPath;
39  import com.liferay.portal.model.impl.UserTrackerPathImpl;
40  import com.liferay.portal.model.impl.UserTrackerPathModelImpl;
41  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42  
43  import java.io.Serializable;
44  
45  import java.util.ArrayList;
46  import java.util.Collections;
47  import java.util.List;
48  
49  /**
50   * <a href="UserTrackerPathPersistenceImpl.java.html"><b><i>View Source</i></b></a>
51   *
52   * <p>
53   * ServiceBuilder generated this class. Modifications in this class will be
54   * overwritten the next time is generated.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       UserTrackerPathPersistence
59   * @see       UserTrackerPathUtil
60   * @generated
61   */
62  public class UserTrackerPathPersistenceImpl extends BasePersistenceImpl<UserTrackerPath>
63      implements UserTrackerPathPersistence {
64      public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerPathImpl.class.getName();
65      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
66          ".List";
67      public static final FinderPath FINDER_PATH_FIND_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
68              UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
69              FINDER_CLASS_NAME_LIST, "findByUserTrackerId",
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_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
77              UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
78              FINDER_CLASS_NAME_LIST, "countByUserTrackerId",
79              new String[] { Long.class.getName() });
80      public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
81              UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
82              FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
83      public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
84              UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
85              FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
86  
87      public void cacheResult(UserTrackerPath userTrackerPath) {
88          EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
89              UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
90              userTrackerPath);
91      }
92  
93      public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
94          for (UserTrackerPath userTrackerPath : userTrackerPaths) {
95              if (EntityCacheUtil.getResult(
96                          UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
97                          UserTrackerPathImpl.class,
98                          userTrackerPath.getPrimaryKey(), this) == null) {
99                  cacheResult(userTrackerPath);
100             }
101         }
102     }
103 
104     public void clearCache() {
105         CacheRegistry.clear(UserTrackerPathImpl.class.getName());
106         EntityCacheUtil.clearCache(UserTrackerPathImpl.class.getName());
107         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
108         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
109     }
110 
111     public void clearCache(UserTrackerPath userTrackerPath) {
112         EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
113             UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
114     }
115 
116     public UserTrackerPath create(long userTrackerPathId) {
117         UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
118 
119         userTrackerPath.setNew(true);
120         userTrackerPath.setPrimaryKey(userTrackerPathId);
121 
122         return userTrackerPath;
123     }
124 
125     public UserTrackerPath remove(Serializable primaryKey)
126         throws NoSuchModelException, SystemException {
127         return remove(((Long)primaryKey).longValue());
128     }
129 
130     public UserTrackerPath remove(long userTrackerPathId)
131         throws NoSuchUserTrackerPathException, SystemException {
132         Session session = null;
133 
134         try {
135             session = openSession();
136 
137             UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
138                     new Long(userTrackerPathId));
139 
140             if (userTrackerPath == null) {
141                 if (_log.isWarnEnabled()) {
142                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
143                         userTrackerPathId);
144                 }
145 
146                 throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
147                     userTrackerPathId);
148             }
149 
150             return remove(userTrackerPath);
151         }
152         catch (NoSuchUserTrackerPathException nsee) {
153             throw nsee;
154         }
155         catch (Exception e) {
156             throw processException(e);
157         }
158         finally {
159             closeSession(session);
160         }
161     }
162 
163     public UserTrackerPath remove(UserTrackerPath userTrackerPath)
164         throws SystemException {
165         for (ModelListener<UserTrackerPath> listener : listeners) {
166             listener.onBeforeRemove(userTrackerPath);
167         }
168 
169         userTrackerPath = removeImpl(userTrackerPath);
170 
171         for (ModelListener<UserTrackerPath> listener : listeners) {
172             listener.onAfterRemove(userTrackerPath);
173         }
174 
175         return userTrackerPath;
176     }
177 
178     protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath)
179         throws SystemException {
180         userTrackerPath = toUnwrappedModel(userTrackerPath);
181 
182         Session session = null;
183 
184         try {
185             session = openSession();
186 
187             if (userTrackerPath.isCachedModel() ||
188                     BatchSessionUtil.isEnabled()) {
189                 Object staleObject = session.get(UserTrackerPathImpl.class,
190                         userTrackerPath.getPrimaryKeyObj());
191 
192                 if (staleObject != null) {
193                     session.evict(staleObject);
194                 }
195             }
196 
197             session.delete(userTrackerPath);
198 
199             session.flush();
200         }
201         catch (Exception e) {
202             throw processException(e);
203         }
204         finally {
205             closeSession(session);
206         }
207 
208         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
209 
210         EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
211             UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
212 
213         return userTrackerPath;
214     }
215 
216     public UserTrackerPath updateImpl(
217         com.liferay.portal.model.UserTrackerPath userTrackerPath, boolean merge)
218         throws SystemException {
219         userTrackerPath = toUnwrappedModel(userTrackerPath);
220 
221         Session session = null;
222 
223         try {
224             session = openSession();
225 
226             BatchSessionUtil.update(session, userTrackerPath, merge);
227 
228             userTrackerPath.setNew(false);
229         }
230         catch (Exception e) {
231             throw processException(e);
232         }
233         finally {
234             closeSession(session);
235         }
236 
237         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
238 
239         EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
240             UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
241             userTrackerPath);
242 
243         return userTrackerPath;
244     }
245 
246     protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
247         if (userTrackerPath instanceof UserTrackerPathImpl) {
248             return userTrackerPath;
249         }
250 
251         UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
252 
253         userTrackerPathImpl.setNew(userTrackerPath.isNew());
254         userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
255 
256         userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
257         userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
258         userTrackerPathImpl.setPath(userTrackerPath.getPath());
259         userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
260 
261         return userTrackerPathImpl;
262     }
263 
264     public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
265         throws NoSuchModelException, SystemException {
266         return findByPrimaryKey(((Long)primaryKey).longValue());
267     }
268 
269     public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
270         throws NoSuchUserTrackerPathException, SystemException {
271         UserTrackerPath userTrackerPath = fetchByPrimaryKey(userTrackerPathId);
272 
273         if (userTrackerPath == null) {
274             if (_log.isWarnEnabled()) {
275                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userTrackerPathId);
276             }
277 
278             throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
279                 userTrackerPathId);
280         }
281 
282         return userTrackerPath;
283     }
284 
285     public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey)
286         throws SystemException {
287         return fetchByPrimaryKey(((Long)primaryKey).longValue());
288     }
289 
290     public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId)
291         throws SystemException {
292         UserTrackerPath userTrackerPath = (UserTrackerPath)EntityCacheUtil.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
293                 UserTrackerPathImpl.class, userTrackerPathId, this);
294 
295         if (userTrackerPath == null) {
296             Session session = null;
297 
298             try {
299                 session = openSession();
300 
301                 userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
302                         new Long(userTrackerPathId));
303             }
304             catch (Exception e) {
305                 throw processException(e);
306             }
307             finally {
308                 if (userTrackerPath != null) {
309                     cacheResult(userTrackerPath);
310                 }
311 
312                 closeSession(session);
313             }
314         }
315 
316         return userTrackerPath;
317     }
318 
319     public List<UserTrackerPath> findByUserTrackerId(long userTrackerId)
320         throws SystemException {
321         return findByUserTrackerId(userTrackerId, QueryUtil.ALL_POS,
322             QueryUtil.ALL_POS, null);
323     }
324 
325     public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
326         int start, int end) throws SystemException {
327         return findByUserTrackerId(userTrackerId, start, end, null);
328     }
329 
330     public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
331         int start, int end, OrderByComparator orderByComparator)
332         throws SystemException {
333         Object[] finderArgs = new Object[] {
334                 new Long(userTrackerId),
335                 
336                 String.valueOf(start), String.valueOf(end),
337                 String.valueOf(orderByComparator)
338             };
339 
340         List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERTRACKERID,
341                 finderArgs, this);
342 
343         if (list == null) {
344             Session session = null;
345 
346             try {
347                 session = openSession();
348 
349                 StringBundler query = null;
350 
351                 if (orderByComparator != null) {
352                     query = new StringBundler(3 +
353                             (orderByComparator.getOrderByFields().length * 3));
354                 }
355                 else {
356                     query = new StringBundler(2);
357                 }
358 
359                 query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
360 
361                 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
362 
363                 if (orderByComparator != null) {
364                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
365                         orderByComparator);
366                 }
367 
368                 String sql = query.toString();
369 
370                 Query q = session.createQuery(sql);
371 
372                 QueryPos qPos = QueryPos.getInstance(q);
373 
374                 qPos.add(userTrackerId);
375 
376                 list = (List<UserTrackerPath>)QueryUtil.list(q, getDialect(),
377                         start, end);
378             }
379             catch (Exception e) {
380                 throw processException(e);
381             }
382             finally {
383                 if (list == null) {
384                     list = new ArrayList<UserTrackerPath>();
385                 }
386 
387                 cacheResult(list);
388 
389                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERTRACKERID,
390                     finderArgs, list);
391 
392                 closeSession(session);
393             }
394         }
395 
396         return list;
397     }
398 
399     public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
400         OrderByComparator orderByComparator)
401         throws NoSuchUserTrackerPathException, SystemException {
402         List<UserTrackerPath> list = findByUserTrackerId(userTrackerId, 0, 1,
403                 orderByComparator);
404 
405         if (list.isEmpty()) {
406             StringBundler msg = new StringBundler(4);
407 
408             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
409 
410             msg.append("userTrackerId=");
411             msg.append(userTrackerId);
412 
413             msg.append(StringPool.CLOSE_CURLY_BRACE);
414 
415             throw new NoSuchUserTrackerPathException(msg.toString());
416         }
417         else {
418             return list.get(0);
419         }
420     }
421 
422     public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
423         OrderByComparator orderByComparator)
424         throws NoSuchUserTrackerPathException, SystemException {
425         int count = countByUserTrackerId(userTrackerId);
426 
427         List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
428                 count - 1, count, orderByComparator);
429 
430         if (list.isEmpty()) {
431             StringBundler msg = new StringBundler(4);
432 
433             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
434 
435             msg.append("userTrackerId=");
436             msg.append(userTrackerId);
437 
438             msg.append(StringPool.CLOSE_CURLY_BRACE);
439 
440             throw new NoSuchUserTrackerPathException(msg.toString());
441         }
442         else {
443             return list.get(0);
444         }
445     }
446 
447     public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
448         long userTrackerPathId, long userTrackerId,
449         OrderByComparator orderByComparator)
450         throws NoSuchUserTrackerPathException, SystemException {
451         UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
452 
453         Session session = null;
454 
455         try {
456             session = openSession();
457 
458             UserTrackerPath[] array = new UserTrackerPathImpl[3];
459 
460             array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
461                     userTrackerId, orderByComparator, true);
462 
463             array[1] = userTrackerPath;
464 
465             array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
466                     userTrackerId, orderByComparator, false);
467 
468             return array;
469         }
470         catch (Exception e) {
471             throw processException(e);
472         }
473         finally {
474             closeSession(session);
475         }
476     }
477 
478     protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
479         UserTrackerPath userTrackerPath, long userTrackerId,
480         OrderByComparator orderByComparator, boolean previous) {
481         StringBundler query = null;
482 
483         if (orderByComparator != null) {
484             query = new StringBundler(6 +
485                     (orderByComparator.getOrderByFields().length * 6));
486         }
487         else {
488             query = new StringBundler(3);
489         }
490 
491         query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
492 
493         query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
494 
495         if (orderByComparator != null) {
496             String[] orderByFields = orderByComparator.getOrderByFields();
497 
498             if (orderByFields.length > 0) {
499                 query.append(WHERE_AND);
500             }
501 
502             for (int i = 0; i < orderByFields.length; i++) {
503                 query.append(_ORDER_BY_ENTITY_ALIAS);
504                 query.append(orderByFields[i]);
505 
506                 if ((i + 1) < orderByFields.length) {
507                     if (orderByComparator.isAscending() ^ previous) {
508                         query.append(WHERE_GREATER_THAN_HAS_NEXT);
509                     }
510                     else {
511                         query.append(WHERE_LESSER_THAN_HAS_NEXT);
512                     }
513                 }
514                 else {
515                     if (orderByComparator.isAscending() ^ previous) {
516                         query.append(WHERE_GREATER_THAN);
517                     }
518                     else {
519                         query.append(WHERE_LESSER_THAN);
520                     }
521                 }
522             }
523 
524             query.append(ORDER_BY_CLAUSE);
525 
526             for (int i = 0; i < orderByFields.length; i++) {
527                 query.append(_ORDER_BY_ENTITY_ALIAS);
528                 query.append(orderByFields[i]);
529 
530                 if ((i + 1) < orderByFields.length) {
531                     if (orderByComparator.isAscending() ^ previous) {
532                         query.append(ORDER_BY_ASC_HAS_NEXT);
533                     }
534                     else {
535                         query.append(ORDER_BY_DESC_HAS_NEXT);
536                     }
537                 }
538                 else {
539                     if (orderByComparator.isAscending() ^ previous) {
540                         query.append(ORDER_BY_ASC);
541                     }
542                     else {
543                         query.append(ORDER_BY_DESC);
544                     }
545                 }
546             }
547         }
548 
549         String sql = query.toString();
550 
551         Query q = session.createQuery(sql);
552 
553         q.setFirstResult(0);
554         q.setMaxResults(2);
555 
556         QueryPos qPos = QueryPos.getInstance(q);
557 
558         qPos.add(userTrackerId);
559 
560         if (orderByComparator != null) {
561             Object[] values = orderByComparator.getOrderByValues(userTrackerPath);
562 
563             for (Object value : values) {
564                 qPos.add(value);
565             }
566         }
567 
568         List<UserTrackerPath> list = q.list();
569 
570         if (list.size() == 2) {
571             return list.get(1);
572         }
573         else {
574             return null;
575         }
576     }
577 
578     public List<UserTrackerPath> findAll() throws SystemException {
579         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
580     }
581 
582     public List<UserTrackerPath> findAll(int start, int end)
583         throws SystemException {
584         return findAll(start, end, null);
585     }
586 
587     public List<UserTrackerPath> findAll(int start, int end,
588         OrderByComparator orderByComparator) throws SystemException {
589         Object[] finderArgs = new Object[] {
590                 String.valueOf(start), String.valueOf(end),
591                 String.valueOf(orderByComparator)
592             };
593 
594         List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
595                 finderArgs, this);
596 
597         if (list == null) {
598             Session session = null;
599 
600             try {
601                 session = openSession();
602 
603                 StringBundler query = null;
604                 String sql = null;
605 
606                 if (orderByComparator != null) {
607                     query = new StringBundler(2 +
608                             (orderByComparator.getOrderByFields().length * 3));
609 
610                     query.append(_SQL_SELECT_USERTRACKERPATH);
611 
612                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
613                         orderByComparator);
614 
615                     sql = query.toString();
616                 }
617 
618                 sql = _SQL_SELECT_USERTRACKERPATH;
619 
620                 Query q = session.createQuery(sql);
621 
622                 if (orderByComparator == null) {
623                     list = (List<UserTrackerPath>)QueryUtil.list(q,
624                             getDialect(), start, end, false);
625 
626                     Collections.sort(list);
627                 }
628                 else {
629                     list = (List<UserTrackerPath>)QueryUtil.list(q,
630                             getDialect(), start, end);
631                 }
632             }
633             catch (Exception e) {
634                 throw processException(e);
635             }
636             finally {
637                 if (list == null) {
638                     list = new ArrayList<UserTrackerPath>();
639                 }
640 
641                 cacheResult(list);
642 
643                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
644 
645                 closeSession(session);
646             }
647         }
648 
649         return list;
650     }
651 
652     public void removeByUserTrackerId(long userTrackerId)
653         throws SystemException {
654         for (UserTrackerPath userTrackerPath : findByUserTrackerId(
655                 userTrackerId)) {
656             remove(userTrackerPath);
657         }
658     }
659 
660     public void removeAll() throws SystemException {
661         for (UserTrackerPath userTrackerPath : findAll()) {
662             remove(userTrackerPath);
663         }
664     }
665 
666     public int countByUserTrackerId(long userTrackerId)
667         throws SystemException {
668         Object[] finderArgs = new Object[] { new Long(userTrackerId) };
669 
670         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
671                 finderArgs, this);
672 
673         if (count == null) {
674             Session session = null;
675 
676             try {
677                 session = openSession();
678 
679                 StringBundler query = new StringBundler(2);
680 
681                 query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
682 
683                 query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
684 
685                 String sql = query.toString();
686 
687                 Query q = session.createQuery(sql);
688 
689                 QueryPos qPos = QueryPos.getInstance(q);
690 
691                 qPos.add(userTrackerId);
692 
693                 count = (Long)q.uniqueResult();
694             }
695             catch (Exception e) {
696                 throw processException(e);
697             }
698             finally {
699                 if (count == null) {
700                     count = Long.valueOf(0);
701                 }
702 
703                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
704                     finderArgs, count);
705 
706                 closeSession(session);
707             }
708         }
709 
710         return count.intValue();
711     }
712 
713     public int countAll() throws SystemException {
714         Object[] finderArgs = new Object[0];
715 
716         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
717                 finderArgs, this);
718 
719         if (count == null) {
720             Session session = null;
721 
722             try {
723                 session = openSession();
724 
725                 Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
726 
727                 count = (Long)q.uniqueResult();
728             }
729             catch (Exception e) {
730                 throw processException(e);
731             }
732             finally {
733                 if (count == null) {
734                     count = Long.valueOf(0);
735                 }
736 
737                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
738                     count);
739 
740                 closeSession(session);
741             }
742         }
743 
744         return count.intValue();
745     }
746 
747     public void afterPropertiesSet() {
748         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
749                     com.liferay.portal.util.PropsUtil.get(
750                         "value.object.listener.com.liferay.portal.model.UserTrackerPath")));
751 
752         if (listenerClassNames.length > 0) {
753             try {
754                 List<ModelListener<UserTrackerPath>> listenersList = new ArrayList<ModelListener<UserTrackerPath>>();
755 
756                 for (String listenerClassName : listenerClassNames) {
757                     listenersList.add((ModelListener<UserTrackerPath>)InstanceFactory.newInstance(
758                             listenerClassName));
759                 }
760 
761                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
762             }
763             catch (Exception e) {
764                 _log.error(e);
765             }
766         }
767     }
768 
769     @BeanReference(type = AccountPersistence.class)
770     protected AccountPersistence accountPersistence;
771     @BeanReference(type = AddressPersistence.class)
772     protected AddressPersistence addressPersistence;
773     @BeanReference(type = BrowserTrackerPersistence.class)
774     protected BrowserTrackerPersistence browserTrackerPersistence;
775     @BeanReference(type = ClassNamePersistence.class)
776     protected ClassNamePersistence classNamePersistence;
777     @BeanReference(type = CompanyPersistence.class)
778     protected CompanyPersistence companyPersistence;
779     @BeanReference(type = ContactPersistence.class)
780     protected ContactPersistence contactPersistence;
781     @BeanReference(type = CountryPersistence.class)
782     protected CountryPersistence countryPersistence;
783     @BeanReference(type = EmailAddressPersistence.class)
784     protected EmailAddressPersistence emailAddressPersistence;
785     @BeanReference(type = GroupPersistence.class)
786     protected GroupPersistence groupPersistence;
787     @BeanReference(type = ImagePersistence.class)
788     protected ImagePersistence imagePersistence;
789     @BeanReference(type = LayoutPersistence.class)
790     protected LayoutPersistence layoutPersistence;
791     @BeanReference(type = LayoutPrototypePersistence.class)
792     protected LayoutPrototypePersistence layoutPrototypePersistence;
793     @BeanReference(type = LayoutSetPersistence.class)
794     protected LayoutSetPersistence layoutSetPersistence;
795     @BeanReference(type = LayoutSetPrototypePersistence.class)
796     protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
797     @BeanReference(type = ListTypePersistence.class)
798     protected ListTypePersistence listTypePersistence;
799     @BeanReference(type = LockPersistence.class)
800     protected LockPersistence lockPersistence;
801     @BeanReference(type = MembershipRequestPersistence.class)
802     protected MembershipRequestPersistence membershipRequestPersistence;
803     @BeanReference(type = OrganizationPersistence.class)
804     protected OrganizationPersistence organizationPersistence;
805     @BeanReference(type = OrgGroupPermissionPersistence.class)
806     protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
807     @BeanReference(type = OrgGroupRolePersistence.class)
808     protected OrgGroupRolePersistence orgGroupRolePersistence;
809     @BeanReference(type = OrgLaborPersistence.class)
810     protected OrgLaborPersistence orgLaborPersistence;
811     @BeanReference(type = PasswordPolicyPersistence.class)
812     protected PasswordPolicyPersistence passwordPolicyPersistence;
813     @BeanReference(type = PasswordPolicyRelPersistence.class)
814     protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
815     @BeanReference(type = PasswordTrackerPersistence.class)
816     protected PasswordTrackerPersistence passwordTrackerPersistence;
817     @BeanReference(type = PermissionPersistence.class)
818     protected PermissionPersistence permissionPersistence;
819     @BeanReference(type = PhonePersistence.class)
820     protected PhonePersistence phonePersistence;
821     @BeanReference(type = PluginSettingPersistence.class)
822     protected PluginSettingPersistence pluginSettingPersistence;
823     @BeanReference(type = PortletPersistence.class)
824     protected PortletPersistence portletPersistence;
825     @BeanReference(type = PortletItemPersistence.class)
826     protected PortletItemPersistence portletItemPersistence;
827     @BeanReference(type = PortletPreferencesPersistence.class)
828     protected PortletPreferencesPersistence portletPreferencesPersistence;
829     @BeanReference(type = RegionPersistence.class)
830     protected RegionPersistence regionPersistence;
831     @BeanReference(type = ReleasePersistence.class)
832     protected ReleasePersistence releasePersistence;
833     @BeanReference(type = ResourcePersistence.class)
834     protected ResourcePersistence resourcePersistence;
835     @BeanReference(type = ResourceActionPersistence.class)
836     protected ResourceActionPersistence resourceActionPersistence;
837     @BeanReference(type = ResourceCodePersistence.class)
838     protected ResourceCodePersistence resourceCodePersistence;
839     @BeanReference(type = ResourcePermissionPersistence.class)
840     protected ResourcePermissionPersistence resourcePermissionPersistence;
841     @BeanReference(type = RolePersistence.class)
842     protected RolePersistence rolePersistence;
843     @BeanReference(type = ServiceComponentPersistence.class)
844     protected ServiceComponentPersistence serviceComponentPersistence;
845     @BeanReference(type = ShardPersistence.class)
846     protected ShardPersistence shardPersistence;
847     @BeanReference(type = SubscriptionPersistence.class)
848     protected SubscriptionPersistence subscriptionPersistence;
849     @BeanReference(type = TicketPersistence.class)
850     protected TicketPersistence ticketPersistence;
851     @BeanReference(type = TeamPersistence.class)
852     protected TeamPersistence teamPersistence;
853     @BeanReference(type = UserPersistence.class)
854     protected UserPersistence userPersistence;
855     @BeanReference(type = UserGroupPersistence.class)
856     protected UserGroupPersistence userGroupPersistence;
857     @BeanReference(type = UserGroupGroupRolePersistence.class)
858     protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
859     @BeanReference(type = UserGroupRolePersistence.class)
860     protected UserGroupRolePersistence userGroupRolePersistence;
861     @BeanReference(type = UserIdMapperPersistence.class)
862     protected UserIdMapperPersistence userIdMapperPersistence;
863     @BeanReference(type = UserTrackerPersistence.class)
864     protected UserTrackerPersistence userTrackerPersistence;
865     @BeanReference(type = UserTrackerPathPersistence.class)
866     protected UserTrackerPathPersistence userTrackerPathPersistence;
867     @BeanReference(type = WebDAVPropsPersistence.class)
868     protected WebDAVPropsPersistence webDAVPropsPersistence;
869     @BeanReference(type = WebsitePersistence.class)
870     protected WebsitePersistence websitePersistence;
871     @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
872     protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
873     @BeanReference(type = WorkflowInstanceLinkPersistence.class)
874     protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
875     private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
876     private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
877     private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
878     private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
879     private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
880     private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
881     private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
882     private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
883     private static Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
884 }