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