001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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                            BatchSessionUtil.delete(session, userTrackerPath);
222                    }
223                    catch (Exception e) {
224                            throw processException(e);
225                    }
226                    finally {
227                            closeSession(session);
228                    }
229    
230                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
231    
232                    EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
233                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
234    
235                    return userTrackerPath;
236            }
237    
238            public UserTrackerPath updateImpl(
239                    com.liferay.portal.model.UserTrackerPath userTrackerPath, boolean merge)
240                    throws SystemException {
241                    userTrackerPath = toUnwrappedModel(userTrackerPath);
242    
243                    Session session = null;
244    
245                    try {
246                            session = openSession();
247    
248                            BatchSessionUtil.update(session, userTrackerPath, merge);
249    
250                            userTrackerPath.setNew(false);
251                    }
252                    catch (Exception e) {
253                            throw processException(e);
254                    }
255                    finally {
256                            closeSession(session);
257                    }
258    
259                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
260    
261                    EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
262                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
263                            userTrackerPath);
264    
265                    return userTrackerPath;
266            }
267    
268            protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
269                    if (userTrackerPath instanceof UserTrackerPathImpl) {
270                            return userTrackerPath;
271                    }
272    
273                    UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
274    
275                    userTrackerPathImpl.setNew(userTrackerPath.isNew());
276                    userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
277    
278                    userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
279                    userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
280                    userTrackerPathImpl.setPath(userTrackerPath.getPath());
281                    userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
282    
283                    return userTrackerPathImpl;
284            }
285    
286            /**
287             * Finds the user tracker path with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
288             *
289             * @param primaryKey the primary key of the user tracker path to find
290             * @return the user tracker path
291             * @throws com.liferay.portal.NoSuchModelException if a user tracker path with the primary key could not be found
292             * @throws SystemException if a system exception occurred
293             */
294            public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
295                    throws NoSuchModelException, SystemException {
296                    return findByPrimaryKey(((Long)primaryKey).longValue());
297            }
298    
299            /**
300             * Finds the user tracker path with the primary key or throws a {@link com.liferay.portal.NoSuchUserTrackerPathException} if it could not be found.
301             *
302             * @param userTrackerPathId the primary key of the user tracker path to find
303             * @return the user tracker path
304             * @throws com.liferay.portal.NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
305             * @throws SystemException if a system exception occurred
306             */
307            public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
308                    throws NoSuchUserTrackerPathException, SystemException {
309                    UserTrackerPath userTrackerPath = fetchByPrimaryKey(userTrackerPathId);
310    
311                    if (userTrackerPath == null) {
312                            if (_log.isWarnEnabled()) {
313                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userTrackerPathId);
314                            }
315    
316                            throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
317                                    userTrackerPathId);
318                    }
319    
320                    return userTrackerPath;
321            }
322    
323            /**
324             * Finds the user tracker path with the primary key or returns <code>null</code> if it could not be found.
325             *
326             * @param primaryKey the primary key of the user tracker path to find
327             * @return the user tracker path, or <code>null</code> if a user tracker path with the primary key could not be found
328             * @throws SystemException if a system exception occurred
329             */
330            public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey)
331                    throws SystemException {
332                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
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 userTrackerPathId 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(long userTrackerPathId)
343                    throws SystemException {
344                    UserTrackerPath userTrackerPath = (UserTrackerPath)EntityCacheUtil.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
345                                    UserTrackerPathImpl.class, userTrackerPathId, this);
346    
347                    if (userTrackerPath == null) {
348                            Session session = null;
349    
350                            try {
351                                    session = openSession();
352    
353                                    userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
354                                                    new Long(userTrackerPathId));
355                            }
356                            catch (Exception e) {
357                                    throw processException(e);
358                            }
359                            finally {
360                                    if (userTrackerPath != null) {
361                                            cacheResult(userTrackerPath);
362                                    }
363    
364                                    closeSession(session);
365                            }
366                    }
367    
368                    return userTrackerPath;
369            }
370    
371            /**
372             * Finds all the user tracker paths where userTrackerId = &#63;.
373             *
374             * @param userTrackerId the user tracker id to search with
375             * @return the matching user tracker paths
376             * @throws SystemException if a system exception occurred
377             */
378            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId)
379                    throws SystemException {
380                    return findByUserTrackerId(userTrackerId, QueryUtil.ALL_POS,
381                            QueryUtil.ALL_POS, null);
382            }
383    
384            /**
385             * Finds a range of all the user tracker paths where userTrackerId = &#63;.
386             *
387             * <p>
388             * 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.
389             * </p>
390             *
391             * @param userTrackerId the user tracker id to search with
392             * @param start the lower bound of the range of user tracker paths to return
393             * @param end the upper bound of the range of user tracker paths to return (not inclusive)
394             * @return the range of matching user tracker paths
395             * @throws SystemException if a system exception occurred
396             */
397            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
398                    int start, int end) throws SystemException {
399                    return findByUserTrackerId(userTrackerId, start, end, null);
400            }
401    
402            /**
403             * Finds an ordered range of all the user tracker paths where userTrackerId = &#63;.
404             *
405             * <p>
406             * 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.
407             * </p>
408             *
409             * @param userTrackerId the user tracker id to search with
410             * @param start the lower bound of the range of user tracker paths to return
411             * @param end the upper bound of the range of user tracker paths to return (not inclusive)
412             * @param orderByComparator the comparator to order the results by
413             * @return the ordered range of matching user tracker paths
414             * @throws SystemException if a system exception occurred
415             */
416            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
417                    int start, int end, OrderByComparator orderByComparator)
418                    throws SystemException {
419                    Object[] finderArgs = new Object[] {
420                                    userTrackerId,
421                                    
422                                    String.valueOf(start), String.valueOf(end),
423                                    String.valueOf(orderByComparator)
424                            };
425    
426                    List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERTRACKERID,
427                                    finderArgs, this);
428    
429                    if (list == null) {
430                            Session session = null;
431    
432                            try {
433                                    session = openSession();
434    
435                                    StringBundler query = null;
436    
437                                    if (orderByComparator != null) {
438                                            query = new StringBundler(3 +
439                                                            (orderByComparator.getOrderByFields().length * 3));
440                                    }
441                                    else {
442                                            query = new StringBundler(2);
443                                    }
444    
445                                    query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
446    
447                                    query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
448    
449                                    if (orderByComparator != null) {
450                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
451                                                    orderByComparator);
452                                    }
453    
454                                    String sql = query.toString();
455    
456                                    Query q = session.createQuery(sql);
457    
458                                    QueryPos qPos = QueryPos.getInstance(q);
459    
460                                    qPos.add(userTrackerId);
461    
462                                    list = (List<UserTrackerPath>)QueryUtil.list(q, getDialect(),
463                                                    start, end);
464                            }
465                            catch (Exception e) {
466                                    throw processException(e);
467                            }
468                            finally {
469                                    if (list == null) {
470                                            list = new ArrayList<UserTrackerPath>();
471                                    }
472    
473                                    cacheResult(list);
474    
475                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERTRACKERID,
476                                            finderArgs, list);
477    
478                                    closeSession(session);
479                            }
480                    }
481    
482                    return list;
483            }
484    
485            /**
486             * Finds the first user tracker path in the ordered set where userTrackerId = &#63;.
487             *
488             * <p>
489             * 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.
490             * </p>
491             *
492             * @param userTrackerId the user tracker id to search with
493             * @param orderByComparator the comparator to order the set by
494             * @return the first matching user tracker path
495             * @throws com.liferay.portal.NoSuchUserTrackerPathException if a matching user tracker path could not be found
496             * @throws SystemException if a system exception occurred
497             */
498            public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
499                    OrderByComparator orderByComparator)
500                    throws NoSuchUserTrackerPathException, SystemException {
501                    List<UserTrackerPath> list = findByUserTrackerId(userTrackerId, 0, 1,
502                                    orderByComparator);
503    
504                    if (list.isEmpty()) {
505                            StringBundler msg = new StringBundler(4);
506    
507                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
508    
509                            msg.append("userTrackerId=");
510                            msg.append(userTrackerId);
511    
512                            msg.append(StringPool.CLOSE_CURLY_BRACE);
513    
514                            throw new NoSuchUserTrackerPathException(msg.toString());
515                    }
516                    else {
517                            return list.get(0);
518                    }
519            }
520    
521            /**
522             * Finds the last user tracker path in the ordered set where userTrackerId = &#63;.
523             *
524             * <p>
525             * 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.
526             * </p>
527             *
528             * @param userTrackerId the user tracker id to search with
529             * @param orderByComparator the comparator to order the set by
530             * @return the last matching user tracker path
531             * @throws com.liferay.portal.NoSuchUserTrackerPathException if a matching user tracker path could not be found
532             * @throws SystemException if a system exception occurred
533             */
534            public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
535                    OrderByComparator orderByComparator)
536                    throws NoSuchUserTrackerPathException, SystemException {
537                    int count = countByUserTrackerId(userTrackerId);
538    
539                    List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
540                                    count - 1, count, orderByComparator);
541    
542                    if (list.isEmpty()) {
543                            StringBundler msg = new StringBundler(4);
544    
545                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
546    
547                            msg.append("userTrackerId=");
548                            msg.append(userTrackerId);
549    
550                            msg.append(StringPool.CLOSE_CURLY_BRACE);
551    
552                            throw new NoSuchUserTrackerPathException(msg.toString());
553                    }
554                    else {
555                            return list.get(0);
556                    }
557            }
558    
559            /**
560             * Finds the user tracker paths before and after the current user tracker path in the ordered set where userTrackerId = &#63;.
561             *
562             * <p>
563             * 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.
564             * </p>
565             *
566             * @param userTrackerPathId the primary key of the current user tracker path
567             * @param userTrackerId the user tracker id to search with
568             * @param orderByComparator the comparator to order the set by
569             * @return the previous, current, and next user tracker path
570             * @throws com.liferay.portal.NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
571             * @throws SystemException if a system exception occurred
572             */
573            public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
574                    long userTrackerPathId, long userTrackerId,
575                    OrderByComparator orderByComparator)
576                    throws NoSuchUserTrackerPathException, SystemException {
577                    UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
578    
579                    Session session = null;
580    
581                    try {
582                            session = openSession();
583    
584                            UserTrackerPath[] array = new UserTrackerPathImpl[3];
585    
586                            array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
587                                            userTrackerId, orderByComparator, true);
588    
589                            array[1] = userTrackerPath;
590    
591                            array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
592                                            userTrackerId, orderByComparator, false);
593    
594                            return array;
595                    }
596                    catch (Exception e) {
597                            throw processException(e);
598                    }
599                    finally {
600                            closeSession(session);
601                    }
602            }
603    
604            protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
605                    UserTrackerPath userTrackerPath, long userTrackerId,
606                    OrderByComparator orderByComparator, boolean previous) {
607                    StringBundler query = null;
608    
609                    if (orderByComparator != null) {
610                            query = new StringBundler(6 +
611                                            (orderByComparator.getOrderByFields().length * 6));
612                    }
613                    else {
614                            query = new StringBundler(3);
615                    }
616    
617                    query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
618    
619                    query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
620    
621                    if (orderByComparator != null) {
622                            String[] orderByFields = orderByComparator.getOrderByFields();
623    
624                            if (orderByFields.length > 0) {
625                                    query.append(WHERE_AND);
626                            }
627    
628                            for (int i = 0; i < orderByFields.length; i++) {
629                                    query.append(_ORDER_BY_ENTITY_ALIAS);
630                                    query.append(orderByFields[i]);
631    
632                                    if ((i + 1) < orderByFields.length) {
633                                            if (orderByComparator.isAscending() ^ previous) {
634                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
635                                            }
636                                            else {
637                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
638                                            }
639                                    }
640                                    else {
641                                            if (orderByComparator.isAscending() ^ previous) {
642                                                    query.append(WHERE_GREATER_THAN);
643                                            }
644                                            else {
645                                                    query.append(WHERE_LESSER_THAN);
646                                            }
647                                    }
648                            }
649    
650                            query.append(ORDER_BY_CLAUSE);
651    
652                            for (int i = 0; i < orderByFields.length; i++) {
653                                    query.append(_ORDER_BY_ENTITY_ALIAS);
654                                    query.append(orderByFields[i]);
655    
656                                    if ((i + 1) < orderByFields.length) {
657                                            if (orderByComparator.isAscending() ^ previous) {
658                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
659                                            }
660                                            else {
661                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
662                                            }
663                                    }
664                                    else {
665                                            if (orderByComparator.isAscending() ^ previous) {
666                                                    query.append(ORDER_BY_ASC);
667                                            }
668                                            else {
669                                                    query.append(ORDER_BY_DESC);
670                                            }
671                                    }
672                            }
673                    }
674    
675                    String sql = query.toString();
676    
677                    Query q = session.createQuery(sql);
678    
679                    q.setFirstResult(0);
680                    q.setMaxResults(2);
681    
682                    QueryPos qPos = QueryPos.getInstance(q);
683    
684                    qPos.add(userTrackerId);
685    
686                    if (orderByComparator != null) {
687                            Object[] values = orderByComparator.getOrderByValues(userTrackerPath);
688    
689                            for (Object value : values) {
690                                    qPos.add(value);
691                            }
692                    }
693    
694                    List<UserTrackerPath> list = q.list();
695    
696                    if (list.size() == 2) {
697                            return list.get(1);
698                    }
699                    else {
700                            return null;
701                    }
702            }
703    
704            /**
705             * Finds all the user tracker paths.
706             *
707             * @return the user tracker paths
708             * @throws SystemException if a system exception occurred
709             */
710            public List<UserTrackerPath> findAll() throws SystemException {
711                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
712            }
713    
714            /**
715             * Finds a range of all the user tracker paths.
716             *
717             * <p>
718             * 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.
719             * </p>
720             *
721             * @param start the lower bound of the range of user tracker paths to return
722             * @param end the upper bound of the range of user tracker paths to return (not inclusive)
723             * @return the range of user tracker paths
724             * @throws SystemException if a system exception occurred
725             */
726            public List<UserTrackerPath> findAll(int start, int end)
727                    throws SystemException {
728                    return findAll(start, end, null);
729            }
730    
731            /**
732             * Finds an ordered range of all the user tracker paths.
733             *
734             * <p>
735             * 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.
736             * </p>
737             *
738             * @param start the lower bound of the range of user tracker paths to return
739             * @param end the upper bound of the range of user tracker paths to return (not inclusive)
740             * @param orderByComparator the comparator to order the results by
741             * @return the ordered range of user tracker paths
742             * @throws SystemException if a system exception occurred
743             */
744            public List<UserTrackerPath> findAll(int start, int end,
745                    OrderByComparator orderByComparator) throws SystemException {
746                    Object[] finderArgs = new Object[] {
747                                    String.valueOf(start), String.valueOf(end),
748                                    String.valueOf(orderByComparator)
749                            };
750    
751                    List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
752                                    finderArgs, this);
753    
754                    if (list == null) {
755                            Session session = null;
756    
757                            try {
758                                    session = openSession();
759    
760                                    StringBundler query = null;
761                                    String sql = null;
762    
763                                    if (orderByComparator != null) {
764                                            query = new StringBundler(2 +
765                                                            (orderByComparator.getOrderByFields().length * 3));
766    
767                                            query.append(_SQL_SELECT_USERTRACKERPATH);
768    
769                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
770                                                    orderByComparator);
771    
772                                            sql = query.toString();
773                                    }
774                                    else {
775                                            sql = _SQL_SELECT_USERTRACKERPATH;
776                                    }
777    
778                                    Query q = session.createQuery(sql);
779    
780                                    if (orderByComparator == null) {
781                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
782                                                            getDialect(), start, end, false);
783    
784                                            Collections.sort(list);
785                                    }
786                                    else {
787                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
788                                                            getDialect(), start, end);
789                                    }
790                            }
791                            catch (Exception e) {
792                                    throw processException(e);
793                            }
794                            finally {
795                                    if (list == null) {
796                                            list = new ArrayList<UserTrackerPath>();
797                                    }
798    
799                                    cacheResult(list);
800    
801                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
802    
803                                    closeSession(session);
804                            }
805                    }
806    
807                    return list;
808            }
809    
810            /**
811             * Removes all the user tracker paths where userTrackerId = &#63; from the database.
812             *
813             * @param userTrackerId the user tracker id to search with
814             * @throws SystemException if a system exception occurred
815             */
816            public void removeByUserTrackerId(long userTrackerId)
817                    throws SystemException {
818                    for (UserTrackerPath userTrackerPath : findByUserTrackerId(
819                                    userTrackerId)) {
820                            remove(userTrackerPath);
821                    }
822            }
823    
824            /**
825             * Removes all the user tracker paths from the database.
826             *
827             * @throws SystemException if a system exception occurred
828             */
829            public void removeAll() throws SystemException {
830                    for (UserTrackerPath userTrackerPath : findAll()) {
831                            remove(userTrackerPath);
832                    }
833            }
834    
835            /**
836             * Counts all the user tracker paths where userTrackerId = &#63;.
837             *
838             * @param userTrackerId the user tracker id to search with
839             * @return the number of matching user tracker paths
840             * @throws SystemException if a system exception occurred
841             */
842            public int countByUserTrackerId(long userTrackerId)
843                    throws SystemException {
844                    Object[] finderArgs = new Object[] { userTrackerId };
845    
846                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
847                                    finderArgs, this);
848    
849                    if (count == null) {
850                            Session session = null;
851    
852                            try {
853                                    session = openSession();
854    
855                                    StringBundler query = new StringBundler(2);
856    
857                                    query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
858    
859                                    query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
860    
861                                    String sql = query.toString();
862    
863                                    Query q = session.createQuery(sql);
864    
865                                    QueryPos qPos = QueryPos.getInstance(q);
866    
867                                    qPos.add(userTrackerId);
868    
869                                    count = (Long)q.uniqueResult();
870                            }
871                            catch (Exception e) {
872                                    throw processException(e);
873                            }
874                            finally {
875                                    if (count == null) {
876                                            count = Long.valueOf(0);
877                                    }
878    
879                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
880                                            finderArgs, count);
881    
882                                    closeSession(session);
883                            }
884                    }
885    
886                    return count.intValue();
887            }
888    
889            /**
890             * Counts all the user tracker paths.
891             *
892             * @return the number of user tracker paths
893             * @throws SystemException if a system exception occurred
894             */
895            public int countAll() throws SystemException {
896                    Object[] finderArgs = new Object[0];
897    
898                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
899                                    finderArgs, this);
900    
901                    if (count == null) {
902                            Session session = null;
903    
904                            try {
905                                    session = openSession();
906    
907                                    Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
908    
909                                    count = (Long)q.uniqueResult();
910                            }
911                            catch (Exception e) {
912                                    throw processException(e);
913                            }
914                            finally {
915                                    if (count == null) {
916                                            count = Long.valueOf(0);
917                                    }
918    
919                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
920                                            count);
921    
922                                    closeSession(session);
923                            }
924                    }
925    
926                    return count.intValue();
927            }
928    
929            /**
930             * Initializes the user tracker path persistence.
931             */
932            public void afterPropertiesSet() {
933                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
934                                            com.liferay.portal.util.PropsUtil.get(
935                                                    "value.object.listener.com.liferay.portal.model.UserTrackerPath")));
936    
937                    if (listenerClassNames.length > 0) {
938                            try {
939                                    List<ModelListener<UserTrackerPath>> listenersList = new ArrayList<ModelListener<UserTrackerPath>>();
940    
941                                    for (String listenerClassName : listenerClassNames) {
942                                            listenersList.add((ModelListener<UserTrackerPath>)InstanceFactory.newInstance(
943                                                            listenerClassName));
944                                    }
945    
946                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
947                            }
948                            catch (Exception e) {
949                                    _log.error(e);
950                            }
951                    }
952            }
953    
954            public void destroy() {
955                    EntityCacheUtil.removeCache(UserTrackerPathImpl.class.getName());
956                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
957                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
958            }
959    
960            @BeanReference(type = AccountPersistence.class)
961            protected AccountPersistence accountPersistence;
962            @BeanReference(type = AddressPersistence.class)
963            protected AddressPersistence addressPersistence;
964            @BeanReference(type = BrowserTrackerPersistence.class)
965            protected BrowserTrackerPersistence browserTrackerPersistence;
966            @BeanReference(type = ClassNamePersistence.class)
967            protected ClassNamePersistence classNamePersistence;
968            @BeanReference(type = ClusterGroupPersistence.class)
969            protected ClusterGroupPersistence clusterGroupPersistence;
970            @BeanReference(type = CompanyPersistence.class)
971            protected CompanyPersistence companyPersistence;
972            @BeanReference(type = ContactPersistence.class)
973            protected ContactPersistence contactPersistence;
974            @BeanReference(type = CountryPersistence.class)
975            protected CountryPersistence countryPersistence;
976            @BeanReference(type = EmailAddressPersistence.class)
977            protected EmailAddressPersistence emailAddressPersistence;
978            @BeanReference(type = GroupPersistence.class)
979            protected GroupPersistence groupPersistence;
980            @BeanReference(type = ImagePersistence.class)
981            protected ImagePersistence imagePersistence;
982            @BeanReference(type = LayoutPersistence.class)
983            protected LayoutPersistence layoutPersistence;
984            @BeanReference(type = LayoutPrototypePersistence.class)
985            protected LayoutPrototypePersistence layoutPrototypePersistence;
986            @BeanReference(type = LayoutSetPersistence.class)
987            protected LayoutSetPersistence layoutSetPersistence;
988            @BeanReference(type = LayoutSetPrototypePersistence.class)
989            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
990            @BeanReference(type = ListTypePersistence.class)
991            protected ListTypePersistence listTypePersistence;
992            @BeanReference(type = LockPersistence.class)
993            protected LockPersistence lockPersistence;
994            @BeanReference(type = MembershipRequestPersistence.class)
995            protected MembershipRequestPersistence membershipRequestPersistence;
996            @BeanReference(type = OrganizationPersistence.class)
997            protected OrganizationPersistence organizationPersistence;
998            @BeanReference(type = OrgGroupPermissionPersistence.class)
999            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1000            @BeanReference(type = OrgGroupRolePersistence.class)
1001            protected OrgGroupRolePersistence orgGroupRolePersistence;
1002            @BeanReference(type = OrgLaborPersistence.class)
1003            protected OrgLaborPersistence orgLaborPersistence;
1004            @BeanReference(type = PasswordPolicyPersistence.class)
1005            protected PasswordPolicyPersistence passwordPolicyPersistence;
1006            @BeanReference(type = PasswordPolicyRelPersistence.class)
1007            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1008            @BeanReference(type = PasswordTrackerPersistence.class)
1009            protected PasswordTrackerPersistence passwordTrackerPersistence;
1010            @BeanReference(type = PermissionPersistence.class)
1011            protected PermissionPersistence permissionPersistence;
1012            @BeanReference(type = PhonePersistence.class)
1013            protected PhonePersistence phonePersistence;
1014            @BeanReference(type = PluginSettingPersistence.class)
1015            protected PluginSettingPersistence pluginSettingPersistence;
1016            @BeanReference(type = PortletPersistence.class)
1017            protected PortletPersistence portletPersistence;
1018            @BeanReference(type = PortletItemPersistence.class)
1019            protected PortletItemPersistence portletItemPersistence;
1020            @BeanReference(type = PortletPreferencesPersistence.class)
1021            protected PortletPreferencesPersistence portletPreferencesPersistence;
1022            @BeanReference(type = RegionPersistence.class)
1023            protected RegionPersistence regionPersistence;
1024            @BeanReference(type = ReleasePersistence.class)
1025            protected ReleasePersistence releasePersistence;
1026            @BeanReference(type = ResourcePersistence.class)
1027            protected ResourcePersistence resourcePersistence;
1028            @BeanReference(type = ResourceActionPersistence.class)
1029            protected ResourceActionPersistence resourceActionPersistence;
1030            @BeanReference(type = ResourceCodePersistence.class)
1031            protected ResourceCodePersistence resourceCodePersistence;
1032            @BeanReference(type = ResourcePermissionPersistence.class)
1033            protected ResourcePermissionPersistence resourcePermissionPersistence;
1034            @BeanReference(type = RolePersistence.class)
1035            protected RolePersistence rolePersistence;
1036            @BeanReference(type = ServiceComponentPersistence.class)
1037            protected ServiceComponentPersistence serviceComponentPersistence;
1038            @BeanReference(type = ShardPersistence.class)
1039            protected ShardPersistence shardPersistence;
1040            @BeanReference(type = SubscriptionPersistence.class)
1041            protected SubscriptionPersistence subscriptionPersistence;
1042            @BeanReference(type = TicketPersistence.class)
1043            protected TicketPersistence ticketPersistence;
1044            @BeanReference(type = TeamPersistence.class)
1045            protected TeamPersistence teamPersistence;
1046            @BeanReference(type = UserPersistence.class)
1047            protected UserPersistence userPersistence;
1048            @BeanReference(type = UserGroupPersistence.class)
1049            protected UserGroupPersistence userGroupPersistence;
1050            @BeanReference(type = UserGroupGroupRolePersistence.class)
1051            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1052            @BeanReference(type = UserGroupRolePersistence.class)
1053            protected UserGroupRolePersistence userGroupRolePersistence;
1054            @BeanReference(type = UserIdMapperPersistence.class)
1055            protected UserIdMapperPersistence userIdMapperPersistence;
1056            @BeanReference(type = UserTrackerPersistence.class)
1057            protected UserTrackerPersistence userTrackerPersistence;
1058            @BeanReference(type = UserTrackerPathPersistence.class)
1059            protected UserTrackerPathPersistence userTrackerPathPersistence;
1060            @BeanReference(type = WebDAVPropsPersistence.class)
1061            protected WebDAVPropsPersistence webDAVPropsPersistence;
1062            @BeanReference(type = WebsitePersistence.class)
1063            protected WebsitePersistence websitePersistence;
1064            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1065            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1066            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1067            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1068            private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1069            private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1070            private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1071            private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1072            private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
1073            private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1074            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1075            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1076            private static Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1077    }