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 * 3));
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(6 +
433                                            (orderByComparator.getOrderByFields().length * 6));
434                    }
435                    else {
436                            query = new StringBundler(3);
437                    }
438    
439                    query.append(_SQL_SELECT_PASSWORDTRACKER_WHERE);
440    
441                    query.append(_FINDER_COLUMN_USERID_USERID_2);
442    
443                    if (orderByComparator != null) {
444                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
445    
446                            if (orderByConditionFields.length > 0) {
447                                    query.append(WHERE_AND);
448                            }
449    
450                            for (int i = 0; i < orderByConditionFields.length; i++) {
451                                    query.append(_ORDER_BY_ENTITY_ALIAS);
452                                    query.append(orderByConditionFields[i]);
453    
454                                    if ((i + 1) < orderByConditionFields.length) {
455                                            if (orderByComparator.isAscending() ^ previous) {
456                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
457                                            }
458                                            else {
459                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
460                                            }
461                                    }
462                                    else {
463                                            if (orderByComparator.isAscending() ^ previous) {
464                                                    query.append(WHERE_GREATER_THAN);
465                                            }
466                                            else {
467                                                    query.append(WHERE_LESSER_THAN);
468                                            }
469                                    }
470                            }
471    
472                            query.append(ORDER_BY_CLAUSE);
473    
474                            String[] orderByFields = orderByComparator.getOrderByFields();
475    
476                            for (int i = 0; i < orderByFields.length; i++) {
477                                    query.append(_ORDER_BY_ENTITY_ALIAS);
478                                    query.append(orderByFields[i]);
479    
480                                    if ((i + 1) < orderByFields.length) {
481                                            if (orderByComparator.isAscending() ^ previous) {
482                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
483                                            }
484                                            else {
485                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
486                                            }
487                                    }
488                                    else {
489                                            if (orderByComparator.isAscending() ^ previous) {
490                                                    query.append(ORDER_BY_ASC);
491                                            }
492                                            else {
493                                                    query.append(ORDER_BY_DESC);
494                                            }
495                                    }
496                            }
497                    }
498                    else {
499                            query.append(PasswordTrackerModelImpl.ORDER_BY_JPQL);
500                    }
501    
502                    String sql = query.toString();
503    
504                    Query q = session.createQuery(sql);
505    
506                    q.setFirstResult(0);
507                    q.setMaxResults(2);
508    
509                    QueryPos qPos = QueryPos.getInstance(q);
510    
511                    qPos.add(userId);
512    
513                    if (orderByComparator != null) {
514                            Object[] values = orderByComparator.getOrderByConditionValues(passwordTracker);
515    
516                            for (Object value : values) {
517                                    qPos.add(value);
518                            }
519                    }
520    
521                    List<PasswordTracker> list = q.list();
522    
523                    if (list.size() == 2) {
524                            return list.get(1);
525                    }
526                    else {
527                            return null;
528                    }
529            }
530    
531            /**
532             * Removes all the password trackers where userId = &#63; from the database.
533             *
534             * @param userId the user ID
535             */
536            @Override
537            public void removeByUserId(long userId) {
538                    for (PasswordTracker passwordTracker : findByUserId(userId,
539                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
540                            remove(passwordTracker);
541                    }
542            }
543    
544            /**
545             * Returns the number of password trackers where userId = &#63;.
546             *
547             * @param userId the user ID
548             * @return the number of matching password trackers
549             */
550            @Override
551            public int countByUserId(long userId) {
552                    FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
553    
554                    Object[] finderArgs = new Object[] { userId };
555    
556                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
557    
558                    if (count == null) {
559                            StringBundler query = new StringBundler(2);
560    
561                            query.append(_SQL_COUNT_PASSWORDTRACKER_WHERE);
562    
563                            query.append(_FINDER_COLUMN_USERID_USERID_2);
564    
565                            String sql = query.toString();
566    
567                            Session session = null;
568    
569                            try {
570                                    session = openSession();
571    
572                                    Query q = session.createQuery(sql);
573    
574                                    QueryPos qPos = QueryPos.getInstance(q);
575    
576                                    qPos.add(userId);
577    
578                                    count = (Long)q.uniqueResult();
579    
580                                    finderCache.putResult(finderPath, finderArgs, count);
581                            }
582                            catch (Exception e) {
583                                    finderCache.removeResult(finderPath, finderArgs);
584    
585                                    throw processException(e);
586                            }
587                            finally {
588                                    closeSession(session);
589                            }
590                    }
591    
592                    return count.intValue();
593            }
594    
595            private static final String _FINDER_COLUMN_USERID_USERID_2 = "passwordTracker.userId = ?";
596    
597            public PasswordTrackerPersistenceImpl() {
598                    setModelClass(PasswordTracker.class);
599            }
600    
601            /**
602             * Caches the password tracker in the entity cache if it is enabled.
603             *
604             * @param passwordTracker the password tracker
605             */
606            @Override
607            public void cacheResult(PasswordTracker passwordTracker) {
608                    entityCache.putResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
609                            PasswordTrackerImpl.class, passwordTracker.getPrimaryKey(),
610                            passwordTracker);
611    
612                    passwordTracker.resetOriginalValues();
613            }
614    
615            /**
616             * Caches the password trackers in the entity cache if it is enabled.
617             *
618             * @param passwordTrackers the password trackers
619             */
620            @Override
621            public void cacheResult(List<PasswordTracker> passwordTrackers) {
622                    for (PasswordTracker passwordTracker : passwordTrackers) {
623                            if (entityCache.getResult(
624                                                    PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
625                                                    PasswordTrackerImpl.class,
626                                                    passwordTracker.getPrimaryKey()) == null) {
627                                    cacheResult(passwordTracker);
628                            }
629                            else {
630                                    passwordTracker.resetOriginalValues();
631                            }
632                    }
633            }
634    
635            /**
636             * Clears the cache for all password trackers.
637             *
638             * <p>
639             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
640             * </p>
641             */
642            @Override
643            public void clearCache() {
644                    entityCache.clearCache(PasswordTrackerImpl.class);
645    
646                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
647                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
648                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
649            }
650    
651            /**
652             * Clears the cache for the password tracker.
653             *
654             * <p>
655             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
656             * </p>
657             */
658            @Override
659            public void clearCache(PasswordTracker passwordTracker) {
660                    entityCache.removeResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
661                            PasswordTrackerImpl.class, passwordTracker.getPrimaryKey());
662    
663                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
664                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
665            }
666    
667            @Override
668            public void clearCache(List<PasswordTracker> passwordTrackers) {
669                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
670                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
671    
672                    for (PasswordTracker passwordTracker : passwordTrackers) {
673                            entityCache.removeResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
674                                    PasswordTrackerImpl.class, passwordTracker.getPrimaryKey());
675                    }
676            }
677    
678            /**
679             * Creates a new password tracker with the primary key. Does not add the password tracker to the database.
680             *
681             * @param passwordTrackerId the primary key for the new password tracker
682             * @return the new password tracker
683             */
684            @Override
685            public PasswordTracker create(long passwordTrackerId) {
686                    PasswordTracker passwordTracker = new PasswordTrackerImpl();
687    
688                    passwordTracker.setNew(true);
689                    passwordTracker.setPrimaryKey(passwordTrackerId);
690    
691                    passwordTracker.setCompanyId(companyProvider.getCompanyId());
692    
693                    return passwordTracker;
694            }
695    
696            /**
697             * Removes the password tracker with the primary key from the database. Also notifies the appropriate model listeners.
698             *
699             * @param passwordTrackerId the primary key of the password tracker
700             * @return the password tracker that was removed
701             * @throws NoSuchPasswordTrackerException if a password tracker with the primary key could not be found
702             */
703            @Override
704            public PasswordTracker remove(long passwordTrackerId)
705                    throws NoSuchPasswordTrackerException {
706                    return remove((Serializable)passwordTrackerId);
707            }
708    
709            /**
710             * Removes the password tracker with the primary key from the database. Also notifies the appropriate model listeners.
711             *
712             * @param primaryKey the primary key of the password tracker
713             * @return the password tracker that was removed
714             * @throws NoSuchPasswordTrackerException if a password tracker with the primary key could not be found
715             */
716            @Override
717            public PasswordTracker remove(Serializable primaryKey)
718                    throws NoSuchPasswordTrackerException {
719                    Session session = null;
720    
721                    try {
722                            session = openSession();
723    
724                            PasswordTracker passwordTracker = (PasswordTracker)session.get(PasswordTrackerImpl.class,
725                                            primaryKey);
726    
727                            if (passwordTracker == null) {
728                                    if (_log.isWarnEnabled()) {
729                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
730                                    }
731    
732                                    throw new NoSuchPasswordTrackerException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
733                                            primaryKey);
734                            }
735    
736                            return remove(passwordTracker);
737                    }
738                    catch (NoSuchPasswordTrackerException nsee) {
739                            throw nsee;
740                    }
741                    catch (Exception e) {
742                            throw processException(e);
743                    }
744                    finally {
745                            closeSession(session);
746                    }
747            }
748    
749            @Override
750            protected PasswordTracker removeImpl(PasswordTracker passwordTracker) {
751                    passwordTracker = toUnwrappedModel(passwordTracker);
752    
753                    Session session = null;
754    
755                    try {
756                            session = openSession();
757    
758                            if (!session.contains(passwordTracker)) {
759                                    passwordTracker = (PasswordTracker)session.get(PasswordTrackerImpl.class,
760                                                    passwordTracker.getPrimaryKeyObj());
761                            }
762    
763                            if (passwordTracker != null) {
764                                    session.delete(passwordTracker);
765                            }
766                    }
767                    catch (Exception e) {
768                            throw processException(e);
769                    }
770                    finally {
771                            closeSession(session);
772                    }
773    
774                    if (passwordTracker != null) {
775                            clearCache(passwordTracker);
776                    }
777    
778                    return passwordTracker;
779            }
780    
781            @Override
782            public PasswordTracker updateImpl(PasswordTracker passwordTracker) {
783                    passwordTracker = toUnwrappedModel(passwordTracker);
784    
785                    boolean isNew = passwordTracker.isNew();
786    
787                    PasswordTrackerModelImpl passwordTrackerModelImpl = (PasswordTrackerModelImpl)passwordTracker;
788    
789                    Session session = null;
790    
791                    try {
792                            session = openSession();
793    
794                            if (passwordTracker.isNew()) {
795                                    session.save(passwordTracker);
796    
797                                    passwordTracker.setNew(false);
798                            }
799                            else {
800                                    passwordTracker = (PasswordTracker)session.merge(passwordTracker);
801                            }
802                    }
803                    catch (Exception e) {
804                            throw processException(e);
805                    }
806                    finally {
807                            closeSession(session);
808                    }
809    
810                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
811    
812                    if (isNew || !PasswordTrackerModelImpl.COLUMN_BITMASK_ENABLED) {
813                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
814                    }
815    
816                    else {
817                            if ((passwordTrackerModelImpl.getColumnBitmask() &
818                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
819                                    Object[] args = new Object[] {
820                                                    passwordTrackerModelImpl.getOriginalUserId()
821                                            };
822    
823                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
824                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
825                                            args);
826    
827                                    args = new Object[] { passwordTrackerModelImpl.getUserId() };
828    
829                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
830                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
831                                            args);
832                            }
833                    }
834    
835                    entityCache.putResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
836                            PasswordTrackerImpl.class, passwordTracker.getPrimaryKey(),
837                            passwordTracker, false);
838    
839                    passwordTracker.resetOriginalValues();
840    
841                    return passwordTracker;
842            }
843    
844            protected PasswordTracker toUnwrappedModel(PasswordTracker passwordTracker) {
845                    if (passwordTracker instanceof PasswordTrackerImpl) {
846                            return passwordTracker;
847                    }
848    
849                    PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
850    
851                    passwordTrackerImpl.setNew(passwordTracker.isNew());
852                    passwordTrackerImpl.setPrimaryKey(passwordTracker.getPrimaryKey());
853    
854                    passwordTrackerImpl.setMvccVersion(passwordTracker.getMvccVersion());
855                    passwordTrackerImpl.setPasswordTrackerId(passwordTracker.getPasswordTrackerId());
856                    passwordTrackerImpl.setCompanyId(passwordTracker.getCompanyId());
857                    passwordTrackerImpl.setUserId(passwordTracker.getUserId());
858                    passwordTrackerImpl.setCreateDate(passwordTracker.getCreateDate());
859                    passwordTrackerImpl.setPassword(passwordTracker.getPassword());
860    
861                    return passwordTrackerImpl;
862            }
863    
864            /**
865             * Returns the password tracker with the primary key or throws a {@link com.liferay.portal.exception.NoSuchModelException} if it could not be found.
866             *
867             * @param primaryKey the primary key of the password tracker
868             * @return the password tracker
869             * @throws NoSuchPasswordTrackerException if a password tracker with the primary key could not be found
870             */
871            @Override
872            public PasswordTracker findByPrimaryKey(Serializable primaryKey)
873                    throws NoSuchPasswordTrackerException {
874                    PasswordTracker passwordTracker = fetchByPrimaryKey(primaryKey);
875    
876                    if (passwordTracker == null) {
877                            if (_log.isWarnEnabled()) {
878                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
879                            }
880    
881                            throw new NoSuchPasswordTrackerException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
882                                    primaryKey);
883                    }
884    
885                    return passwordTracker;
886            }
887    
888            /**
889             * Returns the password tracker with the primary key or throws a {@link NoSuchPasswordTrackerException} if it could not be found.
890             *
891             * @param passwordTrackerId the primary key of the password tracker
892             * @return the password tracker
893             * @throws NoSuchPasswordTrackerException if a password tracker with the primary key could not be found
894             */
895            @Override
896            public PasswordTracker findByPrimaryKey(long passwordTrackerId)
897                    throws NoSuchPasswordTrackerException {
898                    return findByPrimaryKey((Serializable)passwordTrackerId);
899            }
900    
901            /**
902             * Returns the password tracker with the primary key or returns <code>null</code> if it could not be found.
903             *
904             * @param primaryKey the primary key of the password tracker
905             * @return the password tracker, or <code>null</code> if a password tracker with the primary key could not be found
906             */
907            @Override
908            public PasswordTracker fetchByPrimaryKey(Serializable primaryKey) {
909                    PasswordTracker passwordTracker = (PasswordTracker)entityCache.getResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
910                                    PasswordTrackerImpl.class, primaryKey);
911    
912                    if (passwordTracker == _nullPasswordTracker) {
913                            return null;
914                    }
915    
916                    if (passwordTracker == null) {
917                            Session session = null;
918    
919                            try {
920                                    session = openSession();
921    
922                                    passwordTracker = (PasswordTracker)session.get(PasswordTrackerImpl.class,
923                                                    primaryKey);
924    
925                                    if (passwordTracker != null) {
926                                            cacheResult(passwordTracker);
927                                    }
928                                    else {
929                                            entityCache.putResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
930                                                    PasswordTrackerImpl.class, primaryKey,
931                                                    _nullPasswordTracker);
932                                    }
933                            }
934                            catch (Exception e) {
935                                    entityCache.removeResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
936                                            PasswordTrackerImpl.class, primaryKey);
937    
938                                    throw processException(e);
939                            }
940                            finally {
941                                    closeSession(session);
942                            }
943                    }
944    
945                    return passwordTracker;
946            }
947    
948            /**
949             * Returns the password tracker with the primary key or returns <code>null</code> if it could not be found.
950             *
951             * @param passwordTrackerId the primary key of the password tracker
952             * @return the password tracker, or <code>null</code> if a password tracker with the primary key could not be found
953             */
954            @Override
955            public PasswordTracker fetchByPrimaryKey(long passwordTrackerId) {
956                    return fetchByPrimaryKey((Serializable)passwordTrackerId);
957            }
958    
959            @Override
960            public Map<Serializable, PasswordTracker> fetchByPrimaryKeys(
961                    Set<Serializable> primaryKeys) {
962                    if (primaryKeys.isEmpty()) {
963                            return Collections.emptyMap();
964                    }
965    
966                    Map<Serializable, PasswordTracker> map = new HashMap<Serializable, PasswordTracker>();
967    
968                    if (primaryKeys.size() == 1) {
969                            Iterator<Serializable> iterator = primaryKeys.iterator();
970    
971                            Serializable primaryKey = iterator.next();
972    
973                            PasswordTracker passwordTracker = fetchByPrimaryKey(primaryKey);
974    
975                            if (passwordTracker != null) {
976                                    map.put(primaryKey, passwordTracker);
977                            }
978    
979                            return map;
980                    }
981    
982                    Set<Serializable> uncachedPrimaryKeys = null;
983    
984                    for (Serializable primaryKey : primaryKeys) {
985                            PasswordTracker passwordTracker = (PasswordTracker)entityCache.getResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
986                                            PasswordTrackerImpl.class, primaryKey);
987    
988                            if (passwordTracker == null) {
989                                    if (uncachedPrimaryKeys == null) {
990                                            uncachedPrimaryKeys = new HashSet<Serializable>();
991                                    }
992    
993                                    uncachedPrimaryKeys.add(primaryKey);
994                            }
995                            else {
996                                    map.put(primaryKey, passwordTracker);
997                            }
998                    }
999    
1000                    if (uncachedPrimaryKeys == null) {
1001                            return map;
1002                    }
1003    
1004                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
1005                                    1);
1006    
1007                    query.append(_SQL_SELECT_PASSWORDTRACKER_WHERE_PKS_IN);
1008    
1009                    for (Serializable primaryKey : uncachedPrimaryKeys) {
1010                            query.append(String.valueOf(primaryKey));
1011    
1012                            query.append(StringPool.COMMA);
1013                    }
1014    
1015                    query.setIndex(query.index() - 1);
1016    
1017                    query.append(StringPool.CLOSE_PARENTHESIS);
1018    
1019                    String sql = query.toString();
1020    
1021                    Session session = null;
1022    
1023                    try {
1024                            session = openSession();
1025    
1026                            Query q = session.createQuery(sql);
1027    
1028                            for (PasswordTracker passwordTracker : (List<PasswordTracker>)q.list()) {
1029                                    map.put(passwordTracker.getPrimaryKeyObj(), passwordTracker);
1030    
1031                                    cacheResult(passwordTracker);
1032    
1033                                    uncachedPrimaryKeys.remove(passwordTracker.getPrimaryKeyObj());
1034                            }
1035    
1036                            for (Serializable primaryKey : uncachedPrimaryKeys) {
1037                                    entityCache.putResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
1038                                            PasswordTrackerImpl.class, primaryKey, _nullPasswordTracker);
1039                            }
1040                    }
1041                    catch (Exception e) {
1042                            throw processException(e);
1043                    }
1044                    finally {
1045                            closeSession(session);
1046                    }
1047    
1048                    return map;
1049            }
1050    
1051            /**
1052             * Returns all the password trackers.
1053             *
1054             * @return the password trackers
1055             */
1056            @Override
1057            public List<PasswordTracker> findAll() {
1058                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1059            }
1060    
1061            /**
1062             * Returns a range of all the password trackers.
1063             *
1064             * <p>
1065             * 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.
1066             * </p>
1067             *
1068             * @param start the lower bound of the range of password trackers
1069             * @param end the upper bound of the range of password trackers (not inclusive)
1070             * @return the range of password trackers
1071             */
1072            @Override
1073            public List<PasswordTracker> findAll(int start, int end) {
1074                    return findAll(start, end, null);
1075            }
1076    
1077            /**
1078             * Returns an ordered range of all the password trackers.
1079             *
1080             * <p>
1081             * 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.
1082             * </p>
1083             *
1084             * @param start the lower bound of the range of password trackers
1085             * @param end the upper bound of the range of password trackers (not inclusive)
1086             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1087             * @return the ordered range of password trackers
1088             */
1089            @Override
1090            public List<PasswordTracker> findAll(int start, int end,
1091                    OrderByComparator<PasswordTracker> orderByComparator) {
1092                    return findAll(start, end, orderByComparator, true);
1093            }
1094    
1095            /**
1096             * Returns an ordered range of all the password trackers.
1097             *
1098             * <p>
1099             * 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.
1100             * </p>
1101             *
1102             * @param start the lower bound of the range of password trackers
1103             * @param end the upper bound of the range of password trackers (not inclusive)
1104             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1105             * @param retrieveFromCache whether to retrieve from the finder cache
1106             * @return the ordered range of password trackers
1107             */
1108            @Override
1109            public List<PasswordTracker> findAll(int start, int end,
1110                    OrderByComparator<PasswordTracker> orderByComparator,
1111                    boolean retrieveFromCache) {
1112                    boolean pagination = true;
1113                    FinderPath finderPath = null;
1114                    Object[] finderArgs = null;
1115    
1116                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1117                                    (orderByComparator == null)) {
1118                            pagination = false;
1119                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1120                            finderArgs = FINDER_ARGS_EMPTY;
1121                    }
1122                    else {
1123                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1124                            finderArgs = new Object[] { start, end, orderByComparator };
1125                    }
1126    
1127                    List<PasswordTracker> list = null;
1128    
1129                    if (retrieveFromCache) {
1130                            list = (List<PasswordTracker>)finderCache.getResult(finderPath,
1131                                            finderArgs, this);
1132                    }
1133    
1134                    if (list == null) {
1135                            StringBundler query = null;
1136                            String sql = null;
1137    
1138                            if (orderByComparator != null) {
1139                                    query = new StringBundler(2 +
1140                                                    (orderByComparator.getOrderByFields().length * 3));
1141    
1142                                    query.append(_SQL_SELECT_PASSWORDTRACKER);
1143    
1144                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1145                                            orderByComparator);
1146    
1147                                    sql = query.toString();
1148                            }
1149                            else {
1150                                    sql = _SQL_SELECT_PASSWORDTRACKER;
1151    
1152                                    if (pagination) {
1153                                            sql = sql.concat(PasswordTrackerModelImpl.ORDER_BY_JPQL);
1154                                    }
1155                            }
1156    
1157                            Session session = null;
1158    
1159                            try {
1160                                    session = openSession();
1161    
1162                                    Query q = session.createQuery(sql);
1163    
1164                                    if (!pagination) {
1165                                            list = (List<PasswordTracker>)QueryUtil.list(q,
1166                                                            getDialect(), start, end, false);
1167    
1168                                            Collections.sort(list);
1169    
1170                                            list = Collections.unmodifiableList(list);
1171                                    }
1172                                    else {
1173                                            list = (List<PasswordTracker>)QueryUtil.list(q,
1174                                                            getDialect(), start, end);
1175                                    }
1176    
1177                                    cacheResult(list);
1178    
1179                                    finderCache.putResult(finderPath, finderArgs, list);
1180                            }
1181                            catch (Exception e) {
1182                                    finderCache.removeResult(finderPath, finderArgs);
1183    
1184                                    throw processException(e);
1185                            }
1186                            finally {
1187                                    closeSession(session);
1188                            }
1189                    }
1190    
1191                    return list;
1192            }
1193    
1194            /**
1195             * Removes all the password trackers from the database.
1196             *
1197             */
1198            @Override
1199            public void removeAll() {
1200                    for (PasswordTracker passwordTracker : findAll()) {
1201                            remove(passwordTracker);
1202                    }
1203            }
1204    
1205            /**
1206             * Returns the number of password trackers.
1207             *
1208             * @return the number of password trackers
1209             */
1210            @Override
1211            public int countAll() {
1212                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
1213                                    FINDER_ARGS_EMPTY, this);
1214    
1215                    if (count == null) {
1216                            Session session = null;
1217    
1218                            try {
1219                                    session = openSession();
1220    
1221                                    Query q = session.createQuery(_SQL_COUNT_PASSWORDTRACKER);
1222    
1223                                    count = (Long)q.uniqueResult();
1224    
1225                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
1226                                            count);
1227                            }
1228                            catch (Exception e) {
1229                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
1230                                            FINDER_ARGS_EMPTY);
1231    
1232                                    throw processException(e);
1233                            }
1234                            finally {
1235                                    closeSession(session);
1236                            }
1237                    }
1238    
1239                    return count.intValue();
1240            }
1241    
1242            @Override
1243            public Set<String> getBadColumnNames() {
1244                    return _badColumnNames;
1245            }
1246    
1247            @Override
1248            protected Map<String, Integer> getTableColumnsMap() {
1249                    return PasswordTrackerModelImpl.TABLE_COLUMNS_MAP;
1250            }
1251    
1252            /**
1253             * Initializes the password tracker persistence.
1254             */
1255            public void afterPropertiesSet() {
1256            }
1257    
1258            public void destroy() {
1259                    entityCache.removeCache(PasswordTrackerImpl.class.getName());
1260                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1261                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1262                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1263            }
1264    
1265            @BeanReference(type = CompanyProviderWrapper.class)
1266            protected CompanyProvider companyProvider;
1267            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1268            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1269            private static final String _SQL_SELECT_PASSWORDTRACKER = "SELECT passwordTracker FROM PasswordTracker passwordTracker";
1270            private static final String _SQL_SELECT_PASSWORDTRACKER_WHERE_PKS_IN = "SELECT passwordTracker FROM PasswordTracker passwordTracker WHERE passwordTrackerId IN (";
1271            private static final String _SQL_SELECT_PASSWORDTRACKER_WHERE = "SELECT passwordTracker FROM PasswordTracker passwordTracker WHERE ";
1272            private static final String _SQL_COUNT_PASSWORDTRACKER = "SELECT COUNT(passwordTracker) FROM PasswordTracker passwordTracker";
1273            private static final String _SQL_COUNT_PASSWORDTRACKER_WHERE = "SELECT COUNT(passwordTracker) FROM PasswordTracker passwordTracker WHERE ";
1274            private static final String _ORDER_BY_ENTITY_ALIAS = "passwordTracker.";
1275            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PasswordTracker exists with the primary key ";
1276            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PasswordTracker exists with the key {";
1277            private static final Log _log = LogFactoryUtil.getLog(PasswordTrackerPersistenceImpl.class);
1278            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
1279                                    "password"
1280                            });
1281            private static final PasswordTracker _nullPasswordTracker = new PasswordTrackerImpl() {
1282                            @Override
1283                            public Object clone() {
1284                                    return this;
1285                            }
1286    
1287                            @Override
1288                            public CacheModel<PasswordTracker> toCacheModel() {
1289                                    return _nullPasswordTrackerCacheModel;
1290                            }
1291                    };
1292    
1293            private static final CacheModel<PasswordTracker> _nullPasswordTrackerCacheModel =
1294                    new NullCacheModel();
1295    
1296            private static class NullCacheModel implements CacheModel<PasswordTracker>,
1297                    MVCCModel {
1298                    @Override
1299                    public long getMvccVersion() {
1300                            return -1;
1301                    }
1302    
1303                    @Override
1304                    public void setMvccVersion(long mvccVersion) {
1305                    }
1306    
1307                    @Override
1308                    public PasswordTracker toEntityModel() {
1309                            return _nullPasswordTracker;
1310                    }
1311            }
1312    }