1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.persistence;
24  
25  import com.liferay.portal.NoSuchModelException;
26  import com.liferay.portal.NoSuchPasswordTrackerException;
27  import com.liferay.portal.SystemException;
28  import com.liferay.portal.kernel.annotation.BeanReference;
29  import com.liferay.portal.kernel.cache.CacheRegistry;
30  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
31  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
32  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
33  import com.liferay.portal.kernel.dao.orm.FinderPath;
34  import com.liferay.portal.kernel.dao.orm.Query;
35  import com.liferay.portal.kernel.dao.orm.QueryPos;
36  import com.liferay.portal.kernel.dao.orm.QueryUtil;
37  import com.liferay.portal.kernel.dao.orm.Session;
38  import com.liferay.portal.kernel.log.Log;
39  import com.liferay.portal.kernel.log.LogFactoryUtil;
40  import com.liferay.portal.kernel.util.GetterUtil;
41  import com.liferay.portal.kernel.util.OrderByComparator;
42  import com.liferay.portal.kernel.util.StringBundler;
43  import com.liferay.portal.kernel.util.StringPool;
44  import com.liferay.portal.kernel.util.StringUtil;
45  import com.liferay.portal.model.ModelListener;
46  import com.liferay.portal.model.PasswordTracker;
47  import com.liferay.portal.model.impl.PasswordTrackerImpl;
48  import com.liferay.portal.model.impl.PasswordTrackerModelImpl;
49  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
50  
51  import java.io.Serializable;
52  
53  import java.util.ArrayList;
54  import java.util.Collections;
55  import java.util.List;
56  
57  /**
58   * <a href="PasswordTrackerPersistenceImpl.java.html"><b><i>View Source</i></b></a>
59   *
60   * <p>
61   * ServiceBuilder generated this class. Modifications in this class will be
62   * overwritten the next time is generated.
63   * </p>
64   *
65   * @author    Brian Wing Shun Chan
66   * @see       PasswordTrackerPersistence
67   * @see       PasswordTrackerUtil
68   * @generated
69   */
70  public class PasswordTrackerPersistenceImpl extends BasePersistenceImpl<PasswordTracker>
71      implements PasswordTrackerPersistence {
72      public static final String FINDER_CLASS_NAME_ENTITY = PasswordTrackerImpl.class.getName();
73      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
74          ".List";
75      public static final FinderPath FINDER_PATH_FIND_BY_USERID = new FinderPath(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
76              PasswordTrackerModelImpl.FINDER_CACHE_ENABLED,
77              FINDER_CLASS_NAME_LIST, "findByUserId",
78              new String[] { Long.class.getName() });
79      public static final FinderPath FINDER_PATH_FIND_BY_OBC_USERID = new FinderPath(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
80              PasswordTrackerModelImpl.FINDER_CACHE_ENABLED,
81              FINDER_CLASS_NAME_LIST, "findByUserId",
82              new String[] {
83                  Long.class.getName(),
84                  
85              "java.lang.Integer", "java.lang.Integer",
86                  "com.liferay.portal.kernel.util.OrderByComparator"
87              });
88      public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
89              PasswordTrackerModelImpl.FINDER_CACHE_ENABLED,
90              FINDER_CLASS_NAME_LIST, "countByUserId",
91              new String[] { Long.class.getName() });
92      public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
93              PasswordTrackerModelImpl.FINDER_CACHE_ENABLED,
94              FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
95      public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
96              PasswordTrackerModelImpl.FINDER_CACHE_ENABLED,
97              FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
98  
99      public void cacheResult(PasswordTracker passwordTracker) {
100         EntityCacheUtil.putResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
101             PasswordTrackerImpl.class, passwordTracker.getPrimaryKey(),
102             passwordTracker);
103     }
104 
105     public void cacheResult(List<PasswordTracker> passwordTrackers) {
106         for (PasswordTracker passwordTracker : passwordTrackers) {
107             if (EntityCacheUtil.getResult(
108                         PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
109                         PasswordTrackerImpl.class,
110                         passwordTracker.getPrimaryKey(), this) == null) {
111                 cacheResult(passwordTracker);
112             }
113         }
114     }
115 
116     public void clearCache() {
117         CacheRegistry.clear(PasswordTrackerImpl.class.getName());
118         EntityCacheUtil.clearCache(PasswordTrackerImpl.class.getName());
119         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
120         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
121     }
122 
123     public PasswordTracker create(long passwordTrackerId) {
124         PasswordTracker passwordTracker = new PasswordTrackerImpl();
125 
126         passwordTracker.setNew(true);
127         passwordTracker.setPrimaryKey(passwordTrackerId);
128 
129         return passwordTracker;
130     }
131 
132     public PasswordTracker remove(Serializable primaryKey)
133         throws NoSuchModelException, SystemException {
134         return remove(((Long)primaryKey).longValue());
135     }
136 
137     public PasswordTracker remove(long passwordTrackerId)
138         throws NoSuchPasswordTrackerException, SystemException {
139         Session session = null;
140 
141         try {
142             session = openSession();
143 
144             PasswordTracker passwordTracker = (PasswordTracker)session.get(PasswordTrackerImpl.class,
145                     new Long(passwordTrackerId));
146 
147             if (passwordTracker == null) {
148                 if (_log.isWarnEnabled()) {
149                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
150                         passwordTrackerId);
151                 }
152 
153                 throw new NoSuchPasswordTrackerException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
154                     passwordTrackerId);
155             }
156 
157             return remove(passwordTracker);
158         }
159         catch (NoSuchPasswordTrackerException nsee) {
160             throw nsee;
161         }
162         catch (Exception e) {
163             throw processException(e);
164         }
165         finally {
166             closeSession(session);
167         }
168     }
169 
170     public PasswordTracker remove(PasswordTracker passwordTracker)
171         throws SystemException {
172         for (ModelListener<PasswordTracker> listener : listeners) {
173             listener.onBeforeRemove(passwordTracker);
174         }
175 
176         passwordTracker = removeImpl(passwordTracker);
177 
178         for (ModelListener<PasswordTracker> listener : listeners) {
179             listener.onAfterRemove(passwordTracker);
180         }
181 
182         return passwordTracker;
183     }
184 
185     protected PasswordTracker removeImpl(PasswordTracker passwordTracker)
186         throws SystemException {
187         passwordTracker = toUnwrappedModel(passwordTracker);
188 
189         Session session = null;
190 
191         try {
192             session = openSession();
193 
194             if (passwordTracker.isCachedModel() ||
195                     BatchSessionUtil.isEnabled()) {
196                 Object staleObject = session.get(PasswordTrackerImpl.class,
197                         passwordTracker.getPrimaryKeyObj());
198 
199                 if (staleObject != null) {
200                     session.evict(staleObject);
201                 }
202             }
203 
204             session.delete(passwordTracker);
205 
206             session.flush();
207         }
208         catch (Exception e) {
209             throw processException(e);
210         }
211         finally {
212             closeSession(session);
213         }
214 
215         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
216 
217         EntityCacheUtil.removeResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
218             PasswordTrackerImpl.class, passwordTracker.getPrimaryKey());
219 
220         return passwordTracker;
221     }
222 
223     /**
224      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
225      */
226     public PasswordTracker update(PasswordTracker passwordTracker)
227         throws SystemException {
228         if (_log.isWarnEnabled()) {
229             _log.warn(
230                 "Using the deprecated update(PasswordTracker passwordTracker) method. Use update(PasswordTracker passwordTracker, boolean merge) instead.");
231         }
232 
233         return update(passwordTracker, false);
234     }
235 
236     public PasswordTracker updateImpl(
237         com.liferay.portal.model.PasswordTracker passwordTracker, boolean merge)
238         throws SystemException {
239         passwordTracker = toUnwrappedModel(passwordTracker);
240 
241         Session session = null;
242 
243         try {
244             session = openSession();
245 
246             BatchSessionUtil.update(session, passwordTracker, merge);
247 
248             passwordTracker.setNew(false);
249         }
250         catch (Exception e) {
251             throw processException(e);
252         }
253         finally {
254             closeSession(session);
255         }
256 
257         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
258 
259         EntityCacheUtil.putResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
260             PasswordTrackerImpl.class, passwordTracker.getPrimaryKey(),
261             passwordTracker);
262 
263         return passwordTracker;
264     }
265 
266     protected PasswordTracker toUnwrappedModel(PasswordTracker passwordTracker) {
267         if (passwordTracker instanceof PasswordTrackerImpl) {
268             return passwordTracker;
269         }
270 
271         PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
272 
273         passwordTrackerImpl.setNew(passwordTracker.isNew());
274         passwordTrackerImpl.setPrimaryKey(passwordTracker.getPrimaryKey());
275 
276         passwordTrackerImpl.setPasswordTrackerId(passwordTracker.getPasswordTrackerId());
277         passwordTrackerImpl.setUserId(passwordTracker.getUserId());
278         passwordTrackerImpl.setCreateDate(passwordTracker.getCreateDate());
279         passwordTrackerImpl.setPassword(passwordTracker.getPassword());
280 
281         return passwordTrackerImpl;
282     }
283 
284     public PasswordTracker findByPrimaryKey(Serializable primaryKey)
285         throws NoSuchModelException, SystemException {
286         return findByPrimaryKey(((Long)primaryKey).longValue());
287     }
288 
289     public PasswordTracker findByPrimaryKey(long passwordTrackerId)
290         throws NoSuchPasswordTrackerException, SystemException {
291         PasswordTracker passwordTracker = fetchByPrimaryKey(passwordTrackerId);
292 
293         if (passwordTracker == null) {
294             if (_log.isWarnEnabled()) {
295                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + passwordTrackerId);
296             }
297 
298             throw new NoSuchPasswordTrackerException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
299                 passwordTrackerId);
300         }
301 
302         return passwordTracker;
303     }
304 
305     public PasswordTracker fetchByPrimaryKey(Serializable primaryKey)
306         throws SystemException {
307         return fetchByPrimaryKey(((Long)primaryKey).longValue());
308     }
309 
310     public PasswordTracker fetchByPrimaryKey(long passwordTrackerId)
311         throws SystemException {
312         PasswordTracker passwordTracker = (PasswordTracker)EntityCacheUtil.getResult(PasswordTrackerModelImpl.ENTITY_CACHE_ENABLED,
313                 PasswordTrackerImpl.class, passwordTrackerId, this);
314 
315         if (passwordTracker == null) {
316             Session session = null;
317 
318             try {
319                 session = openSession();
320 
321                 passwordTracker = (PasswordTracker)session.get(PasswordTrackerImpl.class,
322                         new Long(passwordTrackerId));
323             }
324             catch (Exception e) {
325                 throw processException(e);
326             }
327             finally {
328                 if (passwordTracker != null) {
329                     cacheResult(passwordTracker);
330                 }
331 
332                 closeSession(session);
333             }
334         }
335 
336         return passwordTracker;
337     }
338 
339     public List<PasswordTracker> findByUserId(long userId)
340         throws SystemException {
341         Object[] finderArgs = new Object[] { new Long(userId) };
342 
343         List<PasswordTracker> list = (List<PasswordTracker>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_USERID,
344                 finderArgs, this);
345 
346         if (list == null) {
347             Session session = null;
348 
349             try {
350                 session = openSession();
351 
352                 StringBundler query = new StringBundler(3);
353 
354                 query.append(_SQL_SELECT_PASSWORDTRACKER_WHERE);
355 
356                 query.append(_FINDER_COLUMN_USERID_USERID_2);
357 
358                 query.append(PasswordTrackerModelImpl.ORDER_BY_JPQL);
359 
360                 String sql = query.toString();
361 
362                 Query q = session.createQuery(sql);
363 
364                 QueryPos qPos = QueryPos.getInstance(q);
365 
366                 qPos.add(userId);
367 
368                 list = q.list();
369             }
370             catch (Exception e) {
371                 throw processException(e);
372             }
373             finally {
374                 if (list == null) {
375                     list = new ArrayList<PasswordTracker>();
376                 }
377 
378                 cacheResult(list);
379 
380                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_USERID,
381                     finderArgs, list);
382 
383                 closeSession(session);
384             }
385         }
386 
387         return list;
388     }
389 
390     public List<PasswordTracker> findByUserId(long userId, int start, int end)
391         throws SystemException {
392         return findByUserId(userId, start, end, null);
393     }
394 
395     public List<PasswordTracker> findByUserId(long userId, int start, int end,
396         OrderByComparator obc) throws SystemException {
397         Object[] finderArgs = new Object[] {
398                 new Long(userId),
399                 
400                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
401             };
402 
403         List<PasswordTracker> list = (List<PasswordTracker>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_USERID,
404                 finderArgs, this);
405 
406         if (list == null) {
407             Session session = null;
408 
409             try {
410                 session = openSession();
411 
412                 StringBundler query = null;
413 
414                 if (obc != null) {
415                     query = new StringBundler(3 +
416                             (obc.getOrderByFields().length * 3));
417                 }
418                 else {
419                     query = new StringBundler(3);
420                 }
421 
422                 query.append(_SQL_SELECT_PASSWORDTRACKER_WHERE);
423 
424                 query.append(_FINDER_COLUMN_USERID_USERID_2);
425 
426                 if (obc != null) {
427                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
428                 }
429 
430                 else {
431                     query.append(PasswordTrackerModelImpl.ORDER_BY_JPQL);
432                 }
433 
434                 String sql = query.toString();
435 
436                 Query q = session.createQuery(sql);
437 
438                 QueryPos qPos = QueryPos.getInstance(q);
439 
440                 qPos.add(userId);
441 
442                 list = (List<PasswordTracker>)QueryUtil.list(q, getDialect(),
443                         start, end);
444             }
445             catch (Exception e) {
446                 throw processException(e);
447             }
448             finally {
449                 if (list == null) {
450                     list = new ArrayList<PasswordTracker>();
451                 }
452 
453                 cacheResult(list);
454 
455                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_USERID,
456                     finderArgs, list);
457 
458                 closeSession(session);
459             }
460         }
461 
462         return list;
463     }
464 
465     public PasswordTracker findByUserId_First(long userId, OrderByComparator obc)
466         throws NoSuchPasswordTrackerException, SystemException {
467         List<PasswordTracker> list = findByUserId(userId, 0, 1, obc);
468 
469         if (list.isEmpty()) {
470             StringBundler msg = new StringBundler(4);
471 
472             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
473 
474             msg.append("userId=");
475             msg.append(userId);
476 
477             msg.append(StringPool.CLOSE_CURLY_BRACE);
478 
479             throw new NoSuchPasswordTrackerException(msg.toString());
480         }
481         else {
482             return list.get(0);
483         }
484     }
485 
486     public PasswordTracker findByUserId_Last(long userId, OrderByComparator obc)
487         throws NoSuchPasswordTrackerException, SystemException {
488         int count = countByUserId(userId);
489 
490         List<PasswordTracker> list = findByUserId(userId, count - 1, count, obc);
491 
492         if (list.isEmpty()) {
493             StringBundler msg = new StringBundler(4);
494 
495             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
496 
497             msg.append("userId=");
498             msg.append(userId);
499 
500             msg.append(StringPool.CLOSE_CURLY_BRACE);
501 
502             throw new NoSuchPasswordTrackerException(msg.toString());
503         }
504         else {
505             return list.get(0);
506         }
507     }
508 
509     public PasswordTracker[] findByUserId_PrevAndNext(long passwordTrackerId,
510         long userId, OrderByComparator obc)
511         throws NoSuchPasswordTrackerException, SystemException {
512         PasswordTracker passwordTracker = findByPrimaryKey(passwordTrackerId);
513 
514         int count = countByUserId(userId);
515 
516         Session session = null;
517 
518         try {
519             session = openSession();
520 
521             StringBundler query = null;
522 
523             if (obc != null) {
524                 query = new StringBundler(3 +
525                         (obc.getOrderByFields().length * 3));
526             }
527             else {
528                 query = new StringBundler(3);
529             }
530 
531             query.append(_SQL_SELECT_PASSWORDTRACKER_WHERE);
532 
533             query.append(_FINDER_COLUMN_USERID_USERID_2);
534 
535             if (obc != null) {
536                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
537             }
538 
539             else {
540                 query.append(PasswordTrackerModelImpl.ORDER_BY_JPQL);
541             }
542 
543             String sql = query.toString();
544 
545             Query q = session.createQuery(sql);
546 
547             QueryPos qPos = QueryPos.getInstance(q);
548 
549             qPos.add(userId);
550 
551             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
552                     passwordTracker);
553 
554             PasswordTracker[] array = new PasswordTrackerImpl[3];
555 
556             array[0] = (PasswordTracker)objArray[0];
557             array[1] = (PasswordTracker)objArray[1];
558             array[2] = (PasswordTracker)objArray[2];
559 
560             return array;
561         }
562         catch (Exception e) {
563             throw processException(e);
564         }
565         finally {
566             closeSession(session);
567         }
568     }
569 
570     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
571         throws SystemException {
572         Session session = null;
573 
574         try {
575             session = openSession();
576 
577             dynamicQuery.compile(session);
578 
579             return dynamicQuery.list();
580         }
581         catch (Exception e) {
582             throw processException(e);
583         }
584         finally {
585             closeSession(session);
586         }
587     }
588 
589     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
590         int start, int end) throws SystemException {
591         Session session = null;
592 
593         try {
594             session = openSession();
595 
596             dynamicQuery.setLimit(start, end);
597 
598             dynamicQuery.compile(session);
599 
600             return dynamicQuery.list();
601         }
602         catch (Exception e) {
603             throw processException(e);
604         }
605         finally {
606             closeSession(session);
607         }
608     }
609 
610     public List<PasswordTracker> findAll() throws SystemException {
611         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
612     }
613 
614     public List<PasswordTracker> findAll(int start, int end)
615         throws SystemException {
616         return findAll(start, end, null);
617     }
618 
619     public List<PasswordTracker> findAll(int start, int end,
620         OrderByComparator obc) throws SystemException {
621         Object[] finderArgs = new Object[] {
622                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
623             };
624 
625         List<PasswordTracker> list = (List<PasswordTracker>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
626                 finderArgs, this);
627 
628         if (list == null) {
629             Session session = null;
630 
631             try {
632                 session = openSession();
633 
634                 StringBundler query = null;
635                 String sql = null;
636 
637                 if (obc != null) {
638                     query = new StringBundler(2 +
639                             (obc.getOrderByFields().length * 3));
640 
641                     query.append(_SQL_SELECT_PASSWORDTRACKER);
642 
643                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
644 
645                     sql = query.toString();
646                 }
647 
648                 else {
649                     sql = _SQL_SELECT_PASSWORDTRACKER.concat(PasswordTrackerModelImpl.ORDER_BY_JPQL);
650                 }
651 
652                 Query q = session.createQuery(sql);
653 
654                 if (obc == null) {
655                     list = (List<PasswordTracker>)QueryUtil.list(q,
656                             getDialect(), start, end, false);
657 
658                     Collections.sort(list);
659                 }
660                 else {
661                     list = (List<PasswordTracker>)QueryUtil.list(q,
662                             getDialect(), start, end);
663                 }
664             }
665             catch (Exception e) {
666                 throw processException(e);
667             }
668             finally {
669                 if (list == null) {
670                     list = new ArrayList<PasswordTracker>();
671                 }
672 
673                 cacheResult(list);
674 
675                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
676 
677                 closeSession(session);
678             }
679         }
680 
681         return list;
682     }
683 
684     public void removeByUserId(long userId) throws SystemException {
685         for (PasswordTracker passwordTracker : findByUserId(userId)) {
686             remove(passwordTracker);
687         }
688     }
689 
690     public void removeAll() throws SystemException {
691         for (PasswordTracker passwordTracker : findAll()) {
692             remove(passwordTracker);
693         }
694     }
695 
696     public int countByUserId(long userId) throws SystemException {
697         Object[] finderArgs = new Object[] { new Long(userId) };
698 
699         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
700                 finderArgs, this);
701 
702         if (count == null) {
703             Session session = null;
704 
705             try {
706                 session = openSession();
707 
708                 StringBundler query = new StringBundler(2);
709 
710                 query.append(_SQL_COUNT_PASSWORDTRACKER_WHERE);
711 
712                 query.append(_FINDER_COLUMN_USERID_USERID_2);
713 
714                 String sql = query.toString();
715 
716                 Query q = session.createQuery(sql);
717 
718                 QueryPos qPos = QueryPos.getInstance(q);
719 
720                 qPos.add(userId);
721 
722                 count = (Long)q.uniqueResult();
723             }
724             catch (Exception e) {
725                 throw processException(e);
726             }
727             finally {
728                 if (count == null) {
729                     count = Long.valueOf(0);
730                 }
731 
732                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
733                     finderArgs, count);
734 
735                 closeSession(session);
736             }
737         }
738 
739         return count.intValue();
740     }
741 
742     public int countAll() throws SystemException {
743         Object[] finderArgs = new Object[0];
744 
745         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
746                 finderArgs, this);
747 
748         if (count == null) {
749             Session session = null;
750 
751             try {
752                 session = openSession();
753 
754                 Query q = session.createQuery(_SQL_COUNT_PASSWORDTRACKER);
755 
756                 count = (Long)q.uniqueResult();
757             }
758             catch (Exception e) {
759                 throw processException(e);
760             }
761             finally {
762                 if (count == null) {
763                     count = Long.valueOf(0);
764                 }
765 
766                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
767                     count);
768 
769                 closeSession(session);
770             }
771         }
772 
773         return count.intValue();
774     }
775 
776     public void afterPropertiesSet() {
777         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
778                     com.liferay.portal.util.PropsUtil.get(
779                         "value.object.listener.com.liferay.portal.model.PasswordTracker")));
780 
781         if (listenerClassNames.length > 0) {
782             try {
783                 List<ModelListener<PasswordTracker>> listenersList = new ArrayList<ModelListener<PasswordTracker>>();
784 
785                 for (String listenerClassName : listenerClassNames) {
786                     listenersList.add((ModelListener<PasswordTracker>)Class.forName(
787                             listenerClassName).newInstance());
788                 }
789 
790                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
791             }
792             catch (Exception e) {
793                 _log.error(e);
794             }
795         }
796     }
797 
798     @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence")
799     protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
800     @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence")
801     protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
802     @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence")
803     protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
804     @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence")
805     protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
806     @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
807     protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
808     @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence")
809     protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
810     @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence")
811     protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
812     @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence")
813     protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
814     @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
815     protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
816     @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence")
817     protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
818     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence")
819     protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
820     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence")
821     protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
822     @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence")
823     protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
824     @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence")
825     protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
826     @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence")
827     protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
828     @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence")
829     protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
830     @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence")
831     protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
832     @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence")
833     protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
834     @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence")
835     protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
836     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence")
837     protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
838     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence")
839     protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
840     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence")
841     protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
842     @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence")
843     protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
844     @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence")
845     protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
846     @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence")
847     protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
848     @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence")
849     protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
850     @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence")
851     protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
852     @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence")
853     protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
854     @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence")
855     protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
856     @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence")
857     protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
858     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
859     protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
860     @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence")
861     protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
862     @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence")
863     protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
864     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence")
865     protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
866     @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence")
867     protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
868     @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence")
869     protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
870     @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence")
871     protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
872     @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence")
873     protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
874     @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
875     protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
876     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence")
877     protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
878     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupGroupRolePersistence")
879     protected com.liferay.portal.service.persistence.UserGroupGroupRolePersistence userGroupGroupRolePersistence;
880     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence")
881     protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
882     @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence")
883     protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
884     @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence")
885     protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
886     @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence")
887     protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
888     @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence")
889     protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
890     @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence")
891     protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
892     private static final String _SQL_SELECT_PASSWORDTRACKER = "SELECT passwordTracker FROM PasswordTracker passwordTracker";
893     private static final String _SQL_SELECT_PASSWORDTRACKER_WHERE = "SELECT passwordTracker FROM PasswordTracker passwordTracker WHERE ";
894     private static final String _SQL_COUNT_PASSWORDTRACKER = "SELECT COUNT(passwordTracker) FROM PasswordTracker passwordTracker";
895     private static final String _SQL_COUNT_PASSWORDTRACKER_WHERE = "SELECT COUNT(passwordTracker) FROM PasswordTracker passwordTracker WHERE ";
896     private static final String _FINDER_COLUMN_USERID_USERID_2 = "passwordTracker.userId = ?";
897     private static final String _ORDER_BY_ENTITY_ALIAS = "passwordTracker.";
898     private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PasswordTracker exists with the primary key ";
899     private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PasswordTracker exists with the key {";
900     private static Log _log = LogFactoryUtil.getLog(PasswordTrackerPersistenceImpl.class);
901 }