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