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