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