001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchUserTrackerPathException;
019    import com.liferay.portal.kernel.annotation.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.model.UserTrackerPath;
039    import com.liferay.portal.model.impl.UserTrackerPathImpl;
040    import com.liferay.portal.model.impl.UserTrackerPathModelImpl;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import java.io.Serializable;
044    
045    import java.util.ArrayList;
046    import java.util.Collections;
047    import java.util.List;
048    
049    /**
050     * The persistence implementation for the user tracker path service.
051     *
052     * <p>
053     * Never modify or reference this class directly. Always use {@link UserTrackerPathUtil} to access the user tracker path persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
054     * </p>
055     *
056     * <p>
057     * Caching information and settings can be found in <code>portal.properties</code>
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see UserTrackerPathPersistence
062     * @see UserTrackerPathUtil
063     * @generated
064     */
065    public class UserTrackerPathPersistenceImpl extends BasePersistenceImpl<UserTrackerPath>
066            implements UserTrackerPathPersistence {
067            public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerPathImpl.class.getName();
068            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
069                    ".List";
070            public static final FinderPath FINDER_PATH_FIND_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
071                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
072                            FINDER_CLASS_NAME_LIST, "findByUserTrackerId",
073                            new String[] {
074                                    Long.class.getName(),
075                                    
076                            "java.lang.Integer", "java.lang.Integer",
077                                    "com.liferay.portal.kernel.util.OrderByComparator"
078                            });
079            public static final FinderPath FINDER_PATH_COUNT_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
080                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
081                            FINDER_CLASS_NAME_LIST, "countByUserTrackerId",
082                            new String[] { Long.class.getName() });
083            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
084                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
085                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
086            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
087                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
088                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
089    
090            /**
091             * Caches the user tracker path in the entity cache if it is enabled.
092             *
093             * @param userTrackerPath the user tracker path to cache
094             */
095            public void cacheResult(UserTrackerPath userTrackerPath) {
096                    EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
097                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
098                            userTrackerPath);
099            }
100    
101            /**
102             * Caches the user tracker paths in the entity cache if it is enabled.
103             *
104             * @param userTrackerPaths the user tracker paths to cache
105             */
106            public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
107                    for (UserTrackerPath userTrackerPath : userTrackerPaths) {
108                            if (EntityCacheUtil.getResult(
109                                                    UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
110                                                    UserTrackerPathImpl.class,
111                                                    userTrackerPath.getPrimaryKey(), this) == null) {
112                                    cacheResult(userTrackerPath);
113                            }
114                    }
115            }
116    
117            /**
118             * Clears the cache for all user tracker paths.
119             *
120             * <p>
121             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
122             * </p>
123             */
124            public void clearCache() {
125                    CacheRegistryUtil.clear(UserTrackerPathImpl.class.getName());
126                    EntityCacheUtil.clearCache(UserTrackerPathImpl.class.getName());
127                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
128                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
129            }
130    
131            /**
132             * Clears the cache for the user tracker path.
133             *
134             * <p>
135             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
136             * </p>
137             */
138            public void clearCache(UserTrackerPath userTrackerPath) {
139                    EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
140                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
141            }
142    
143            /**
144             * Creates a new user tracker path with the primary key. Does not add the user tracker path to the database.
145             *
146             * @param userTrackerPathId the primary key for the new user tracker path
147             * @return the new user tracker path
148             */
149            public UserTrackerPath create(long userTrackerPathId) {
150                    UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
151    
152                    userTrackerPath.setNew(true);
153                    userTrackerPath.setPrimaryKey(userTrackerPathId);
154    
155                    return userTrackerPath;
156            }
157    
158            /**
159             * Removes the user tracker path with the primary key from the database. Also notifies the appropriate model listeners.
160             *
161             * @param primaryKey the primary key of the user tracker path to remove
162             * @return the user tracker path that was removed
163             * @throws com.liferay.portal.NoSuchModelException if a user tracker path with the primary key could not be found
164             * @throws SystemException if a system exception occurred
165             */
166            public UserTrackerPath remove(Serializable primaryKey)
167                    throws NoSuchModelException, SystemException {
168                    return remove(((Long)primaryKey).longValue());
169            }
170    
171            /**
172             * Removes the user tracker path with the primary key from the database. Also notifies the appropriate model listeners.
173             *
174             * @param userTrackerPathId the primary key of the user tracker path to remove
175             * @return the user tracker path that was removed
176             * @throws com.liferay.portal.NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
177             * @throws SystemException if a system exception occurred
178             */
179            public UserTrackerPath remove(long userTrackerPathId)
180                    throws NoSuchUserTrackerPathException, SystemException {
181                    Session session = null;
182    
183                    try {
184                            session = openSession();
185    
186                            UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
187                                            new Long(userTrackerPathId));
188    
189                            if (userTrackerPath == null) {
190                                    if (_log.isWarnEnabled()) {
191                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
192                                                    userTrackerPathId);
193                                    }
194    
195                                    throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
196                                            userTrackerPathId);
197                            }
198    
199                            return remove(userTrackerPath);
200                    }
201                    catch (NoSuchUserTrackerPathException nsee) {
202                            throw nsee;
203                    }
204                    catch (Exception e) {
205                            throw processException(e);
206                    }
207                    finally {
208                            closeSession(session);
209                    }
210            }
211    
212            protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath)
213                    throws SystemException {
214                    userTrackerPath = toUnwrappedModel(userTrackerPath);
215    
216                    Session session = null;
217    
218                    try {
219                            session = openSession();
220    
221                            if (userTrackerPath.isCachedModel() ||
222                                            BatchSessionUtil.isEnabled()) {
223                                    Object staleObject = session.get(UserTrackerPathImpl.class,
224                                                    userTrackerPath.getPrimaryKeyObj());
225    
226                                    if (staleObject != null) {
227                                            session.evict(staleObject);
228                                    }
229                            }
230    
231                            session.delete(userTrackerPath);
232    
233                            session.flush();
234                    }
235                    catch (Exception e) {
236                            throw processException(e);
237                    }
238                    finally {
239                            closeSession(session);
240                    }
241    
242                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
243    
244                    EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
245                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
246    
247                    return userTrackerPath;
248            }
249    
250            public UserTrackerPath updateImpl(
251                    com.liferay.portal.model.UserTrackerPath userTrackerPath, boolean merge)
252                    throws SystemException {
253                    userTrackerPath = toUnwrappedModel(userTrackerPath);
254    
255                    Session session = null;
256    
257                    try {
258                            session = openSession();
259    
260                            BatchSessionUtil.update(session, userTrackerPath, merge);
261    
262                            userTrackerPath.setNew(false);
263                    }
264                    catch (Exception e) {
265                            throw processException(e);
266                    }
267                    finally {
268                            closeSession(session);
269                    }
270    
271                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
272    
273                    EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
274                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
275                            userTrackerPath);
276    
277                    return userTrackerPath;
278            }
279    
280            protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
281                    if (userTrackerPath instanceof UserTrackerPathImpl) {
282                            return userTrackerPath;
283                    }
284    
285                    UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
286    
287                    userTrackerPathImpl.setNew(userTrackerPath.isNew());
288                    userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
289    
290                    userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
291                    userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
292                    userTrackerPathImpl.setPath(userTrackerPath.getPath());
293                    userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
294    
295                    return userTrackerPathImpl;
296            }
297    
298            /**
299             * Finds the user tracker path with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
300             *
301             * @param primaryKey the primary key of the user tracker path to find
302             * @return the user tracker path
303             * @throws com.liferay.portal.NoSuchModelException if a user tracker path with the primary key could not be found
304             * @throws SystemException if a system exception occurred
305             */
306            public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
307                    throws NoSuchModelException, SystemException {
308                    return findByPrimaryKey(((Long)primaryKey).longValue());
309            }
310    
311            /**
312             * Finds the user tracker path with the primary key or throws a {@link com.liferay.portal.NoSuchUserTrackerPathException} if it could not be found.
313             *
314             * @param userTrackerPathId the primary key of the user tracker path to find
315             * @return the user tracker path
316             * @throws com.liferay.portal.NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
317             * @throws SystemException if a system exception occurred
318             */
319            public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
320                    throws NoSuchUserTrackerPathException, SystemException {
321                    UserTrackerPath userTrackerPath = fetchByPrimaryKey(userTrackerPathId);
322    
323                    if (userTrackerPath == null) {
324                            if (_log.isWarnEnabled()) {
325                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userTrackerPathId);
326                            }
327    
328                            throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
329                                    userTrackerPathId);
330                    }
331    
332                    return userTrackerPath;
333            }
334    
335            /**
336             * Finds the user tracker path with the primary key or returns <code>null</code> if it could not be found.
337             *
338             * @param primaryKey the primary key of the user tracker path to find
339             * @return the user tracker path, or <code>null</code> if a user tracker path with the primary key could not be found
340             * @throws SystemException if a system exception occurred
341             */
342            public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey)
343                    throws SystemException {
344                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
345            }
346    
347            /**
348             * Finds the user tracker path with the primary key or returns <code>null</code> if it could not be found.
349             *
350             * @param userTrackerPathId the primary key of the user tracker path to find
351             * @return the user tracker path, or <code>null</code> if a user tracker path with the primary key could not be found
352             * @throws SystemException if a system exception occurred
353             */
354            public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId)
355                    throws SystemException {
356                    UserTrackerPath userTrackerPath = (UserTrackerPath)EntityCacheUtil.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
357                                    UserTrackerPathImpl.class, userTrackerPathId, this);
358    
359                    if (userTrackerPath == null) {
360                            Session session = null;
361    
362                            try {
363                                    session = openSession();
364    
365                                    userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
366                                                    new Long(userTrackerPathId));
367                            }
368                            catch (Exception e) {
369                                    throw processException(e);
370                            }
371                            finally {
372                                    if (userTrackerPath != null) {
373                                            cacheResult(userTrackerPath);
374                                    }
375    
376                                    closeSession(session);
377                            }
378                    }
379    
380                    return userTrackerPath;
381            }
382    
383            /**
384             * Finds all the user tracker paths where userTrackerId = &#63;.
385             *
386             * @param userTrackerId the user tracker id to search with
387             * @return the matching user tracker paths
388             * @throws SystemException if a system exception occurred
389             */
390            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId)
391                    throws SystemException {
392                    return findByUserTrackerId(userTrackerId, QueryUtil.ALL_POS,
393                            QueryUtil.ALL_POS, null);
394            }
395    
396            /**
397             * Finds a range of all the user tracker paths where userTrackerId = &#63;.
398             *
399             * <p>
400             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
401             * </p>
402             *
403             * @param userTrackerId the user tracker id to search with
404             * @param start the lower bound of the range of user tracker paths to return
405             * @param end the upper bound of the range of user tracker paths to return (not inclusive)
406             * @return the range of matching user tracker paths
407             * @throws SystemException if a system exception occurred
408             */
409            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
410                    int start, int end) throws SystemException {
411                    return findByUserTrackerId(userTrackerId, start, end, null);
412            }
413    
414            /**
415             * Finds an ordered range of all the user tracker paths where userTrackerId = &#63;.
416             *
417             * <p>
418             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
419             * </p>
420             *
421             * @param userTrackerId the user tracker id to search with
422             * @param start the lower bound of the range of user tracker paths to return
423             * @param end the upper bound of the range of user tracker paths to return (not inclusive)
424             * @param orderByComparator the comparator to order the results by
425             * @return the ordered range of matching user tracker paths
426             * @throws SystemException if a system exception occurred
427             */
428            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
429                    int start, int end, OrderByComparator orderByComparator)
430                    throws SystemException {
431                    Object[] finderArgs = new Object[] {
432                                    userTrackerId,
433                                    
434                                    String.valueOf(start), String.valueOf(end),
435                                    String.valueOf(orderByComparator)
436                            };
437    
438                    List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERTRACKERID,
439                                    finderArgs, this);
440    
441                    if (list == null) {
442                            Session session = null;
443    
444                            try {
445                                    session = openSession();
446    
447                                    StringBundler query = null;
448    
449                                    if (orderByComparator != null) {
450                                            query = new StringBundler(3 +
451                                                            (orderByComparator.getOrderByFields().length * 3));
452                                    }
453                                    else {
454                                            query = new StringBundler(2);
455                                    }
456    
457                                    query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
458    
459                                    query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
460    
461                                    if (orderByComparator != null) {
462                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
463                                                    orderByComparator);
464                                    }
465    
466                                    String sql = query.toString();
467    
468                                    Query q = session.createQuery(sql);
469    
470                                    QueryPos qPos = QueryPos.getInstance(q);
471    
472                                    qPos.add(userTrackerId);
473    
474                                    list = (List<UserTrackerPath>)QueryUtil.list(q, getDialect(),
475                                                    start, end);
476                            }
477                            catch (Exception e) {
478                                    throw processException(e);
479                            }
480                            finally {
481                                    if (list == null) {
482                                            list = new ArrayList<UserTrackerPath>();
483                                    }
484    
485                                    cacheResult(list);
486    
487                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERTRACKERID,
488                                            finderArgs, list);
489    
490                                    closeSession(session);
491                            }
492                    }
493    
494                    return list;
495            }
496    
497            /**
498             * Finds the first user tracker path in the ordered set where userTrackerId = &#63;.
499             *
500             * <p>
501             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
502             * </p>
503             *
504             * @param userTrackerId the user tracker id to search with
505             * @param orderByComparator the comparator to order the set by
506             * @return the first matching user tracker path
507             * @throws com.liferay.portal.NoSuchUserTrackerPathException if a matching user tracker path could not be found
508             * @throws SystemException if a system exception occurred
509             */
510            public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
511                    OrderByComparator orderByComparator)
512                    throws NoSuchUserTrackerPathException, SystemException {
513                    List<UserTrackerPath> list = findByUserTrackerId(userTrackerId, 0, 1,
514                                    orderByComparator);
515    
516                    if (list.isEmpty()) {
517                            StringBundler msg = new StringBundler(4);
518    
519                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
520    
521                            msg.append("userTrackerId=");
522                            msg.append(userTrackerId);
523    
524                            msg.append(StringPool.CLOSE_CURLY_BRACE);
525    
526                            throw new NoSuchUserTrackerPathException(msg.toString());
527                    }
528                    else {
529                            return list.get(0);
530                    }
531            }
532    
533            /**
534             * Finds the last user tracker path in the ordered set where userTrackerId = &#63;.
535             *
536             * <p>
537             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
538             * </p>
539             *
540             * @param userTrackerId the user tracker id to search with
541             * @param orderByComparator the comparator to order the set by
542             * @return the last matching user tracker path
543             * @throws com.liferay.portal.NoSuchUserTrackerPathException if a matching user tracker path could not be found
544             * @throws SystemException if a system exception occurred
545             */
546            public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
547                    OrderByComparator orderByComparator)
548                    throws NoSuchUserTrackerPathException, SystemException {
549                    int count = countByUserTrackerId(userTrackerId);
550    
551                    List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
552                                    count - 1, count, orderByComparator);
553    
554                    if (list.isEmpty()) {
555                            StringBundler msg = new StringBundler(4);
556    
557                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
558    
559                            msg.append("userTrackerId=");
560                            msg.append(userTrackerId);
561    
562                            msg.append(StringPool.CLOSE_CURLY_BRACE);
563    
564                            throw new NoSuchUserTrackerPathException(msg.toString());
565                    }
566                    else {
567                            return list.get(0);
568                    }
569            }
570    
571            /**
572             * Finds the user tracker paths before and after the current user tracker path in the ordered set where userTrackerId = &#63;.
573             *
574             * <p>
575             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
576             * </p>
577             *
578             * @param userTrackerPathId the primary key of the current user tracker path
579             * @param userTrackerId the user tracker id to search with
580             * @param orderByComparator the comparator to order the set by
581             * @return the previous, current, and next user tracker path
582             * @throws com.liferay.portal.NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
583             * @throws SystemException if a system exception occurred
584             */
585            public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
586                    long userTrackerPathId, long userTrackerId,
587                    OrderByComparator orderByComparator)
588                    throws NoSuchUserTrackerPathException, SystemException {
589                    UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
590    
591                    Session session = null;
592    
593                    try {
594                            session = openSession();
595    
596                            UserTrackerPath[] array = new UserTrackerPathImpl[3];
597    
598                            array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
599                                            userTrackerId, orderByComparator, true);
600    
601                            array[1] = userTrackerPath;
602    
603                            array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
604                                            userTrackerId, orderByComparator, false);
605    
606                            return array;
607                    }
608                    catch (Exception e) {
609                            throw processException(e);
610                    }
611                    finally {
612                            closeSession(session);
613                    }
614            }
615    
616            protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
617                    UserTrackerPath userTrackerPath, long userTrackerId,
618                    OrderByComparator orderByComparator, boolean previous) {
619                    StringBundler query = null;
620    
621                    if (orderByComparator != null) {
622                            query = new StringBundler(6 +
623                                            (orderByComparator.getOrderByFields().length * 6));
624                    }
625                    else {
626                            query = new StringBundler(3);
627                    }
628    
629                    query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
630    
631                    query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
632    
633                    if (orderByComparator != null) {
634                            String[] orderByFields = orderByComparator.getOrderByFields();
635    
636                            if (orderByFields.length > 0) {
637                                    query.append(WHERE_AND);
638                            }
639    
640                            for (int i = 0; i < orderByFields.length; i++) {
641                                    query.append(_ORDER_BY_ENTITY_ALIAS);
642                                    query.append(orderByFields[i]);
643    
644                                    if ((i + 1) < orderByFields.length) {
645                                            if (orderByComparator.isAscending() ^ previous) {
646                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
647                                            }
648                                            else {
649                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
650                                            }
651                                    }
652                                    else {
653                                            if (orderByComparator.isAscending() ^ previous) {
654                                                    query.append(WHERE_GREATER_THAN);
655                                            }
656                                            else {
657                                                    query.append(WHERE_LESSER_THAN);
658                                            }
659                                    }
660                            }
661    
662                            query.append(ORDER_BY_CLAUSE);
663    
664                            for (int i = 0; i < orderByFields.length; i++) {
665                                    query.append(_ORDER_BY_ENTITY_ALIAS);
666                                    query.append(orderByFields[i]);
667    
668                                    if ((i + 1) < orderByFields.length) {
669                                            if (orderByComparator.isAscending() ^ previous) {
670                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
671                                            }
672                                            else {
673                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
674                                            }
675                                    }
676                                    else {
677                                            if (orderByComparator.isAscending() ^ previous) {
678                                                    query.append(ORDER_BY_ASC);
679                                            }
680                                            else {
681                                                    query.append(ORDER_BY_DESC);
682                                            }
683                                    }
684                            }
685                    }
686    
687                    String sql = query.toString();
688    
689                    Query q = session.createQuery(sql);
690    
691                    q.setFirstResult(0);
692                    q.setMaxResults(2);
693    
694                    QueryPos qPos = QueryPos.getInstance(q);
695    
696                    qPos.add(userTrackerId);
697    
698                    if (orderByComparator != null) {
699                            Object[] values = orderByComparator.getOrderByValues(userTrackerPath);
700    
701                            for (Object value : values) {
702                                    qPos.add(value);
703                            }
704                    }
705    
706                    List<UserTrackerPath> list = q.list();
707    
708                    if (list.size() == 2) {
709                            return list.get(1);
710                    }
711                    else {
712                            return null;
713                    }
714            }
715    
716            /**
717             * Finds all the user tracker paths.
718             *
719             * @return the user tracker paths
720             * @throws SystemException if a system exception occurred
721             */
722            public List<UserTrackerPath> findAll() throws SystemException {
723                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
724            }
725    
726            /**
727             * Finds a range of all the user tracker paths.
728             *
729             * <p>
730             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
731             * </p>
732             *
733             * @param start the lower bound of the range of user tracker paths to return
734             * @param end the upper bound of the range of user tracker paths to return (not inclusive)
735             * @return the range of user tracker paths
736             * @throws SystemException if a system exception occurred
737             */
738            public List<UserTrackerPath> findAll(int start, int end)
739                    throws SystemException {
740                    return findAll(start, end, null);
741            }
742    
743            /**
744             * Finds an ordered range of all the user tracker paths.
745             *
746             * <p>
747             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
748             * </p>
749             *
750             * @param start the lower bound of the range of user tracker paths to return
751             * @param end the upper bound of the range of user tracker paths to return (not inclusive)
752             * @param orderByComparator the comparator to order the results by
753             * @return the ordered range of user tracker paths
754             * @throws SystemException if a system exception occurred
755             */
756            public List<UserTrackerPath> findAll(int start, int end,
757                    OrderByComparator orderByComparator) throws SystemException {
758                    Object[] finderArgs = new Object[] {
759                                    String.valueOf(start), String.valueOf(end),
760                                    String.valueOf(orderByComparator)
761                            };
762    
763                    List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
764                                    finderArgs, this);
765    
766                    if (list == null) {
767                            Session session = null;
768    
769                            try {
770                                    session = openSession();
771    
772                                    StringBundler query = null;
773                                    String sql = null;
774    
775                                    if (orderByComparator != null) {
776                                            query = new StringBundler(2 +
777                                                            (orderByComparator.getOrderByFields().length * 3));
778    
779                                            query.append(_SQL_SELECT_USERTRACKERPATH);
780    
781                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
782                                                    orderByComparator);
783    
784                                            sql = query.toString();
785                                    }
786                                    else {
787                                            sql = _SQL_SELECT_USERTRACKERPATH;
788                                    }
789    
790                                    Query q = session.createQuery(sql);
791    
792                                    if (orderByComparator == null) {
793                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
794                                                            getDialect(), start, end, false);
795    
796                                            Collections.sort(list);
797                                    }
798                                    else {
799                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
800                                                            getDialect(), start, end);
801                                    }
802                            }
803                            catch (Exception e) {
804                                    throw processException(e);
805                            }
806                            finally {
807                                    if (list == null) {
808                                            list = new ArrayList<UserTrackerPath>();
809                                    }
810    
811                                    cacheResult(list);
812    
813                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
814    
815                                    closeSession(session);
816                            }
817                    }
818    
819                    return list;
820            }
821    
822            /**
823             * Removes all the user tracker paths where userTrackerId = &#63; from the database.
824             *
825             * @param userTrackerId the user tracker id to search with
826             * @throws SystemException if a system exception occurred
827             */
828            public void removeByUserTrackerId(long userTrackerId)
829                    throws SystemException {
830                    for (UserTrackerPath userTrackerPath : findByUserTrackerId(
831                                    userTrackerId)) {
832                            remove(userTrackerPath);
833                    }
834            }
835    
836            /**
837             * Removes all the user tracker paths from the database.
838             *
839             * @throws SystemException if a system exception occurred
840             */
841            public void removeAll() throws SystemException {
842                    for (UserTrackerPath userTrackerPath : findAll()) {
843                            remove(userTrackerPath);
844                    }
845            }
846    
847            /**
848             * Counts all the user tracker paths where userTrackerId = &#63;.
849             *
850             * @param userTrackerId the user tracker id to search with
851             * @return the number of matching user tracker paths
852             * @throws SystemException if a system exception occurred
853             */
854            public int countByUserTrackerId(long userTrackerId)
855                    throws SystemException {
856                    Object[] finderArgs = new Object[] { userTrackerId };
857    
858                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
859                                    finderArgs, this);
860    
861                    if (count == null) {
862                            Session session = null;
863    
864                            try {
865                                    session = openSession();
866    
867                                    StringBundler query = new StringBundler(2);
868    
869                                    query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
870    
871                                    query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
872    
873                                    String sql = query.toString();
874    
875                                    Query q = session.createQuery(sql);
876    
877                                    QueryPos qPos = QueryPos.getInstance(q);
878    
879                                    qPos.add(userTrackerId);
880    
881                                    count = (Long)q.uniqueResult();
882                            }
883                            catch (Exception e) {
884                                    throw processException(e);
885                            }
886                            finally {
887                                    if (count == null) {
888                                            count = Long.valueOf(0);
889                                    }
890    
891                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
892                                            finderArgs, count);
893    
894                                    closeSession(session);
895                            }
896                    }
897    
898                    return count.intValue();
899            }
900    
901            /**
902             * Counts all the user tracker paths.
903             *
904             * @return the number of user tracker paths
905             * @throws SystemException if a system exception occurred
906             */
907            public int countAll() throws SystemException {
908                    Object[] finderArgs = new Object[0];
909    
910                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
911                                    finderArgs, this);
912    
913                    if (count == null) {
914                            Session session = null;
915    
916                            try {
917                                    session = openSession();
918    
919                                    Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
920    
921                                    count = (Long)q.uniqueResult();
922                            }
923                            catch (Exception e) {
924                                    throw processException(e);
925                            }
926                            finally {
927                                    if (count == null) {
928                                            count = Long.valueOf(0);
929                                    }
930    
931                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
932                                            count);
933    
934                                    closeSession(session);
935                            }
936                    }
937    
938                    return count.intValue();
939            }
940    
941            /**
942             * Initializes the user tracker path persistence.
943             */
944            public void afterPropertiesSet() {
945                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
946                                            com.liferay.portal.util.PropsUtil.get(
947                                                    "value.object.listener.com.liferay.portal.model.UserTrackerPath")));
948    
949                    if (listenerClassNames.length > 0) {
950                            try {
951                                    List<ModelListener<UserTrackerPath>> listenersList = new ArrayList<ModelListener<UserTrackerPath>>();
952    
953                                    for (String listenerClassName : listenerClassNames) {
954                                            listenersList.add((ModelListener<UserTrackerPath>)InstanceFactory.newInstance(
955                                                            listenerClassName));
956                                    }
957    
958                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
959                            }
960                            catch (Exception e) {
961                                    _log.error(e);
962                            }
963                    }
964            }
965    
966            @BeanReference(type = AccountPersistence.class)
967            protected AccountPersistence accountPersistence;
968            @BeanReference(type = AddressPersistence.class)
969            protected AddressPersistence addressPersistence;
970            @BeanReference(type = BrowserTrackerPersistence.class)
971            protected BrowserTrackerPersistence browserTrackerPersistence;
972            @BeanReference(type = ClassNamePersistence.class)
973            protected ClassNamePersistence classNamePersistence;
974            @BeanReference(type = ClusterGroupPersistence.class)
975            protected ClusterGroupPersistence clusterGroupPersistence;
976            @BeanReference(type = CompanyPersistence.class)
977            protected CompanyPersistence companyPersistence;
978            @BeanReference(type = ContactPersistence.class)
979            protected ContactPersistence contactPersistence;
980            @BeanReference(type = CountryPersistence.class)
981            protected CountryPersistence countryPersistence;
982            @BeanReference(type = EmailAddressPersistence.class)
983            protected EmailAddressPersistence emailAddressPersistence;
984            @BeanReference(type = GroupPersistence.class)
985            protected GroupPersistence groupPersistence;
986            @BeanReference(type = ImagePersistence.class)
987            protected ImagePersistence imagePersistence;
988            @BeanReference(type = LayoutPersistence.class)
989            protected LayoutPersistence layoutPersistence;
990            @BeanReference(type = LayoutPrototypePersistence.class)
991            protected LayoutPrototypePersistence layoutPrototypePersistence;
992            @BeanReference(type = LayoutSetPersistence.class)
993            protected LayoutSetPersistence layoutSetPersistence;
994            @BeanReference(type = LayoutSetPrototypePersistence.class)
995            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
996            @BeanReference(type = ListTypePersistence.class)
997            protected ListTypePersistence listTypePersistence;
998            @BeanReference(type = LockPersistence.class)
999            protected LockPersistence lockPersistence;
1000            @BeanReference(type = MembershipRequestPersistence.class)
1001            protected MembershipRequestPersistence membershipRequestPersistence;
1002            @BeanReference(type = OrganizationPersistence.class)
1003            protected OrganizationPersistence organizationPersistence;
1004            @BeanReference(type = OrgGroupPermissionPersistence.class)
1005            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1006            @BeanReference(type = OrgGroupRolePersistence.class)
1007            protected OrgGroupRolePersistence orgGroupRolePersistence;
1008            @BeanReference(type = OrgLaborPersistence.class)
1009            protected OrgLaborPersistence orgLaborPersistence;
1010            @BeanReference(type = PasswordPolicyPersistence.class)
1011            protected PasswordPolicyPersistence passwordPolicyPersistence;
1012            @BeanReference(type = PasswordPolicyRelPersistence.class)
1013            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1014            @BeanReference(type = PasswordTrackerPersistence.class)
1015            protected PasswordTrackerPersistence passwordTrackerPersistence;
1016            @BeanReference(type = PermissionPersistence.class)
1017            protected PermissionPersistence permissionPersistence;
1018            @BeanReference(type = PhonePersistence.class)
1019            protected PhonePersistence phonePersistence;
1020            @BeanReference(type = PluginSettingPersistence.class)
1021            protected PluginSettingPersistence pluginSettingPersistence;
1022            @BeanReference(type = PortletPersistence.class)
1023            protected PortletPersistence portletPersistence;
1024            @BeanReference(type = PortletItemPersistence.class)
1025            protected PortletItemPersistence portletItemPersistence;
1026            @BeanReference(type = PortletPreferencesPersistence.class)
1027            protected PortletPreferencesPersistence portletPreferencesPersistence;
1028            @BeanReference(type = RegionPersistence.class)
1029            protected RegionPersistence regionPersistence;
1030            @BeanReference(type = ReleasePersistence.class)
1031            protected ReleasePersistence releasePersistence;
1032            @BeanReference(type = ResourcePersistence.class)
1033            protected ResourcePersistence resourcePersistence;
1034            @BeanReference(type = ResourceActionPersistence.class)
1035            protected ResourceActionPersistence resourceActionPersistence;
1036            @BeanReference(type = ResourceCodePersistence.class)
1037            protected ResourceCodePersistence resourceCodePersistence;
1038            @BeanReference(type = ResourcePermissionPersistence.class)
1039            protected ResourcePermissionPersistence resourcePermissionPersistence;
1040            @BeanReference(type = RolePersistence.class)
1041            protected RolePersistence rolePersistence;
1042            @BeanReference(type = ServiceComponentPersistence.class)
1043            protected ServiceComponentPersistence serviceComponentPersistence;
1044            @BeanReference(type = ShardPersistence.class)
1045            protected ShardPersistence shardPersistence;
1046            @BeanReference(type = SubscriptionPersistence.class)
1047            protected SubscriptionPersistence subscriptionPersistence;
1048            @BeanReference(type = TicketPersistence.class)
1049            protected TicketPersistence ticketPersistence;
1050            @BeanReference(type = TeamPersistence.class)
1051            protected TeamPersistence teamPersistence;
1052            @BeanReference(type = UserPersistence.class)
1053            protected UserPersistence userPersistence;
1054            @BeanReference(type = UserGroupPersistence.class)
1055            protected UserGroupPersistence userGroupPersistence;
1056            @BeanReference(type = UserGroupGroupRolePersistence.class)
1057            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1058            @BeanReference(type = UserGroupRolePersistence.class)
1059            protected UserGroupRolePersistence userGroupRolePersistence;
1060            @BeanReference(type = UserIdMapperPersistence.class)
1061            protected UserIdMapperPersistence userIdMapperPersistence;
1062            @BeanReference(type = UserTrackerPersistence.class)
1063            protected UserTrackerPersistence userTrackerPersistence;
1064            @BeanReference(type = UserTrackerPathPersistence.class)
1065            protected UserTrackerPathPersistence userTrackerPathPersistence;
1066            @BeanReference(type = WebDAVPropsPersistence.class)
1067            protected WebDAVPropsPersistence webDAVPropsPersistence;
1068            @BeanReference(type = WebsitePersistence.class)
1069            protected WebsitePersistence websitePersistence;
1070            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1071            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1072            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1073            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1074            private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1075            private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1076            private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1077            private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1078            private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
1079            private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1080            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1081            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1082            private static Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1083    }