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