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