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