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