001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchUserTrackerPathException;
019    import com.liferay.portal.kernel.annotation.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.model.UserTrackerPath;
039    import com.liferay.portal.model.impl.UserTrackerPathImpl;
040    import com.liferay.portal.model.impl.UserTrackerPathModelImpl;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import java.io.Serializable;
044    
045    import java.util.ArrayList;
046    import java.util.Collections;
047    import java.util.List;
048    
049    /**
050     * @author    Brian Wing Shun Chan
051     * @see       UserTrackerPathPersistence
052     * @see       UserTrackerPathUtil
053     * @generated
054     */
055    public class UserTrackerPathPersistenceImpl extends BasePersistenceImpl<UserTrackerPath>
056            implements UserTrackerPathPersistence {
057            public static final String FINDER_CLASS_NAME_ENTITY = UserTrackerPathImpl.class.getName();
058            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
059                    ".List";
060            public static final FinderPath FINDER_PATH_FIND_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
061                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
062                            FINDER_CLASS_NAME_LIST, "findByUserTrackerId",
063                            new String[] {
064                                    Long.class.getName(),
065                                    
066                            "java.lang.Integer", "java.lang.Integer",
067                                    "com.liferay.portal.kernel.util.OrderByComparator"
068                            });
069            public static final FinderPath FINDER_PATH_COUNT_BY_USERTRACKERID = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
070                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
071                            FINDER_CLASS_NAME_LIST, "countByUserTrackerId",
072                            new String[] { Long.class.getName() });
073            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
074                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
075                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
076            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
077                            UserTrackerPathModelImpl.FINDER_CACHE_ENABLED,
078                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
079    
080            public void cacheResult(UserTrackerPath userTrackerPath) {
081                    EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
082                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
083                            userTrackerPath);
084            }
085    
086            public void cacheResult(List<UserTrackerPath> userTrackerPaths) {
087                    for (UserTrackerPath userTrackerPath : userTrackerPaths) {
088                            if (EntityCacheUtil.getResult(
089                                                    UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
090                                                    UserTrackerPathImpl.class,
091                                                    userTrackerPath.getPrimaryKey(), this) == null) {
092                                    cacheResult(userTrackerPath);
093                            }
094                    }
095            }
096    
097            public void clearCache() {
098                    CacheRegistryUtil.clear(UserTrackerPathImpl.class.getName());
099                    EntityCacheUtil.clearCache(UserTrackerPathImpl.class.getName());
100                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
101                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
102            }
103    
104            public void clearCache(UserTrackerPath userTrackerPath) {
105                    EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
106                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
107            }
108    
109            public UserTrackerPath create(long userTrackerPathId) {
110                    UserTrackerPath userTrackerPath = new UserTrackerPathImpl();
111    
112                    userTrackerPath.setNew(true);
113                    userTrackerPath.setPrimaryKey(userTrackerPathId);
114    
115                    return userTrackerPath;
116            }
117    
118            public UserTrackerPath remove(Serializable primaryKey)
119                    throws NoSuchModelException, SystemException {
120                    return remove(((Long)primaryKey).longValue());
121            }
122    
123            public UserTrackerPath remove(long userTrackerPathId)
124                    throws NoSuchUserTrackerPathException, SystemException {
125                    Session session = null;
126    
127                    try {
128                            session = openSession();
129    
130                            UserTrackerPath userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
131                                            new Long(userTrackerPathId));
132    
133                            if (userTrackerPath == null) {
134                                    if (_log.isWarnEnabled()) {
135                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
136                                                    userTrackerPathId);
137                                    }
138    
139                                    throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
140                                            userTrackerPathId);
141                            }
142    
143                            return remove(userTrackerPath);
144                    }
145                    catch (NoSuchUserTrackerPathException nsee) {
146                            throw nsee;
147                    }
148                    catch (Exception e) {
149                            throw processException(e);
150                    }
151                    finally {
152                            closeSession(session);
153                    }
154            }
155    
156            protected UserTrackerPath removeImpl(UserTrackerPath userTrackerPath)
157                    throws SystemException {
158                    userTrackerPath = toUnwrappedModel(userTrackerPath);
159    
160                    Session session = null;
161    
162                    try {
163                            session = openSession();
164    
165                            if (userTrackerPath.isCachedModel() ||
166                                            BatchSessionUtil.isEnabled()) {
167                                    Object staleObject = session.get(UserTrackerPathImpl.class,
168                                                    userTrackerPath.getPrimaryKeyObj());
169    
170                                    if (staleObject != null) {
171                                            session.evict(staleObject);
172                                    }
173                            }
174    
175                            session.delete(userTrackerPath);
176    
177                            session.flush();
178                    }
179                    catch (Exception e) {
180                            throw processException(e);
181                    }
182                    finally {
183                            closeSession(session);
184                    }
185    
186                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
187    
188                    EntityCacheUtil.removeResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
189                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey());
190    
191                    return userTrackerPath;
192            }
193    
194            public UserTrackerPath updateImpl(
195                    com.liferay.portal.model.UserTrackerPath userTrackerPath, boolean merge)
196                    throws SystemException {
197                    userTrackerPath = toUnwrappedModel(userTrackerPath);
198    
199                    Session session = null;
200    
201                    try {
202                            session = openSession();
203    
204                            BatchSessionUtil.update(session, userTrackerPath, merge);
205    
206                            userTrackerPath.setNew(false);
207                    }
208                    catch (Exception e) {
209                            throw processException(e);
210                    }
211                    finally {
212                            closeSession(session);
213                    }
214    
215                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
216    
217                    EntityCacheUtil.putResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
218                            UserTrackerPathImpl.class, userTrackerPath.getPrimaryKey(),
219                            userTrackerPath);
220    
221                    return userTrackerPath;
222            }
223    
224            protected UserTrackerPath toUnwrappedModel(UserTrackerPath userTrackerPath) {
225                    if (userTrackerPath instanceof UserTrackerPathImpl) {
226                            return userTrackerPath;
227                    }
228    
229                    UserTrackerPathImpl userTrackerPathImpl = new UserTrackerPathImpl();
230    
231                    userTrackerPathImpl.setNew(userTrackerPath.isNew());
232                    userTrackerPathImpl.setPrimaryKey(userTrackerPath.getPrimaryKey());
233    
234                    userTrackerPathImpl.setUserTrackerPathId(userTrackerPath.getUserTrackerPathId());
235                    userTrackerPathImpl.setUserTrackerId(userTrackerPath.getUserTrackerId());
236                    userTrackerPathImpl.setPath(userTrackerPath.getPath());
237                    userTrackerPathImpl.setPathDate(userTrackerPath.getPathDate());
238    
239                    return userTrackerPathImpl;
240            }
241    
242            public UserTrackerPath findByPrimaryKey(Serializable primaryKey)
243                    throws NoSuchModelException, SystemException {
244                    return findByPrimaryKey(((Long)primaryKey).longValue());
245            }
246    
247            public UserTrackerPath findByPrimaryKey(long userTrackerPathId)
248                    throws NoSuchUserTrackerPathException, SystemException {
249                    UserTrackerPath userTrackerPath = fetchByPrimaryKey(userTrackerPathId);
250    
251                    if (userTrackerPath == null) {
252                            if (_log.isWarnEnabled()) {
253                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userTrackerPathId);
254                            }
255    
256                            throw new NoSuchUserTrackerPathException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
257                                    userTrackerPathId);
258                    }
259    
260                    return userTrackerPath;
261            }
262    
263            public UserTrackerPath fetchByPrimaryKey(Serializable primaryKey)
264                    throws SystemException {
265                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
266            }
267    
268            public UserTrackerPath fetchByPrimaryKey(long userTrackerPathId)
269                    throws SystemException {
270                    UserTrackerPath userTrackerPath = (UserTrackerPath)EntityCacheUtil.getResult(UserTrackerPathModelImpl.ENTITY_CACHE_ENABLED,
271                                    UserTrackerPathImpl.class, userTrackerPathId, this);
272    
273                    if (userTrackerPath == null) {
274                            Session session = null;
275    
276                            try {
277                                    session = openSession();
278    
279                                    userTrackerPath = (UserTrackerPath)session.get(UserTrackerPathImpl.class,
280                                                    new Long(userTrackerPathId));
281                            }
282                            catch (Exception e) {
283                                    throw processException(e);
284                            }
285                            finally {
286                                    if (userTrackerPath != null) {
287                                            cacheResult(userTrackerPath);
288                                    }
289    
290                                    closeSession(session);
291                            }
292                    }
293    
294                    return userTrackerPath;
295            }
296    
297            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId)
298                    throws SystemException {
299                    return findByUserTrackerId(userTrackerId, QueryUtil.ALL_POS,
300                            QueryUtil.ALL_POS, null);
301            }
302    
303            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
304                    int start, int end) throws SystemException {
305                    return findByUserTrackerId(userTrackerId, start, end, null);
306            }
307    
308            public List<UserTrackerPath> findByUserTrackerId(long userTrackerId,
309                    int start, int end, OrderByComparator orderByComparator)
310                    throws SystemException {
311                    Object[] finderArgs = new Object[] {
312                                    userTrackerId,
313                                    
314                                    String.valueOf(start), String.valueOf(end),
315                                    String.valueOf(orderByComparator)
316                            };
317    
318                    List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERTRACKERID,
319                                    finderArgs, this);
320    
321                    if (list == null) {
322                            Session session = null;
323    
324                            try {
325                                    session = openSession();
326    
327                                    StringBundler query = null;
328    
329                                    if (orderByComparator != null) {
330                                            query = new StringBundler(3 +
331                                                            (orderByComparator.getOrderByFields().length * 3));
332                                    }
333                                    else {
334                                            query = new StringBundler(2);
335                                    }
336    
337                                    query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
338    
339                                    query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
340    
341                                    if (orderByComparator != null) {
342                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
343                                                    orderByComparator);
344                                    }
345    
346                                    String sql = query.toString();
347    
348                                    Query q = session.createQuery(sql);
349    
350                                    QueryPos qPos = QueryPos.getInstance(q);
351    
352                                    qPos.add(userTrackerId);
353    
354                                    list = (List<UserTrackerPath>)QueryUtil.list(q, getDialect(),
355                                                    start, end);
356                            }
357                            catch (Exception e) {
358                                    throw processException(e);
359                            }
360                            finally {
361                                    if (list == null) {
362                                            list = new ArrayList<UserTrackerPath>();
363                                    }
364    
365                                    cacheResult(list);
366    
367                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERTRACKERID,
368                                            finderArgs, list);
369    
370                                    closeSession(session);
371                            }
372                    }
373    
374                    return list;
375            }
376    
377            public UserTrackerPath findByUserTrackerId_First(long userTrackerId,
378                    OrderByComparator orderByComparator)
379                    throws NoSuchUserTrackerPathException, SystemException {
380                    List<UserTrackerPath> list = findByUserTrackerId(userTrackerId, 0, 1,
381                                    orderByComparator);
382    
383                    if (list.isEmpty()) {
384                            StringBundler msg = new StringBundler(4);
385    
386                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
387    
388                            msg.append("userTrackerId=");
389                            msg.append(userTrackerId);
390    
391                            msg.append(StringPool.CLOSE_CURLY_BRACE);
392    
393                            throw new NoSuchUserTrackerPathException(msg.toString());
394                    }
395                    else {
396                            return list.get(0);
397                    }
398            }
399    
400            public UserTrackerPath findByUserTrackerId_Last(long userTrackerId,
401                    OrderByComparator orderByComparator)
402                    throws NoSuchUserTrackerPathException, SystemException {
403                    int count = countByUserTrackerId(userTrackerId);
404    
405                    List<UserTrackerPath> list = findByUserTrackerId(userTrackerId,
406                                    count - 1, count, orderByComparator);
407    
408                    if (list.isEmpty()) {
409                            StringBundler msg = new StringBundler(4);
410    
411                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
412    
413                            msg.append("userTrackerId=");
414                            msg.append(userTrackerId);
415    
416                            msg.append(StringPool.CLOSE_CURLY_BRACE);
417    
418                            throw new NoSuchUserTrackerPathException(msg.toString());
419                    }
420                    else {
421                            return list.get(0);
422                    }
423            }
424    
425            public UserTrackerPath[] findByUserTrackerId_PrevAndNext(
426                    long userTrackerPathId, long userTrackerId,
427                    OrderByComparator orderByComparator)
428                    throws NoSuchUserTrackerPathException, SystemException {
429                    UserTrackerPath userTrackerPath = findByPrimaryKey(userTrackerPathId);
430    
431                    Session session = null;
432    
433                    try {
434                            session = openSession();
435    
436                            UserTrackerPath[] array = new UserTrackerPathImpl[3];
437    
438                            array[0] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
439                                            userTrackerId, orderByComparator, true);
440    
441                            array[1] = userTrackerPath;
442    
443                            array[2] = getByUserTrackerId_PrevAndNext(session, userTrackerPath,
444                                            userTrackerId, orderByComparator, false);
445    
446                            return array;
447                    }
448                    catch (Exception e) {
449                            throw processException(e);
450                    }
451                    finally {
452                            closeSession(session);
453                    }
454            }
455    
456            protected UserTrackerPath getByUserTrackerId_PrevAndNext(Session session,
457                    UserTrackerPath userTrackerPath, long userTrackerId,
458                    OrderByComparator orderByComparator, boolean previous) {
459                    StringBundler query = null;
460    
461                    if (orderByComparator != null) {
462                            query = new StringBundler(6 +
463                                            (orderByComparator.getOrderByFields().length * 6));
464                    }
465                    else {
466                            query = new StringBundler(3);
467                    }
468    
469                    query.append(_SQL_SELECT_USERTRACKERPATH_WHERE);
470    
471                    query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
472    
473                    if (orderByComparator != null) {
474                            String[] orderByFields = orderByComparator.getOrderByFields();
475    
476                            if (orderByFields.length > 0) {
477                                    query.append(WHERE_AND);
478                            }
479    
480                            for (int i = 0; i < orderByFields.length; i++) {
481                                    query.append(_ORDER_BY_ENTITY_ALIAS);
482                                    query.append(orderByFields[i]);
483    
484                                    if ((i + 1) < orderByFields.length) {
485                                            if (orderByComparator.isAscending() ^ previous) {
486                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
487                                            }
488                                            else {
489                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
490                                            }
491                                    }
492                                    else {
493                                            if (orderByComparator.isAscending() ^ previous) {
494                                                    query.append(WHERE_GREATER_THAN);
495                                            }
496                                            else {
497                                                    query.append(WHERE_LESSER_THAN);
498                                            }
499                                    }
500                            }
501    
502                            query.append(ORDER_BY_CLAUSE);
503    
504                            for (int i = 0; i < orderByFields.length; i++) {
505                                    query.append(_ORDER_BY_ENTITY_ALIAS);
506                                    query.append(orderByFields[i]);
507    
508                                    if ((i + 1) < orderByFields.length) {
509                                            if (orderByComparator.isAscending() ^ previous) {
510                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
511                                            }
512                                            else {
513                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
514                                            }
515                                    }
516                                    else {
517                                            if (orderByComparator.isAscending() ^ previous) {
518                                                    query.append(ORDER_BY_ASC);
519                                            }
520                                            else {
521                                                    query.append(ORDER_BY_DESC);
522                                            }
523                                    }
524                            }
525                    }
526    
527                    String sql = query.toString();
528    
529                    Query q = session.createQuery(sql);
530    
531                    q.setFirstResult(0);
532                    q.setMaxResults(2);
533    
534                    QueryPos qPos = QueryPos.getInstance(q);
535    
536                    qPos.add(userTrackerId);
537    
538                    if (orderByComparator != null) {
539                            Object[] values = orderByComparator.getOrderByValues(userTrackerPath);
540    
541                            for (Object value : values) {
542                                    qPos.add(value);
543                            }
544                    }
545    
546                    List<UserTrackerPath> list = q.list();
547    
548                    if (list.size() == 2) {
549                            return list.get(1);
550                    }
551                    else {
552                            return null;
553                    }
554            }
555    
556            public List<UserTrackerPath> findAll() throws SystemException {
557                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
558            }
559    
560            public List<UserTrackerPath> findAll(int start, int end)
561                    throws SystemException {
562                    return findAll(start, end, null);
563            }
564    
565            public List<UserTrackerPath> findAll(int start, int end,
566                    OrderByComparator orderByComparator) throws SystemException {
567                    Object[] finderArgs = new Object[] {
568                                    String.valueOf(start), String.valueOf(end),
569                                    String.valueOf(orderByComparator)
570                            };
571    
572                    List<UserTrackerPath> list = (List<UserTrackerPath>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
573                                    finderArgs, this);
574    
575                    if (list == null) {
576                            Session session = null;
577    
578                            try {
579                                    session = openSession();
580    
581                                    StringBundler query = null;
582                                    String sql = null;
583    
584                                    if (orderByComparator != null) {
585                                            query = new StringBundler(2 +
586                                                            (orderByComparator.getOrderByFields().length * 3));
587    
588                                            query.append(_SQL_SELECT_USERTRACKERPATH);
589    
590                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
591                                                    orderByComparator);
592    
593                                            sql = query.toString();
594                                    }
595                                    else {
596                                            sql = _SQL_SELECT_USERTRACKERPATH;
597                                    }
598    
599                                    Query q = session.createQuery(sql);
600    
601                                    if (orderByComparator == null) {
602                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
603                                                            getDialect(), start, end, false);
604    
605                                            Collections.sort(list);
606                                    }
607                                    else {
608                                            list = (List<UserTrackerPath>)QueryUtil.list(q,
609                                                            getDialect(), start, end);
610                                    }
611                            }
612                            catch (Exception e) {
613                                    throw processException(e);
614                            }
615                            finally {
616                                    if (list == null) {
617                                            list = new ArrayList<UserTrackerPath>();
618                                    }
619    
620                                    cacheResult(list);
621    
622                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
623    
624                                    closeSession(session);
625                            }
626                    }
627    
628                    return list;
629            }
630    
631            public void removeByUserTrackerId(long userTrackerId)
632                    throws SystemException {
633                    for (UserTrackerPath userTrackerPath : findByUserTrackerId(
634                                    userTrackerId)) {
635                            remove(userTrackerPath);
636                    }
637            }
638    
639            public void removeAll() throws SystemException {
640                    for (UserTrackerPath userTrackerPath : findAll()) {
641                            remove(userTrackerPath);
642                    }
643            }
644    
645            public int countByUserTrackerId(long userTrackerId)
646                    throws SystemException {
647                    Object[] finderArgs = new Object[] { userTrackerId };
648    
649                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
650                                    finderArgs, this);
651    
652                    if (count == null) {
653                            Session session = null;
654    
655                            try {
656                                    session = openSession();
657    
658                                    StringBundler query = new StringBundler(2);
659    
660                                    query.append(_SQL_COUNT_USERTRACKERPATH_WHERE);
661    
662                                    query.append(_FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2);
663    
664                                    String sql = query.toString();
665    
666                                    Query q = session.createQuery(sql);
667    
668                                    QueryPos qPos = QueryPos.getInstance(q);
669    
670                                    qPos.add(userTrackerId);
671    
672                                    count = (Long)q.uniqueResult();
673                            }
674                            catch (Exception e) {
675                                    throw processException(e);
676                            }
677                            finally {
678                                    if (count == null) {
679                                            count = Long.valueOf(0);
680                                    }
681    
682                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERTRACKERID,
683                                            finderArgs, count);
684    
685                                    closeSession(session);
686                            }
687                    }
688    
689                    return count.intValue();
690            }
691    
692            public int countAll() throws SystemException {
693                    Object[] finderArgs = new Object[0];
694    
695                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
696                                    finderArgs, this);
697    
698                    if (count == null) {
699                            Session session = null;
700    
701                            try {
702                                    session = openSession();
703    
704                                    Query q = session.createQuery(_SQL_COUNT_USERTRACKERPATH);
705    
706                                    count = (Long)q.uniqueResult();
707                            }
708                            catch (Exception e) {
709                                    throw processException(e);
710                            }
711                            finally {
712                                    if (count == null) {
713                                            count = Long.valueOf(0);
714                                    }
715    
716                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
717                                            count);
718    
719                                    closeSession(session);
720                            }
721                    }
722    
723                    return count.intValue();
724            }
725    
726            public void afterPropertiesSet() {
727                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
728                                            com.liferay.portal.util.PropsUtil.get(
729                                                    "value.object.listener.com.liferay.portal.model.UserTrackerPath")));
730    
731                    if (listenerClassNames.length > 0) {
732                            try {
733                                    List<ModelListener<UserTrackerPath>> listenersList = new ArrayList<ModelListener<UserTrackerPath>>();
734    
735                                    for (String listenerClassName : listenerClassNames) {
736                                            listenersList.add((ModelListener<UserTrackerPath>)InstanceFactory.newInstance(
737                                                            listenerClassName));
738                                    }
739    
740                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
741                            }
742                            catch (Exception e) {
743                                    _log.error(e);
744                            }
745                    }
746            }
747    
748            @BeanReference(type = AccountPersistence.class)
749            protected AccountPersistence accountPersistence;
750            @BeanReference(type = AddressPersistence.class)
751            protected AddressPersistence addressPersistence;
752            @BeanReference(type = BrowserTrackerPersistence.class)
753            protected BrowserTrackerPersistence browserTrackerPersistence;
754            @BeanReference(type = ClassNamePersistence.class)
755            protected ClassNamePersistence classNamePersistence;
756            @BeanReference(type = CompanyPersistence.class)
757            protected CompanyPersistence companyPersistence;
758            @BeanReference(type = ContactPersistence.class)
759            protected ContactPersistence contactPersistence;
760            @BeanReference(type = CountryPersistence.class)
761            protected CountryPersistence countryPersistence;
762            @BeanReference(type = EmailAddressPersistence.class)
763            protected EmailAddressPersistence emailAddressPersistence;
764            @BeanReference(type = GroupPersistence.class)
765            protected GroupPersistence groupPersistence;
766            @BeanReference(type = ImagePersistence.class)
767            protected ImagePersistence imagePersistence;
768            @BeanReference(type = LayoutPersistence.class)
769            protected LayoutPersistence layoutPersistence;
770            @BeanReference(type = LayoutPrototypePersistence.class)
771            protected LayoutPrototypePersistence layoutPrototypePersistence;
772            @BeanReference(type = LayoutSetPersistence.class)
773            protected LayoutSetPersistence layoutSetPersistence;
774            @BeanReference(type = LayoutSetPrototypePersistence.class)
775            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
776            @BeanReference(type = ListTypePersistence.class)
777            protected ListTypePersistence listTypePersistence;
778            @BeanReference(type = LockPersistence.class)
779            protected LockPersistence lockPersistence;
780            @BeanReference(type = MembershipRequestPersistence.class)
781            protected MembershipRequestPersistence membershipRequestPersistence;
782            @BeanReference(type = OrganizationPersistence.class)
783            protected OrganizationPersistence organizationPersistence;
784            @BeanReference(type = OrgGroupPermissionPersistence.class)
785            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
786            @BeanReference(type = OrgGroupRolePersistence.class)
787            protected OrgGroupRolePersistence orgGroupRolePersistence;
788            @BeanReference(type = OrgLaborPersistence.class)
789            protected OrgLaborPersistence orgLaborPersistence;
790            @BeanReference(type = PasswordPolicyPersistence.class)
791            protected PasswordPolicyPersistence passwordPolicyPersistence;
792            @BeanReference(type = PasswordPolicyRelPersistence.class)
793            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
794            @BeanReference(type = PasswordTrackerPersistence.class)
795            protected PasswordTrackerPersistence passwordTrackerPersistence;
796            @BeanReference(type = PermissionPersistence.class)
797            protected PermissionPersistence permissionPersistence;
798            @BeanReference(type = PhonePersistence.class)
799            protected PhonePersistence phonePersistence;
800            @BeanReference(type = PluginSettingPersistence.class)
801            protected PluginSettingPersistence pluginSettingPersistence;
802            @BeanReference(type = PortletPersistence.class)
803            protected PortletPersistence portletPersistence;
804            @BeanReference(type = PortletItemPersistence.class)
805            protected PortletItemPersistence portletItemPersistence;
806            @BeanReference(type = PortletPreferencesPersistence.class)
807            protected PortletPreferencesPersistence portletPreferencesPersistence;
808            @BeanReference(type = RegionPersistence.class)
809            protected RegionPersistence regionPersistence;
810            @BeanReference(type = ReleasePersistence.class)
811            protected ReleasePersistence releasePersistence;
812            @BeanReference(type = ResourcePersistence.class)
813            protected ResourcePersistence resourcePersistence;
814            @BeanReference(type = ResourceActionPersistence.class)
815            protected ResourceActionPersistence resourceActionPersistence;
816            @BeanReference(type = ResourceCodePersistence.class)
817            protected ResourceCodePersistence resourceCodePersistence;
818            @BeanReference(type = ResourcePermissionPersistence.class)
819            protected ResourcePermissionPersistence resourcePermissionPersistence;
820            @BeanReference(type = RolePersistence.class)
821            protected RolePersistence rolePersistence;
822            @BeanReference(type = ServiceComponentPersistence.class)
823            protected ServiceComponentPersistence serviceComponentPersistence;
824            @BeanReference(type = ShardPersistence.class)
825            protected ShardPersistence shardPersistence;
826            @BeanReference(type = SubscriptionPersistence.class)
827            protected SubscriptionPersistence subscriptionPersistence;
828            @BeanReference(type = TicketPersistence.class)
829            protected TicketPersistence ticketPersistence;
830            @BeanReference(type = TeamPersistence.class)
831            protected TeamPersistence teamPersistence;
832            @BeanReference(type = UserPersistence.class)
833            protected UserPersistence userPersistence;
834            @BeanReference(type = UserGroupPersistence.class)
835            protected UserGroupPersistence userGroupPersistence;
836            @BeanReference(type = UserGroupGroupRolePersistence.class)
837            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
838            @BeanReference(type = UserGroupRolePersistence.class)
839            protected UserGroupRolePersistence userGroupRolePersistence;
840            @BeanReference(type = UserIdMapperPersistence.class)
841            protected UserIdMapperPersistence userIdMapperPersistence;
842            @BeanReference(type = UserTrackerPersistence.class)
843            protected UserTrackerPersistence userTrackerPersistence;
844            @BeanReference(type = UserTrackerPathPersistence.class)
845            protected UserTrackerPathPersistence userTrackerPathPersistence;
846            @BeanReference(type = WebDAVPropsPersistence.class)
847            protected WebDAVPropsPersistence webDAVPropsPersistence;
848            @BeanReference(type = WebsitePersistence.class)
849            protected WebsitePersistence websitePersistence;
850            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
851            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
852            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
853            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
854            private static final String _SQL_SELECT_USERTRACKERPATH = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath";
855            private static final String _SQL_SELECT_USERTRACKERPATH_WHERE = "SELECT userTrackerPath FROM UserTrackerPath userTrackerPath WHERE ";
856            private static final String _SQL_COUNT_USERTRACKERPATH = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath";
857            private static final String _SQL_COUNT_USERTRACKERPATH_WHERE = "SELECT COUNT(userTrackerPath) FROM UserTrackerPath userTrackerPath WHERE ";
858            private static final String _FINDER_COLUMN_USERTRACKERID_USERTRACKERID_2 = "userTrackerPath.userTrackerId = ?";
859            private static final String _ORDER_BY_ENTITY_ALIAS = "userTrackerPath.";
860            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserTrackerPath exists with the primary key ";
861            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserTrackerPath exists with the key {";
862            private static Log _log = LogFactoryUtil.getLog(UserTrackerPathPersistenceImpl.class);
863    }