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