001    /**
002     * Copyright (c) 2000-present 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.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.NoSuchUserTrackerPathException;
020    import com.liferay.portal.kernel.bean.BeanReference;
021    import com.liferay.portal.kernel.dao.orm.EntityCache;
022    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderCache;
024    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
025    import com.liferay.portal.kernel.dao.orm.FinderPath;
026    import com.liferay.portal.kernel.dao.orm.Query;
027    import com.liferay.portal.kernel.dao.orm.QueryPos;
028    import com.liferay.portal.kernel.dao.orm.QueryUtil;
029    import com.liferay.portal.kernel.dao.orm.Session;
030    import com.liferay.portal.kernel.log.Log;
031    import com.liferay.portal.kernel.log.LogFactoryUtil;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.SetUtil;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.model.CacheModel;
037    import com.liferay.portal.model.MVCCModel;
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.CompanyProvider;
042    import com.liferay.portal.service.persistence.UserTrackerPathPersistence;
043    
044    import java.io.Serializable;
045    
046    import java.util.Collections;
047    import java.util.HashMap;
048    import java.util.HashSet;
049    import java.util.Iterator;
050    import java.util.List;
051    import java.util.Map;
052    import java.util.Set;
053    
054    /**
055     * The persistence implementation for the user tracker path service.
056     *
057     * <p>
058     * Caching information and settings can be found in <code>portal.properties</code>
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see UserTrackerPathPersistence
063     * @see com.liferay.portal.service.persistence.UserTrackerPathUtil
064     * @generated
065     */
066    @ProviderType
067    public class UserTrackerPathPersistenceImpl extends BasePersistenceImpl<UserTrackerPath>
068            implements UserTrackerPathPersistence {
069            /*
070             * NOTE FOR DEVELOPERS:
071             *
072             * 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.
073             */
074            public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerPathImpl.class.getName();
075            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List1";
077            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078                    ".List2";
079            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
080                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
081                            UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
082                            "findAll", new String[0]);
083            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
084                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
085                            UserTrackerPathImpl.class,
086                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
087            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
088                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
089                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
090            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID =
091                    new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
092                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
093                            UserTrackerPathImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
094                            "findByUserTrackerId",
095                            new String[] {
096                                    Long.class.getName(),
097                                    
098                            Integer.class.getName(), Integer.class.getName(),
099                                    OrderByComparator.class.getName()
100                            });
101            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID =
102                    new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
103                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
104                            UserTrackerPathImpl.class,
105                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserTrackerId",
106                            new String[] { Long.class.getName() },
107                            UserTrackerPathModelImpl.USERTRACKERID_COLUMN_BITMASK);
108            public static final FinderPath FINDER_PATH_COUNT_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
109                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED, Long.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserTrackerId",
111                            new String[] { Long.class.getName() });
112    
113            /**
114             * Returns all the user tracker paths where userTrackerId = &#63;.
115             *
116             * @param userTrackerId the user tracker ID
117             * @return the matching user tracker paths
118             */
119            @Override
120            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId) {
121                    return findByUserTrackerId(userTrackerId, QueryUtil.ALL_POS,
122                            QueryUtil.ALL_POS, null);
123            }
124    
125            /**
126             * Returns a range of all the user tracker paths where userTrackerId = &#63;.
127             *
128             * <p>
129             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserTrackerPathModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
130             * </p>
131             *
132             * @param userTrackerId the user tracker ID
133             * @param start the lower bound of the range of user tracker paths
134             * @param end the upper bound of the range of user tracker paths (not inclusive)
135             * @return the range of matching user tracker paths
136             */
137            @Override
138            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
139                    int start, int end) {
140                    return findByUserTrackerId(userTrackerId, start, end, null);
141            }
142    
143            /**
144             * Returns an ordered range of all the user tracker paths where userTrackerId = &#63;.
145             *
146             * <p>
147             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserTrackerPathModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
148             * </p>
149             *
150             * @param userTrackerId the user tracker ID
151             * @param start the lower bound of the range of user tracker paths
152             * @param end the upper bound of the range of user tracker paths (not inclusive)
153             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
154             * @return the ordered range of matching user tracker paths
155             */
156            @Override
157            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
158                    int start, int end, OrderByComparator<UserTrackerPath> orderByComparator) {
159                    return findByUserTrackerId(userTrackerId, start, end,
160                            orderByComparator, true);
161            }
162    
163            /**
164             * Returns an ordered range of all the user tracker paths where userTrackerId = &#63;.
165             *
166             * <p>
167             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserTrackerPathModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
168             * </p>
169             *
170             * @param userTrackerId the user tracker ID
171             * @param start the lower bound of the range of user tracker paths
172             * @param end the upper bound of the range of user tracker paths (not inclusive)
173             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
174             * @param retrieveFromCache whether to retrieve from the finder cache
175             * @return the ordered range of matching user tracker paths
176             */
177            @Override
178            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
179                    int start, int end,
180                    OrderByComparator<UserTrackerPath> orderByComparator,
181                    boolean retrieveFromCache) {
182                    boolean pagination = true;
183                    FinderPath finderPath = null;
184                    Object[] finderArgs = null;
185    
186                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
187                                    (orderByComparator == null)) {
188                            pagination = false;
189                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID;
190                            finderArgs = new Object[] { userTrackerId };
191                    }
192                    else {
193                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERTRACKERID;
194                            finderArgs = new Object[] {
195                                            userTrackerId,
196                                            
197                                            start, end, orderByComparator
198                                    };
199                    }
200    
201                    List<UserTrackerPath> list = null;
202    
203                    if (retrieveFromCache) {
204                            list = (List<UserTrackerPath>)finderCache.getResult(finderPath,
205                                            finderArgs, this);
206    
207                            if ((list != null) && !list.isEmpty()) {
208                                    for (UserTrackerPath userTrackerPath : list) {
209                                            if ((userTrackerId != userTrackerPath.getUserTrackerId())) {
210                                                    list = null;
211    
212                                                    break;
213                                            }
214                                    }
215                            }
216                    }
217    
218                    if (list == null) {
219                            StringBundler query = null;
220    
221                            if (orderByComparator != null) {
222                                    query = new StringBundler(3 +
223                                                    (orderByComparator.getOrderByFields().length * 3));
224                            }
225                            else {
226                                    query = new StringBundler(3);
227                            }
228    
229                            query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
230    
231                            query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
232    
233                            if (orderByComparator != null) {
234                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
235                                            orderByComparator);
236                            }
237                            else
238                             if (pagination) {
239                                    query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
240                            }
241    
242                            String sql = query.toString();
243    
244                            Session session = null;
245    
246                            try {
247                                    session = openSession();
248    
249                                    Query q = session.createQuery(sql);
250    
251                                    QueryPos qPos = QueryPos.getInstance(q);
252    
253                                    qPos.add(userTrackerId);
254    
255                                    if (!pagination) {
256                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
257                                                            getDialect(), start, end, false);
258    
259                                            Collections.sort(list);
260    
261                                            list = Collections.unmodifiableList(list);
262                                    }
263                                    else {
264                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
265                                                            getDialect(), start, end);
266                                    }
267    
268                                    cacheResult(list);
269    
270                                    finderCache.putResult(finderPath, finderArgs, list);
271                            }
272                            catch (Exception e) {
273                                    finderCache.removeResult(finderPath, finderArgs);
274    
275                                    throw processException(e);
276                            }
277                            finally {
278                                    closeSession(session);
279                            }
280                    }
281    
282                    return list;
283            }
284    
285            /**
286             * Returns the first user tracker path in the ordered set where userTrackerId = &#63;.
287             *
288             * @param userTrackerId the user tracker ID
289             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
290             * @return the first matching user tracker path
291             * @throws NoSuchUserTrackerPathException if a matching user tracker path could not be found
292             */
293            @Override
294            public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
295                    OrderByComparator<UserTrackerPath> orderByComparator)
296                    throws NoSuchUserTrackerPathException {
297                    UserTrackerPath userTrackerPath = fetchByUserTrackerId_First(userTrackerId,
298                                    orderByComparator);
299    
300                    if (userTrackerPath != null) {
301                            return userTrackerPath;
302                    }
303    
304                    StringBundler msg = new StringBundler(4);
305    
306                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
307    
308                    msg.append("userTrackerId=");
309                    msg.append(userTrackerId);
310    
311                    msg.append(StringPool.CLOSE_CURLY_BRACE);
312    
313                    throw new NoSuchUserTrackerPathException(msg.toString());
314            }
315    
316            /**
317             * Returns the first user tracker path in the ordered set where userTrackerId = &#63;.
318             *
319             * @param userTrackerId the user tracker ID
320             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
321             * @return the first matching user tracker path, or <code>null</code> if a matching user tracker path could not be found
322             */
323            @Override
324            public UserTrackerPath fetchByUserTrackerId_First(long userTrackerId,
325                    OrderByComparator<UserTrackerPath> orderByComparator) {
326                    List<UserTrackerPath> list = findByUserTrackerId(userTrackerId, 0, 1,
327                                    orderByComparator);
328    
329                    if (!list.isEmpty()) {
330                            return list.get(0);
331                    }
332    
333                    return null;
334            }
335    
336            /**
337             * Returns the last user tracker path in the ordered set where userTrackerId = &#63;.
338             *
339             * @param userTrackerId the user tracker ID
340             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
341             * @return the last matching user tracker path
342             * @throws NoSuchUserTrackerPathException if a matching user tracker path could not be found
343             */
344            @Override
345            public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
346                    OrderByComparator<UserTrackerPath> orderByComparator)
347                    throws NoSuchUserTrackerPathException {
348                    UserTrackerPath userTrackerPath = fetchByUserTrackerId_Last(userTrackerId,
349                                    orderByComparator);
350    
351                    if (userTrackerPath != null) {
352                            return userTrackerPath;
353                    }
354    
355                    StringBundler msg = new StringBundler(4);
356    
357                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
358    
359                    msg.append("userTrackerId=");
360                    msg.append(userTrackerId);
361    
362                    msg.append(StringPool.CLOSE_CURLY_BRACE);
363    
364                    throw new NoSuchUserTrackerPathException(msg.toString());
365            }
366    
367            /**
368             * Returns the last user tracker path in the ordered set where userTrackerId = &#63;.
369             *
370             * @param userTrackerId the user tracker ID
371             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
372             * @return the last matching user tracker path, or <code>null</code> if a matching user tracker path could not be found
373             */
374            @Override
375            public UserTrackerPath fetchByUserTrackerId_Last(long userTrackerId,
376                    OrderByComparator<UserTrackerPath> orderByComparator) {
377                    int count = countByUserTrackerId(userTrackerId);
378    
379                    if (count == 0) {
380                            return null;
381                    }
382    
383                    List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
384                                    count - 1, count, orderByComparator);
385    
386                    if (!list.isEmpty()) {
387                            return list.get(0);
388                    }
389    
390                    return null;
391            }
392    
393            /**
394             * Returns the user tracker paths before and after the current user tracker path in the ordered set where userTrackerId = &#63;.
395             *
396             * @param userTrackerPathId the primary key of the current user tracker path
397             * @param userTrackerId the user tracker ID
398             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
399             * @return the previous, current, and next user tracker path
400             * @throws NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
401             */
402            @Override
403            public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
404                    long userTrackerPathId, long userTrackerId,
405                    OrderByComparator<UserTrackerPath> orderByComparator)
406                    throws NoSuchUserTrackerPathException {
407                    UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
408    
409                    Session session = null;
410    
411                    try {
412                            session = openSession();
413    
414                            UserTrackerPath[] array = new UserTrackerPathImpl[3];
415    
416                            array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
417                                            userTrackerId, orderByComparator, true);
418    
419                            array[1] = userTrackerPath;
420    
421                            array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
422                                            userTrackerId, orderByComparator, false);
423    
424                            return array;
425                    }
426                    catch (Exception e) {
427                            throw processException(e);
428                    }
429                    finally {
430                            closeSession(session);
431                    }
432            }
433    
434            protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
435                    UserTrackerPath userTrackerPath, long userTrackerId,
436                    OrderByComparator<UserTrackerPath> orderByComparator, boolean previous) {
437                    StringBundler query = null;
438    
439                    if (orderByComparator != null) {
440                            query = new StringBundler(6 +
441                                            (orderByComparator.getOrderByFields().length * 6));
442                    }
443                    else {
444                            query = new StringBundler(3);
445                    }
446    
447                    query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
448    
449                    query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
450    
451                    if (orderByComparator != null) {
452                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
453    
454                            if (orderByConditionFields.length > 0) {
455                                    query.append(WHERE_AND);
456                            }
457    
458                            for (int i = 0; i < orderByConditionFields.length; i++) {
459                                    query.append(_ORDER_BY_ENTITY_ALIAS);
460                                    query.append(orderByConditionFields[i]);
461    
462                                    if ((i + 1) < orderByConditionFields.length) {
463                                            if (orderByComparator.isAscending() ^ previous) {
464                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
465                                            }
466                                            else {
467                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
468                                            }
469                                    }
470                                    else {
471                                            if (orderByComparator.isAscending() ^ previous) {
472                                                    query.append(WHERE_GREATER_THAN);
473                                            }
474                                            else {
475                                                    query.append(WHERE_LESSER_THAN);
476                                            }
477                                    }
478                            }
479    
480                            query.append(ORDER_BY_CLAUSE);
481    
482                            String[] orderByFields = orderByComparator.getOrderByFields();
483    
484                            for (int i = 0; i < orderByFields.length; i++) {
485                                    query.append(_ORDER_BY_ENTITY_ALIAS);
486                                    query.append(orderByFields[i]);
487    
488                                    if ((i + 1) < orderByFields.length) {
489                                            if (orderByComparator.isAscending() ^ previous) {
490                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
491                                            }
492                                            else {
493                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
494                                            }
495                                    }
496                                    else {
497                                            if (orderByComparator.isAscending() ^ previous) {
498                                                    query.append(ORDER_BY_ASC);
499                                            }
500                                            else {
501                                                    query.append(ORDER_BY_DESC);
502                                            }
503                                    }
504                            }
505                    }
506                    else {
507                            query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
508                    }
509    
510                    String sql = query.toString();
511    
512                    Query q = session.createQuery(sql);
513    
514                    q.setFirstResult(0);
515                    q.setMaxResults(2);
516    
517                    QueryPos qPos = QueryPos.getInstance(q);
518    
519                    qPos.add(userTrackerId);
520    
521                    if (orderByComparator != null) {
522                            Object[] values = orderByComparator.getOrderByConditionValues(userTrackerPath);
523    
524                            for (Object value : values) {
525                                    qPos.add(value);
526                            }
527                    }
528    
529                    List<UserTrackerPath> list = q.list();
530    
531                    if (list.size() == 2) {
532                            return list.get(1);
533                    }
534                    else {
535                            return null;
536                    }
537            }
538    
539            /**
540             * Removes all the user tracker paths where userTrackerId = &#63; from the database.
541             *
542             * @param userTrackerId the user tracker ID
543             */
544            @Override
545            public void removeByUserTrackerId(long userTrackerId) {
546                    for (UserTrackerPath userTrackerPath : findByUserTrackerId(
547                                    userTrackerId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
548                            remove(userTrackerPath);
549                    }
550            }
551    
552            /**
553             * Returns the number of user tracker paths where userTrackerId = &#63;.
554             *
555             * @param userTrackerId the user tracker ID
556             * @return the number of matching user tracker paths
557             */
558            @Override
559            public int countByUserTrackerId(long userTrackerId) {
560                    FinderPath finderPath = FINDER_PATH_COUNT_BY_USERTRACKERID;
561    
562                    Object[] finderArgs = new Object[] { userTrackerId };
563    
564                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
565    
566                    if (count == null) {
567                            StringBundler query = new StringBundler(2);
568    
569                            query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
570    
571                            query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
572    
573                            String sql = query.toString();
574    
575                            Session session = null;
576    
577                            try {
578                                    session = openSession();
579    
580                                    Query q = session.createQuery(sql);
581    
582                                    QueryPos qPos = QueryPos.getInstance(q);
583    
584                                    qPos.add(userTrackerId);
585    
586                                    count = (Long)q.uniqueResult();
587    
588                                    finderCache.putResult(finderPath, finderArgs, count);
589                            }
590                            catch (Exception e) {
591                                    finderCache.removeResult(finderPath, finderArgs);
592    
593                                    throw processException(e);
594                            }
595                            finally {
596                                    closeSession(session);
597                            }
598                    }
599    
600                    return count.intValue();
601            }
602    
603            private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
604    
605            public UserTrackerPathPersistenceImpl() {
606                    setModelClass(UserTrackerPath.class);
607            }
608    
609            /**
610             * Caches the user tracker path in the entity cache if it is enabled.
611             *
612             * @param userTrackerPath the user tracker path
613             */
614            @Override
615            public void cacheResult(UserTrackerPath userTrackerPath) {
616                    entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
617                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
618                            userTrackerPath);
619    
620                    userTrackerPath.resetOriginalValues();
621            }
622    
623            /**
624             * Caches the user tracker paths in the entity cache if it is enabled.
625             *
626             * @param userTrackerPaths the user tracker paths
627             */
628            @Override
629            public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
630                    for (UserTrackerPath userTrackerPath : userTrackerPaths) {
631                            if (entityCache.getResult(
632                                                    UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
633                                                    UserTrackerPathImpl.class,
634                                                    userTrackerPath.getPrimaryKey()) == null) {
635                                    cacheResult(userTrackerPath);
636                            }
637                            else {
638                                    userTrackerPath.resetOriginalValues();
639                            }
640                    }
641            }
642    
643            /**
644             * Clears the cache for all user tracker paths.
645             *
646             * <p>
647             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
648             * </p>
649             */
650            @Override
651            public void clearCache() {
652                    entityCache.clearCache(UserTrackerPathImpl.class);
653    
654                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
655                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
656                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
657            }
658    
659            /**
660             * Clears the cache for the user tracker path.
661             *
662             * <p>
663             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
664             * </p>
665             */
666            @Override
667            public void clearCache(UserTrackerPath userTrackerPath) {
668                    entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
669                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
670    
671                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
672                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
673            }
674    
675            @Override
676            public void clearCache(List<UserTrackerPath> userTrackerPaths) {
677                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
678                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
679    
680                    for (UserTrackerPath userTrackerPath : userTrackerPaths) {
681                            entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
682                                    UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
683                    }
684            }
685    
686            /**
687             * Creates a new user tracker path with the primary key. Does not add the user tracker path to the database.
688             *
689             * @param userTrackerPathId the primary key for the new user tracker path
690             * @return the new user tracker path
691             */
692            @Override
693            public UserTrackerPath create(long userTrackerPathId) {
694                    UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
695    
696                    userTrackerPath.setNew(true);
697                    userTrackerPath.setPrimaryKey(userTrackerPathId);
698    
699                    return userTrackerPath;
700            }
701    
702            /**
703             * Removes the user tracker path with the primary key from the database. Also notifies the appropriate model listeners.
704             *
705             * @param userTrackerPathId the primary key of the user tracker path
706             * @return the user tracker path that was removed
707             * @throws NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
708             */
709            @Override
710            public UserTrackerPath remove(long userTrackerPathId)
711                    throws NoSuchUserTrackerPathException {
712                    return remove((Serializable)userTrackerPathId);
713            }
714    
715            /**
716             * Removes the user tracker path with the primary key from the database. Also notifies the appropriate model listeners.
717             *
718             * @param primaryKey the primary key of the user tracker path
719             * @return the user tracker path that was removed
720             * @throws NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
721             */
722            @Override
723            public UserTrackerPath remove(Serializable primaryKey)
724                    throws NoSuchUserTrackerPathException {
725                    Session session = null;
726    
727                    try {
728                            session = openSession();
729    
730                            UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
731                                            primaryKey);
732    
733                            if (userTrackerPath == null) {
734                                    if (_log.isWarnEnabled()) {
735                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
736                                    }
737    
738                                    throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
739                                            primaryKey);
740                            }
741    
742                            return remove(userTrackerPath);
743                    }
744                    catch (NoSuchUserTrackerPathException nsee) {
745                            throw nsee;
746                    }
747                    catch (Exception e) {
748                            throw processException(e);
749                    }
750                    finally {
751                            closeSession(session);
752                    }
753            }
754    
755            @Override
756            protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath) {
757                    userTrackerPath = toUnwrappedModel(userTrackerPath);
758    
759                    Session session = null;
760    
761                    try {
762                            session = openSession();
763    
764                            if (!session.contains(userTrackerPath)) {
765                                    userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
766                                                    userTrackerPath.getPrimaryKeyObj());
767                            }
768    
769                            if (userTrackerPath != null) {
770                                    session.delete(userTrackerPath);
771                            }
772                    }
773                    catch (Exception e) {
774                            throw processException(e);
775                    }
776                    finally {
777                            closeSession(session);
778                    }
779    
780                    if (userTrackerPath != null) {
781                            clearCache(userTrackerPath);
782                    }
783    
784                    return userTrackerPath;
785            }
786    
787            @Override
788            public UserTrackerPath updateImpl(UserTrackerPath userTrackerPath) {
789                    userTrackerPath = toUnwrappedModel(userTrackerPath);
790    
791                    boolean isNew = userTrackerPath.isNew();
792    
793                    UserTrackerPathModelImpl userTrackerPathModelImpl = (UserTrackerPathModelImpl)userTrackerPath;
794    
795                    Session session = null;
796    
797                    try {
798                            session = openSession();
799    
800                            if (userTrackerPath.isNew()) {
801                                    session.save(userTrackerPath);
802    
803                                    userTrackerPath.setNew(false);
804                            }
805                            else {
806                                    userTrackerPath = (UserTrackerPath)session.merge(userTrackerPath);
807                            }
808                    }
809                    catch (Exception e) {
810                            throw processException(e);
811                    }
812                    finally {
813                            closeSession(session);
814                    }
815    
816                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
817    
818                    if (isNew || !UserTrackerPathModelImpl.COLUMN_BITMASK_ENABLED) {
819                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
820                    }
821    
822                    else {
823                            if ((userTrackerPathModelImpl.getColumnBitmask() &
824                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID.getColumnBitmask()) != 0) {
825                                    Object[] args = new Object[] {
826                                                    userTrackerPathModelImpl.getOriginalUserTrackerId()
827                                            };
828    
829                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
830                                            args);
831                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
832                                            args);
833    
834                                    args = new Object[] { userTrackerPathModelImpl.getUserTrackerId() };
835    
836                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
837                                            args);
838                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
839                                            args);
840                            }
841                    }
842    
843                    entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
844                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
845                            userTrackerPath, false);
846    
847                    userTrackerPath.resetOriginalValues();
848    
849                    return userTrackerPath;
850            }
851    
852            protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
853                    if (userTrackerPath instanceof UserTrackerPathImpl) {
854                            return userTrackerPath;
855                    }
856    
857                    UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
858    
859                    userTrackerPathImpl.setNew(userTrackerPath.isNew());
860                    userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
861    
862                    userTrackerPathImpl.setMvccVersion(userTrackerPath.getMvccVersion());
863                    userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
864                    userTrackerPathImpl.setCompanyId(userTrackerPath.getCompanyId());
865                    userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
866                    userTrackerPathImpl.setPath(userTrackerPath.getPath());
867                    userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
868    
869                    return userTrackerPathImpl;
870            }
871    
872            /**
873             * Returns the user tracker path with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
874             *
875             * @param primaryKey the primary key of the user tracker path
876             * @return the user tracker path
877             * @throws NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
878             */
879            @Override
880            public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
881                    throws NoSuchUserTrackerPathException {
882                    UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
883    
884                    if (userTrackerPath == null) {
885                            if (_log.isWarnEnabled()) {
886                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
887                            }
888    
889                            throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
890                                    primaryKey);
891                    }
892    
893                    return userTrackerPath;
894            }
895    
896            /**
897             * Returns the user tracker path with the primary key or throws a {@link NoSuchUserTrackerPathException} if it could not be found.
898             *
899             * @param userTrackerPathId the primary key of the user tracker path
900             * @return the user tracker path
901             * @throws NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
902             */
903            @Override
904            public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
905                    throws NoSuchUserTrackerPathException {
906                    return findByPrimaryKey((Serializable)userTrackerPathId);
907            }
908    
909            /**
910             * Returns the user tracker path with the primary key or returns <code>null</code> if it could not be found.
911             *
912             * @param primaryKey the primary key of the user tracker path
913             * @return the user tracker path, or <code>null</code> if a user tracker path with the primary key could not be found
914             */
915            @Override
916            public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey) {
917                    UserTrackerPath userTrackerPath = (UserTrackerPath)entityCache.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
918                                    UserTrackerPathImpl.class, primaryKey);
919    
920                    if (userTrackerPath == _nullUserTrackerPath) {
921                            return null;
922                    }
923    
924                    if (userTrackerPath == null) {
925                            Session session = null;
926    
927                            try {
928                                    session = openSession();
929    
930                                    userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
931                                                    primaryKey);
932    
933                                    if (userTrackerPath != null) {
934                                            cacheResult(userTrackerPath);
935                                    }
936                                    else {
937                                            entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
938                                                    UserTrackerPathImpl.class, primaryKey,
939                                                    _nullUserTrackerPath);
940                                    }
941                            }
942                            catch (Exception e) {
943                                    entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
944                                            UserTrackerPathImpl.class, primaryKey);
945    
946                                    throw processException(e);
947                            }
948                            finally {
949                                    closeSession(session);
950                            }
951                    }
952    
953                    return userTrackerPath;
954            }
955    
956            /**
957             * Returns the user tracker path with the primary key or returns <code>null</code> if it could not be found.
958             *
959             * @param userTrackerPathId the primary key of the user tracker path
960             * @return the user tracker path, or <code>null</code> if a user tracker path with the primary key could not be found
961             */
962            @Override
963            public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId) {
964                    return fetchByPrimaryKey((Serializable)userTrackerPathId);
965            }
966    
967            @Override
968            public Map<Serializable, UserTrackerPath> fetchByPrimaryKeys(
969                    Set<Serializable> primaryKeys) {
970                    if (primaryKeys.isEmpty()) {
971                            return Collections.emptyMap();
972                    }
973    
974                    Map<Serializable, UserTrackerPath> map = new HashMap<Serializable, UserTrackerPath>();
975    
976                    if (primaryKeys.size() == 1) {
977                            Iterator<Serializable> iterator = primaryKeys.iterator();
978    
979                            Serializable primaryKey = iterator.next();
980    
981                            UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
982    
983                            if (userTrackerPath != null) {
984                                    map.put(primaryKey, userTrackerPath);
985                            }
986    
987                            return map;
988                    }
989    
990                    Set<Serializable> uncachedPrimaryKeys = null;
991    
992                    for (Serializable primaryKey : primaryKeys) {
993                            UserTrackerPath userTrackerPath = (UserTrackerPath)entityCache.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
994                                            UserTrackerPathImpl.class, primaryKey);
995    
996                            if (userTrackerPath == null) {
997                                    if (uncachedPrimaryKeys == null) {
998                                            uncachedPrimaryKeys = new HashSet<Serializable>();
999                                    }
1000    
1001                                    uncachedPrimaryKeys.add(primaryKey);
1002                            }
1003                            else {
1004                                    map.put(primaryKey, userTrackerPath);
1005                            }
1006                    }
1007    
1008                    if (uncachedPrimaryKeys == null) {
1009                            return map;
1010                    }
1011    
1012                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1013                                    1);
1014    
1015                    query.append(_SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN);
1016    
1017                    for (Serializable primaryKey : uncachedPrimaryKeys) {
1018                            query.append(String.valueOf(primaryKey));
1019    
1020                            query.append(StringPool.COMMA);
1021                    }
1022    
1023                    query.setIndex(query.index() - 1);
1024    
1025                    query.append(StringPool.CLOSE_PARENTHESIS);
1026    
1027                    String sql = query.toString();
1028    
1029                    Session session = null;
1030    
1031                    try {
1032                            session = openSession();
1033    
1034                            Query q = session.createQuery(sql);
1035    
1036                            for (UserTrackerPath userTrackerPath : (List<UserTrackerPath>)q.list()) {
1037                                    map.put(userTrackerPath.getPrimaryKeyObj(), userTrackerPath);
1038    
1039                                    cacheResult(userTrackerPath);
1040    
1041                                    uncachedPrimaryKeys.remove(userTrackerPath.getPrimaryKeyObj());
1042                            }
1043    
1044                            for (Serializable primaryKey : uncachedPrimaryKeys) {
1045                                    entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
1046                                            UserTrackerPathImpl.class, primaryKey, _nullUserTrackerPath);
1047                            }
1048                    }
1049                    catch (Exception e) {
1050                            throw processException(e);
1051                    }
1052                    finally {
1053                            closeSession(session);
1054                    }
1055    
1056                    return map;
1057            }
1058    
1059            /**
1060             * Returns all the user tracker paths.
1061             *
1062             * @return the user tracker paths
1063             */
1064            @Override
1065            public List<UserTrackerPath> findAll() {
1066                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1067            }
1068    
1069            /**
1070             * Returns a range of all the user tracker paths.
1071             *
1072             * <p>
1073             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserTrackerPathModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1074             * </p>
1075             *
1076             * @param start the lower bound of the range of user tracker paths
1077             * @param end the upper bound of the range of user tracker paths (not inclusive)
1078             * @return the range of user tracker paths
1079             */
1080            @Override
1081            public List<UserTrackerPath> findAll(int start, int end) {
1082                    return findAll(start, end, null);
1083            }
1084    
1085            /**
1086             * Returns an ordered range of all the user tracker paths.
1087             *
1088             * <p>
1089             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserTrackerPathModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1090             * </p>
1091             *
1092             * @param start the lower bound of the range of user tracker paths
1093             * @param end the upper bound of the range of user tracker paths (not inclusive)
1094             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1095             * @return the ordered range of user tracker paths
1096             */
1097            @Override
1098            public List<UserTrackerPath> findAll(int start, int end,
1099                    OrderByComparator<UserTrackerPath> orderByComparator) {
1100                    return findAll(start, end, orderByComparator, true);
1101            }
1102    
1103            /**
1104             * Returns an ordered range of all the user tracker paths.
1105             *
1106             * <p>
1107             * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserTrackerPathModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1108             * </p>
1109             *
1110             * @param start the lower bound of the range of user tracker paths
1111             * @param end the upper bound of the range of user tracker paths (not inclusive)
1112             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1113             * @param retrieveFromCache whether to retrieve from the finder cache
1114             * @return the ordered range of user tracker paths
1115             */
1116            @Override
1117            public List<UserTrackerPath> findAll(int start, int end,
1118                    OrderByComparator<UserTrackerPath> orderByComparator,
1119                    boolean retrieveFromCache) {
1120                    boolean pagination = true;
1121                    FinderPath finderPath = null;
1122                    Object[] finderArgs = null;
1123    
1124                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1125                                    (orderByComparator == null)) {
1126                            pagination = false;
1127                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1128                            finderArgs = FINDER_ARGS_EMPTY;
1129                    }
1130                    else {
1131                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1132                            finderArgs = new Object[] { start, end, orderByComparator };
1133                    }
1134    
1135                    List<UserTrackerPath> list = null;
1136    
1137                    if (retrieveFromCache) {
1138                            list = (List<UserTrackerPath>)finderCache.getResult(finderPath,
1139                                            finderArgs, this);
1140                    }
1141    
1142                    if (list == null) {
1143                            StringBundler query = null;
1144                            String sql = null;
1145    
1146                            if (orderByComparator != null) {
1147                                    query = new StringBundler(2 +
1148                                                    (orderByComparator.getOrderByFields().length * 3));
1149    
1150                                    query.append(_SQL_SELECT_USERTRACKERPATH);
1151    
1152                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1153                                            orderByComparator);
1154    
1155                                    sql = query.toString();
1156                            }
1157                            else {
1158                                    sql = _SQL_SELECT_USERTRACKERPATH;
1159    
1160                                    if (pagination) {
1161                                            sql = sql.concat(UserTrackerPathModelImpl.ORDER_BY_JPQL);
1162                                    }
1163                            }
1164    
1165                            Session session = null;
1166    
1167                            try {
1168                                    session = openSession();
1169    
1170                                    Query q = session.createQuery(sql);
1171    
1172                                    if (!pagination) {
1173                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
1174                                                            getDialect(), start, end, false);
1175    
1176                                            Collections.sort(list);
1177    
1178                                            list = Collections.unmodifiableList(list);
1179                                    }
1180                                    else {
1181                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
1182                                                            getDialect(), start, end);
1183                                    }
1184    
1185                                    cacheResult(list);
1186    
1187                                    finderCache.putResult(finderPath, finderArgs, list);
1188                            }
1189                            catch (Exception e) {
1190                                    finderCache.removeResult(finderPath, finderArgs);
1191    
1192                                    throw processException(e);
1193                            }
1194                            finally {
1195                                    closeSession(session);
1196                            }
1197                    }
1198    
1199                    return list;
1200            }
1201    
1202            /**
1203             * Removes all the user tracker paths from the database.
1204             *
1205             */
1206            @Override
1207            public void removeAll() {
1208                    for (UserTrackerPath userTrackerPath : findAll()) {
1209                            remove(userTrackerPath);
1210                    }
1211            }
1212    
1213            /**
1214             * Returns the number of user tracker paths.
1215             *
1216             * @return the number of user tracker paths
1217             */
1218            @Override
1219            public int countAll() {
1220                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
1221                                    FINDER_ARGS_EMPTY, this);
1222    
1223                    if (count == null) {
1224                            Session session = null;
1225    
1226                            try {
1227                                    session = openSession();
1228    
1229                                    Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
1230    
1231                                    count = (Long)q.uniqueResult();
1232    
1233                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
1234                                            count);
1235                            }
1236                            catch (Exception e) {
1237                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
1238                                            FINDER_ARGS_EMPTY);
1239    
1240                                    throw processException(e);
1241                            }
1242                            finally {
1243                                    closeSession(session);
1244                            }
1245                    }
1246    
1247                    return count.intValue();
1248            }
1249    
1250            @Override
1251            public Set<String> getBadColumnNames() {
1252                    return _badColumnNames;
1253            }
1254    
1255            @Override
1256            protected Map<String, Integer> getTableColumnsMap() {
1257                    return UserTrackerPathModelImpl.TABLE_COLUMNS_MAP;
1258            }
1259    
1260            /**
1261             * Initializes the user tracker path persistence.
1262             */
1263            public void afterPropertiesSet() {
1264            }
1265    
1266            public void destroy() {
1267                    entityCache.removeCache(UserTrackerPathImpl.class.getName());
1268                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1269                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1270                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1271            }
1272    
1273            @BeanReference(type = CompanyProvider.class)
1274            protected CompanyProvider companyProvider;
1275            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1276            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1277            private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1278            private static final String _SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE userTrackerPathId IN (";
1279            private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1280            private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1281            private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1282            private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1283            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1284            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1285            private static final Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1286            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1287                                    "path"
1288                            });
1289            private static final UserTrackerPath _nullUserTrackerPath = new UserTrackerPathImpl() {
1290                            @Override
1291                            public Object clone() {
1292                                    return this;
1293                            }
1294    
1295                            @Override
1296                            public CacheModel<UserTrackerPath> toCacheModel() {
1297                                    return _nullUserTrackerPathCacheModel;
1298                            }
1299                    };
1300    
1301            private static final CacheModel<UserTrackerPath> _nullUserTrackerPathCacheModel =
1302                    new NullCacheModel();
1303    
1304            private static class NullCacheModel implements CacheModel<UserTrackerPath>,
1305                    MVCCModel {
1306                    @Override
1307                    public long getMvccVersion() {
1308                            return -1;
1309                    }
1310    
1311                    @Override
1312                    public void setMvccVersion(long mvccVersion) {
1313                    }
1314    
1315                    @Override
1316                    public UserTrackerPath toEntityModel() {
1317                            return _nullUserTrackerPath;
1318                    }
1319            }
1320    }