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 * 2));
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(4 +
442                                            (orderByComparator.getOrderByConditionFields().length * 3) +
443                                            (orderByComparator.getOrderByFields().length * 3));
444                    }
445                    else {
446                            query = new StringBundler(3);
447                    }
448    
449                    query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
450    
451                    query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
452    
453                    if (orderByComparator != null) {
454                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
455    
456                            if (orderByConditionFields.length > 0) {
457                                    query.append(WHERE_AND);
458                            }
459    
460                            for (int i = 0; i < orderByConditionFields.length; i++) {
461                                    query.append(_ORDER_BY_ENTITY_ALIAS);
462                                    query.append(orderByConditionFields[i]);
463    
464                                    if ((i + 1) < orderByConditionFields.length) {
465                                            if (orderByComparator.isAscending() ^ previous) {
466                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
467                                            }
468                                            else {
469                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
470                                            }
471                                    }
472                                    else {
473                                            if (orderByComparator.isAscending() ^ previous) {
474                                                    query.append(WHERE_GREATER_THAN);
475                                            }
476                                            else {
477                                                    query.append(WHERE_LESSER_THAN);
478                                            }
479                                    }
480                            }
481    
482                            query.append(ORDER_BY_CLAUSE);
483    
484                            String[] orderByFields = orderByComparator.getOrderByFields();
485    
486                            for (int i = 0; i < orderByFields.length; i++) {
487                                    query.append(_ORDER_BY_ENTITY_ALIAS);
488                                    query.append(orderByFields[i]);
489    
490                                    if ((i + 1) < orderByFields.length) {
491                                            if (orderByComparator.isAscending() ^ previous) {
492                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
493                                            }
494                                            else {
495                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
496                                            }
497                                    }
498                                    else {
499                                            if (orderByComparator.isAscending() ^ previous) {
500                                                    query.append(ORDER_BY_ASC);
501                                            }
502                                            else {
503                                                    query.append(ORDER_BY_DESC);
504                                            }
505                                    }
506                            }
507                    }
508                    else {
509                            query.append(UserTrackerPathModelImpl.ORDER_BY_JPQL);
510                    }
511    
512                    String sql = query.toString();
513    
514                    Query q = session.createQuery(sql);
515    
516                    q.setFirstResult(0);
517                    q.setMaxResults(2);
518    
519                    QueryPos qPos = QueryPos.getInstance(q);
520    
521                    qPos.add(userTrackerId);
522    
523                    if (orderByComparator != null) {
524                            Object[] values = orderByComparator.getOrderByConditionValues(userTrackerPath);
525    
526                            for (Object value : values) {
527                                    qPos.add(value);
528                            }
529                    }
530    
531                    List<UserTrackerPath> list = q.list();
532    
533                    if (list.size() == 2) {
534                            return list.get(1);
535                    }
536                    else {
537                            return null;
538                    }
539            }
540    
541            /**
542             * Removes all the user tracker paths where userTrackerId = &#63; from the database.
543             *
544             * @param userTrackerId the user tracker ID
545             */
546            @Override
547            public void removeByUserTrackerId(long userTrackerId) {
548                    for (UserTrackerPath userTrackerPath : findByUserTrackerId(
549                                    userTrackerId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
550                            remove(userTrackerPath);
551                    }
552            }
553    
554            /**
555             * Returns the number of user tracker paths where userTrackerId = &#63;.
556             *
557             * @param userTrackerId the user tracker ID
558             * @return the number of matching user tracker paths
559             */
560            @Override
561            public int countByUserTrackerId(long userTrackerId) {
562                    FinderPath finderPath = FINDER_PATH_COUNT_BY_USERTRACKERID;
563    
564                    Object[] finderArgs = new Object[] { userTrackerId };
565    
566                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
567    
568                    if (count == null) {
569                            StringBundler query = new StringBundler(2);
570    
571                            query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
572    
573                            query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
574    
575                            String sql = query.toString();
576    
577                            Session session = null;
578    
579                            try {
580                                    session = openSession();
581    
582                                    Query q = session.createQuery(sql);
583    
584                                    QueryPos qPos = QueryPos.getInstance(q);
585    
586                                    qPos.add(userTrackerId);
587    
588                                    count = (Long)q.uniqueResult();
589    
590                                    finderCache.putResult(finderPath, finderArgs, count);
591                            }
592                            catch (Exception e) {
593                                    finderCache.removeResult(finderPath, finderArgs);
594    
595                                    throw processException(e);
596                            }
597                            finally {
598                                    closeSession(session);
599                            }
600                    }
601    
602                    return count.intValue();
603            }
604    
605            private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
606    
607            public UserTrackerPathPersistenceImpl() {
608                    setModelClass(UserTrackerPath.class);
609            }
610    
611            /**
612             * Caches the user tracker path in the entity cache if it is enabled.
613             *
614             * @param userTrackerPath the user tracker path
615             */
616            @Override
617            public void cacheResult(UserTrackerPath userTrackerPath) {
618                    entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
619                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
620                            userTrackerPath);
621    
622                    userTrackerPath.resetOriginalValues();
623            }
624    
625            /**
626             * Caches the user tracker paths in the entity cache if it is enabled.
627             *
628             * @param userTrackerPaths the user tracker paths
629             */
630            @Override
631            public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
632                    for (UserTrackerPath userTrackerPath : userTrackerPaths) {
633                            if (entityCache.getResult(
634                                                    UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
635                                                    UserTrackerPathImpl.class,
636                                                    userTrackerPath.getPrimaryKey()) == null) {
637                                    cacheResult(userTrackerPath);
638                            }
639                            else {
640                                    userTrackerPath.resetOriginalValues();
641                            }
642                    }
643            }
644    
645            /**
646             * Clears the cache for all user tracker paths.
647             *
648             * <p>
649             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
650             * </p>
651             */
652            @Override
653            public void clearCache() {
654                    entityCache.clearCache(UserTrackerPathImpl.class);
655    
656                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
657                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
658                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
659            }
660    
661            /**
662             * Clears the cache for the user tracker path.
663             *
664             * <p>
665             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
666             * </p>
667             */
668            @Override
669            public void clearCache(UserTrackerPath userTrackerPath) {
670                    entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
671                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
672    
673                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
674                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
675            }
676    
677            @Override
678            public void clearCache(List<UserTrackerPath> userTrackerPaths) {
679                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
680                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
681    
682                    for (UserTrackerPath userTrackerPath : userTrackerPaths) {
683                            entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
684                                    UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
685                    }
686            }
687    
688            /**
689             * Creates a new user tracker path with the primary key. Does not add the user tracker path to the database.
690             *
691             * @param userTrackerPathId the primary key for the new user tracker path
692             * @return the new user tracker path
693             */
694            @Override
695            public UserTrackerPath create(long userTrackerPathId) {
696                    UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
697    
698                    userTrackerPath.setNew(true);
699                    userTrackerPath.setPrimaryKey(userTrackerPathId);
700    
701                    userTrackerPath.setCompanyId(companyProvider.getCompanyId());
702    
703                    return userTrackerPath;
704            }
705    
706            /**
707             * Removes the user tracker path with the primary key from the database. Also notifies the appropriate model listeners.
708             *
709             * @param userTrackerPathId the primary key of the user tracker path
710             * @return the user tracker path that was removed
711             * @throws NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
712             */
713            @Override
714            public UserTrackerPath remove(long userTrackerPathId)
715                    throws NoSuchUserTrackerPathException {
716                    return remove((Serializable)userTrackerPathId);
717            }
718    
719            /**
720             * Removes the user tracker path with the primary key from the database. Also notifies the appropriate model listeners.
721             *
722             * @param primaryKey the primary key of the user tracker path
723             * @return the user tracker path that was removed
724             * @throws NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
725             */
726            @Override
727            public UserTrackerPath remove(Serializable primaryKey)
728                    throws NoSuchUserTrackerPathException {
729                    Session session = null;
730    
731                    try {
732                            session = openSession();
733    
734                            UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
735                                            primaryKey);
736    
737                            if (userTrackerPath == null) {
738                                    if (_log.isWarnEnabled()) {
739                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
740                                    }
741    
742                                    throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
743                                            primaryKey);
744                            }
745    
746                            return remove(userTrackerPath);
747                    }
748                    catch (NoSuchUserTrackerPathException nsee) {
749                            throw nsee;
750                    }
751                    catch (Exception e) {
752                            throw processException(e);
753                    }
754                    finally {
755                            closeSession(session);
756                    }
757            }
758    
759            @Override
760            protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath) {
761                    userTrackerPath = toUnwrappedModel(userTrackerPath);
762    
763                    Session session = null;
764    
765                    try {
766                            session = openSession();
767    
768                            if (!session.contains(userTrackerPath)) {
769                                    userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
770                                                    userTrackerPath.getPrimaryKeyObj());
771                            }
772    
773                            if (userTrackerPath != null) {
774                                    session.delete(userTrackerPath);
775                            }
776                    }
777                    catch (Exception e) {
778                            throw processException(e);
779                    }
780                    finally {
781                            closeSession(session);
782                    }
783    
784                    if (userTrackerPath != null) {
785                            clearCache(userTrackerPath);
786                    }
787    
788                    return userTrackerPath;
789            }
790    
791            @Override
792            public UserTrackerPath updateImpl(UserTrackerPath userTrackerPath) {
793                    userTrackerPath = toUnwrappedModel(userTrackerPath);
794    
795                    boolean isNew = userTrackerPath.isNew();
796    
797                    UserTrackerPathModelImpl userTrackerPathModelImpl = (UserTrackerPathModelImpl)userTrackerPath;
798    
799                    Session session = null;
800    
801                    try {
802                            session = openSession();
803    
804                            if (userTrackerPath.isNew()) {
805                                    session.save(userTrackerPath);
806    
807                                    userTrackerPath.setNew(false);
808                            }
809                            else {
810                                    userTrackerPath = (UserTrackerPath)session.merge(userTrackerPath);
811                            }
812                    }
813                    catch (Exception e) {
814                            throw processException(e);
815                    }
816                    finally {
817                            closeSession(session);
818                    }
819    
820                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
821    
822                    if (isNew || !UserTrackerPathModelImpl.COLUMN_BITMASK_ENABLED) {
823                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
824                    }
825    
826                    else {
827                            if ((userTrackerPathModelImpl.getColumnBitmask() &
828                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID.getColumnBitmask()) != 0) {
829                                    Object[] args = new Object[] {
830                                                    userTrackerPathModelImpl.getOriginalUserTrackerId()
831                                            };
832    
833                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
834                                            args);
835                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
836                                            args);
837    
838                                    args = new Object[] { userTrackerPathModelImpl.getUserTrackerId() };
839    
840                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
841                                            args);
842                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERTRACKERID,
843                                            args);
844                            }
845                    }
846    
847                    entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
848                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
849                            userTrackerPath, false);
850    
851                    userTrackerPath.resetOriginalValues();
852    
853                    return userTrackerPath;
854            }
855    
856            protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
857                    if (userTrackerPath instanceof UserTrackerPathImpl) {
858                            return userTrackerPath;
859                    }
860    
861                    UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
862    
863                    userTrackerPathImpl.setNew(userTrackerPath.isNew());
864                    userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
865    
866                    userTrackerPathImpl.setMvccVersion(userTrackerPath.getMvccVersion());
867                    userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
868                    userTrackerPathImpl.setCompanyId(userTrackerPath.getCompanyId());
869                    userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
870                    userTrackerPathImpl.setPath(userTrackerPath.getPath());
871                    userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
872    
873                    return userTrackerPathImpl;
874            }
875    
876            /**
877             * Returns the user tracker path with the primary key or throws a {@link com.liferay.portal.exception.NoSuchModelException} if it could not be found.
878             *
879             * @param primaryKey the primary key of the user tracker path
880             * @return the user tracker path
881             * @throws NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
882             */
883            @Override
884            public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
885                    throws NoSuchUserTrackerPathException {
886                    UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
887    
888                    if (userTrackerPath == null) {
889                            if (_log.isWarnEnabled()) {
890                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
891                            }
892    
893                            throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
894                                    primaryKey);
895                    }
896    
897                    return userTrackerPath;
898            }
899    
900            /**
901             * Returns the user tracker path with the primary key or throws a {@link NoSuchUserTrackerPathException} if it could not be found.
902             *
903             * @param userTrackerPathId the primary key of the user tracker path
904             * @return the user tracker path
905             * @throws NoSuchUserTrackerPathException if a user tracker path with the primary key could not be found
906             */
907            @Override
908            public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
909                    throws NoSuchUserTrackerPathException {
910                    return findByPrimaryKey((Serializable)userTrackerPathId);
911            }
912    
913            /**
914             * Returns the user tracker path with the primary key or returns <code>null</code> if it could not be found.
915             *
916             * @param primaryKey the primary key of the user tracker path
917             * @return the user tracker path, or <code>null</code> if a user tracker path with the primary key could not be found
918             */
919            @Override
920            public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey) {
921                    UserTrackerPath userTrackerPath = (UserTrackerPath)entityCache.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
922                                    UserTrackerPathImpl.class, primaryKey);
923    
924                    if (userTrackerPath == _nullUserTrackerPath) {
925                            return null;
926                    }
927    
928                    if (userTrackerPath == null) {
929                            Session session = null;
930    
931                            try {
932                                    session = openSession();
933    
934                                    userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
935                                                    primaryKey);
936    
937                                    if (userTrackerPath != null) {
938                                            cacheResult(userTrackerPath);
939                                    }
940                                    else {
941                                            entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
942                                                    UserTrackerPathImpl.class, primaryKey,
943                                                    _nullUserTrackerPath);
944                                    }
945                            }
946                            catch (Exception e) {
947                                    entityCache.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
948                                            UserTrackerPathImpl.class, primaryKey);
949    
950                                    throw processException(e);
951                            }
952                            finally {
953                                    closeSession(session);
954                            }
955                    }
956    
957                    return userTrackerPath;
958            }
959    
960            /**
961             * Returns the user tracker path with the primary key or returns <code>null</code> if it could not be found.
962             *
963             * @param userTrackerPathId the primary key of the user tracker path
964             * @return the user tracker path, or <code>null</code> if a user tracker path with the primary key could not be found
965             */
966            @Override
967            public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId) {
968                    return fetchByPrimaryKey((Serializable)userTrackerPathId);
969            }
970    
971            @Override
972            public Map<Serializable, UserTrackerPath> fetchByPrimaryKeys(
973                    Set<Serializable> primaryKeys) {
974                    if (primaryKeys.isEmpty()) {
975                            return Collections.emptyMap();
976                    }
977    
978                    Map<Serializable, UserTrackerPath> map = new HashMap<Serializable, UserTrackerPath>();
979    
980                    if (primaryKeys.size() == 1) {
981                            Iterator<Serializable> iterator = primaryKeys.iterator();
982    
983                            Serializable primaryKey = iterator.next();
984    
985                            UserTrackerPath userTrackerPath = fetchByPrimaryKey(primaryKey);
986    
987                            if (userTrackerPath != null) {
988                                    map.put(primaryKey, userTrackerPath);
989                            }
990    
991                            return map;
992                    }
993    
994                    Set<Serializable> uncachedPrimaryKeys = null;
995    
996                    for (Serializable primaryKey : primaryKeys) {
997                            UserTrackerPath userTrackerPath = (UserTrackerPath)entityCache.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
998                                            UserTrackerPathImpl.class, primaryKey);
999    
1000                            if (userTrackerPath == null) {
1001                                    if (uncachedPrimaryKeys == null) {
1002                                            uncachedPrimaryKeys = new HashSet<Serializable>();
1003                                    }
1004    
1005                                    uncachedPrimaryKeys.add(primaryKey);
1006                            }
1007                            else {
1008                                    map.put(primaryKey, userTrackerPath);
1009                            }
1010                    }
1011    
1012                    if (uncachedPrimaryKeys == null) {
1013                            return map;
1014                    }
1015    
1016                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1017                                    1);
1018    
1019                    query.append(_SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN);
1020    
1021                    for (Serializable primaryKey : uncachedPrimaryKeys) {
1022                            query.append(String.valueOf(primaryKey));
1023    
1024                            query.append(StringPool.COMMA);
1025                    }
1026    
1027                    query.setIndex(query.index() - 1);
1028    
1029                    query.append(StringPool.CLOSE_PARENTHESIS);
1030    
1031                    String sql = query.toString();
1032    
1033                    Session session = null;
1034    
1035                    try {
1036                            session = openSession();
1037    
1038                            Query q = session.createQuery(sql);
1039    
1040                            for (UserTrackerPath userTrackerPath : (List<UserTrackerPath>)q.list()) {
1041                                    map.put(userTrackerPath.getPrimaryKeyObj(), userTrackerPath);
1042    
1043                                    cacheResult(userTrackerPath);
1044    
1045                                    uncachedPrimaryKeys.remove(userTrackerPath.getPrimaryKeyObj());
1046                            }
1047    
1048                            for (Serializable primaryKey : uncachedPrimaryKeys) {
1049                                    entityCache.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
1050                                            UserTrackerPathImpl.class, primaryKey, _nullUserTrackerPath);
1051                            }
1052                    }
1053                    catch (Exception e) {
1054                            throw processException(e);
1055                    }
1056                    finally {
1057                            closeSession(session);
1058                    }
1059    
1060                    return map;
1061            }
1062    
1063            /**
1064             * Returns all the user tracker paths.
1065             *
1066             * @return the user tracker paths
1067             */
1068            @Override
1069            public List<UserTrackerPath> findAll() {
1070                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1071            }
1072    
1073            /**
1074             * Returns a range of all the user tracker paths.
1075             *
1076             * <p>
1077             * 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.
1078             * </p>
1079             *
1080             * @param start the lower bound of the range of user tracker paths
1081             * @param end the upper bound of the range of user tracker paths (not inclusive)
1082             * @return the range of user tracker paths
1083             */
1084            @Override
1085            public List<UserTrackerPath> findAll(int start, int end) {
1086                    return findAll(start, end, null);
1087            }
1088    
1089            /**
1090             * Returns an ordered range of all the user tracker paths.
1091             *
1092             * <p>
1093             * 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.
1094             * </p>
1095             *
1096             * @param start the lower bound of the range of user tracker paths
1097             * @param end the upper bound of the range of user tracker paths (not inclusive)
1098             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1099             * @return the ordered range of user tracker paths
1100             */
1101            @Override
1102            public List<UserTrackerPath> findAll(int start, int end,
1103                    OrderByComparator<UserTrackerPath> orderByComparator) {
1104                    return findAll(start, end, orderByComparator, true);
1105            }
1106    
1107            /**
1108             * Returns an ordered range of all the user tracker paths.
1109             *
1110             * <p>
1111             * 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.
1112             * </p>
1113             *
1114             * @param start the lower bound of the range of user tracker paths
1115             * @param end the upper bound of the range of user tracker paths (not inclusive)
1116             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1117             * @param retrieveFromCache whether to retrieve from the finder cache
1118             * @return the ordered range of user tracker paths
1119             */
1120            @Override
1121            public List<UserTrackerPath> findAll(int start, int end,
1122                    OrderByComparator<UserTrackerPath> orderByComparator,
1123                    boolean retrieveFromCache) {
1124                    boolean pagination = true;
1125                    FinderPath finderPath = null;
1126                    Object[] finderArgs = null;
1127    
1128                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1129                                    (orderByComparator == null)) {
1130                            pagination = false;
1131                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1132                            finderArgs = FINDER_ARGS_EMPTY;
1133                    }
1134                    else {
1135                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1136                            finderArgs = new Object[] { start, end, orderByComparator };
1137                    }
1138    
1139                    List<UserTrackerPath> list = null;
1140    
1141                    if (retrieveFromCache) {
1142                            list = (List<UserTrackerPath>)finderCache.getResult(finderPath,
1143                                            finderArgs, this);
1144                    }
1145    
1146                    if (list == null) {
1147                            StringBundler query = null;
1148                            String sql = null;
1149    
1150                            if (orderByComparator != null) {
1151                                    query = new StringBundler(2 +
1152                                                    (orderByComparator.getOrderByFields().length * 2));
1153    
1154                                    query.append(_SQL_SELECT_USERTRACKERPATH);
1155    
1156                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1157                                            orderByComparator);
1158    
1159                                    sql = query.toString();
1160                            }
1161                            else {
1162                                    sql = _SQL_SELECT_USERTRACKERPATH;
1163    
1164                                    if (pagination) {
1165                                            sql = sql.concat(UserTrackerPathModelImpl.ORDER_BY_JPQL);
1166                                    }
1167                            }
1168    
1169                            Session session = null;
1170    
1171                            try {
1172                                    session = openSession();
1173    
1174                                    Query q = session.createQuery(sql);
1175    
1176                                    if (!pagination) {
1177                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
1178                                                            getDialect(), start, end, false);
1179    
1180                                            Collections.sort(list);
1181    
1182                                            list = Collections.unmodifiableList(list);
1183                                    }
1184                                    else {
1185                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
1186                                                            getDialect(), start, end);
1187                                    }
1188    
1189                                    cacheResult(list);
1190    
1191                                    finderCache.putResult(finderPath, finderArgs, list);
1192                            }
1193                            catch (Exception e) {
1194                                    finderCache.removeResult(finderPath, finderArgs);
1195    
1196                                    throw processException(e);
1197                            }
1198                            finally {
1199                                    closeSession(session);
1200                            }
1201                    }
1202    
1203                    return list;
1204            }
1205    
1206            /**
1207             * Removes all the user tracker paths from the database.
1208             *
1209             */
1210            @Override
1211            public void removeAll() {
1212                    for (UserTrackerPath userTrackerPath : findAll()) {
1213                            remove(userTrackerPath);
1214                    }
1215            }
1216    
1217            /**
1218             * Returns the number of user tracker paths.
1219             *
1220             * @return the number of user tracker paths
1221             */
1222            @Override
1223            public int countAll() {
1224                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
1225                                    FINDER_ARGS_EMPTY, this);
1226    
1227                    if (count == null) {
1228                            Session session = null;
1229    
1230                            try {
1231                                    session = openSession();
1232    
1233                                    Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
1234    
1235                                    count = (Long)q.uniqueResult();
1236    
1237                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
1238                                            count);
1239                            }
1240                            catch (Exception e) {
1241                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
1242                                            FINDER_ARGS_EMPTY);
1243    
1244                                    throw processException(e);
1245                            }
1246                            finally {
1247                                    closeSession(session);
1248                            }
1249                    }
1250    
1251                    return count.intValue();
1252            }
1253    
1254            @Override
1255            public Set<String> getBadColumnNames() {
1256                    return _badColumnNames;
1257            }
1258    
1259            @Override
1260            protected Map<String, Integer> getTableColumnsMap() {
1261                    return UserTrackerPathModelImpl.TABLE_COLUMNS_MAP;
1262            }
1263    
1264            /**
1265             * Initializes the user tracker path persistence.
1266             */
1267            public void afterPropertiesSet() {
1268            }
1269    
1270            public void destroy() {
1271                    entityCache.removeCache(UserTrackerPathImpl.class.getName());
1272                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1273                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1274                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1275            }
1276    
1277            @BeanReference(type = CompanyProviderWrapper.class)
1278            protected CompanyProvider companyProvider;
1279            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1280            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1281            private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
1282            private static final String _SQL_SELECT_USERTRACKERPATH_WHERE_PKS_IN = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE userTrackerPathId IN (";
1283            private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
1284            private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
1285            private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
1286            private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
1287            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
1288            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
1289            private static final Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
1290            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1291                                    "path"
1292                            });
1293            private static final UserTrackerPath _nullUserTrackerPath = new UserTrackerPathImpl() {
1294                            @Override
1295                            public Object clone() {
1296                                    return this;
1297                            }
1298    
1299                            @Override
1300                            public CacheModel<UserTrackerPath> toCacheModel() {
1301                                    return _nullUserTrackerPathCacheModel;
1302                            }
1303                    };
1304    
1305            private static final CacheModel<UserTrackerPath> _nullUserTrackerPathCacheModel =
1306                    new NullCacheModel();
1307    
1308            private static class NullCacheModel implements CacheModel<UserTrackerPath>,
1309                    MVCCModel {
1310                    @Override
1311                    public long getMvccVersion() {
1312                            return -1;
1313                    }
1314    
1315                    @Override
1316                    public void setMvccVersion(long mvccVersion) {
1317                    }
1318    
1319                    @Override
1320                    public UserTrackerPath toEntityModel() {
1321                            return _nullUserTrackerPath;
1322                    }
1323            }
1324    }