001    /**
002     * Copyright (c) 2000-2011 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                            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                            StringBundler query = null;
431    
432                            if (orderByComparator != null) {
433                                    query = new StringBundler(3 +
434                                                    (orderByComparator.getOrderByFields().length * 3));
435                            }
436                            else {
437                                    query = new StringBundler(2);
438                            }
439    
440                            query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
441    
442                            query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
443    
444                            if (orderByComparator != null) {
445                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
446                                            orderByComparator);
447                            }
448    
449                            String sql = query.toString();
450    
451                            Session session = null;
452    
453                            try {
454                                    session = openSession();
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                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_USERTRACKERID,
471                                                    finderArgs);
472                                    }
473                                    else {
474                                            cacheResult(list);
475    
476                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERTRACKERID,
477                                                    finderArgs, list);
478                                    }
479    
480                                    closeSession(session);
481                            }
482                    }
483    
484                    return list;
485            }
486    
487            /**
488             * Finds the first user tracker path in the ordered set where userTrackerId = &#63;.
489             *
490             * <p>
491             * 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.
492             * </p>
493             *
494             * @param userTrackerId the user tracker id to search with
495             * @param orderByComparator the comparator to order the set by
496             * @return the first matching user tracker path
497             * @throws com.liferay.portal.NoSuchUserTrackerPathException if a matching user tracker path could not be found
498             * @throws SystemException if a system exception occurred
499             */
500            public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
501                    OrderByComparator orderByComparator)
502                    throws NoSuchUserTrackerPathException, SystemException {
503                    List<UserTrackerPath> list = findByUserTrackerId(userTrackerId, 0, 1,
504                                    orderByComparator);
505    
506                    if (list.isEmpty()) {
507                            StringBundler msg = new StringBundler(4);
508    
509                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
510    
511                            msg.append("userTrackerId=");
512                            msg.append(userTrackerId);
513    
514                            msg.append(StringPool.CLOSE_CURLY_BRACE);
515    
516                            throw new NoSuchUserTrackerPathException(msg.toString());
517                    }
518                    else {
519                            return list.get(0);
520                    }
521            }
522    
523            /**
524             * Finds the last user tracker path in the ordered set where userTrackerId = &#63;.
525             *
526             * <p>
527             * 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.
528             * </p>
529             *
530             * @param userTrackerId the user tracker id to search with
531             * @param orderByComparator the comparator to order the set by
532             * @return the last matching user tracker path
533             * @throws com.liferay.portal.NoSuchUserTrackerPathException if a matching user tracker path could not be found
534             * @throws SystemException if a system exception occurred
535             */
536            public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
537                    OrderByComparator orderByComparator)
538                    throws NoSuchUserTrackerPathException, SystemException {
539                    int count = countByUserTrackerId(userTrackerId);
540    
541                    List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
542                                    count - 1, count, orderByComparator);
543    
544                    if (list.isEmpty()) {
545                            StringBundler msg = new StringBundler(4);
546    
547                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
548    
549                            msg.append("userTrackerId=");
550                            msg.append(userTrackerId);
551    
552                            msg.append(StringPool.CLOSE_CURLY_BRACE);
553    
554                            throw new NoSuchUserTrackerPathException(msg.toString());
555                    }
556                    else {
557                            return list.get(0);
558                    }
559            }
560    
561            /**
562             * Finds the user tracker paths before and after the current user tracker path in the ordered set where userTrackerId = &#63;.
563             *
564             * <p>
565             * 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.
566             * </p>
567             *
568             * @param userTrackerPathId the primary key of the current user tracker path
569             * @param userTrackerId the user tracker id to search with
570             * @param orderByComparator the comparator to order the set by
571             * @return the previous, current, and next user tracker path
572             * @throws com.liferay.portal.NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
573             * @throws SystemException if a system exception occurred
574             */
575            public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
576                    long userTrackerPathId, long userTrackerId,
577                    OrderByComparator orderByComparator)
578                    throws NoSuchUserTrackerPathException, SystemException {
579                    UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
580    
581                    Session session = null;
582    
583                    try {
584                            session = openSession();
585    
586                            UserTrackerPath[] array = new UserTrackerPathImpl[3];
587    
588                            array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
589                                            userTrackerId, orderByComparator, true);
590    
591                            array[1] = userTrackerPath;
592    
593                            array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
594                                            userTrackerId, orderByComparator, false);
595    
596                            return array;
597                    }
598                    catch (Exception e) {
599                            throw processException(e);
600                    }
601                    finally {
602                            closeSession(session);
603                    }
604            }
605    
606            protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
607                    UserTrackerPath userTrackerPath, long userTrackerId,
608                    OrderByComparator orderByComparator, boolean previous) {
609                    StringBundler query = null;
610    
611                    if (orderByComparator != null) {
612                            query = new StringBundler(6 +
613                                            (orderByComparator.getOrderByFields().length * 6));
614                    }
615                    else {
616                            query = new StringBundler(3);
617                    }
618    
619                    query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
620    
621                    query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
622    
623                    if (orderByComparator != null) {
624                            String[] orderByFields = orderByComparator.getOrderByFields();
625    
626                            if (orderByFields.length > 0) {
627                                    query.append(WHERE_AND);
628                            }
629    
630                            for (int i = 0; i < orderByFields.length; i++) {
631                                    query.append(_ORDER_BY_ENTITY_ALIAS);
632                                    query.append(orderByFields[i]);
633    
634                                    if ((i + 1) < orderByFields.length) {
635                                            if (orderByComparator.isAscending() ^ previous) {
636                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
637                                            }
638                                            else {
639                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
640                                            }
641                                    }
642                                    else {
643                                            if (orderByComparator.isAscending() ^ previous) {
644                                                    query.append(WHERE_GREATER_THAN);
645                                            }
646                                            else {
647                                                    query.append(WHERE_LESSER_THAN);
648                                            }
649                                    }
650                            }
651    
652                            query.append(ORDER_BY_CLAUSE);
653    
654                            for (int i = 0; i < orderByFields.length; i++) {
655                                    query.append(_ORDER_BY_ENTITY_ALIAS);
656                                    query.append(orderByFields[i]);
657    
658                                    if ((i + 1) < orderByFields.length) {
659                                            if (orderByComparator.isAscending() ^ previous) {
660                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
661                                            }
662                                            else {
663                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
664                                            }
665                                    }
666                                    else {
667                                            if (orderByComparator.isAscending() ^ previous) {
668                                                    query.append(ORDER_BY_ASC);
669                                            }
670                                            else {
671                                                    query.append(ORDER_BY_DESC);
672                                            }
673                                    }
674                            }
675                    }
676    
677                    String sql = query.toString();
678    
679                    Query q = session.createQuery(sql);
680    
681                    q.setFirstResult(0);
682                    q.setMaxResults(2);
683    
684                    QueryPos qPos = QueryPos.getInstance(q);
685    
686                    qPos.add(userTrackerId);
687    
688                    if (orderByComparator != null) {
689                            Object[] values = orderByComparator.getOrderByValues(userTrackerPath);
690    
691                            for (Object value : values) {
692                                    qPos.add(value);
693                            }
694                    }
695    
696                    List<UserTrackerPath> list = q.list();
697    
698                    if (list.size() == 2) {
699                            return list.get(1);
700                    }
701                    else {
702                            return null;
703                    }
704            }
705    
706            /**
707             * Finds all the user tracker paths.
708             *
709             * @return the user tracker paths
710             * @throws SystemException if a system exception occurred
711             */
712            public List<UserTrackerPath> findAll() throws SystemException {
713                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
714            }
715    
716            /**
717             * Finds a range of all the user tracker paths.
718             *
719             * <p>
720             * 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.
721             * </p>
722             *
723             * @param start the lower bound of the range of user tracker paths to return
724             * @param end the upper bound of the range of user tracker paths to return (not inclusive)
725             * @return the range of user tracker paths
726             * @throws SystemException if a system exception occurred
727             */
728            public List<UserTrackerPath> findAll(int start, int end)
729                    throws SystemException {
730                    return findAll(start, end, null);
731            }
732    
733            /**
734             * Finds an ordered range of all the user tracker paths.
735             *
736             * <p>
737             * 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.
738             * </p>
739             *
740             * @param start the lower bound of the range of user tracker paths to return
741             * @param end the upper bound of the range of user tracker paths to return (not inclusive)
742             * @param orderByComparator the comparator to order the results by
743             * @return the ordered range of user tracker paths
744             * @throws SystemException if a system exception occurred
745             */
746            public List<UserTrackerPath> findAll(int start, int end,
747                    OrderByComparator orderByComparator) throws SystemException {
748                    Object[] finderArgs = new Object[] {
749                                    String.valueOf(start), String.valueOf(end),
750                                    String.valueOf(orderByComparator)
751                            };
752    
753                    List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
754                                    finderArgs, this);
755    
756                    if (list == null) {
757                            StringBundler query = null;
758                            String sql = null;
759    
760                            if (orderByComparator != null) {
761                                    query = new StringBundler(2 +
762                                                    (orderByComparator.getOrderByFields().length * 3));
763    
764                                    query.append(_SQL_SELECT_USERTRACKERPATH);
765    
766                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
767                                            orderByComparator);
768    
769                                    sql = query.toString();
770                            }
771                            else {
772                                    sql = _SQL_SELECT_USERTRACKERPATH;
773                            }
774    
775                            Session session = null;
776    
777                            try {
778                                    session = openSession();
779    
780                                    Query q = session.createQuery(sql);
781    
782                                    if (orderByComparator == null) {
783                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
784                                                            getDialect(), start, end, false);
785    
786                                            Collections.sort(list);
787                                    }
788                                    else {
789                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
790                                                            getDialect(), start, end);
791                                    }
792                            }
793                            catch (Exception e) {
794                                    throw processException(e);
795                            }
796                            finally {
797                                    if (list == null) {
798                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
799                                                    finderArgs);
800                                    }
801                                    else {
802                                            cacheResult(list);
803    
804                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
805                                                    list);
806                                    }
807    
808                                    closeSession(session);
809                            }
810                    }
811    
812                    return list;
813            }
814    
815            /**
816             * Removes all the user tracker paths where userTrackerId = &#63; from the database.
817             *
818             * @param userTrackerId the user tracker id to search with
819             * @throws SystemException if a system exception occurred
820             */
821            public void removeByUserTrackerId(long userTrackerId)
822                    throws SystemException {
823                    for (UserTrackerPath userTrackerPath : findByUserTrackerId(
824                                    userTrackerId)) {
825                            remove(userTrackerPath);
826                    }
827            }
828    
829            /**
830             * Removes all the user tracker paths from the database.
831             *
832             * @throws SystemException if a system exception occurred
833             */
834            public void removeAll() throws SystemException {
835                    for (UserTrackerPath userTrackerPath : findAll()) {
836                            remove(userTrackerPath);
837                    }
838            }
839    
840            /**
841             * Counts all the user tracker paths where userTrackerId = &#63;.
842             *
843             * @param userTrackerId the user tracker id to search with
844             * @return the number of matching user tracker paths
845             * @throws SystemException if a system exception occurred
846             */
847            public int countByUserTrackerId(long userTrackerId)
848                    throws SystemException {
849                    Object[] finderArgs = new Object[] { userTrackerId };
850    
851                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
852                                    finderArgs, this);
853    
854                    if (count == null) {
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                            Session session = null;
864    
865                            try {
866                                    session = openSession();
867    
868                                    Query q = session.createQuery(sql);
869    
870                                    QueryPos qPos = QueryPos.getInstance(q);
871    
872                                    qPos.add(userTrackerId);
873    
874                                    count = (Long)q.uniqueResult();
875                            }
876                            catch (Exception e) {
877                                    throw processException(e);
878                            }
879                            finally {
880                                    if (count == null) {
881                                            count = Long.valueOf(0);
882                                    }
883    
884                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
885                                            finderArgs, count);
886    
887                                    closeSession(session);
888                            }
889                    }
890    
891                    return count.intValue();
892            }
893    
894            /**
895             * Counts all the user tracker paths.
896             *
897             * @return the number of user tracker paths
898             * @throws SystemException if a system exception occurred
899             */
900            public int countAll() throws SystemException {
901                    Object[] finderArgs = new Object[0];
902    
903                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
904                                    finderArgs, this);
905    
906                    if (count == null) {
907                            Session session = null;
908    
909                            try {
910                                    session = openSession();
911    
912                                    Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
913    
914                                    count = (Long)q.uniqueResult();
915                            }
916                            catch (Exception e) {
917                                    throw processException(e);
918                            }
919                            finally {
920                                    if (count == null) {
921                                            count = Long.valueOf(0);
922                                    }
923    
924                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
925                                            count);
926    
927                                    closeSession(session);
928                            }
929                    }
930    
931                    return count.intValue();
932            }
933    
934            /**
935             * Initializes the user tracker path persistence.
936             */
937            public void afterPropertiesSet() {
938                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
939                                            com.liferay.portal.util.PropsUtil.get(
940                                                    "value.object.listener.com.liferay.portal.model.UserTrackerPath")));
941    
942                    if (listenerClassNames.length > 0) {
943                            try {
944                                    List<ModelListener<UserTrackerPath>> listenersList = new ArrayList<ModelListener<UserTrackerPath>>();
945    
946                                    for (String listenerClassName : listenerClassNames) {
947                                            listenersList.add((ModelListener<UserTrackerPath>)InstanceFactory.newInstance(
948                                                            listenerClassName));
949                                    }
950    
951                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
952                            }
953                            catch (Exception e) {
954                                    _log.error(e);
955                            }
956                    }
957            }
958    
959            public void destroy() {
960                    EntityCacheUtil.removeCache(UserTrackerPathImpl.class.getName());
961                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
962                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
963            }
964    
965            @BeanReference(type = AccountPersistence.class)
966            protected AccountPersistence accountPersistence;
967            @BeanReference(type = AddressPersistence.class)
968            protected AddressPersistence addressPersistence;
969            @BeanReference(type = BrowserTrackerPersistence.class)
970            protected BrowserTrackerPersistence browserTrackerPersistence;
971            @BeanReference(type = ClassNamePersistence.class)
972            protected ClassNamePersistence classNamePersistence;
973            @BeanReference(type = ClusterGroupPersistence.class)
974            protected ClusterGroupPersistence clusterGroupPersistence;
975            @BeanReference(type = CompanyPersistence.class)
976            protected CompanyPersistence companyPersistence;
977            @BeanReference(type = ContactPersistence.class)
978            protected ContactPersistence contactPersistence;
979            @BeanReference(type = CountryPersistence.class)
980            protected CountryPersistence countryPersistence;
981            @BeanReference(type = EmailAddressPersistence.class)
982            protected EmailAddressPersistence emailAddressPersistence;
983            @BeanReference(type = GroupPersistence.class)
984            protected GroupPersistence groupPersistence;
985            @BeanReference(type = ImagePersistence.class)
986            protected ImagePersistence imagePersistence;
987            @BeanReference(type = LayoutPersistence.class)
988            protected LayoutPersistence layoutPersistence;
989            @BeanReference(type = LayoutPrototypePersistence.class)
990            protected LayoutPrototypePersistence layoutPrototypePersistence;
991            @BeanReference(type = LayoutSetPersistence.class)
992            protected LayoutSetPersistence layoutSetPersistence;
993            @BeanReference(type = LayoutSetPrototypePersistence.class)
994            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
995            @BeanReference(type = ListTypePersistence.class)
996            protected ListTypePersistence listTypePersistence;
997            @BeanReference(type = LockPersistence.class)
998            protected LockPersistence lockPersistence;
999            @BeanReference(type = MembershipRequestPersistence.class)
1000            protected MembershipRequestPersistence membershipRequestPersistence;
1001            @BeanReference(type = OrganizationPersistence.class)
1002            protected OrganizationPersistence organizationPersistence;
1003            @BeanReference(type = OrgGroupPermissionPersistence.class)
1004            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1005            @BeanReference(type = OrgGroupRolePersistence.class)
1006            protected OrgGroupRolePersistence orgGroupRolePersistence;
1007            @BeanReference(type = OrgLaborPersistence.class)
1008            protected OrgLaborPersistence orgLaborPersistence;
1009            @BeanReference(type = PasswordPolicyPersistence.class)
1010            protected PasswordPolicyPersistence passwordPolicyPersistence;
1011            @BeanReference(type = PasswordPolicyRelPersistence.class)
1012            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1013            @BeanReference(type = PasswordTrackerPersistence.class)
1014            protected PasswordTrackerPersistence passwordTrackerPersistence;
1015            @BeanReference(type = PermissionPersistence.class)
1016            protected PermissionPersistence permissionPersistence;
1017            @BeanReference(type = PhonePersistence.class)
1018            protected PhonePersistence phonePersistence;
1019            @BeanReference(type = PluginSettingPersistence.class)
1020            protected PluginSettingPersistence pluginSettingPersistence;
1021            @BeanReference(type = PortletPersistence.class)
1022            protected PortletPersistence portletPersistence;
1023            @BeanReference(type = PortletItemPersistence.class)
1024            protected PortletItemPersistence portletItemPersistence;
1025            @BeanReference(type = PortletPreferencesPersistence.class)
1026            protected PortletPreferencesPersistence portletPreferencesPersistence;
1027            @BeanReference(type = RegionPersistence.class)
1028            protected RegionPersistence regionPersistence;
1029            @BeanReference(type = ReleasePersistence.class)
1030            protected ReleasePersistence releasePersistence;
1031            @BeanReference(type = ResourcePersistence.class)
1032            protected ResourcePersistence resourcePersistence;
1033            @BeanReference(type = ResourceActionPersistence.class)
1034            protected ResourceActionPersistence resourceActionPersistence;
1035            @BeanReference(type = ResourceCodePersistence.class)
1036            protected ResourceCodePersistence resourceCodePersistence;
1037            @BeanReference(type = ResourcePermissionPersistence.class)
1038            protected ResourcePermissionPersistence resourcePermissionPersistence;
1039            @BeanReference(type = RolePersistence.class)
1040            protected RolePersistence rolePersistence;
1041            @BeanReference(type = ServiceComponentPersistence.class)
1042            protected ServiceComponentPersistence serviceComponentPersistence;
1043            @BeanReference(type = ShardPersistence.class)
1044            protected ShardPersistence shardPersistence;
1045            @BeanReference(type = SubscriptionPersistence.class)
1046            protected SubscriptionPersistence subscriptionPersistence;
1047            @BeanReference(type = TicketPersistence.class)
1048            protected TicketPersistence ticketPersistence;
1049            @BeanReference(type = TeamPersistence.class)
1050            protected TeamPersistence teamPersistence;
1051            @BeanReference(type = UserPersistence.class)
1052            protected UserPersistence userPersistence;
1053            @BeanReference(type = UserGroupPersistence.class)
1054            protected UserGroupPersistence userGroupPersistence;
1055            @BeanReference(type = UserGroupGroupRolePersistence.class)
1056            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1057            @BeanReference(type = UserGroupRolePersistence.class)
1058            protected UserGroupRolePersistence userGroupRolePersistence;
1059            @BeanReference(type = UserIdMapperPersistence.class)
1060            protected UserIdMapperPersistence userIdMapperPersistence;
1061            @BeanReference(type = UserTrackerPersistence.class)
1062            protected UserTrackerPersistence userTrackerPersistence;
1063            @BeanReference(type = UserTrackerPathPersistence.class)
1064            protected UserTrackerPathPersistence userTrackerPathPersistence;
1065            @BeanReference(type = WebDAVPropsPersistence.class)
1066            protected WebDAVPropsPersistence webDAVPropsPersistence;
1067            @BeanReference(type = WebsitePersistence.class)
1068            protected WebsitePersistence websitePersistence;
1069            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1070            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1071            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1072            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1073            private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1074            private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1075            private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1076            private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1077            private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
1078            private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1079            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1080            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1081            private static Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1082    }