001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchPasswordPolicyRelException;
019    import com.liferay.portal.kernel.annotation.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.model.PasswordPolicyRel;
039    import com.liferay.portal.model.impl.PasswordPolicyRelImpl;
040    import com.liferay.portal.model.impl.PasswordPolicyRelModelImpl;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import java.io.Serializable;
044    
045    import java.util.ArrayList;
046    import java.util.Collections;
047    import java.util.List;
048    
049    /**
050     * The persistence for the password policy rel service.
051     *
052     * <p>
053     * Never modify this class directly. Modify <code>service.xml</code> and rerun ServiceBuilder to regnerate this class.
054     * </p>
055     *
056     * <p>
057     * Caching information and settings can be found in <code>portal.properties</code>
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see PasswordPolicyRelPersistence
062     * @see PasswordPolicyRelUtil
063     * @generated
064     */
065    public class PasswordPolicyRelPersistenceImpl extends BasePersistenceImpl<PasswordPolicyRel>
066            implements PasswordPolicyRelPersistence {
067            public static final String FINDER_CLASS_NAME_ENTITY = PasswordPolicyRelImpl.class.getName();
068            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
069                    ".List";
070            public static final FinderPath FINDER_PATH_FIND_BY_PASSWORDPOLICYID = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
071                            PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
072                            FINDER_CLASS_NAME_LIST, "findByPasswordPolicyId",
073                            new String[] {
074                                    Long.class.getName(),
075                                    
076                            "java.lang.Integer", "java.lang.Integer",
077                                    "com.liferay.portal.kernel.util.OrderByComparator"
078                            });
079            public static final FinderPath FINDER_PATH_COUNT_BY_PASSWORDPOLICYID = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
080                            PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
081                            FINDER_CLASS_NAME_LIST, "countByPasswordPolicyId",
082                            new String[] { Long.class.getName() });
083            public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
084                            PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
085                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
086                            new String[] { Long.class.getName(), Long.class.getName() });
087            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
088                            PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
089                            FINDER_CLASS_NAME_LIST, "countByC_C",
090                            new String[] { Long.class.getName(), Long.class.getName() });
091            public static final FinderPath FINDER_PATH_FETCH_BY_P_C_C = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
092                            PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
093                            FINDER_CLASS_NAME_ENTITY, "fetchByP_C_C",
094                            new String[] {
095                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
096                            });
097            public static final FinderPath FINDER_PATH_COUNT_BY_P_C_C = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
098                            PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
099                            FINDER_CLASS_NAME_LIST, "countByP_C_C",
100                            new String[] {
101                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
102                            });
103            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
104                            PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
105                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
106            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
107                            PasswordPolicyRelModelImpl.FINDER_CACHE_ENABLED,
108                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
109    
110            /**
111             * Caches the password policy rel in the entity cache if it is enabled.
112             *
113             * @param passwordPolicyRel the password policy rel to cache
114             */
115            public void cacheResult(PasswordPolicyRel passwordPolicyRel) {
116                    EntityCacheUtil.putResult(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
117                            PasswordPolicyRelImpl.class, passwordPolicyRel.getPrimaryKey(),
118                            passwordPolicyRel);
119    
120                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
121                            new Object[] {
122                                    new Long(passwordPolicyRel.getClassNameId()),
123                                    new Long(passwordPolicyRel.getClassPK())
124                            }, passwordPolicyRel);
125    
126                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_C_C,
127                            new Object[] {
128                                    new Long(passwordPolicyRel.getPasswordPolicyId()),
129                                    new Long(passwordPolicyRel.getClassNameId()),
130                                    new Long(passwordPolicyRel.getClassPK())
131                            }, passwordPolicyRel);
132            }
133    
134            /**
135             * Caches the password policy rels in the entity cache if it is enabled.
136             *
137             * @param passwordPolicyRels the password policy rels to cache
138             */
139            public void cacheResult(List<PasswordPolicyRel> passwordPolicyRels) {
140                    for (PasswordPolicyRel passwordPolicyRel : passwordPolicyRels) {
141                            if (EntityCacheUtil.getResult(
142                                                    PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
143                                                    PasswordPolicyRelImpl.class,
144                                                    passwordPolicyRel.getPrimaryKey(), this) == null) {
145                                    cacheResult(passwordPolicyRel);
146                            }
147                    }
148            }
149    
150            /**
151             * Clears the cache for all password policy rels.
152             *
153             * <p>
154             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
155             * </p>
156             */
157            public void clearCache() {
158                    CacheRegistryUtil.clear(PasswordPolicyRelImpl.class.getName());
159                    EntityCacheUtil.clearCache(PasswordPolicyRelImpl.class.getName());
160                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
161                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
162            }
163    
164            /**
165             * Clears the cache for the password policy rel.
166             *
167             * <p>
168             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
169             * </p>
170             */
171            public void clearCache(PasswordPolicyRel passwordPolicyRel) {
172                    EntityCacheUtil.removeResult(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
173                            PasswordPolicyRelImpl.class, passwordPolicyRel.getPrimaryKey());
174    
175                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
176                            new Object[] {
177                                    new Long(passwordPolicyRel.getClassNameId()),
178                                    new Long(passwordPolicyRel.getClassPK())
179                            });
180    
181                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_C_C,
182                            new Object[] {
183                                    new Long(passwordPolicyRel.getPasswordPolicyId()),
184                                    new Long(passwordPolicyRel.getClassNameId()),
185                                    new Long(passwordPolicyRel.getClassPK())
186                            });
187            }
188    
189            /**
190             * Creates a new password policy rel with the primary key.
191             *
192             * @param passwordPolicyRelId the primary key for the new password policy rel
193             * @return the new password policy rel
194             */
195            public PasswordPolicyRel create(long passwordPolicyRelId) {
196                    PasswordPolicyRel passwordPolicyRel = new PasswordPolicyRelImpl();
197    
198                    passwordPolicyRel.setNew(true);
199                    passwordPolicyRel.setPrimaryKey(passwordPolicyRelId);
200    
201                    return passwordPolicyRel;
202            }
203    
204            /**
205             * Removes the password policy rel with the primary key from the database. Also notifies the appropriate model listeners.
206             *
207             * @param primaryKey the primary key of the password policy rel to remove
208             * @return the password policy rel that was removed
209             * @throws com.liferay.portal.NoSuchModelException if a password policy rel with the primary key could not be found
210             * @throws SystemException if a system exception occurred
211             */
212            public PasswordPolicyRel remove(Serializable primaryKey)
213                    throws NoSuchModelException, SystemException {
214                    return remove(((Long)primaryKey).longValue());
215            }
216    
217            /**
218             * Removes the password policy rel with the primary key from the database. Also notifies the appropriate model listeners.
219             *
220             * @param passwordPolicyRelId the primary key of the password policy rel to remove
221             * @return the password policy rel that was removed
222             * @throws com.liferay.portal.NoSuchPasswordPolicyRelException if a password policy rel with the primary key could not be found
223             * @throws SystemException if a system exception occurred
224             */
225            public PasswordPolicyRel remove(long passwordPolicyRelId)
226                    throws NoSuchPasswordPolicyRelException, SystemException {
227                    Session session = null;
228    
229                    try {
230                            session = openSession();
231    
232                            PasswordPolicyRel passwordPolicyRel = (PasswordPolicyRel)session.get(PasswordPolicyRelImpl.class,
233                                            new Long(passwordPolicyRelId));
234    
235                            if (passwordPolicyRel == null) {
236                                    if (_log.isWarnEnabled()) {
237                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
238                                                    passwordPolicyRelId);
239                                    }
240    
241                                    throw new NoSuchPasswordPolicyRelException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
242                                            passwordPolicyRelId);
243                            }
244    
245                            return remove(passwordPolicyRel);
246                    }
247                    catch (NoSuchPasswordPolicyRelException nsee) {
248                            throw nsee;
249                    }
250                    catch (Exception e) {
251                            throw processException(e);
252                    }
253                    finally {
254                            closeSession(session);
255                    }
256            }
257    
258            protected PasswordPolicyRel removeImpl(PasswordPolicyRel passwordPolicyRel)
259                    throws SystemException {
260                    passwordPolicyRel = toUnwrappedModel(passwordPolicyRel);
261    
262                    Session session = null;
263    
264                    try {
265                            session = openSession();
266    
267                            if (passwordPolicyRel.isCachedModel() ||
268                                            BatchSessionUtil.isEnabled()) {
269                                    Object staleObject = session.get(PasswordPolicyRelImpl.class,
270                                                    passwordPolicyRel.getPrimaryKeyObj());
271    
272                                    if (staleObject != null) {
273                                            session.evict(staleObject);
274                                    }
275                            }
276    
277                            session.delete(passwordPolicyRel);
278    
279                            session.flush();
280                    }
281                    catch (Exception e) {
282                            throw processException(e);
283                    }
284                    finally {
285                            closeSession(session);
286                    }
287    
288                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
289    
290                    PasswordPolicyRelModelImpl passwordPolicyRelModelImpl = (PasswordPolicyRelModelImpl)passwordPolicyRel;
291    
292                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
293                            new Object[] {
294                                    new Long(passwordPolicyRelModelImpl.getOriginalClassNameId()),
295                                    new Long(passwordPolicyRelModelImpl.getOriginalClassPK())
296                            });
297    
298                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_C_C,
299                            new Object[] {
300                                    new Long(passwordPolicyRelModelImpl.getOriginalPasswordPolicyId()),
301                                    new Long(passwordPolicyRelModelImpl.getOriginalClassNameId()),
302                                    new Long(passwordPolicyRelModelImpl.getOriginalClassPK())
303                            });
304    
305                    EntityCacheUtil.removeResult(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
306                            PasswordPolicyRelImpl.class, passwordPolicyRel.getPrimaryKey());
307    
308                    return passwordPolicyRel;
309            }
310    
311            public PasswordPolicyRel updateImpl(
312                    com.liferay.portal.model.PasswordPolicyRel passwordPolicyRel,
313                    boolean merge) throws SystemException {
314                    passwordPolicyRel = toUnwrappedModel(passwordPolicyRel);
315    
316                    boolean isNew = passwordPolicyRel.isNew();
317    
318                    PasswordPolicyRelModelImpl passwordPolicyRelModelImpl = (PasswordPolicyRelModelImpl)passwordPolicyRel;
319    
320                    Session session = null;
321    
322                    try {
323                            session = openSession();
324    
325                            BatchSessionUtil.update(session, passwordPolicyRel, merge);
326    
327                            passwordPolicyRel.setNew(false);
328                    }
329                    catch (Exception e) {
330                            throw processException(e);
331                    }
332                    finally {
333                            closeSession(session);
334                    }
335    
336                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
337    
338                    EntityCacheUtil.putResult(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
339                            PasswordPolicyRelImpl.class, passwordPolicyRel.getPrimaryKey(),
340                            passwordPolicyRel);
341    
342                    if (!isNew &&
343                                    ((passwordPolicyRel.getClassNameId() != passwordPolicyRelModelImpl.getOriginalClassNameId()) ||
344                                    (passwordPolicyRel.getClassPK() != passwordPolicyRelModelImpl.getOriginalClassPK()))) {
345                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
346                                    new Object[] {
347                                            new Long(passwordPolicyRelModelImpl.getOriginalClassNameId()),
348                                            new Long(passwordPolicyRelModelImpl.getOriginalClassPK())
349                                    });
350                    }
351    
352                    if (isNew ||
353                                    ((passwordPolicyRel.getClassNameId() != passwordPolicyRelModelImpl.getOriginalClassNameId()) ||
354                                    (passwordPolicyRel.getClassPK() != passwordPolicyRelModelImpl.getOriginalClassPK()))) {
355                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
356                                    new Object[] {
357                                            new Long(passwordPolicyRel.getClassNameId()),
358                                            new Long(passwordPolicyRel.getClassPK())
359                                    }, passwordPolicyRel);
360                    }
361    
362                    if (!isNew &&
363                                    ((passwordPolicyRel.getPasswordPolicyId() != passwordPolicyRelModelImpl.getOriginalPasswordPolicyId()) ||
364                                    (passwordPolicyRel.getClassNameId() != passwordPolicyRelModelImpl.getOriginalClassNameId()) ||
365                                    (passwordPolicyRel.getClassPK() != passwordPolicyRelModelImpl.getOriginalClassPK()))) {
366                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_C_C,
367                                    new Object[] {
368                                            new Long(passwordPolicyRelModelImpl.getOriginalPasswordPolicyId()),
369                                            new Long(passwordPolicyRelModelImpl.getOriginalClassNameId()),
370                                            new Long(passwordPolicyRelModelImpl.getOriginalClassPK())
371                                    });
372                    }
373    
374                    if (isNew ||
375                                    ((passwordPolicyRel.getPasswordPolicyId() != passwordPolicyRelModelImpl.getOriginalPasswordPolicyId()) ||
376                                    (passwordPolicyRel.getClassNameId() != passwordPolicyRelModelImpl.getOriginalClassNameId()) ||
377                                    (passwordPolicyRel.getClassPK() != passwordPolicyRelModelImpl.getOriginalClassPK()))) {
378                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_C_C,
379                                    new Object[] {
380                                            new Long(passwordPolicyRel.getPasswordPolicyId()),
381                                            new Long(passwordPolicyRel.getClassNameId()),
382                                            new Long(passwordPolicyRel.getClassPK())
383                                    }, passwordPolicyRel);
384                    }
385    
386                    return passwordPolicyRel;
387            }
388    
389            protected PasswordPolicyRel toUnwrappedModel(
390                    PasswordPolicyRel passwordPolicyRel) {
391                    if (passwordPolicyRel instanceof PasswordPolicyRelImpl) {
392                            return passwordPolicyRel;
393                    }
394    
395                    PasswordPolicyRelImpl passwordPolicyRelImpl = new PasswordPolicyRelImpl();
396    
397                    passwordPolicyRelImpl.setNew(passwordPolicyRel.isNew());
398                    passwordPolicyRelImpl.setPrimaryKey(passwordPolicyRel.getPrimaryKey());
399    
400                    passwordPolicyRelImpl.setPasswordPolicyRelId(passwordPolicyRel.getPasswordPolicyRelId());
401                    passwordPolicyRelImpl.setPasswordPolicyId(passwordPolicyRel.getPasswordPolicyId());
402                    passwordPolicyRelImpl.setClassNameId(passwordPolicyRel.getClassNameId());
403                    passwordPolicyRelImpl.setClassPK(passwordPolicyRel.getClassPK());
404    
405                    return passwordPolicyRelImpl;
406            }
407    
408            /**
409             * Finds the password policy rel with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
410             *
411             * @param primaryKey the primary key of the password policy rel to find
412             * @return the password policy rel
413             * @throws com.liferay.portal.NoSuchModelException if a password policy rel with the primary key could not be found
414             * @throws SystemException if a system exception occurred
415             */
416            public PasswordPolicyRel findByPrimaryKey(Serializable primaryKey)
417                    throws NoSuchModelException, SystemException {
418                    return findByPrimaryKey(((Long)primaryKey).longValue());
419            }
420    
421            /**
422             * Finds the password policy rel with the primary key or throws a {@link com.liferay.portal.NoSuchPasswordPolicyRelException} if it could not be found.
423             *
424             * @param passwordPolicyRelId the primary key of the password policy rel to find
425             * @return the password policy rel
426             * @throws com.liferay.portal.NoSuchPasswordPolicyRelException if a password policy rel with the primary key could not be found
427             * @throws SystemException if a system exception occurred
428             */
429            public PasswordPolicyRel findByPrimaryKey(long passwordPolicyRelId)
430                    throws NoSuchPasswordPolicyRelException, SystemException {
431                    PasswordPolicyRel passwordPolicyRel = fetchByPrimaryKey(passwordPolicyRelId);
432    
433                    if (passwordPolicyRel == null) {
434                            if (_log.isWarnEnabled()) {
435                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
436                                            passwordPolicyRelId);
437                            }
438    
439                            throw new NoSuchPasswordPolicyRelException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
440                                    passwordPolicyRelId);
441                    }
442    
443                    return passwordPolicyRel;
444            }
445    
446            /**
447             * Finds the password policy rel with the primary key or returns <code>null</code> if it could not be found.
448             *
449             * @param primaryKey the primary key of the password policy rel to find
450             * @return the password policy rel, or <code>null</code> if a password policy rel with the primary key could not be found
451             * @throws SystemException if a system exception occurred
452             */
453            public PasswordPolicyRel fetchByPrimaryKey(Serializable primaryKey)
454                    throws SystemException {
455                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
456            }
457    
458            /**
459             * Finds the password policy rel with the primary key or returns <code>null</code> if it could not be found.
460             *
461             * @param passwordPolicyRelId the primary key of the password policy rel to find
462             * @return the password policy rel, or <code>null</code> if a password policy rel with the primary key could not be found
463             * @throws SystemException if a system exception occurred
464             */
465            public PasswordPolicyRel fetchByPrimaryKey(long passwordPolicyRelId)
466                    throws SystemException {
467                    PasswordPolicyRel passwordPolicyRel = (PasswordPolicyRel)EntityCacheUtil.getResult(PasswordPolicyRelModelImpl.ENTITY_CACHE_ENABLED,
468                                    PasswordPolicyRelImpl.class, passwordPolicyRelId, this);
469    
470                    if (passwordPolicyRel == null) {
471                            Session session = null;
472    
473                            try {
474                                    session = openSession();
475    
476                                    passwordPolicyRel = (PasswordPolicyRel)session.get(PasswordPolicyRelImpl.class,
477                                                    new Long(passwordPolicyRelId));
478                            }
479                            catch (Exception e) {
480                                    throw processException(e);
481                            }
482                            finally {
483                                    if (passwordPolicyRel != null) {
484                                            cacheResult(passwordPolicyRel);
485                                    }
486    
487                                    closeSession(session);
488                            }
489                    }
490    
491                    return passwordPolicyRel;
492            }
493    
494            /**
495             * Finds all the password policy rels where passwordPolicyId = &#63;.
496             *
497             * @param passwordPolicyId the password policy id to search with
498             * @return the matching password policy rels
499             * @throws SystemException if a system exception occurred
500             */
501            public List<PasswordPolicyRel> findByPasswordPolicyId(long passwordPolicyId)
502                    throws SystemException {
503                    return findByPasswordPolicyId(passwordPolicyId, QueryUtil.ALL_POS,
504                            QueryUtil.ALL_POS, null);
505            }
506    
507            /**
508             * Finds a range of all the password policy rels where passwordPolicyId = &#63;.
509             *
510             * <p>
511             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
512             * </p>
513             *
514             * @param passwordPolicyId the password policy id to search with
515             * @param start the lower bound of the range of password policy rels to return
516             * @param end the upper bound of the range of password policy rels to return (not inclusive)
517             * @return the range of matching password policy rels
518             * @throws SystemException if a system exception occurred
519             */
520            public List<PasswordPolicyRel> findByPasswordPolicyId(
521                    long passwordPolicyId, int start, int end) throws SystemException {
522                    return findByPasswordPolicyId(passwordPolicyId, start, end, null);
523            }
524    
525            /**
526             * Finds an ordered range of all the password policy rels where passwordPolicyId = &#63;.
527             *
528             * <p>
529             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
530             * </p>
531             *
532             * @param passwordPolicyId the password policy id to search with
533             * @param start the lower bound of the range of password policy rels to return
534             * @param end the upper bound of the range of password policy rels to return (not inclusive)
535             * @param orderByComparator the comparator to order the results by
536             * @return the ordered range of matching password policy rels
537             * @throws SystemException if a system exception occurred
538             */
539            public List<PasswordPolicyRel> findByPasswordPolicyId(
540                    long passwordPolicyId, int start, int end,
541                    OrderByComparator orderByComparator) throws SystemException {
542                    Object[] finderArgs = new Object[] {
543                                    passwordPolicyId,
544                                    
545                                    String.valueOf(start), String.valueOf(end),
546                                    String.valueOf(orderByComparator)
547                            };
548    
549                    List<PasswordPolicyRel> list = (List<PasswordPolicyRel>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_PASSWORDPOLICYID,
550                                    finderArgs, this);
551    
552                    if (list == null) {
553                            Session session = null;
554    
555                            try {
556                                    session = openSession();
557    
558                                    StringBundler query = null;
559    
560                                    if (orderByComparator != null) {
561                                            query = new StringBundler(3 +
562                                                            (orderByComparator.getOrderByFields().length * 3));
563                                    }
564                                    else {
565                                            query = new StringBundler(2);
566                                    }
567    
568                                    query.append(_SQL_SELECT_PASSWORDPOLICYREL_WHERE);
569    
570                                    query.append(_FINDER_COLUMN_PASSWORDPOLICYID_PASSWORDPOLICYID_2);
571    
572                                    if (orderByComparator != null) {
573                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
574                                                    orderByComparator);
575                                    }
576    
577                                    String sql = query.toString();
578    
579                                    Query q = session.createQuery(sql);
580    
581                                    QueryPos qPos = QueryPos.getInstance(q);
582    
583                                    qPos.add(passwordPolicyId);
584    
585                                    list = (List<PasswordPolicyRel>)QueryUtil.list(q, getDialect(),
586                                                    start, end);
587                            }
588                            catch (Exception e) {
589                                    throw processException(e);
590                            }
591                            finally {
592                                    if (list == null) {
593                                            list = new ArrayList<PasswordPolicyRel>();
594                                    }
595    
596                                    cacheResult(list);
597    
598                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PASSWORDPOLICYID,
599                                            finderArgs, list);
600    
601                                    closeSession(session);
602                            }
603                    }
604    
605                    return list;
606            }
607    
608            /**
609             * Finds the first password policy rel in the ordered set where passwordPolicyId = &#63;.
610             *
611             * <p>
612             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
613             * </p>
614             *
615             * @param passwordPolicyId the password policy id to search with
616             * @param orderByComparator the comparator to order the set by
617             * @return the first matching password policy rel
618             * @throws com.liferay.portal.NoSuchPasswordPolicyRelException if a matching password policy rel could not be found
619             * @throws SystemException if a system exception occurred
620             */
621            public PasswordPolicyRel findByPasswordPolicyId_First(
622                    long passwordPolicyId, OrderByComparator orderByComparator)
623                    throws NoSuchPasswordPolicyRelException, SystemException {
624                    List<PasswordPolicyRel> list = findByPasswordPolicyId(passwordPolicyId,
625                                    0, 1, orderByComparator);
626    
627                    if (list.isEmpty()) {
628                            StringBundler msg = new StringBundler(4);
629    
630                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
631    
632                            msg.append("passwordPolicyId=");
633                            msg.append(passwordPolicyId);
634    
635                            msg.append(StringPool.CLOSE_CURLY_BRACE);
636    
637                            throw new NoSuchPasswordPolicyRelException(msg.toString());
638                    }
639                    else {
640                            return list.get(0);
641                    }
642            }
643    
644            /**
645             * Finds the last password policy rel in the ordered set where passwordPolicyId = &#63;.
646             *
647             * <p>
648             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
649             * </p>
650             *
651             * @param passwordPolicyId the password policy id to search with
652             * @param orderByComparator the comparator to order the set by
653             * @return the last matching password policy rel
654             * @throws com.liferay.portal.NoSuchPasswordPolicyRelException if a matching password policy rel could not be found
655             * @throws SystemException if a system exception occurred
656             */
657            public PasswordPolicyRel findByPasswordPolicyId_Last(
658                    long passwordPolicyId, OrderByComparator orderByComparator)
659                    throws NoSuchPasswordPolicyRelException, SystemException {
660                    int count = countByPasswordPolicyId(passwordPolicyId);
661    
662                    List<PasswordPolicyRel> list = findByPasswordPolicyId(passwordPolicyId,
663                                    count - 1, count, orderByComparator);
664    
665                    if (list.isEmpty()) {
666                            StringBundler msg = new StringBundler(4);
667    
668                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
669    
670                            msg.append("passwordPolicyId=");
671                            msg.append(passwordPolicyId);
672    
673                            msg.append(StringPool.CLOSE_CURLY_BRACE);
674    
675                            throw new NoSuchPasswordPolicyRelException(msg.toString());
676                    }
677                    else {
678                            return list.get(0);
679                    }
680            }
681    
682            /**
683             * Finds the password policy rels before and after the current password policy rel in the ordered set where passwordPolicyId = &#63;.
684             *
685             * <p>
686             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
687             * </p>
688             *
689             * @param passwordPolicyRelId the primary key of the current password policy rel
690             * @param passwordPolicyId the password policy id to search with
691             * @param orderByComparator the comparator to order the set by
692             * @return the previous, current, and next password policy rel
693             * @throws com.liferay.portal.NoSuchPasswordPolicyRelException if a password policy rel with the primary key could not be found
694             * @throws SystemException if a system exception occurred
695             */
696            public PasswordPolicyRel[] findByPasswordPolicyId_PrevAndNext(
697                    long passwordPolicyRelId, long passwordPolicyId,
698                    OrderByComparator orderByComparator)
699                    throws NoSuchPasswordPolicyRelException, SystemException {
700                    PasswordPolicyRel passwordPolicyRel = findByPrimaryKey(passwordPolicyRelId);
701    
702                    Session session = null;
703    
704                    try {
705                            session = openSession();
706    
707                            PasswordPolicyRel[] array = new PasswordPolicyRelImpl[3];
708    
709                            array[0] = getByPasswordPolicyId_PrevAndNext(session,
710                                            passwordPolicyRel, passwordPolicyId, orderByComparator, true);
711    
712                            array[1] = passwordPolicyRel;
713    
714                            array[2] = getByPasswordPolicyId_PrevAndNext(session,
715                                            passwordPolicyRel, passwordPolicyId, orderByComparator,
716                                            false);
717    
718                            return array;
719                    }
720                    catch (Exception e) {
721                            throw processException(e);
722                    }
723                    finally {
724                            closeSession(session);
725                    }
726            }
727    
728            protected PasswordPolicyRel getByPasswordPolicyId_PrevAndNext(
729                    Session session, PasswordPolicyRel passwordPolicyRel,
730                    long passwordPolicyId, OrderByComparator orderByComparator,
731                    boolean previous) {
732                    StringBundler query = null;
733    
734                    if (orderByComparator != null) {
735                            query = new StringBundler(6 +
736                                            (orderByComparator.getOrderByFields().length * 6));
737                    }
738                    else {
739                            query = new StringBundler(3);
740                    }
741    
742                    query.append(_SQL_SELECT_PASSWORDPOLICYREL_WHERE);
743    
744                    query.append(_FINDER_COLUMN_PASSWORDPOLICYID_PASSWORDPOLICYID_2);
745    
746                    if (orderByComparator != null) {
747                            String[] orderByFields = orderByComparator.getOrderByFields();
748    
749                            if (orderByFields.length > 0) {
750                                    query.append(WHERE_AND);
751                            }
752    
753                            for (int i = 0; i < orderByFields.length; i++) {
754                                    query.append(_ORDER_BY_ENTITY_ALIAS);
755                                    query.append(orderByFields[i]);
756    
757                                    if ((i + 1) < orderByFields.length) {
758                                            if (orderByComparator.isAscending() ^ previous) {
759                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
760                                            }
761                                            else {
762                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
763                                            }
764                                    }
765                                    else {
766                                            if (orderByComparator.isAscending() ^ previous) {
767                                                    query.append(WHERE_GREATER_THAN);
768                                            }
769                                            else {
770                                                    query.append(WHERE_LESSER_THAN);
771                                            }
772                                    }
773                            }
774    
775                            query.append(ORDER_BY_CLAUSE);
776    
777                            for (int i = 0; i < orderByFields.length; i++) {
778                                    query.append(_ORDER_BY_ENTITY_ALIAS);
779                                    query.append(orderByFields[i]);
780    
781                                    if ((i + 1) < orderByFields.length) {
782                                            if (orderByComparator.isAscending() ^ previous) {
783                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
784                                            }
785                                            else {
786                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
787                                            }
788                                    }
789                                    else {
790                                            if (orderByComparator.isAscending() ^ previous) {
791                                                    query.append(ORDER_BY_ASC);
792                                            }
793                                            else {
794                                                    query.append(ORDER_BY_DESC);
795                                            }
796                                    }
797                            }
798                    }
799    
800                    String sql = query.toString();
801    
802                    Query q = session.createQuery(sql);
803    
804                    q.setFirstResult(0);
805                    q.setMaxResults(2);
806    
807                    QueryPos qPos = QueryPos.getInstance(q);
808    
809                    qPos.add(passwordPolicyId);
810    
811                    if (orderByComparator != null) {
812                            Object[] values = orderByComparator.getOrderByValues(passwordPolicyRel);
813    
814                            for (Object value : values) {
815                                    qPos.add(value);
816                            }
817                    }
818    
819                    List<PasswordPolicyRel> list = q.list();
820    
821                    if (list.size() == 2) {
822                            return list.get(1);
823                    }
824                    else {
825                            return null;
826                    }
827            }
828    
829            /**
830             * Finds the password policy rel where classNameId = &#63; and classPK = &#63; or throws a {@link com.liferay.portal.NoSuchPasswordPolicyRelException} if it could not be found.
831             *
832             * @param classNameId the class name id to search with
833             * @param classPK the class p k to search with
834             * @return the matching password policy rel
835             * @throws com.liferay.portal.NoSuchPasswordPolicyRelException if a matching password policy rel could not be found
836             * @throws SystemException if a system exception occurred
837             */
838            public PasswordPolicyRel findByC_C(long classNameId, long classPK)
839                    throws NoSuchPasswordPolicyRelException, SystemException {
840                    PasswordPolicyRel passwordPolicyRel = fetchByC_C(classNameId, classPK);
841    
842                    if (passwordPolicyRel == null) {
843                            StringBundler msg = new StringBundler(6);
844    
845                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
846    
847                            msg.append("classNameId=");
848                            msg.append(classNameId);
849    
850                            msg.append(", classPK=");
851                            msg.append(classPK);
852    
853                            msg.append(StringPool.CLOSE_CURLY_BRACE);
854    
855                            if (_log.isWarnEnabled()) {
856                                    _log.warn(msg.toString());
857                            }
858    
859                            throw new NoSuchPasswordPolicyRelException(msg.toString());
860                    }
861    
862                    return passwordPolicyRel;
863            }
864    
865            /**
866             * Finds the password policy rel where classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
867             *
868             * @param classNameId the class name id to search with
869             * @param classPK the class p k to search with
870             * @return the matching password policy rel, or <code>null</code> if a matching password policy rel could not be found
871             * @throws SystemException if a system exception occurred
872             */
873            public PasswordPolicyRel fetchByC_C(long classNameId, long classPK)
874                    throws SystemException {
875                    return fetchByC_C(classNameId, classPK, true);
876            }
877    
878            /**
879             * Finds the password policy rel where classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
880             *
881             * @param classNameId the class name id to search with
882             * @param classPK the class p k to search with
883             * @return the matching password policy rel, or <code>null</code> if a matching password policy rel could not be found
884             * @throws SystemException if a system exception occurred
885             */
886            public PasswordPolicyRel fetchByC_C(long classNameId, long classPK,
887                    boolean retrieveFromCache) throws SystemException {
888                    Object[] finderArgs = new Object[] { classNameId, classPK };
889    
890                    Object result = null;
891    
892                    if (retrieveFromCache) {
893                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
894                                            finderArgs, this);
895                    }
896    
897                    if (result == null) {
898                            Session session = null;
899    
900                            try {
901                                    session = openSession();
902    
903                                    StringBundler query = new StringBundler(3);
904    
905                                    query.append(_SQL_SELECT_PASSWORDPOLICYREL_WHERE);
906    
907                                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
908    
909                                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
910    
911                                    String sql = query.toString();
912    
913                                    Query q = session.createQuery(sql);
914    
915                                    QueryPos qPos = QueryPos.getInstance(q);
916    
917                                    qPos.add(classNameId);
918    
919                                    qPos.add(classPK);
920    
921                                    List<PasswordPolicyRel> list = q.list();
922    
923                                    result = list;
924    
925                                    PasswordPolicyRel passwordPolicyRel = null;
926    
927                                    if (list.isEmpty()) {
928                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
929                                                    finderArgs, list);
930                                    }
931                                    else {
932                                            passwordPolicyRel = list.get(0);
933    
934                                            cacheResult(passwordPolicyRel);
935    
936                                            if ((passwordPolicyRel.getClassNameId() != classNameId) ||
937                                                            (passwordPolicyRel.getClassPK() != classPK)) {
938                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
939                                                            finderArgs, passwordPolicyRel);
940                                            }
941                                    }
942    
943                                    return passwordPolicyRel;
944                            }
945                            catch (Exception e) {
946                                    throw processException(e);
947                            }
948                            finally {
949                                    if (result == null) {
950                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
951                                                    finderArgs, new ArrayList<PasswordPolicyRel>());
952                                    }
953    
954                                    closeSession(session);
955                            }
956                    }
957                    else {
958                            if (result instanceof List<?>) {
959                                    return null;
960                            }
961                            else {
962                                    return (PasswordPolicyRel)result;
963                            }
964                    }
965            }
966    
967            /**
968             * Finds the password policy rel where passwordPolicyId = &#63; and classNameId = &#63; and classPK = &#63; or throws a {@link com.liferay.portal.NoSuchPasswordPolicyRelException} if it could not be found.
969             *
970             * @param passwordPolicyId the password policy id to search with
971             * @param classNameId the class name id to search with
972             * @param classPK the class p k to search with
973             * @return the matching password policy rel
974             * @throws com.liferay.portal.NoSuchPasswordPolicyRelException if a matching password policy rel could not be found
975             * @throws SystemException if a system exception occurred
976             */
977            public PasswordPolicyRel findByP_C_C(long passwordPolicyId,
978                    long classNameId, long classPK)
979                    throws NoSuchPasswordPolicyRelException, SystemException {
980                    PasswordPolicyRel passwordPolicyRel = fetchByP_C_C(passwordPolicyId,
981                                    classNameId, classPK);
982    
983                    if (passwordPolicyRel == null) {
984                            StringBundler msg = new StringBundler(8);
985    
986                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
987    
988                            msg.append("passwordPolicyId=");
989                            msg.append(passwordPolicyId);
990    
991                            msg.append(", classNameId=");
992                            msg.append(classNameId);
993    
994                            msg.append(", classPK=");
995                            msg.append(classPK);
996    
997                            msg.append(StringPool.CLOSE_CURLY_BRACE);
998    
999                            if (_log.isWarnEnabled()) {
1000                                    _log.warn(msg.toString());
1001                            }
1002    
1003                            throw new NoSuchPasswordPolicyRelException(msg.toString());
1004                    }
1005    
1006                    return passwordPolicyRel;
1007            }
1008    
1009            /**
1010             * Finds the password policy rel where passwordPolicyId = &#63; and classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1011             *
1012             * @param passwordPolicyId the password policy id to search with
1013             * @param classNameId the class name id to search with
1014             * @param classPK the class p k to search with
1015             * @return the matching password policy rel, or <code>null</code> if a matching password policy rel could not be found
1016             * @throws SystemException if a system exception occurred
1017             */
1018            public PasswordPolicyRel fetchByP_C_C(long passwordPolicyId,
1019                    long classNameId, long classPK) throws SystemException {
1020                    return fetchByP_C_C(passwordPolicyId, classNameId, classPK, true);
1021            }
1022    
1023            /**
1024             * Finds the password policy rel where passwordPolicyId = &#63; and classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1025             *
1026             * @param passwordPolicyId the password policy id to search with
1027             * @param classNameId the class name id to search with
1028             * @param classPK the class p k to search with
1029             * @return the matching password policy rel, or <code>null</code> if a matching password policy rel could not be found
1030             * @throws SystemException if a system exception occurred
1031             */
1032            public PasswordPolicyRel fetchByP_C_C(long passwordPolicyId,
1033                    long classNameId, long classPK, boolean retrieveFromCache)
1034                    throws SystemException {
1035                    Object[] finderArgs = new Object[] {
1036                                    passwordPolicyId, classNameId, classPK
1037                            };
1038    
1039                    Object result = null;
1040    
1041                    if (retrieveFromCache) {
1042                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_C_C,
1043                                            finderArgs, this);
1044                    }
1045    
1046                    if (result == null) {
1047                            Session session = null;
1048    
1049                            try {
1050                                    session = openSession();
1051    
1052                                    StringBundler query = new StringBundler(4);
1053    
1054                                    query.append(_SQL_SELECT_PASSWORDPOLICYREL_WHERE);
1055    
1056                                    query.append(_FINDER_COLUMN_P_C_C_PASSWORDPOLICYID_2);
1057    
1058                                    query.append(_FINDER_COLUMN_P_C_C_CLASSNAMEID_2);
1059    
1060                                    query.append(_FINDER_COLUMN_P_C_C_CLASSPK_2);
1061    
1062                                    String sql = query.toString();
1063    
1064                                    Query q = session.createQuery(sql);
1065    
1066                                    QueryPos qPos = QueryPos.getInstance(q);
1067    
1068                                    qPos.add(passwordPolicyId);
1069    
1070                                    qPos.add(classNameId);
1071    
1072                                    qPos.add(classPK);
1073    
1074                                    List<PasswordPolicyRel> list = q.list();
1075    
1076                                    result = list;
1077    
1078                                    PasswordPolicyRel passwordPolicyRel = null;
1079    
1080                                    if (list.isEmpty()) {
1081                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_C_C,
1082                                                    finderArgs, list);
1083                                    }
1084                                    else {
1085                                            passwordPolicyRel = list.get(0);
1086    
1087                                            cacheResult(passwordPolicyRel);
1088    
1089                                            if ((passwordPolicyRel.getPasswordPolicyId() != passwordPolicyId) ||
1090                                                            (passwordPolicyRel.getClassNameId() != classNameId) ||
1091                                                            (passwordPolicyRel.getClassPK() != classPK)) {
1092                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_C_C,
1093                                                            finderArgs, passwordPolicyRel);
1094                                            }
1095                                    }
1096    
1097                                    return passwordPolicyRel;
1098                            }
1099                            catch (Exception e) {
1100                                    throw processException(e);
1101                            }
1102                            finally {
1103                                    if (result == null) {
1104                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_C_C,
1105                                                    finderArgs, new ArrayList<PasswordPolicyRel>());
1106                                    }
1107    
1108                                    closeSession(session);
1109                            }
1110                    }
1111                    else {
1112                            if (result instanceof List<?>) {
1113                                    return null;
1114                            }
1115                            else {
1116                                    return (PasswordPolicyRel)result;
1117                            }
1118                    }
1119            }
1120    
1121            /**
1122             * Finds all the password policy rels.
1123             *
1124             * @return the password policy rels
1125             * @throws SystemException if a system exception occurred
1126             */
1127            public List<PasswordPolicyRel> findAll() throws SystemException {
1128                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1129            }
1130    
1131            /**
1132             * Finds a range of all the password policy rels.
1133             *
1134             * <p>
1135             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1136             * </p>
1137             *
1138             * @param start the lower bound of the range of password policy rels to return
1139             * @param end the upper bound of the range of password policy rels to return (not inclusive)
1140             * @return the range of password policy rels
1141             * @throws SystemException if a system exception occurred
1142             */
1143            public List<PasswordPolicyRel> findAll(int start, int end)
1144                    throws SystemException {
1145                    return findAll(start, end, null);
1146            }
1147    
1148            /**
1149             * Finds an ordered range of all the password policy rels.
1150             *
1151             * <p>
1152             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1153             * </p>
1154             *
1155             * @param start the lower bound of the range of password policy rels to return
1156             * @param end the upper bound of the range of password policy rels to return (not inclusive)
1157             * @param orderByComparator the comparator to order the results by
1158             * @return the ordered range of password policy rels
1159             * @throws SystemException if a system exception occurred
1160             */
1161            public List<PasswordPolicyRel> findAll(int start, int end,
1162                    OrderByComparator orderByComparator) throws SystemException {
1163                    Object[] finderArgs = new Object[] {
1164                                    String.valueOf(start), String.valueOf(end),
1165                                    String.valueOf(orderByComparator)
1166                            };
1167    
1168                    List<PasswordPolicyRel> list = (List<PasswordPolicyRel>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1169                                    finderArgs, this);
1170    
1171                    if (list == null) {
1172                            Session session = null;
1173    
1174                            try {
1175                                    session = openSession();
1176    
1177                                    StringBundler query = null;
1178                                    String sql = null;
1179    
1180                                    if (orderByComparator != null) {
1181                                            query = new StringBundler(2 +
1182                                                            (orderByComparator.getOrderByFields().length * 3));
1183    
1184                                            query.append(_SQL_SELECT_PASSWORDPOLICYREL);
1185    
1186                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1187                                                    orderByComparator);
1188    
1189                                            sql = query.toString();
1190                                    }
1191                                    else {
1192                                            sql = _SQL_SELECT_PASSWORDPOLICYREL;
1193                                    }
1194    
1195                                    Query q = session.createQuery(sql);
1196    
1197                                    if (orderByComparator == null) {
1198                                            list = (List<PasswordPolicyRel>)QueryUtil.list(q,
1199                                                            getDialect(), start, end, false);
1200    
1201                                            Collections.sort(list);
1202                                    }
1203                                    else {
1204                                            list = (List<PasswordPolicyRel>)QueryUtil.list(q,
1205                                                            getDialect(), start, end);
1206                                    }
1207                            }
1208                            catch (Exception e) {
1209                                    throw processException(e);
1210                            }
1211                            finally {
1212                                    if (list == null) {
1213                                            list = new ArrayList<PasswordPolicyRel>();
1214                                    }
1215    
1216                                    cacheResult(list);
1217    
1218                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1219    
1220                                    closeSession(session);
1221                            }
1222                    }
1223    
1224                    return list;
1225            }
1226    
1227            /**
1228             * Removes all the password policy rels where passwordPolicyId = &#63; from the database.
1229             *
1230             * @param passwordPolicyId the password policy id to search with
1231             * @throws SystemException if a system exception occurred
1232             */
1233            public void removeByPasswordPolicyId(long passwordPolicyId)
1234                    throws SystemException {
1235                    for (PasswordPolicyRel passwordPolicyRel : findByPasswordPolicyId(
1236                                    passwordPolicyId)) {
1237                            remove(passwordPolicyRel);
1238                    }
1239            }
1240    
1241            /**
1242             * Removes the password policy rel where classNameId = &#63; and classPK = &#63; from the database.
1243             *
1244             * @param classNameId the class name id to search with
1245             * @param classPK the class p k to search with
1246             * @throws SystemException if a system exception occurred
1247             */
1248            public void removeByC_C(long classNameId, long classPK)
1249                    throws NoSuchPasswordPolicyRelException, SystemException {
1250                    PasswordPolicyRel passwordPolicyRel = findByC_C(classNameId, classPK);
1251    
1252                    remove(passwordPolicyRel);
1253            }
1254    
1255            /**
1256             * Removes the password policy rel where passwordPolicyId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
1257             *
1258             * @param passwordPolicyId the password policy id to search with
1259             * @param classNameId the class name id to search with
1260             * @param classPK the class p k to search with
1261             * @throws SystemException if a system exception occurred
1262             */
1263            public void removeByP_C_C(long passwordPolicyId, long classNameId,
1264                    long classPK) throws NoSuchPasswordPolicyRelException, SystemException {
1265                    PasswordPolicyRel passwordPolicyRel = findByP_C_C(passwordPolicyId,
1266                                    classNameId, classPK);
1267    
1268                    remove(passwordPolicyRel);
1269            }
1270    
1271            /**
1272             * Removes all the password policy rels from the database.
1273             *
1274             * @throws SystemException if a system exception occurred
1275             */
1276            public void removeAll() throws SystemException {
1277                    for (PasswordPolicyRel passwordPolicyRel : findAll()) {
1278                            remove(passwordPolicyRel);
1279                    }
1280            }
1281    
1282            /**
1283             * Counts all the password policy rels where passwordPolicyId = &#63;.
1284             *
1285             * @param passwordPolicyId the password policy id to search with
1286             * @return the number of matching password policy rels
1287             * @throws SystemException if a system exception occurred
1288             */
1289            public int countByPasswordPolicyId(long passwordPolicyId)
1290                    throws SystemException {
1291                    Object[] finderArgs = new Object[] { passwordPolicyId };
1292    
1293                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PASSWORDPOLICYID,
1294                                    finderArgs, this);
1295    
1296                    if (count == null) {
1297                            Session session = null;
1298    
1299                            try {
1300                                    session = openSession();
1301    
1302                                    StringBundler query = new StringBundler(2);
1303    
1304                                    query.append(_SQL_COUNT_PASSWORDPOLICYREL_WHERE);
1305    
1306                                    query.append(_FINDER_COLUMN_PASSWORDPOLICYID_PASSWORDPOLICYID_2);
1307    
1308                                    String sql = query.toString();
1309    
1310                                    Query q = session.createQuery(sql);
1311    
1312                                    QueryPos qPos = QueryPos.getInstance(q);
1313    
1314                                    qPos.add(passwordPolicyId);
1315    
1316                                    count = (Long)q.uniqueResult();
1317                            }
1318                            catch (Exception e) {
1319                                    throw processException(e);
1320                            }
1321                            finally {
1322                                    if (count == null) {
1323                                            count = Long.valueOf(0);
1324                                    }
1325    
1326                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PASSWORDPOLICYID,
1327                                            finderArgs, count);
1328    
1329                                    closeSession(session);
1330                            }
1331                    }
1332    
1333                    return count.intValue();
1334            }
1335    
1336            /**
1337             * Counts all the password policy rels where classNameId = &#63; and classPK = &#63;.
1338             *
1339             * @param classNameId the class name id to search with
1340             * @param classPK the class p k to search with
1341             * @return the number of matching password policy rels
1342             * @throws SystemException if a system exception occurred
1343             */
1344            public int countByC_C(long classNameId, long classPK)
1345                    throws SystemException {
1346                    Object[] finderArgs = new Object[] { classNameId, classPK };
1347    
1348                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
1349                                    finderArgs, this);
1350    
1351                    if (count == null) {
1352                            Session session = null;
1353    
1354                            try {
1355                                    session = openSession();
1356    
1357                                    StringBundler query = new StringBundler(3);
1358    
1359                                    query.append(_SQL_COUNT_PASSWORDPOLICYREL_WHERE);
1360    
1361                                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1362    
1363                                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1364    
1365                                    String sql = query.toString();
1366    
1367                                    Query q = session.createQuery(sql);
1368    
1369                                    QueryPos qPos = QueryPos.getInstance(q);
1370    
1371                                    qPos.add(classNameId);
1372    
1373                                    qPos.add(classPK);
1374    
1375                                    count = (Long)q.uniqueResult();
1376                            }
1377                            catch (Exception e) {
1378                                    throw processException(e);
1379                            }
1380                            finally {
1381                                    if (count == null) {
1382                                            count = Long.valueOf(0);
1383                                    }
1384    
1385                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
1386                                            count);
1387    
1388                                    closeSession(session);
1389                            }
1390                    }
1391    
1392                    return count.intValue();
1393            }
1394    
1395            /**
1396             * Counts all the password policy rels where passwordPolicyId = &#63; and classNameId = &#63; and classPK = &#63;.
1397             *
1398             * @param passwordPolicyId the password policy id to search with
1399             * @param classNameId the class name id to search with
1400             * @param classPK the class p k to search with
1401             * @return the number of matching password policy rels
1402             * @throws SystemException if a system exception occurred
1403             */
1404            public int countByP_C_C(long passwordPolicyId, long classNameId,
1405                    long classPK) throws SystemException {
1406                    Object[] finderArgs = new Object[] {
1407                                    passwordPolicyId, classNameId, classPK
1408                            };
1409    
1410                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_C_C,
1411                                    finderArgs, this);
1412    
1413                    if (count == null) {
1414                            Session session = null;
1415    
1416                            try {
1417                                    session = openSession();
1418    
1419                                    StringBundler query = new StringBundler(4);
1420    
1421                                    query.append(_SQL_COUNT_PASSWORDPOLICYREL_WHERE);
1422    
1423                                    query.append(_FINDER_COLUMN_P_C_C_PASSWORDPOLICYID_2);
1424    
1425                                    query.append(_FINDER_COLUMN_P_C_C_CLASSNAMEID_2);
1426    
1427                                    query.append(_FINDER_COLUMN_P_C_C_CLASSPK_2);
1428    
1429                                    String sql = query.toString();
1430    
1431                                    Query q = session.createQuery(sql);
1432    
1433                                    QueryPos qPos = QueryPos.getInstance(q);
1434    
1435                                    qPos.add(passwordPolicyId);
1436    
1437                                    qPos.add(classNameId);
1438    
1439                                    qPos.add(classPK);
1440    
1441                                    count = (Long)q.uniqueResult();
1442                            }
1443                            catch (Exception e) {
1444                                    throw processException(e);
1445                            }
1446                            finally {
1447                                    if (count == null) {
1448                                            count = Long.valueOf(0);
1449                                    }
1450    
1451                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_C_C,
1452                                            finderArgs, count);
1453    
1454                                    closeSession(session);
1455                            }
1456                    }
1457    
1458                    return count.intValue();
1459            }
1460    
1461            /**
1462             * Counts all the password policy rels.
1463             *
1464             * @return the number of password policy rels
1465             * @throws SystemException if a system exception occurred
1466             */
1467            public int countAll() throws SystemException {
1468                    Object[] finderArgs = new Object[0];
1469    
1470                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1471                                    finderArgs, this);
1472    
1473                    if (count == null) {
1474                            Session session = null;
1475    
1476                            try {
1477                                    session = openSession();
1478    
1479                                    Query q = session.createQuery(_SQL_COUNT_PASSWORDPOLICYREL);
1480    
1481                                    count = (Long)q.uniqueResult();
1482                            }
1483                            catch (Exception e) {
1484                                    throw processException(e);
1485                            }
1486                            finally {
1487                                    if (count == null) {
1488                                            count = Long.valueOf(0);
1489                                    }
1490    
1491                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1492                                            count);
1493    
1494                                    closeSession(session);
1495                            }
1496                    }
1497    
1498                    return count.intValue();
1499            }
1500    
1501            /**
1502             * Initializes the password policy rel persistence.
1503             */
1504            public void afterPropertiesSet() {
1505                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1506                                            com.liferay.portal.util.PropsUtil.get(
1507                                                    "value.object.listener.com.liferay.portal.model.PasswordPolicyRel")));
1508    
1509                    if (listenerClassNames.length > 0) {
1510                            try {
1511                                    List<ModelListener<PasswordPolicyRel>> listenersList = new ArrayList<ModelListener<PasswordPolicyRel>>();
1512    
1513                                    for (String listenerClassName : listenerClassNames) {
1514                                            listenersList.add((ModelListener<PasswordPolicyRel>)InstanceFactory.newInstance(
1515                                                            listenerClassName));
1516                                    }
1517    
1518                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1519                            }
1520                            catch (Exception e) {
1521                                    _log.error(e);
1522                            }
1523                    }
1524            }
1525    
1526            @BeanReference(type = AccountPersistence.class)
1527            protected AccountPersistence accountPersistence;
1528            @BeanReference(type = AddressPersistence.class)
1529            protected AddressPersistence addressPersistence;
1530            @BeanReference(type = BrowserTrackerPersistence.class)
1531            protected BrowserTrackerPersistence browserTrackerPersistence;
1532            @BeanReference(type = ClassNamePersistence.class)
1533            protected ClassNamePersistence classNamePersistence;
1534            @BeanReference(type = CompanyPersistence.class)
1535            protected CompanyPersistence companyPersistence;
1536            @BeanReference(type = ContactPersistence.class)
1537            protected ContactPersistence contactPersistence;
1538            @BeanReference(type = CountryPersistence.class)
1539            protected CountryPersistence countryPersistence;
1540            @BeanReference(type = EmailAddressPersistence.class)
1541            protected EmailAddressPersistence emailAddressPersistence;
1542            @BeanReference(type = GroupPersistence.class)
1543            protected GroupPersistence groupPersistence;
1544            @BeanReference(type = ImagePersistence.class)
1545            protected ImagePersistence imagePersistence;
1546            @BeanReference(type = LayoutPersistence.class)
1547            protected LayoutPersistence layoutPersistence;
1548            @BeanReference(type = LayoutPrototypePersistence.class)
1549            protected LayoutPrototypePersistence layoutPrototypePersistence;
1550            @BeanReference(type = LayoutSetPersistence.class)
1551            protected LayoutSetPersistence layoutSetPersistence;
1552            @BeanReference(type = LayoutSetPrototypePersistence.class)
1553            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1554            @BeanReference(type = ListTypePersistence.class)
1555            protected ListTypePersistence listTypePersistence;
1556            @BeanReference(type = LockPersistence.class)
1557            protected LockPersistence lockPersistence;
1558            @BeanReference(type = MembershipRequestPersistence.class)
1559            protected MembershipRequestPersistence membershipRequestPersistence;
1560            @BeanReference(type = OrganizationPersistence.class)
1561            protected OrganizationPersistence organizationPersistence;
1562            @BeanReference(type = OrgGroupPermissionPersistence.class)
1563            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1564            @BeanReference(type = OrgGroupRolePersistence.class)
1565            protected OrgGroupRolePersistence orgGroupRolePersistence;
1566            @BeanReference(type = OrgLaborPersistence.class)
1567            protected OrgLaborPersistence orgLaborPersistence;
1568            @BeanReference(type = PasswordPolicyPersistence.class)
1569            protected PasswordPolicyPersistence passwordPolicyPersistence;
1570            @BeanReference(type = PasswordPolicyRelPersistence.class)
1571            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1572            @BeanReference(type = PasswordTrackerPersistence.class)
1573            protected PasswordTrackerPersistence passwordTrackerPersistence;
1574            @BeanReference(type = PermissionPersistence.class)
1575            protected PermissionPersistence permissionPersistence;
1576            @BeanReference(type = PhonePersistence.class)
1577            protected PhonePersistence phonePersistence;
1578            @BeanReference(type = PluginSettingPersistence.class)
1579            protected PluginSettingPersistence pluginSettingPersistence;
1580            @BeanReference(type = PortletPersistence.class)
1581            protected PortletPersistence portletPersistence;
1582            @BeanReference(type = PortletItemPersistence.class)
1583            protected PortletItemPersistence portletItemPersistence;
1584            @BeanReference(type = PortletPreferencesPersistence.class)
1585            protected PortletPreferencesPersistence portletPreferencesPersistence;
1586            @BeanReference(type = RegionPersistence.class)
1587            protected RegionPersistence regionPersistence;
1588            @BeanReference(type = ReleasePersistence.class)
1589            protected ReleasePersistence releasePersistence;
1590            @BeanReference(type = ResourcePersistence.class)
1591            protected ResourcePersistence resourcePersistence;
1592            @BeanReference(type = ResourceActionPersistence.class)
1593            protected ResourceActionPersistence resourceActionPersistence;
1594            @BeanReference(type = ResourceCodePersistence.class)
1595            protected ResourceCodePersistence resourceCodePersistence;
1596            @BeanReference(type = ResourcePermissionPersistence.class)
1597            protected ResourcePermissionPersistence resourcePermissionPersistence;
1598            @BeanReference(type = RolePersistence.class)
1599            protected RolePersistence rolePersistence;
1600            @BeanReference(type = ServiceComponentPersistence.class)
1601            protected ServiceComponentPersistence serviceComponentPersistence;
1602            @BeanReference(type = ShardPersistence.class)
1603            protected ShardPersistence shardPersistence;
1604            @BeanReference(type = SubscriptionPersistence.class)
1605            protected SubscriptionPersistence subscriptionPersistence;
1606            @BeanReference(type = TicketPersistence.class)
1607            protected TicketPersistence ticketPersistence;
1608            @BeanReference(type = TeamPersistence.class)
1609            protected TeamPersistence teamPersistence;
1610            @BeanReference(type = UserPersistence.class)
1611            protected UserPersistence userPersistence;
1612            @BeanReference(type = UserGroupPersistence.class)
1613            protected UserGroupPersistence userGroupPersistence;
1614            @BeanReference(type = UserGroupGroupRolePersistence.class)
1615            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1616            @BeanReference(type = UserGroupRolePersistence.class)
1617            protected UserGroupRolePersistence userGroupRolePersistence;
1618            @BeanReference(type = UserIdMapperPersistence.class)
1619            protected UserIdMapperPersistence userIdMapperPersistence;
1620            @BeanReference(type = UserTrackerPersistence.class)
1621            protected UserTrackerPersistence userTrackerPersistence;
1622            @BeanReference(type = UserTrackerPathPersistence.class)
1623            protected UserTrackerPathPersistence userTrackerPathPersistence;
1624            @BeanReference(type = WebDAVPropsPersistence.class)
1625            protected WebDAVPropsPersistence webDAVPropsPersistence;
1626            @BeanReference(type = WebsitePersistence.class)
1627            protected WebsitePersistence websitePersistence;
1628            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1629            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1630            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1631            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1632            private static final String _SQL_SELECT_PASSWORDPOLICYREL = "SELECT passwordPolicyRel FROM PasswordPolicyRel passwordPolicyRel";
1633            private static final String _SQL_SELECT_PASSWORDPOLICYREL_WHERE = "SELECT passwordPolicyRel FROM PasswordPolicyRel passwordPolicyRel WHERE ";
1634            private static final String _SQL_COUNT_PASSWORDPOLICYREL = "SELECT COUNT(passwordPolicyRel) FROM PasswordPolicyRel passwordPolicyRel";
1635            private static final String _SQL_COUNT_PASSWORDPOLICYREL_WHERE = "SELECT COUNT(passwordPolicyRel) FROM PasswordPolicyRel passwordPolicyRel WHERE ";
1636            private static final String _FINDER_COLUMN_PASSWORDPOLICYID_PASSWORDPOLICYID_2 =
1637                    "passwordPolicyRel.passwordPolicyId = ?";
1638            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "passwordPolicyRel.classNameId = ? AND ";
1639            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "passwordPolicyRel.classPK = ?";
1640            private static final String _FINDER_COLUMN_P_C_C_PASSWORDPOLICYID_2 = "passwordPolicyRel.passwordPolicyId = ? AND ";
1641            private static final String _FINDER_COLUMN_P_C_C_CLASSNAMEID_2 = "passwordPolicyRel.classNameId = ? AND ";
1642            private static final String _FINDER_COLUMN_P_C_C_CLASSPK_2 = "passwordPolicyRel.classPK = ?";
1643            private static final String _ORDER_BY_ENTITY_ALIAS = "passwordPolicyRel.";
1644            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PasswordPolicyRel exists with the primary key ";
1645            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PasswordPolicyRel exists with the key {";
1646            private static Log _log = LogFactoryUtil.getLog(PasswordPolicyRelPersistenceImpl.class);
1647    }