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