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