1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.NoSuchPasswordPolicyRelException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.kernel.annotation.BeanReference;
28  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
30  import com.liferay.portal.kernel.dao.orm.Query;
31  import com.liferay.portal.kernel.dao.orm.QueryPos;
32  import com.liferay.portal.kernel.dao.orm.QueryUtil;
33  import com.liferay.portal.kernel.dao.orm.Session;
34  import com.liferay.portal.kernel.log.Log;
35  import com.liferay.portal.kernel.log.LogFactoryUtil;
36  import com.liferay.portal.kernel.util.GetterUtil;
37  import com.liferay.portal.kernel.util.OrderByComparator;
38  import com.liferay.portal.kernel.util.StringPool;
39  import com.liferay.portal.kernel.util.StringUtil;
40  import com.liferay.portal.model.ModelListener;
41  import com.liferay.portal.model.PasswordPolicyRel;
42  import com.liferay.portal.model.impl.PasswordPolicyRelImpl;
43  import com.liferay.portal.model.impl.PasswordPolicyRelModelImpl;
44  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
45  
46  import java.util.ArrayList;
47  import java.util.Collections;
48  import java.util.Iterator;
49  import java.util.List;
50  
51  /**
52   * <a href="PasswordPolicyRelPersistenceImpl.java.html"><b><i>View Source</i></b></a>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   */
57  public class PasswordPolicyRelPersistenceImpl extends BasePersistenceImpl
58      implements PasswordPolicyRelPersistence {
59      public PasswordPolicyRel create(long passwordPolicyRelId) {
60          PasswordPolicyRel passwordPolicyRel = new PasswordPolicyRelImpl();
61  
62          passwordPolicyRel.setNew(true);
63          passwordPolicyRel.setPrimaryKey(passwordPolicyRelId);
64  
65          return passwordPolicyRel;
66      }
67  
68      public PasswordPolicyRel remove(long passwordPolicyRelId)
69          throws NoSuchPasswordPolicyRelException, SystemException {
70          Session session = null;
71  
72          try {
73              session = openSession();
74  
75              PasswordPolicyRel passwordPolicyRel = (PasswordPolicyRel)session.get(PasswordPolicyRelImpl.class,
76                      new Long(passwordPolicyRelId));
77  
78              if (passwordPolicyRel == null) {
79                  if (_log.isWarnEnabled()) {
80                      _log.warn(
81                          "No PasswordPolicyRel exists with the primary key " +
82                          passwordPolicyRelId);
83                  }
84  
85                  throw new NoSuchPasswordPolicyRelException(
86                      "No PasswordPolicyRel exists with the primary key " +
87                      passwordPolicyRelId);
88              }
89  
90              return remove(passwordPolicyRel);
91          }
92          catch (NoSuchPasswordPolicyRelException nsee) {
93              throw nsee;
94          }
95          catch (Exception e) {
96              throw processException(e);
97          }
98          finally {
99              closeSession(session);
100         }
101     }
102 
103     public PasswordPolicyRel remove(PasswordPolicyRel passwordPolicyRel)
104         throws SystemException {
105         for (ModelListener listener : listeners) {
106             listener.onBeforeRemove(passwordPolicyRel);
107         }
108 
109         passwordPolicyRel = removeImpl(passwordPolicyRel);
110 
111         for (ModelListener listener : listeners) {
112             listener.onAfterRemove(passwordPolicyRel);
113         }
114 
115         return passwordPolicyRel;
116     }
117 
118     protected PasswordPolicyRel removeImpl(PasswordPolicyRel passwordPolicyRel)
119         throws SystemException {
120         Session session = null;
121 
122         try {
123             session = openSession();
124 
125             if (BatchSessionUtil.isEnabled()) {
126                 Object staleObject = session.get(PasswordPolicyRelImpl.class,
127                         passwordPolicyRel.getPrimaryKeyObj());
128 
129                 if (staleObject != null) {
130                     session.evict(staleObject);
131                 }
132             }
133 
134             session.delete(passwordPolicyRel);
135 
136             session.flush();
137 
138             return passwordPolicyRel;
139         }
140         catch (Exception e) {
141             throw processException(e);
142         }
143         finally {
144             closeSession(session);
145 
146             FinderCacheUtil.clearCache(PasswordPolicyRel.class.getName());
147         }
148     }
149 
150     /**
151      * @deprecated Use <code>update(PasswordPolicyRel passwordPolicyRel, boolean merge)</code>.
152      */
153     public PasswordPolicyRel update(PasswordPolicyRel passwordPolicyRel)
154         throws SystemException {
155         if (_log.isWarnEnabled()) {
156             _log.warn(
157                 "Using the deprecated update(PasswordPolicyRel passwordPolicyRel) method. Use update(PasswordPolicyRel passwordPolicyRel, boolean merge) instead.");
158         }
159 
160         return update(passwordPolicyRel, false);
161     }
162 
163     /**
164      * Add, update, or merge, the entity. This method also calls the model
165      * listeners to trigger the proper events associated with adding, deleting,
166      * or updating an entity.
167      *
168      * @param        passwordPolicyRel the entity to add, update, or merge
169      * @param        merge boolean value for whether to merge the entity. The
170      *                default value is false. Setting merge to true is more
171      *                expensive and should only be true when passwordPolicyRel is
172      *                transient. See LEP-5473 for a detailed discussion of this
173      *                method.
174      * @return        true if the portlet can be displayed via Ajax
175      */
176     public PasswordPolicyRel update(PasswordPolicyRel passwordPolicyRel,
177         boolean merge) throws SystemException {
178         boolean isNew = passwordPolicyRel.isNew();
179 
180         for (ModelListener listener : listeners) {
181             if (isNew) {
182                 listener.onBeforeCreate(passwordPolicyRel);
183             }
184             else {
185                 listener.onBeforeUpdate(passwordPolicyRel);
186             }
187         }
188 
189         passwordPolicyRel = updateImpl(passwordPolicyRel, merge);
190 
191         for (ModelListener listener : listeners) {
192             if (isNew) {
193                 listener.onAfterCreate(passwordPolicyRel);
194             }
195             else {
196                 listener.onAfterUpdate(passwordPolicyRel);
197             }
198         }
199 
200         return passwordPolicyRel;
201     }
202 
203     public PasswordPolicyRel updateImpl(
204         com.liferay.portal.model.PasswordPolicyRel passwordPolicyRel,
205         boolean merge) throws SystemException {
206         Session session = null;
207 
208         try {
209             session = openSession();
210 
211             BatchSessionUtil.update(session, passwordPolicyRel, merge);
212 
213             passwordPolicyRel.setNew(false);
214 
215             return passwordPolicyRel;
216         }
217         catch (Exception e) {
218             throw processException(e);
219         }
220         finally {
221             closeSession(session);
222 
223             FinderCacheUtil.clearCache(PasswordPolicyRel.class.getName());
224         }
225     }
226 
227     public PasswordPolicyRel findByPrimaryKey(long passwordPolicyRelId)
228         throws NoSuchPasswordPolicyRelException, SystemException {
229         PasswordPolicyRel passwordPolicyRel = fetchByPrimaryKey(passwordPolicyRelId);
230 
231         if (passwordPolicyRel == null) {
232             if (_log.isWarnEnabled()) {
233                 _log.warn("No PasswordPolicyRel exists with the primary key " +
234                     passwordPolicyRelId);
235             }
236 
237             throw new NoSuchPasswordPolicyRelException(
238                 "No PasswordPolicyRel exists with the primary key " +
239                 passwordPolicyRelId);
240         }
241 
242         return passwordPolicyRel;
243     }
244 
245     public PasswordPolicyRel fetchByPrimaryKey(long passwordPolicyRelId)
246         throws SystemException {
247         Session session = null;
248 
249         try {
250             session = openSession();
251 
252             return (PasswordPolicyRel)session.get(PasswordPolicyRelImpl.class,
253                 new Long(passwordPolicyRelId));
254         }
255         catch (Exception e) {
256             throw processException(e);
257         }
258         finally {
259             closeSession(session);
260         }
261     }
262 
263     public PasswordPolicyRel findByC_C(long classNameId, long classPK)
264         throws NoSuchPasswordPolicyRelException, SystemException {
265         PasswordPolicyRel passwordPolicyRel = fetchByC_C(classNameId, classPK);
266 
267         if (passwordPolicyRel == null) {
268             StringBuilder msg = new StringBuilder();
269 
270             msg.append("No PasswordPolicyRel exists with the key {");
271 
272             msg.append("classNameId=" + classNameId);
273 
274             msg.append(", ");
275             msg.append("classPK=" + classPK);
276 
277             msg.append(StringPool.CLOSE_CURLY_BRACE);
278 
279             if (_log.isWarnEnabled()) {
280                 _log.warn(msg.toString());
281             }
282 
283             throw new NoSuchPasswordPolicyRelException(msg.toString());
284         }
285 
286         return passwordPolicyRel;
287     }
288 
289     public PasswordPolicyRel fetchByC_C(long classNameId, long classPK)
290         throws SystemException {
291         boolean finderClassNameCacheEnabled = PasswordPolicyRelModelImpl.CACHE_ENABLED;
292         String finderClassName = PasswordPolicyRel.class.getName();
293         String finderMethodName = "fetchByC_C";
294         String[] finderParams = new String[] {
295                 Long.class.getName(), Long.class.getName()
296             };
297         Object[] finderArgs = new Object[] {
298                 new Long(classNameId), new Long(classPK)
299             };
300 
301         Object result = null;
302 
303         if (finderClassNameCacheEnabled) {
304             result = FinderCacheUtil.getResult(finderClassName,
305                     finderMethodName, finderParams, finderArgs, this);
306         }
307 
308         if (result == null) {
309             Session session = null;
310 
311             try {
312                 session = openSession();
313 
314                 StringBuilder query = new StringBuilder();
315 
316                 query.append(
317                     "FROM com.liferay.portal.model.PasswordPolicyRel WHERE ");
318 
319                 query.append("classNameId = ?");
320 
321                 query.append(" AND ");
322 
323                 query.append("classPK = ?");
324 
325                 query.append(" ");
326 
327                 Query q = session.createQuery(query.toString());
328 
329                 QueryPos qPos = QueryPos.getInstance(q);
330 
331                 qPos.add(classNameId);
332 
333                 qPos.add(classPK);
334 
335                 List<PasswordPolicyRel> list = q.list();
336 
337                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
338                     finderClassName, finderMethodName, finderParams,
339                     finderArgs, list);
340 
341                 if (list.size() == 0) {
342                     return null;
343                 }
344                 else {
345                     return list.get(0);
346                 }
347             }
348             catch (Exception e) {
349                 throw processException(e);
350             }
351             finally {
352                 closeSession(session);
353             }
354         }
355         else {
356             List<PasswordPolicyRel> list = (List<PasswordPolicyRel>)result;
357 
358             if (list.size() == 0) {
359                 return null;
360             }
361             else {
362                 return list.get(0);
363             }
364         }
365     }
366 
367     public PasswordPolicyRel findByP_C_C(long passwordPolicyId,
368         long classNameId, long classPK)
369         throws NoSuchPasswordPolicyRelException, SystemException {
370         PasswordPolicyRel passwordPolicyRel = fetchByP_C_C(passwordPolicyId,
371                 classNameId, classPK);
372 
373         if (passwordPolicyRel == null) {
374             StringBuilder msg = new StringBuilder();
375 
376             msg.append("No PasswordPolicyRel exists with the key {");
377 
378             msg.append("passwordPolicyId=" + passwordPolicyId);
379 
380             msg.append(", ");
381             msg.append("classNameId=" + classNameId);
382 
383             msg.append(", ");
384             msg.append("classPK=" + classPK);
385 
386             msg.append(StringPool.CLOSE_CURLY_BRACE);
387 
388             if (_log.isWarnEnabled()) {
389                 _log.warn(msg.toString());
390             }
391 
392             throw new NoSuchPasswordPolicyRelException(msg.toString());
393         }
394 
395         return passwordPolicyRel;
396     }
397 
398     public PasswordPolicyRel fetchByP_C_C(long passwordPolicyId,
399         long classNameId, long classPK) throws SystemException {
400         boolean finderClassNameCacheEnabled = PasswordPolicyRelModelImpl.CACHE_ENABLED;
401         String finderClassName = PasswordPolicyRel.class.getName();
402         String finderMethodName = "fetchByP_C_C";
403         String[] finderParams = new String[] {
404                 Long.class.getName(), Long.class.getName(), Long.class.getName()
405             };
406         Object[] finderArgs = new Object[] {
407                 new Long(passwordPolicyId), new Long(classNameId),
408                 new Long(classPK)
409             };
410 
411         Object result = null;
412 
413         if (finderClassNameCacheEnabled) {
414             result = FinderCacheUtil.getResult(finderClassName,
415                     finderMethodName, finderParams, finderArgs, this);
416         }
417 
418         if (result == null) {
419             Session session = null;
420 
421             try {
422                 session = openSession();
423 
424                 StringBuilder query = new StringBuilder();
425 
426                 query.append(
427                     "FROM com.liferay.portal.model.PasswordPolicyRel WHERE ");
428 
429                 query.append("passwordPolicyId = ?");
430 
431                 query.append(" AND ");
432 
433                 query.append("classNameId = ?");
434 
435                 query.append(" AND ");
436 
437                 query.append("classPK = ?");
438 
439                 query.append(" ");
440 
441                 Query q = session.createQuery(query.toString());
442 
443                 QueryPos qPos = QueryPos.getInstance(q);
444 
445                 qPos.add(passwordPolicyId);
446 
447                 qPos.add(classNameId);
448 
449                 qPos.add(classPK);
450 
451                 List<PasswordPolicyRel> list = q.list();
452 
453                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
454                     finderClassName, finderMethodName, finderParams,
455                     finderArgs, list);
456 
457                 if (list.size() == 0) {
458                     return null;
459                 }
460                 else {
461                     return list.get(0);
462                 }
463             }
464             catch (Exception e) {
465                 throw processException(e);
466             }
467             finally {
468                 closeSession(session);
469             }
470         }
471         else {
472             List<PasswordPolicyRel> list = (List<PasswordPolicyRel>)result;
473 
474             if (list.size() == 0) {
475                 return null;
476             }
477             else {
478                 return list.get(0);
479             }
480         }
481     }
482 
483     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
484         throws SystemException {
485         Session session = null;
486 
487         try {
488             session = openSession();
489 
490             dynamicQuery.compile(session);
491 
492             return dynamicQuery.list();
493         }
494         catch (Exception e) {
495             throw processException(e);
496         }
497         finally {
498             closeSession(session);
499         }
500     }
501 
502     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
503         int start, int end) throws SystemException {
504         Session session = null;
505 
506         try {
507             session = openSession();
508 
509             dynamicQuery.setLimit(start, end);
510 
511             dynamicQuery.compile(session);
512 
513             return dynamicQuery.list();
514         }
515         catch (Exception e) {
516             throw processException(e);
517         }
518         finally {
519             closeSession(session);
520         }
521     }
522 
523     public List<PasswordPolicyRel> findAll() throws SystemException {
524         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
525     }
526 
527     public List<PasswordPolicyRel> findAll(int start, int end)
528         throws SystemException {
529         return findAll(start, end, null);
530     }
531 
532     public List<PasswordPolicyRel> findAll(int start, int end,
533         OrderByComparator obc) throws SystemException {
534         boolean finderClassNameCacheEnabled = PasswordPolicyRelModelImpl.CACHE_ENABLED;
535         String finderClassName = PasswordPolicyRel.class.getName();
536         String finderMethodName = "findAll";
537         String[] finderParams = new String[] {
538                 "java.lang.Integer", "java.lang.Integer",
539                 "com.liferay.portal.kernel.util.OrderByComparator"
540             };
541         Object[] finderArgs = new Object[] {
542                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
543             };
544 
545         Object result = null;
546 
547         if (finderClassNameCacheEnabled) {
548             result = FinderCacheUtil.getResult(finderClassName,
549                     finderMethodName, finderParams, finderArgs, this);
550         }
551 
552         if (result == null) {
553             Session session = null;
554 
555             try {
556                 session = openSession();
557 
558                 StringBuilder query = new StringBuilder();
559 
560                 query.append("FROM com.liferay.portal.model.PasswordPolicyRel ");
561 
562                 if (obc != null) {
563                     query.append("ORDER BY ");
564                     query.append(obc.getOrderBy());
565                 }
566 
567                 Query q = session.createQuery(query.toString());
568 
569                 List<PasswordPolicyRel> list = null;
570 
571                 if (obc == null) {
572                     list = (List<PasswordPolicyRel>)QueryUtil.list(q,
573                             getDialect(), start, end, false);
574 
575                     Collections.sort(list);
576                 }
577                 else {
578                     list = (List<PasswordPolicyRel>)QueryUtil.list(q,
579                             getDialect(), start, end);
580                 }
581 
582                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
583                     finderClassName, finderMethodName, finderParams,
584                     finderArgs, list);
585 
586                 return list;
587             }
588             catch (Exception e) {
589                 throw processException(e);
590             }
591             finally {
592                 closeSession(session);
593             }
594         }
595         else {
596             return (List<PasswordPolicyRel>)result;
597         }
598     }
599 
600     public void removeByC_C(long classNameId, long classPK)
601         throws NoSuchPasswordPolicyRelException, SystemException {
602         PasswordPolicyRel passwordPolicyRel = findByC_C(classNameId, classPK);
603 
604         remove(passwordPolicyRel);
605     }
606 
607     public void removeByP_C_C(long passwordPolicyId, long classNameId,
608         long classPK) throws NoSuchPasswordPolicyRelException, SystemException {
609         PasswordPolicyRel passwordPolicyRel = findByP_C_C(passwordPolicyId,
610                 classNameId, classPK);
611 
612         remove(passwordPolicyRel);
613     }
614 
615     public void removeAll() throws SystemException {
616         for (PasswordPolicyRel passwordPolicyRel : findAll()) {
617             remove(passwordPolicyRel);
618         }
619     }
620 
621     public int countByC_C(long classNameId, long classPK)
622         throws SystemException {
623         boolean finderClassNameCacheEnabled = PasswordPolicyRelModelImpl.CACHE_ENABLED;
624         String finderClassName = PasswordPolicyRel.class.getName();
625         String finderMethodName = "countByC_C";
626         String[] finderParams = new String[] {
627                 Long.class.getName(), Long.class.getName()
628             };
629         Object[] finderArgs = new Object[] {
630                 new Long(classNameId), new Long(classPK)
631             };
632 
633         Object result = null;
634 
635         if (finderClassNameCacheEnabled) {
636             result = FinderCacheUtil.getResult(finderClassName,
637                     finderMethodName, finderParams, finderArgs, this);
638         }
639 
640         if (result == null) {
641             Session session = null;
642 
643             try {
644                 session = openSession();
645 
646                 StringBuilder query = new StringBuilder();
647 
648                 query.append("SELECT COUNT(*) ");
649                 query.append(
650                     "FROM com.liferay.portal.model.PasswordPolicyRel WHERE ");
651 
652                 query.append("classNameId = ?");
653 
654                 query.append(" AND ");
655 
656                 query.append("classPK = ?");
657 
658                 query.append(" ");
659 
660                 Query q = session.createQuery(query.toString());
661 
662                 QueryPos qPos = QueryPos.getInstance(q);
663 
664                 qPos.add(classNameId);
665 
666                 qPos.add(classPK);
667 
668                 Long count = null;
669 
670                 Iterator<Long> itr = q.list().iterator();
671 
672                 if (itr.hasNext()) {
673                     count = itr.next();
674                 }
675 
676                 if (count == null) {
677                     count = new Long(0);
678                 }
679 
680                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
681                     finderClassName, finderMethodName, finderParams,
682                     finderArgs, count);
683 
684                 return count.intValue();
685             }
686             catch (Exception e) {
687                 throw processException(e);
688             }
689             finally {
690                 closeSession(session);
691             }
692         }
693         else {
694             return ((Long)result).intValue();
695         }
696     }
697 
698     public int countByP_C_C(long passwordPolicyId, long classNameId,
699         long classPK) throws SystemException {
700         boolean finderClassNameCacheEnabled = PasswordPolicyRelModelImpl.CACHE_ENABLED;
701         String finderClassName = PasswordPolicyRel.class.getName();
702         String finderMethodName = "countByP_C_C";
703         String[] finderParams = new String[] {
704                 Long.class.getName(), Long.class.getName(), Long.class.getName()
705             };
706         Object[] finderArgs = new Object[] {
707                 new Long(passwordPolicyId), new Long(classNameId),
708                 new Long(classPK)
709             };
710 
711         Object result = null;
712 
713         if (finderClassNameCacheEnabled) {
714             result = FinderCacheUtil.getResult(finderClassName,
715                     finderMethodName, finderParams, finderArgs, this);
716         }
717 
718         if (result == null) {
719             Session session = null;
720 
721             try {
722                 session = openSession();
723 
724                 StringBuilder query = new StringBuilder();
725 
726                 query.append("SELECT COUNT(*) ");
727                 query.append(
728                     "FROM com.liferay.portal.model.PasswordPolicyRel WHERE ");
729 
730                 query.append("passwordPolicyId = ?");
731 
732                 query.append(" AND ");
733 
734                 query.append("classNameId = ?");
735 
736                 query.append(" AND ");
737 
738                 query.append("classPK = ?");
739 
740                 query.append(" ");
741 
742                 Query q = session.createQuery(query.toString());
743 
744                 QueryPos qPos = QueryPos.getInstance(q);
745 
746                 qPos.add(passwordPolicyId);
747 
748                 qPos.add(classNameId);
749 
750                 qPos.add(classPK);
751 
752                 Long count = null;
753 
754                 Iterator<Long> itr = q.list().iterator();
755 
756                 if (itr.hasNext()) {
757                     count = itr.next();
758                 }
759 
760                 if (count == null) {
761                     count = new Long(0);
762                 }
763 
764                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
765                     finderClassName, finderMethodName, finderParams,
766                     finderArgs, count);
767 
768                 return count.intValue();
769             }
770             catch (Exception e) {
771                 throw processException(e);
772             }
773             finally {
774                 closeSession(session);
775             }
776         }
777         else {
778             return ((Long)result).intValue();
779         }
780     }
781 
782     public int countAll() throws SystemException {
783         boolean finderClassNameCacheEnabled = PasswordPolicyRelModelImpl.CACHE_ENABLED;
784         String finderClassName = PasswordPolicyRel.class.getName();
785         String finderMethodName = "countAll";
786         String[] finderParams = new String[] {  };
787         Object[] finderArgs = new Object[] {  };
788 
789         Object result = null;
790 
791         if (finderClassNameCacheEnabled) {
792             result = FinderCacheUtil.getResult(finderClassName,
793                     finderMethodName, finderParams, finderArgs, this);
794         }
795 
796         if (result == null) {
797             Session session = null;
798 
799             try {
800                 session = openSession();
801 
802                 Query q = session.createQuery(
803                         "SELECT COUNT(*) FROM com.liferay.portal.model.PasswordPolicyRel");
804 
805                 Long count = null;
806 
807                 Iterator<Long> itr = q.list().iterator();
808 
809                 if (itr.hasNext()) {
810                     count = itr.next();
811                 }
812 
813                 if (count == null) {
814                     count = new Long(0);
815                 }
816 
817                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
818                     finderClassName, finderMethodName, finderParams,
819                     finderArgs, count);
820 
821                 return count.intValue();
822             }
823             catch (Exception e) {
824                 throw processException(e);
825             }
826             finally {
827                 closeSession(session);
828             }
829         }
830         else {
831             return ((Long)result).intValue();
832         }
833     }
834 
835     public void afterPropertiesSet() {
836         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
837                     com.liferay.portal.util.PropsUtil.get(
838                         "value.object.listener.com.liferay.portal.model.PasswordPolicyRel")));
839 
840         if (listenerClassNames.length > 0) {
841             try {
842                 List<ModelListener> listenersList = new ArrayList<ModelListener>();
843 
844                 for (String listenerClassName : listenerClassNames) {
845                     listenersList.add((ModelListener)Class.forName(
846                             listenerClassName).newInstance());
847                 }
848 
849                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
850             }
851             catch (Exception e) {
852                 _log.error(e);
853             }
854         }
855     }
856 
857     @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
858     protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
859     @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
860     protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
861     @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
862     protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
863     @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
864     protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
865     @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
866     protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
867     @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
868     protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
869     @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
870     protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
871     @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
872     protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
873     @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
874     protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
875     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
876     protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
877     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
878     protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
879     @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
880     protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
881     @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
882     protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
883     @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
884     protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
885     @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
886     protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
887     @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
888     protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
889     @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
890     protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
891     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
892     protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
893     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
894     protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
895     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
896     protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
897     @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
898     protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
899     @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
900     protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
901     @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
902     protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
903     @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
904     protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
905     @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
906     protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
907     @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
908     protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
909     @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
910     protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
911     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
912     protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
913     @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
914     protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
915     @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
916     protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
917     @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
918     protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
919     @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
920     protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
921     @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
922     protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
923     @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
924     protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
925     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
926     protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
927     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
928     protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
929     @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
930     protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
931     @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
932     protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
933     @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
934     protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
935     @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
936     protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
937     @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
938     protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
939     private static Log _log = LogFactoryUtil.getLog(PasswordPolicyRelPersistenceImpl.class);
940 }