001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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.getOriginalClassNameId()),
283                                    new Long(passwordPolicyRelModelImpl.getOriginalClassPK())
284                            });
285    
286                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_C_C,
287                            new Object[] {
288                                    new Long(passwordPolicyRelModelImpl.getOriginalPasswordPolicyId()),
289                                    new Long(passwordPolicyRelModelImpl.getOriginalClassNameId()),
290                                    new Long(passwordPolicyRelModelImpl.getOriginalClassPK())
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                            Session session = null;
542    
543                            try {
544                                    session = openSession();
545    
546                                    StringBundler query = null;
547    
548                                    if (orderByComparator != null) {
549                                            query = new StringBundler(3 +
550                                                            (orderByComparator.getOrderByFields().length * 3));
551                                    }
552                                    else {
553                                            query = new StringBundler(2);
554                                    }
555    
556                                    query.append(_SQL_SELECT_PASSWORDPOLICYREL_WHERE);
557    
558                                    query.append(_FINDER_COLUMN_PASSWORDPOLICYID_PASSWORDPOLICYID_2);
559    
560                                    if (orderByComparator != null) {
561                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
562                                                    orderByComparator);
563                                    }
564    
565                                    String sql = query.toString();
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                                            list = new ArrayList<PasswordPolicyRel>();
582                                    }
583    
584                                    cacheResult(list);
585    
586                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PASSWORDPOLICYID,
587                                            finderArgs, list);
588    
589                                    closeSession(session);
590                            }
591                    }
592    
593                    return list;
594            }
595    
596            /**
597             * Finds the first password policy rel in the ordered set where passwordPolicyId = &#63;.
598             *
599             * <p>
600             * 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.
601             * </p>
602             *
603             * @param passwordPolicyId the password policy id to search with
604             * @param orderByComparator the comparator to order the set by
605             * @return the first matching password policy rel
606             * @throws com.liferay.portal.NoSuchPasswordPolicyRelException if a matching password policy rel could not be found
607             * @throws SystemException if a system exception occurred
608             */
609            public PasswordPolicyRel findByPasswordPolicyId_First(
610                    long passwordPolicyId, OrderByComparator orderByComparator)
611                    throws NoSuchPasswordPolicyRelException, SystemException {
612                    List<PasswordPolicyRel> list = findByPasswordPolicyId(passwordPolicyId,
613                                    0, 1, orderByComparator);
614    
615                    if (list.isEmpty()) {
616                            StringBundler msg = new StringBundler(4);
617    
618                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
619    
620                            msg.append("passwordPolicyId=");
621                            msg.append(passwordPolicyId);
622    
623                            msg.append(StringPool.CLOSE_CURLY_BRACE);
624    
625                            throw new NoSuchPasswordPolicyRelException(msg.toString());
626                    }
627                    else {
628                            return list.get(0);
629                    }
630            }
631    
632            /**
633             * Finds the last password policy rel in the ordered set where passwordPolicyId = &#63;.
634             *
635             * <p>
636             * 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.
637             * </p>
638             *
639             * @param passwordPolicyId the password policy id to search with
640             * @param orderByComparator the comparator to order the set by
641             * @return the last matching password policy rel
642             * @throws com.liferay.portal.NoSuchPasswordPolicyRelException if a matching password policy rel could not be found
643             * @throws SystemException if a system exception occurred
644             */
645            public PasswordPolicyRel findByPasswordPolicyId_Last(
646                    long passwordPolicyId, OrderByComparator orderByComparator)
647                    throws NoSuchPasswordPolicyRelException, SystemException {
648                    int count = countByPasswordPolicyId(passwordPolicyId);
649    
650                    List<PasswordPolicyRel> list = findByPasswordPolicyId(passwordPolicyId,
651                                    count - 1, count, orderByComparator);
652    
653                    if (list.isEmpty()) {
654                            StringBundler msg = new StringBundler(4);
655    
656                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
657    
658                            msg.append("passwordPolicyId=");
659                            msg.append(passwordPolicyId);
660    
661                            msg.append(StringPool.CLOSE_CURLY_BRACE);
662    
663                            throw new NoSuchPasswordPolicyRelException(msg.toString());
664                    }
665                    else {
666                            return list.get(0);
667                    }
668            }
669    
670            /**
671             * Finds the password policy rels before and after the current password policy rel in the ordered set where passwordPolicyId = &#63;.
672             *
673             * <p>
674             * 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.
675             * </p>
676             *
677             * @param passwordPolicyRelId the primary key of the current password policy rel
678             * @param passwordPolicyId the password policy id to search with
679             * @param orderByComparator the comparator to order the set by
680             * @return the previous, current, and next password policy rel
681             * @throws com.liferay.portal.NoSuchPasswordPolicyRelException if a password policy rel with the primary key could not be found
682             * @throws SystemException if a system exception occurred
683             */
684            public PasswordPolicyRel[] findByPasswordPolicyId_PrevAndNext(
685                    long passwordPolicyRelId, long passwordPolicyId,
686                    OrderByComparator orderByComparator)
687                    throws NoSuchPasswordPolicyRelException, SystemException {
688                    PasswordPolicyRel passwordPolicyRel = findByPrimaryKey(passwordPolicyRelId);
689    
690                    Session session = null;
691    
692                    try {
693                            session = openSession();
694    
695                            PasswordPolicyRel[] array = new PasswordPolicyRelImpl[3];
696    
697                            array[0] = getByPasswordPolicyId_PrevAndNext(session,
698                                            passwordPolicyRel, passwordPolicyId, orderByComparator, true);
699    
700                            array[1] = passwordPolicyRel;
701    
702                            array[2] = getByPasswordPolicyId_PrevAndNext(session,
703                                            passwordPolicyRel, passwordPolicyId, orderByComparator,
704                                            false);
705    
706                            return array;
707                    }
708                    catch (Exception e) {
709                            throw processException(e);
710                    }
711                    finally {
712                            closeSession(session);
713                    }
714            }
715    
716            protected PasswordPolicyRel getByPasswordPolicyId_PrevAndNext(
717                    Session session, PasswordPolicyRel passwordPolicyRel,
718                    long passwordPolicyId, OrderByComparator orderByComparator,
719                    boolean previous) {
720                    StringBundler query = null;
721    
722                    if (orderByComparator != null) {
723                            query = new StringBundler(6 +
724                                            (orderByComparator.getOrderByFields().length * 6));
725                    }
726                    else {
727                            query = new StringBundler(3);
728                    }
729    
730                    query.append(_SQL_SELECT_PASSWORDPOLICYREL_WHERE);
731    
732                    query.append(_FINDER_COLUMN_PASSWORDPOLICYID_PASSWORDPOLICYID_2);
733    
734                    if (orderByComparator != null) {
735                            String[] orderByFields = orderByComparator.getOrderByFields();
736    
737                            if (orderByFields.length > 0) {
738                                    query.append(WHERE_AND);
739                            }
740    
741                            for (int i = 0; i < orderByFields.length; i++) {
742                                    query.append(_ORDER_BY_ENTITY_ALIAS);
743                                    query.append(orderByFields[i]);
744    
745                                    if ((i + 1) < orderByFields.length) {
746                                            if (orderByComparator.isAscending() ^ previous) {
747                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
748                                            }
749                                            else {
750                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
751                                            }
752                                    }
753                                    else {
754                                            if (orderByComparator.isAscending() ^ previous) {
755                                                    query.append(WHERE_GREATER_THAN);
756                                            }
757                                            else {
758                                                    query.append(WHERE_LESSER_THAN);
759                                            }
760                                    }
761                            }
762    
763                            query.append(ORDER_BY_CLAUSE);
764    
765                            for (int i = 0; i < orderByFields.length; i++) {
766                                    query.append(_ORDER_BY_ENTITY_ALIAS);
767                                    query.append(orderByFields[i]);
768    
769                                    if ((i + 1) < orderByFields.length) {
770                                            if (orderByComparator.isAscending() ^ previous) {
771                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
772                                            }
773                                            else {
774                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
775                                            }
776                                    }
777                                    else {
778                                            if (orderByComparator.isAscending() ^ previous) {
779                                                    query.append(ORDER_BY_ASC);
780                                            }
781                                            else {
782                                                    query.append(ORDER_BY_DESC);
783                                            }
784                                    }
785                            }
786                    }
787    
788                    String sql = query.toString();
789    
790                    Query q = session.createQuery(sql);
791    
792                    q.setFirstResult(0);
793                    q.setMaxResults(2);
794    
795                    QueryPos qPos = QueryPos.getInstance(q);
796    
797                    qPos.add(passwordPolicyId);
798    
799                    if (orderByComparator != null) {
800                            Object[] values = orderByComparator.getOrderByValues(passwordPolicyRel);
801    
802                            for (Object value : values) {
803                                    qPos.add(value);
804                            }
805                    }
806    
807                    List<PasswordPolicyRel> list = q.list();
808    
809                    if (list.size() == 2) {
810                            return list.get(1);
811                    }
812                    else {
813                            return null;
814                    }
815            }
816    
817            /**
818             * 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.
819             *
820             * @param classNameId the class name id to search with
821             * @param classPK the class p k to search with
822             * @return the matching password policy rel
823             * @throws com.liferay.portal.NoSuchPasswordPolicyRelException if a matching password policy rel could not be found
824             * @throws SystemException if a system exception occurred
825             */
826            public PasswordPolicyRel findByC_C(long classNameId, long classPK)
827                    throws NoSuchPasswordPolicyRelException, SystemException {
828                    PasswordPolicyRel passwordPolicyRel = fetchByC_C(classNameId, classPK);
829    
830                    if (passwordPolicyRel == null) {
831                            StringBundler msg = new StringBundler(6);
832    
833                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
834    
835                            msg.append("classNameId=");
836                            msg.append(classNameId);
837    
838                            msg.append(", classPK=");
839                            msg.append(classPK);
840    
841                            msg.append(StringPool.CLOSE_CURLY_BRACE);
842    
843                            if (_log.isWarnEnabled()) {
844                                    _log.warn(msg.toString());
845                            }
846    
847                            throw new NoSuchPasswordPolicyRelException(msg.toString());
848                    }
849    
850                    return passwordPolicyRel;
851            }
852    
853            /**
854             * 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.
855             *
856             * @param classNameId the class name id to search with
857             * @param classPK the class p k to search with
858             * @return the matching password policy rel, or <code>null</code> if a matching password policy rel could not be found
859             * @throws SystemException if a system exception occurred
860             */
861            public PasswordPolicyRel fetchByC_C(long classNameId, long classPK)
862                    throws SystemException {
863                    return fetchByC_C(classNameId, classPK, true);
864            }
865    
866            /**
867             * 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.
868             *
869             * @param classNameId the class name id to search with
870             * @param classPK the class p k to search with
871             * @return the matching password policy rel, or <code>null</code> if a matching password policy rel could not be found
872             * @throws SystemException if a system exception occurred
873             */
874            public PasswordPolicyRel fetchByC_C(long classNameId, long classPK,
875                    boolean retrieveFromCache) throws SystemException {
876                    Object[] finderArgs = new Object[] { classNameId, classPK };
877    
878                    Object result = null;
879    
880                    if (retrieveFromCache) {
881                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
882                                            finderArgs, this);
883                    }
884    
885                    if (result == null) {
886                            Session session = null;
887    
888                            try {
889                                    session = openSession();
890    
891                                    StringBundler query = new StringBundler(3);
892    
893                                    query.append(_SQL_SELECT_PASSWORDPOLICYREL_WHERE);
894    
895                                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
896    
897                                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
898    
899                                    String sql = query.toString();
900    
901                                    Query q = session.createQuery(sql);
902    
903                                    QueryPos qPos = QueryPos.getInstance(q);
904    
905                                    qPos.add(classNameId);
906    
907                                    qPos.add(classPK);
908    
909                                    List<PasswordPolicyRel> list = q.list();
910    
911                                    result = list;
912    
913                                    PasswordPolicyRel passwordPolicyRel = null;
914    
915                                    if (list.isEmpty()) {
916                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
917                                                    finderArgs, list);
918                                    }
919                                    else {
920                                            passwordPolicyRel = list.get(0);
921    
922                                            cacheResult(passwordPolicyRel);
923    
924                                            if ((passwordPolicyRel.getClassNameId() != classNameId) ||
925                                                            (passwordPolicyRel.getClassPK() != classPK)) {
926                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
927                                                            finderArgs, passwordPolicyRel);
928                                            }
929                                    }
930    
931                                    return passwordPolicyRel;
932                            }
933                            catch (Exception e) {
934                                    throw processException(e);
935                            }
936                            finally {
937                                    if (result == null) {
938                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
939                                                    finderArgs, new ArrayList<PasswordPolicyRel>());
940                                    }
941    
942                                    closeSession(session);
943                            }
944                    }
945                    else {
946                            if (result instanceof List<?>) {
947                                    return null;
948                            }
949                            else {
950                                    return (PasswordPolicyRel)result;
951                            }
952                    }
953            }
954    
955            /**
956             * 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.
957             *
958             * @param passwordPolicyId the password policy id to search with
959             * @param classNameId the class name id to search with
960             * @param classPK the class p k to search with
961             * @return the matching password policy rel
962             * @throws com.liferay.portal.NoSuchPasswordPolicyRelException if a matching password policy rel could not be found
963             * @throws SystemException if a system exception occurred
964             */
965            public PasswordPolicyRel findByP_C_C(long passwordPolicyId,
966                    long classNameId, long classPK)
967                    throws NoSuchPasswordPolicyRelException, SystemException {
968                    PasswordPolicyRel passwordPolicyRel = fetchByP_C_C(passwordPolicyId,
969                                    classNameId, classPK);
970    
971                    if (passwordPolicyRel == null) {
972                            StringBundler msg = new StringBundler(8);
973    
974                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
975    
976                            msg.append("passwordPolicyId=");
977                            msg.append(passwordPolicyId);
978    
979                            msg.append(", classNameId=");
980                            msg.append(classNameId);
981    
982                            msg.append(", classPK=");
983                            msg.append(classPK);
984    
985                            msg.append(StringPool.CLOSE_CURLY_BRACE);
986    
987                            if (_log.isWarnEnabled()) {
988                                    _log.warn(msg.toString());
989                            }
990    
991                            throw new NoSuchPasswordPolicyRelException(msg.toString());
992                    }
993    
994                    return passwordPolicyRel;
995            }
996    
997            /**
998             * 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.
999             *
1000             * @param passwordPolicyId the password policy id to search with
1001             * @param classNameId the class name id to search with
1002             * @param classPK the class p k to search with
1003             * @return the matching password policy rel, or <code>null</code> if a matching password policy rel could not be found
1004             * @throws SystemException if a system exception occurred
1005             */
1006            public PasswordPolicyRel fetchByP_C_C(long passwordPolicyId,
1007                    long classNameId, long classPK) throws SystemException {
1008                    return fetchByP_C_C(passwordPolicyId, classNameId, classPK, true);
1009            }
1010    
1011            /**
1012             * 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.
1013             *
1014             * @param passwordPolicyId the password policy id to search with
1015             * @param classNameId the class name id to search with
1016             * @param classPK the class p k to search with
1017             * @return the matching password policy rel, or <code>null</code> if a matching password policy rel could not be found
1018             * @throws SystemException if a system exception occurred
1019             */
1020            public PasswordPolicyRel fetchByP_C_C(long passwordPolicyId,
1021                    long classNameId, long classPK, boolean retrieveFromCache)
1022                    throws SystemException {
1023                    Object[] finderArgs = new Object[] {
1024                                    passwordPolicyId, classNameId, classPK
1025                            };
1026    
1027                    Object result = null;
1028    
1029                    if (retrieveFromCache) {
1030                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_C_C,
1031                                            finderArgs, this);
1032                    }
1033    
1034                    if (result == null) {
1035                            Session session = null;
1036    
1037                            try {
1038                                    session = openSession();
1039    
1040                                    StringBundler query = new StringBundler(4);
1041    
1042                                    query.append(_SQL_SELECT_PASSWORDPOLICYREL_WHERE);
1043    
1044                                    query.append(_FINDER_COLUMN_P_C_C_PASSWORDPOLICYID_2);
1045    
1046                                    query.append(_FINDER_COLUMN_P_C_C_CLASSNAMEID_2);
1047    
1048                                    query.append(_FINDER_COLUMN_P_C_C_CLASSPK_2);
1049    
1050                                    String sql = query.toString();
1051    
1052                                    Query q = session.createQuery(sql);
1053    
1054                                    QueryPos qPos = QueryPos.getInstance(q);
1055    
1056                                    qPos.add(passwordPolicyId);
1057    
1058                                    qPos.add(classNameId);
1059    
1060                                    qPos.add(classPK);
1061    
1062                                    List<PasswordPolicyRel> list = q.list();
1063    
1064                                    result = list;
1065    
1066                                    PasswordPolicyRel passwordPolicyRel = null;
1067    
1068                                    if (list.isEmpty()) {
1069                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_C_C,
1070                                                    finderArgs, list);
1071                                    }
1072                                    else {
1073                                            passwordPolicyRel = list.get(0);
1074    
1075                                            cacheResult(passwordPolicyRel);
1076    
1077                                            if ((passwordPolicyRel.getPasswordPolicyId() != passwordPolicyId) ||
1078                                                            (passwordPolicyRel.getClassNameId() != classNameId) ||
1079                                                            (passwordPolicyRel.getClassPK() != classPK)) {
1080                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_C_C,
1081                                                            finderArgs, passwordPolicyRel);
1082                                            }
1083                                    }
1084    
1085                                    return passwordPolicyRel;
1086                            }
1087                            catch (Exception e) {
1088                                    throw processException(e);
1089                            }
1090                            finally {
1091                                    if (result == null) {
1092                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_C_C,
1093                                                    finderArgs, new ArrayList<PasswordPolicyRel>());
1094                                    }
1095    
1096                                    closeSession(session);
1097                            }
1098                    }
1099                    else {
1100                            if (result instanceof List<?>) {
1101                                    return null;
1102                            }
1103                            else {
1104                                    return (PasswordPolicyRel)result;
1105                            }
1106                    }
1107            }
1108    
1109            /**
1110             * Finds all the password policy rels.
1111             *
1112             * @return the password policy rels
1113             * @throws SystemException if a system exception occurred
1114             */
1115            public List<PasswordPolicyRel> findAll() throws SystemException {
1116                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1117            }
1118    
1119            /**
1120             * Finds a range of all the password policy rels.
1121             *
1122             * <p>
1123             * 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.
1124             * </p>
1125             *
1126             * @param start the lower bound of the range of password policy rels to return
1127             * @param end the upper bound of the range of password policy rels to return (not inclusive)
1128             * @return the range of password policy rels
1129             * @throws SystemException if a system exception occurred
1130             */
1131            public List<PasswordPolicyRel> findAll(int start, int end)
1132                    throws SystemException {
1133                    return findAll(start, end, null);
1134            }
1135    
1136            /**
1137             * Finds an ordered range of all the password policy rels.
1138             *
1139             * <p>
1140             * 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.
1141             * </p>
1142             *
1143             * @param start the lower bound of the range of password policy rels to return
1144             * @param end the upper bound of the range of password policy rels to return (not inclusive)
1145             * @param orderByComparator the comparator to order the results by
1146             * @return the ordered range of password policy rels
1147             * @throws SystemException if a system exception occurred
1148             */
1149            public List<PasswordPolicyRel> findAll(int start, int end,
1150                    OrderByComparator orderByComparator) throws SystemException {
1151                    Object[] finderArgs = new Object[] {
1152                                    String.valueOf(start), String.valueOf(end),
1153                                    String.valueOf(orderByComparator)
1154                            };
1155    
1156                    List<PasswordPolicyRel> list = (List<PasswordPolicyRel>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1157                                    finderArgs, this);
1158    
1159                    if (list == null) {
1160                            Session session = null;
1161    
1162                            try {
1163                                    session = openSession();
1164    
1165                                    StringBundler query = null;
1166                                    String sql = null;
1167    
1168                                    if (orderByComparator != null) {
1169                                            query = new StringBundler(2 +
1170                                                            (orderByComparator.getOrderByFields().length * 3));
1171    
1172                                            query.append(_SQL_SELECT_PASSWORDPOLICYREL);
1173    
1174                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1175                                                    orderByComparator);
1176    
1177                                            sql = query.toString();
1178                                    }
1179                                    else {
1180                                            sql = _SQL_SELECT_PASSWORDPOLICYREL;
1181                                    }
1182    
1183                                    Query q = session.createQuery(sql);
1184    
1185                                    if (orderByComparator == null) {
1186                                            list = (List<PasswordPolicyRel>)QueryUtil.list(q,
1187                                                            getDialect(), start, end, false);
1188    
1189                                            Collections.sort(list);
1190                                    }
1191                                    else {
1192                                            list = (List<PasswordPolicyRel>)QueryUtil.list(q,
1193                                                            getDialect(), start, end);
1194                                    }
1195                            }
1196                            catch (Exception e) {
1197                                    throw processException(e);
1198                            }
1199                            finally {
1200                                    if (list == null) {
1201                                            list = new ArrayList<PasswordPolicyRel>();
1202                                    }
1203    
1204                                    cacheResult(list);
1205    
1206                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1207    
1208                                    closeSession(session);
1209                            }
1210                    }
1211    
1212                    return list;
1213            }
1214    
1215            /**
1216             * Removes all the password policy rels where passwordPolicyId = &#63; from the database.
1217             *
1218             * @param passwordPolicyId the password policy id to search with
1219             * @throws SystemException if a system exception occurred
1220             */
1221            public void removeByPasswordPolicyId(long passwordPolicyId)
1222                    throws SystemException {
1223                    for (PasswordPolicyRel passwordPolicyRel : findByPasswordPolicyId(
1224                                    passwordPolicyId)) {
1225                            remove(passwordPolicyRel);
1226                    }
1227            }
1228    
1229            /**
1230             * Removes the password policy rel where classNameId = &#63; and classPK = &#63; from the database.
1231             *
1232             * @param classNameId the class name id to search with
1233             * @param classPK the class p k to search with
1234             * @throws SystemException if a system exception occurred
1235             */
1236            public void removeByC_C(long classNameId, long classPK)
1237                    throws NoSuchPasswordPolicyRelException, SystemException {
1238                    PasswordPolicyRel passwordPolicyRel = findByC_C(classNameId, classPK);
1239    
1240                    remove(passwordPolicyRel);
1241            }
1242    
1243            /**
1244             * Removes the password policy rel where passwordPolicyId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
1245             *
1246             * @param passwordPolicyId the password policy id to search with
1247             * @param classNameId the class name id to search with
1248             * @param classPK the class p k to search with
1249             * @throws SystemException if a system exception occurred
1250             */
1251            public void removeByP_C_C(long passwordPolicyId, long classNameId,
1252                    long classPK) throws NoSuchPasswordPolicyRelException, SystemException {
1253                    PasswordPolicyRel passwordPolicyRel = findByP_C_C(passwordPolicyId,
1254                                    classNameId, classPK);
1255    
1256                    remove(passwordPolicyRel);
1257            }
1258    
1259            /**
1260             * Removes all the password policy rels from the database.
1261             *
1262             * @throws SystemException if a system exception occurred
1263             */
1264            public void removeAll() throws SystemException {
1265                    for (PasswordPolicyRel passwordPolicyRel : findAll()) {
1266                            remove(passwordPolicyRel);
1267                    }
1268            }
1269    
1270            /**
1271             * Counts all the password policy rels where passwordPolicyId = &#63;.
1272             *
1273             * @param passwordPolicyId the password policy id to search with
1274             * @return the number of matching password policy rels
1275             * @throws SystemException if a system exception occurred
1276             */
1277            public int countByPasswordPolicyId(long passwordPolicyId)
1278                    throws SystemException {
1279                    Object[] finderArgs = new Object[] { passwordPolicyId };
1280    
1281                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PASSWORDPOLICYID,
1282                                    finderArgs, this);
1283    
1284                    if (count == null) {
1285                            Session session = null;
1286    
1287                            try {
1288                                    session = openSession();
1289    
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                                    Query q = session.createQuery(sql);
1299    
1300                                    QueryPos qPos = QueryPos.getInstance(q);
1301    
1302                                    qPos.add(passwordPolicyId);
1303    
1304                                    count = (Long)q.uniqueResult();
1305                            }
1306                            catch (Exception e) {
1307                                    throw processException(e);
1308                            }
1309                            finally {
1310                                    if (count == null) {
1311                                            count = Long.valueOf(0);
1312                                    }
1313    
1314                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PASSWORDPOLICYID,
1315                                            finderArgs, count);
1316    
1317                                    closeSession(session);
1318                            }
1319                    }
1320    
1321                    return count.intValue();
1322            }
1323    
1324            /**
1325             * Counts all the password policy rels where classNameId = &#63; and classPK = &#63;.
1326             *
1327             * @param classNameId the class name id to search with
1328             * @param classPK the class p k to search with
1329             * @return the number of matching password policy rels
1330             * @throws SystemException if a system exception occurred
1331             */
1332            public int countByC_C(long classNameId, long classPK)
1333                    throws SystemException {
1334                    Object[] finderArgs = new Object[] { classNameId, classPK };
1335    
1336                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
1337                                    finderArgs, this);
1338    
1339                    if (count == null) {
1340                            Session session = null;
1341    
1342                            try {
1343                                    session = openSession();
1344    
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                                    Query q = session.createQuery(sql);
1356    
1357                                    QueryPos qPos = QueryPos.getInstance(q);
1358    
1359                                    qPos.add(classNameId);
1360    
1361                                    qPos.add(classPK);
1362    
1363                                    count = (Long)q.uniqueResult();
1364                            }
1365                            catch (Exception e) {
1366                                    throw processException(e);
1367                            }
1368                            finally {
1369                                    if (count == null) {
1370                                            count = Long.valueOf(0);
1371                                    }
1372    
1373                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
1374                                            count);
1375    
1376                                    closeSession(session);
1377                            }
1378                    }
1379    
1380                    return count.intValue();
1381            }
1382    
1383            /**
1384             * Counts all the password policy rels where passwordPolicyId = &#63; and classNameId = &#63; and classPK = &#63;.
1385             *
1386             * @param passwordPolicyId the password policy id to search with
1387             * @param classNameId the class name id to search with
1388             * @param classPK the class p k to search with
1389             * @return the number of matching password policy rels
1390             * @throws SystemException if a system exception occurred
1391             */
1392            public int countByP_C_C(long passwordPolicyId, long classNameId,
1393                    long classPK) throws SystemException {
1394                    Object[] finderArgs = new Object[] {
1395                                    passwordPolicyId, classNameId, classPK
1396                            };
1397    
1398                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_C_C,
1399                                    finderArgs, this);
1400    
1401                    if (count == null) {
1402                            Session session = null;
1403    
1404                            try {
1405                                    session = openSession();
1406    
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                                    Query q = session.createQuery(sql);
1420    
1421                                    QueryPos qPos = QueryPos.getInstance(q);
1422    
1423                                    qPos.add(passwordPolicyId);
1424    
1425                                    qPos.add(classNameId);
1426    
1427                                    qPos.add(classPK);
1428    
1429                                    count = (Long)q.uniqueResult();
1430                            }
1431                            catch (Exception e) {
1432                                    throw processException(e);
1433                            }
1434                            finally {
1435                                    if (count == null) {
1436                                            count = Long.valueOf(0);
1437                                    }
1438    
1439                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_C_C,
1440                                            finderArgs, count);
1441    
1442                                    closeSession(session);
1443                            }
1444                    }
1445    
1446                    return count.intValue();
1447            }
1448    
1449            /**
1450             * Counts all the password policy rels.
1451             *
1452             * @return the number of password policy rels
1453             * @throws SystemException if a system exception occurred
1454             */
1455            public int countAll() throws SystemException {
1456                    Object[] finderArgs = new Object[0];
1457    
1458                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1459                                    finderArgs, this);
1460    
1461                    if (count == null) {
1462                            Session session = null;
1463    
1464                            try {
1465                                    session = openSession();
1466    
1467                                    Query q = session.createQuery(_SQL_COUNT_PASSWORDPOLICYREL);
1468    
1469                                    count = (Long)q.uniqueResult();
1470                            }
1471                            catch (Exception e) {
1472                                    throw processException(e);
1473                            }
1474                            finally {
1475                                    if (count == null) {
1476                                            count = Long.valueOf(0);
1477                                    }
1478    
1479                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1480                                            count);
1481    
1482                                    closeSession(session);
1483                            }
1484                    }
1485    
1486                    return count.intValue();
1487            }
1488    
1489            /**
1490             * Initializes the password policy rel persistence.
1491             */
1492            public void afterPropertiesSet() {
1493                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1494                                            com.liferay.portal.util.PropsUtil.get(
1495                                                    "value.object.listener.com.liferay.portal.model.PasswordPolicyRel")));
1496    
1497                    if (listenerClassNames.length > 0) {
1498                            try {
1499                                    List<ModelListener<PasswordPolicyRel>> listenersList = new ArrayList<ModelListener<PasswordPolicyRel>>();
1500    
1501                                    for (String listenerClassName : listenerClassNames) {
1502                                            listenersList.add((ModelListener<PasswordPolicyRel>)InstanceFactory.newInstance(
1503                                                            listenerClassName));
1504                                    }
1505    
1506                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1507                            }
1508                            catch (Exception e) {
1509                                    _log.error(e);
1510                            }
1511                    }
1512            }
1513    
1514            public void destroy() {
1515                    EntityCacheUtil.removeCache(PasswordPolicyRelImpl.class.getName());
1516                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1517                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1518            }
1519    
1520            @BeanReference(type = AccountPersistence.class)
1521            protected AccountPersistence accountPersistence;
1522            @BeanReference(type = AddressPersistence.class)
1523            protected AddressPersistence addressPersistence;
1524            @BeanReference(type = BrowserTrackerPersistence.class)
1525            protected BrowserTrackerPersistence browserTrackerPersistence;
1526            @BeanReference(type = ClassNamePersistence.class)
1527            protected ClassNamePersistence classNamePersistence;
1528            @BeanReference(type = ClusterGroupPersistence.class)
1529            protected ClusterGroupPersistence clusterGroupPersistence;
1530            @BeanReference(type = CompanyPersistence.class)
1531            protected CompanyPersistence companyPersistence;
1532            @BeanReference(type = ContactPersistence.class)
1533            protected ContactPersistence contactPersistence;
1534            @BeanReference(type = CountryPersistence.class)
1535            protected CountryPersistence countryPersistence;
1536            @BeanReference(type = EmailAddressPersistence.class)
1537            protected EmailAddressPersistence emailAddressPersistence;
1538            @BeanReference(type = GroupPersistence.class)
1539            protected GroupPersistence groupPersistence;
1540            @BeanReference(type = ImagePersistence.class)
1541            protected ImagePersistence imagePersistence;
1542            @BeanReference(type = LayoutPersistence.class)
1543            protected LayoutPersistence layoutPersistence;
1544            @BeanReference(type = LayoutPrototypePersistence.class)
1545            protected LayoutPrototypePersistence layoutPrototypePersistence;
1546            @BeanReference(type = LayoutSetPersistence.class)
1547            protected LayoutSetPersistence layoutSetPersistence;
1548            @BeanReference(type = LayoutSetPrototypePersistence.class)
1549            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1550            @BeanReference(type = ListTypePersistence.class)
1551            protected ListTypePersistence listTypePersistence;
1552            @BeanReference(type = LockPersistence.class)
1553            protected LockPersistence lockPersistence;
1554            @BeanReference(type = MembershipRequestPersistence.class)
1555            protected MembershipRequestPersistence membershipRequestPersistence;
1556            @BeanReference(type = OrganizationPersistence.class)
1557            protected OrganizationPersistence organizationPersistence;
1558            @BeanReference(type = OrgGroupPermissionPersistence.class)
1559            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1560            @BeanReference(type = OrgGroupRolePersistence.class)
1561            protected OrgGroupRolePersistence orgGroupRolePersistence;
1562            @BeanReference(type = OrgLaborPersistence.class)
1563            protected OrgLaborPersistence orgLaborPersistence;
1564            @BeanReference(type = PasswordPolicyPersistence.class)
1565            protected PasswordPolicyPersistence passwordPolicyPersistence;
1566            @BeanReference(type = PasswordPolicyRelPersistence.class)
1567            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1568            @BeanReference(type = PasswordTrackerPersistence.class)
1569            protected PasswordTrackerPersistence passwordTrackerPersistence;
1570            @BeanReference(type = PermissionPersistence.class)
1571            protected PermissionPersistence permissionPersistence;
1572            @BeanReference(type = PhonePersistence.class)
1573            protected PhonePersistence phonePersistence;
1574            @BeanReference(type = PluginSettingPersistence.class)
1575            protected PluginSettingPersistence pluginSettingPersistence;
1576            @BeanReference(type = PortletPersistence.class)
1577            protected PortletPersistence portletPersistence;
1578            @BeanReference(type = PortletItemPersistence.class)
1579            protected PortletItemPersistence portletItemPersistence;
1580            @BeanReference(type = PortletPreferencesPersistence.class)
1581            protected PortletPreferencesPersistence portletPreferencesPersistence;
1582            @BeanReference(type = RegionPersistence.class)
1583            protected RegionPersistence regionPersistence;
1584            @BeanReference(type = ReleasePersistence.class)
1585            protected ReleasePersistence releasePersistence;
1586            @BeanReference(type = ResourcePersistence.class)
1587            protected ResourcePersistence resourcePersistence;
1588            @BeanReference(type = ResourceActionPersistence.class)
1589            protected ResourceActionPersistence resourceActionPersistence;
1590            @BeanReference(type = ResourceCodePersistence.class)
1591            protected ResourceCodePersistence resourceCodePersistence;
1592            @BeanReference(type = ResourcePermissionPersistence.class)
1593            protected ResourcePermissionPersistence resourcePermissionPersistence;
1594            @BeanReference(type = RolePersistence.class)
1595            protected RolePersistence rolePersistence;
1596            @BeanReference(type = ServiceComponentPersistence.class)
1597            protected ServiceComponentPersistence serviceComponentPersistence;
1598            @BeanReference(type = ShardPersistence.class)
1599            protected ShardPersistence shardPersistence;
1600            @BeanReference(type = SubscriptionPersistence.class)
1601            protected SubscriptionPersistence subscriptionPersistence;
1602            @BeanReference(type = TicketPersistence.class)
1603            protected TicketPersistence ticketPersistence;
1604            @BeanReference(type = TeamPersistence.class)
1605            protected TeamPersistence teamPersistence;
1606            @BeanReference(type = UserPersistence.class)
1607            protected UserPersistence userPersistence;
1608            @BeanReference(type = UserGroupPersistence.class)
1609            protected UserGroupPersistence userGroupPersistence;
1610            @BeanReference(type = UserGroupGroupRolePersistence.class)
1611            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1612            @BeanReference(type = UserGroupRolePersistence.class)
1613            protected UserGroupRolePersistence userGroupRolePersistence;
1614            @BeanReference(type = UserIdMapperPersistence.class)
1615            protected UserIdMapperPersistence userIdMapperPersistence;
1616            @BeanReference(type = UserTrackerPersistence.class)
1617            protected UserTrackerPersistence userTrackerPersistence;
1618            @BeanReference(type = UserTrackerPathPersistence.class)
1619            protected UserTrackerPathPersistence userTrackerPathPersistence;
1620            @BeanReference(type = WebDAVPropsPersistence.class)
1621            protected WebDAVPropsPersistence webDAVPropsPersistence;
1622            @BeanReference(type = WebsitePersistence.class)
1623            protected WebsitePersistence websitePersistence;
1624            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1625            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1626            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1627            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1628            private static final String _SQL_SELECT_PASSWORDPOLICYREL = "SELECT passwordPolicyRel FROM PasswordPolicyRel passwordPolicyRel";
1629            private static final String _SQL_SELECT_PASSWORDPOLICYREL_WHERE = "SELECT passwordPolicyRel FROM PasswordPolicyRel passwordPolicyRel WHERE ";
1630            private static final String _SQL_COUNT_PASSWORDPOLICYREL = "SELECT COUNT(passwordPolicyRel) FROM PasswordPolicyRel passwordPolicyRel";
1631            private static final String _SQL_COUNT_PASSWORDPOLICYREL_WHERE = "SELECT COUNT(passwordPolicyRel) FROM PasswordPolicyRel passwordPolicyRel WHERE ";
1632            private static final String _FINDER_COLUMN_PASSWORDPOLICYID_PASSWORDPOLICYID_2 =
1633                    "passwordPolicyRel.passwordPolicyId = ?";
1634            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "passwordPolicyRel.classNameId = ? AND ";
1635            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "passwordPolicyRel.classPK = ?";
1636            private static final String _FINDER_COLUMN_P_C_C_PASSWORDPOLICYID_2 = "passwordPolicyRel.passwordPolicyId = ? AND ";
1637            private static final String _FINDER_COLUMN_P_C_C_CLASSNAMEID_2 = "passwordPolicyRel.classNameId = ? AND ";
1638            private static final String _FINDER_COLUMN_P_C_C_CLASSPK_2 = "passwordPolicyRel.classPK = ?";
1639            private static final String _ORDER_BY_ENTITY_ALIAS = "passwordPolicyRel.";
1640            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PasswordPolicyRel exists with the primary key ";
1641            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PasswordPolicyRel exists with the key {";
1642            private static Log _log = LogFactoryUtil.getLog(PasswordPolicyRelPersistenceImpl.class);
1643    }