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