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