001    /**
002     * Copyright (c) 2000-present 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.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.NoSuchPasswordPolicyException;
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.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.OrderByComparator;
031    import com.liferay.portal.kernel.util.SetUtil;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.StringUtil;
035    import com.liferay.portal.kernel.util.Validator;
036    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
037    import com.liferay.portal.model.CacheModel;
038    import com.liferay.portal.model.MVCCModel;
039    import com.liferay.portal.model.PasswordPolicy;
040    import com.liferay.portal.model.impl.PasswordPolicyImpl;
041    import com.liferay.portal.model.impl.PasswordPolicyModelImpl;
042    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
043    import com.liferay.portal.service.ServiceContext;
044    import com.liferay.portal.service.ServiceContextThreadLocal;
045    import com.liferay.portal.service.persistence.PasswordPolicyPersistence;
046    
047    import java.io.Serializable;
048    
049    import java.util.Collections;
050    import java.util.Date;
051    import java.util.HashMap;
052    import java.util.HashSet;
053    import java.util.Iterator;
054    import java.util.List;
055    import java.util.Map;
056    import java.util.Set;
057    
058    /**
059     * The persistence implementation for the password policy service.
060     *
061     * <p>
062     * Caching information and settings can be found in <code>portal.properties</code>
063     * </p>
064     *
065     * @author Brian Wing Shun Chan
066     * @see PasswordPolicyPersistence
067     * @see com.liferay.portal.service.persistence.PasswordPolicyUtil
068     * @generated
069     */
070    @ProviderType
071    public class PasswordPolicyPersistenceImpl extends BasePersistenceImpl<PasswordPolicy>
072            implements PasswordPolicyPersistence {
073            /*
074             * NOTE FOR DEVELOPERS:
075             *
076             * Never modify or reference this class directly. Always use {@link PasswordPolicyUtil} to access the password policy persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
077             */
078            public static final String FINDER_CLASS_NAME_ENTITY = PasswordPolicyImpl.class.getName();
079            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080                    ".List1";
081            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082                    ".List2";
083            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
084                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
085                            PasswordPolicyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
086                            "findAll", new String[0]);
087            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
088                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
089                            PasswordPolicyImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
091            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
092                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED, Long.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
095                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
096                            PasswordPolicyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
097                            "findByUuid",
098                            new String[] {
099                                    String.class.getName(),
100                                    
101                            Integer.class.getName(), Integer.class.getName(),
102                                    OrderByComparator.class.getName()
103                            });
104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
105                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
106                            PasswordPolicyImpl.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
108                            new String[] { String.class.getName() },
109                            PasswordPolicyModelImpl.UUID_COLUMN_BITMASK);
110            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
111                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED, Long.class,
112                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
113                            new String[] { String.class.getName() });
114    
115            /**
116             * Returns all the password policies where uuid = &#63;.
117             *
118             * @param uuid the uuid
119             * @return the matching password policies
120             */
121            @Override
122            public List<PasswordPolicy> findByUuid(String uuid) {
123                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
124            }
125    
126            /**
127             * Returns a range of all the password policies where uuid = &#63;.
128             *
129             * <p>
130             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
131             * </p>
132             *
133             * @param uuid the uuid
134             * @param start the lower bound of the range of password policies
135             * @param end the upper bound of the range of password policies (not inclusive)
136             * @return the range of matching password policies
137             */
138            @Override
139            public List<PasswordPolicy> findByUuid(String uuid, int start, int end) {
140                    return findByUuid(uuid, start, end, null);
141            }
142    
143            /**
144             * Returns an ordered range of all the password policies where uuid = &#63;.
145             *
146             * <p>
147             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
148             * </p>
149             *
150             * @param uuid the uuid
151             * @param start the lower bound of the range of password policies
152             * @param end the upper bound of the range of password policies (not inclusive)
153             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
154             * @return the ordered range of matching password policies
155             */
156            @Override
157            public List<PasswordPolicy> findByUuid(String uuid, int start, int end,
158                    OrderByComparator<PasswordPolicy> orderByComparator) {
159                    boolean pagination = true;
160                    FinderPath finderPath = null;
161                    Object[] finderArgs = null;
162    
163                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
164                                    (orderByComparator == null)) {
165                            pagination = false;
166                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
167                            finderArgs = new Object[] { uuid };
168                    }
169                    else {
170                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
171                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
172                    }
173    
174                    List<PasswordPolicy> list = (List<PasswordPolicy>)FinderCacheUtil.getResult(finderPath,
175                                    finderArgs, this);
176    
177                    if ((list != null) && !list.isEmpty()) {
178                            for (PasswordPolicy passwordPolicy : list) {
179                                    if (!Validator.equals(uuid, passwordPolicy.getUuid())) {
180                                            list = null;
181    
182                                            break;
183                                    }
184                            }
185                    }
186    
187                    if (list == null) {
188                            StringBundler query = null;
189    
190                            if (orderByComparator != null) {
191                                    query = new StringBundler(3 +
192                                                    (orderByComparator.getOrderByFields().length * 3));
193                            }
194                            else {
195                                    query = new StringBundler(3);
196                            }
197    
198                            query.append(_SQL_SELECT_PASSWORDPOLICY_WHERE);
199    
200                            boolean bindUuid = false;
201    
202                            if (uuid == null) {
203                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
204                            }
205                            else if (uuid.equals(StringPool.BLANK)) {
206                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
207                            }
208                            else {
209                                    bindUuid = true;
210    
211                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
212                            }
213    
214                            if (orderByComparator != null) {
215                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
216                                            orderByComparator);
217                            }
218                            else
219                             if (pagination) {
220                                    query.append(PasswordPolicyModelImpl.ORDER_BY_JPQL);
221                            }
222    
223                            String sql = query.toString();
224    
225                            Session session = null;
226    
227                            try {
228                                    session = openSession();
229    
230                                    Query q = session.createQuery(sql);
231    
232                                    QueryPos qPos = QueryPos.getInstance(q);
233    
234                                    if (bindUuid) {
235                                            qPos.add(uuid);
236                                    }
237    
238                                    if (!pagination) {
239                                            list = (List<PasswordPolicy>)QueryUtil.list(q,
240                                                            getDialect(), start, end, false);
241    
242                                            Collections.sort(list);
243    
244                                            list = Collections.unmodifiableList(list);
245                                    }
246                                    else {
247                                            list = (List<PasswordPolicy>)QueryUtil.list(q,
248                                                            getDialect(), start, end);
249                                    }
250    
251                                    cacheResult(list);
252    
253                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
254                            }
255                            catch (Exception e) {
256                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
257    
258                                    throw processException(e);
259                            }
260                            finally {
261                                    closeSession(session);
262                            }
263                    }
264    
265                    return list;
266            }
267    
268            /**
269             * Returns the first password policy in the ordered set where uuid = &#63;.
270             *
271             * @param uuid the uuid
272             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
273             * @return the first matching password policy
274             * @throws NoSuchPasswordPolicyException if a matching password policy could not be found
275             */
276            @Override
277            public PasswordPolicy findByUuid_First(String uuid,
278                    OrderByComparator<PasswordPolicy> orderByComparator)
279                    throws NoSuchPasswordPolicyException {
280                    PasswordPolicy passwordPolicy = fetchByUuid_First(uuid,
281                                    orderByComparator);
282    
283                    if (passwordPolicy != null) {
284                            return passwordPolicy;
285                    }
286    
287                    StringBundler msg = new StringBundler(4);
288    
289                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
290    
291                    msg.append("uuid=");
292                    msg.append(uuid);
293    
294                    msg.append(StringPool.CLOSE_CURLY_BRACE);
295    
296                    throw new NoSuchPasswordPolicyException(msg.toString());
297            }
298    
299            /**
300             * Returns the first password policy in the ordered set where uuid = &#63;.
301             *
302             * @param uuid the uuid
303             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
304             * @return the first matching password policy, or <code>null</code> if a matching password policy could not be found
305             */
306            @Override
307            public PasswordPolicy fetchByUuid_First(String uuid,
308                    OrderByComparator<PasswordPolicy> orderByComparator) {
309                    List<PasswordPolicy> list = findByUuid(uuid, 0, 1, orderByComparator);
310    
311                    if (!list.isEmpty()) {
312                            return list.get(0);
313                    }
314    
315                    return null;
316            }
317    
318            /**
319             * Returns the last password policy in the ordered set where uuid = &#63;.
320             *
321             * @param uuid the uuid
322             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
323             * @return the last matching password policy
324             * @throws NoSuchPasswordPolicyException if a matching password policy could not be found
325             */
326            @Override
327            public PasswordPolicy findByUuid_Last(String uuid,
328                    OrderByComparator<PasswordPolicy> orderByComparator)
329                    throws NoSuchPasswordPolicyException {
330                    PasswordPolicy passwordPolicy = fetchByUuid_Last(uuid, orderByComparator);
331    
332                    if (passwordPolicy != null) {
333                            return passwordPolicy;
334                    }
335    
336                    StringBundler msg = new StringBundler(4);
337    
338                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
339    
340                    msg.append("uuid=");
341                    msg.append(uuid);
342    
343                    msg.append(StringPool.CLOSE_CURLY_BRACE);
344    
345                    throw new NoSuchPasswordPolicyException(msg.toString());
346            }
347    
348            /**
349             * Returns the last password policy in the ordered set where uuid = &#63;.
350             *
351             * @param uuid the uuid
352             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
353             * @return the last matching password policy, or <code>null</code> if a matching password policy could not be found
354             */
355            @Override
356            public PasswordPolicy fetchByUuid_Last(String uuid,
357                    OrderByComparator<PasswordPolicy> orderByComparator) {
358                    int count = countByUuid(uuid);
359    
360                    if (count == 0) {
361                            return null;
362                    }
363    
364                    List<PasswordPolicy> list = findByUuid(uuid, count - 1, count,
365                                    orderByComparator);
366    
367                    if (!list.isEmpty()) {
368                            return list.get(0);
369                    }
370    
371                    return null;
372            }
373    
374            /**
375             * Returns the password policies before and after the current password policy in the ordered set where uuid = &#63;.
376             *
377             * @param passwordPolicyId the primary key of the current password policy
378             * @param uuid the uuid
379             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
380             * @return the previous, current, and next password policy
381             * @throws NoSuchPasswordPolicyException if a password policy with the primary key could not be found
382             */
383            @Override
384            public PasswordPolicy[] findByUuid_PrevAndNext(long passwordPolicyId,
385                    String uuid, OrderByComparator<PasswordPolicy> orderByComparator)
386                    throws NoSuchPasswordPolicyException {
387                    PasswordPolicy passwordPolicy = findByPrimaryKey(passwordPolicyId);
388    
389                    Session session = null;
390    
391                    try {
392                            session = openSession();
393    
394                            PasswordPolicy[] array = new PasswordPolicyImpl[3];
395    
396                            array[0] = getByUuid_PrevAndNext(session, passwordPolicy, uuid,
397                                            orderByComparator, true);
398    
399                            array[1] = passwordPolicy;
400    
401                            array[2] = getByUuid_PrevAndNext(session, passwordPolicy, uuid,
402                                            orderByComparator, false);
403    
404                            return array;
405                    }
406                    catch (Exception e) {
407                            throw processException(e);
408                    }
409                    finally {
410                            closeSession(session);
411                    }
412            }
413    
414            protected PasswordPolicy getByUuid_PrevAndNext(Session session,
415                    PasswordPolicy passwordPolicy, String uuid,
416                    OrderByComparator<PasswordPolicy> orderByComparator, boolean previous) {
417                    StringBundler query = null;
418    
419                    if (orderByComparator != null) {
420                            query = new StringBundler(6 +
421                                            (orderByComparator.getOrderByFields().length * 6));
422                    }
423                    else {
424                            query = new StringBundler(3);
425                    }
426    
427                    query.append(_SQL_SELECT_PASSWORDPOLICY_WHERE);
428    
429                    boolean bindUuid = false;
430    
431                    if (uuid == null) {
432                            query.append(_FINDER_COLUMN_UUID_UUID_1);
433                    }
434                    else if (uuid.equals(StringPool.BLANK)) {
435                            query.append(_FINDER_COLUMN_UUID_UUID_3);
436                    }
437                    else {
438                            bindUuid = true;
439    
440                            query.append(_FINDER_COLUMN_UUID_UUID_2);
441                    }
442    
443                    if (orderByComparator != null) {
444                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
445    
446                            if (orderByConditionFields.length > 0) {
447                                    query.append(WHERE_AND);
448                            }
449    
450                            for (int i = 0; i < orderByConditionFields.length; i++) {
451                                    query.append(_ORDER_BY_ENTITY_ALIAS);
452                                    query.append(orderByConditionFields[i]);
453    
454                                    if ((i + 1) < orderByConditionFields.length) {
455                                            if (orderByComparator.isAscending() ^ previous) {
456                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
457                                            }
458                                            else {
459                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
460                                            }
461                                    }
462                                    else {
463                                            if (orderByComparator.isAscending() ^ previous) {
464                                                    query.append(WHERE_GREATER_THAN);
465                                            }
466                                            else {
467                                                    query.append(WHERE_LESSER_THAN);
468                                            }
469                                    }
470                            }
471    
472                            query.append(ORDER_BY_CLAUSE);
473    
474                            String[] orderByFields = orderByComparator.getOrderByFields();
475    
476                            for (int i = 0; i < orderByFields.length; i++) {
477                                    query.append(_ORDER_BY_ENTITY_ALIAS);
478                                    query.append(orderByFields[i]);
479    
480                                    if ((i + 1) < orderByFields.length) {
481                                            if (orderByComparator.isAscending() ^ previous) {
482                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
483                                            }
484                                            else {
485                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
486                                            }
487                                    }
488                                    else {
489                                            if (orderByComparator.isAscending() ^ previous) {
490                                                    query.append(ORDER_BY_ASC);
491                                            }
492                                            else {
493                                                    query.append(ORDER_BY_DESC);
494                                            }
495                                    }
496                            }
497                    }
498                    else {
499                            query.append(PasswordPolicyModelImpl.ORDER_BY_JPQL);
500                    }
501    
502                    String sql = query.toString();
503    
504                    Query q = session.createQuery(sql);
505    
506                    q.setFirstResult(0);
507                    q.setMaxResults(2);
508    
509                    QueryPos qPos = QueryPos.getInstance(q);
510    
511                    if (bindUuid) {
512                            qPos.add(uuid);
513                    }
514    
515                    if (orderByComparator != null) {
516                            Object[] values = orderByComparator.getOrderByConditionValues(passwordPolicy);
517    
518                            for (Object value : values) {
519                                    qPos.add(value);
520                            }
521                    }
522    
523                    List<PasswordPolicy> list = q.list();
524    
525                    if (list.size() == 2) {
526                            return list.get(1);
527                    }
528                    else {
529                            return null;
530                    }
531            }
532    
533            /**
534             * Returns all the password policies that the user has permission to view where uuid = &#63;.
535             *
536             * @param uuid the uuid
537             * @return the matching password policies that the user has permission to view
538             */
539            @Override
540            public List<PasswordPolicy> filterFindByUuid(String uuid) {
541                    return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
542            }
543    
544            /**
545             * Returns a range of all the password policies that the user has permission to view where uuid = &#63;.
546             *
547             * <p>
548             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
549             * </p>
550             *
551             * @param uuid the uuid
552             * @param start the lower bound of the range of password policies
553             * @param end the upper bound of the range of password policies (not inclusive)
554             * @return the range of matching password policies that the user has permission to view
555             */
556            @Override
557            public List<PasswordPolicy> filterFindByUuid(String uuid, int start, int end) {
558                    return filterFindByUuid(uuid, start, end, null);
559            }
560    
561            /**
562             * Returns an ordered range of all the password policies that the user has permissions to view where uuid = &#63;.
563             *
564             * <p>
565             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
566             * </p>
567             *
568             * @param uuid the uuid
569             * @param start the lower bound of the range of password policies
570             * @param end the upper bound of the range of password policies (not inclusive)
571             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
572             * @return the ordered range of matching password policies that the user has permission to view
573             */
574            @Override
575            public List<PasswordPolicy> filterFindByUuid(String uuid, int start,
576                    int end, OrderByComparator<PasswordPolicy> orderByComparator) {
577                    if (!InlineSQLHelperUtil.isEnabled()) {
578                            return findByUuid(uuid, start, end, orderByComparator);
579                    }
580    
581                    StringBundler query = null;
582    
583                    if (orderByComparator != null) {
584                            query = new StringBundler(3 +
585                                            (orderByComparator.getOrderByFields().length * 3));
586                    }
587                    else {
588                            query = new StringBundler(3);
589                    }
590    
591                    if (getDB().isSupportsInlineDistinct()) {
592                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_WHERE);
593                    }
594                    else {
595                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_1);
596                    }
597    
598                    boolean bindUuid = false;
599    
600                    if (uuid == null) {
601                            query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
602                    }
603                    else if (uuid.equals(StringPool.BLANK)) {
604                            query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
605                    }
606                    else {
607                            bindUuid = true;
608    
609                            query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
610                    }
611    
612                    if (!getDB().isSupportsInlineDistinct()) {
613                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_2);
614                    }
615    
616                    if (orderByComparator != null) {
617                            if (getDB().isSupportsInlineDistinct()) {
618                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
619                                            orderByComparator, true);
620                            }
621                            else {
622                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
623                                            orderByComparator, true);
624                            }
625                    }
626                    else {
627                            if (getDB().isSupportsInlineDistinct()) {
628                                    query.append(PasswordPolicyModelImpl.ORDER_BY_JPQL);
629                            }
630                            else {
631                                    query.append(PasswordPolicyModelImpl.ORDER_BY_SQL);
632                            }
633                    }
634    
635                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
636                                    PasswordPolicy.class.getName(),
637                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
638    
639                    Session session = null;
640    
641                    try {
642                            session = openSession();
643    
644                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
645    
646                            if (getDB().isSupportsInlineDistinct()) {
647                                    q.addEntity(_FILTER_ENTITY_ALIAS, PasswordPolicyImpl.class);
648                            }
649                            else {
650                                    q.addEntity(_FILTER_ENTITY_TABLE, PasswordPolicyImpl.class);
651                            }
652    
653                            QueryPos qPos = QueryPos.getInstance(q);
654    
655                            if (bindUuid) {
656                                    qPos.add(uuid);
657                            }
658    
659                            return (List<PasswordPolicy>)QueryUtil.list(q, getDialect(), start,
660                                    end);
661                    }
662                    catch (Exception e) {
663                            throw processException(e);
664                    }
665                    finally {
666                            closeSession(session);
667                    }
668            }
669    
670            /**
671             * Returns the password policies before and after the current password policy in the ordered set of password policies that the user has permission to view where uuid = &#63;.
672             *
673             * @param passwordPolicyId the primary key of the current password policy
674             * @param uuid the uuid
675             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
676             * @return the previous, current, and next password policy
677             * @throws NoSuchPasswordPolicyException if a password policy with the primary key could not be found
678             */
679            @Override
680            public PasswordPolicy[] filterFindByUuid_PrevAndNext(
681                    long passwordPolicyId, String uuid,
682                    OrderByComparator<PasswordPolicy> orderByComparator)
683                    throws NoSuchPasswordPolicyException {
684                    if (!InlineSQLHelperUtil.isEnabled()) {
685                            return findByUuid_PrevAndNext(passwordPolicyId, uuid,
686                                    orderByComparator);
687                    }
688    
689                    PasswordPolicy passwordPolicy = findByPrimaryKey(passwordPolicyId);
690    
691                    Session session = null;
692    
693                    try {
694                            session = openSession();
695    
696                            PasswordPolicy[] array = new PasswordPolicyImpl[3];
697    
698                            array[0] = filterGetByUuid_PrevAndNext(session, passwordPolicy,
699                                            uuid, orderByComparator, true);
700    
701                            array[1] = passwordPolicy;
702    
703                            array[2] = filterGetByUuid_PrevAndNext(session, passwordPolicy,
704                                            uuid, orderByComparator, false);
705    
706                            return array;
707                    }
708                    catch (Exception e) {
709                            throw processException(e);
710                    }
711                    finally {
712                            closeSession(session);
713                    }
714            }
715    
716            protected PasswordPolicy filterGetByUuid_PrevAndNext(Session session,
717                    PasswordPolicy passwordPolicy, String uuid,
718                    OrderByComparator<PasswordPolicy> orderByComparator, boolean previous) {
719                    StringBundler query = null;
720    
721                    if (orderByComparator != null) {
722                            query = new StringBundler(6 +
723                                            (orderByComparator.getOrderByFields().length * 6));
724                    }
725                    else {
726                            query = new StringBundler(3);
727                    }
728    
729                    if (getDB().isSupportsInlineDistinct()) {
730                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_WHERE);
731                    }
732                    else {
733                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_1);
734                    }
735    
736                    boolean bindUuid = false;
737    
738                    if (uuid == null) {
739                            query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
740                    }
741                    else if (uuid.equals(StringPool.BLANK)) {
742                            query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
743                    }
744                    else {
745                            bindUuid = true;
746    
747                            query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
748                    }
749    
750                    if (!getDB().isSupportsInlineDistinct()) {
751                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_2);
752                    }
753    
754                    if (orderByComparator != null) {
755                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
756    
757                            if (orderByConditionFields.length > 0) {
758                                    query.append(WHERE_AND);
759                            }
760    
761                            for (int i = 0; i < orderByConditionFields.length; i++) {
762                                    if (getDB().isSupportsInlineDistinct()) {
763                                            query.append(_ORDER_BY_ENTITY_ALIAS);
764                                    }
765                                    else {
766                                            query.append(_ORDER_BY_ENTITY_TABLE);
767                                    }
768    
769                                    query.append(orderByConditionFields[i]);
770    
771                                    if ((i + 1) < orderByConditionFields.length) {
772                                            if (orderByComparator.isAscending() ^ previous) {
773                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
774                                            }
775                                            else {
776                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
777                                            }
778                                    }
779                                    else {
780                                            if (orderByComparator.isAscending() ^ previous) {
781                                                    query.append(WHERE_GREATER_THAN);
782                                            }
783                                            else {
784                                                    query.append(WHERE_LESSER_THAN);
785                                            }
786                                    }
787                            }
788    
789                            query.append(ORDER_BY_CLAUSE);
790    
791                            String[] orderByFields = orderByComparator.getOrderByFields();
792    
793                            for (int i = 0; i < orderByFields.length; i++) {
794                                    if (getDB().isSupportsInlineDistinct()) {
795                                            query.append(_ORDER_BY_ENTITY_ALIAS);
796                                    }
797                                    else {
798                                            query.append(_ORDER_BY_ENTITY_TABLE);
799                                    }
800    
801                                    query.append(orderByFields[i]);
802    
803                                    if ((i + 1) < orderByFields.length) {
804                                            if (orderByComparator.isAscending() ^ previous) {
805                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
806                                            }
807                                            else {
808                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
809                                            }
810                                    }
811                                    else {
812                                            if (orderByComparator.isAscending() ^ previous) {
813                                                    query.append(ORDER_BY_ASC);
814                                            }
815                                            else {
816                                                    query.append(ORDER_BY_DESC);
817                                            }
818                                    }
819                            }
820                    }
821                    else {
822                            if (getDB().isSupportsInlineDistinct()) {
823                                    query.append(PasswordPolicyModelImpl.ORDER_BY_JPQL);
824                            }
825                            else {
826                                    query.append(PasswordPolicyModelImpl.ORDER_BY_SQL);
827                            }
828                    }
829    
830                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
831                                    PasswordPolicy.class.getName(),
832                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
833    
834                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
835    
836                    q.setFirstResult(0);
837                    q.setMaxResults(2);
838    
839                    if (getDB().isSupportsInlineDistinct()) {
840                            q.addEntity(_FILTER_ENTITY_ALIAS, PasswordPolicyImpl.class);
841                    }
842                    else {
843                            q.addEntity(_FILTER_ENTITY_TABLE, PasswordPolicyImpl.class);
844                    }
845    
846                    QueryPos qPos = QueryPos.getInstance(q);
847    
848                    if (bindUuid) {
849                            qPos.add(uuid);
850                    }
851    
852                    if (orderByComparator != null) {
853                            Object[] values = orderByComparator.getOrderByConditionValues(passwordPolicy);
854    
855                            for (Object value : values) {
856                                    qPos.add(value);
857                            }
858                    }
859    
860                    List<PasswordPolicy> list = q.list();
861    
862                    if (list.size() == 2) {
863                            return list.get(1);
864                    }
865                    else {
866                            return null;
867                    }
868            }
869    
870            /**
871             * Removes all the password policies where uuid = &#63; from the database.
872             *
873             * @param uuid the uuid
874             */
875            @Override
876            public void removeByUuid(String uuid) {
877                    for (PasswordPolicy passwordPolicy : findByUuid(uuid,
878                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
879                            remove(passwordPolicy);
880                    }
881            }
882    
883            /**
884             * Returns the number of password policies where uuid = &#63;.
885             *
886             * @param uuid the uuid
887             * @return the number of matching password policies
888             */
889            @Override
890            public int countByUuid(String uuid) {
891                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
892    
893                    Object[] finderArgs = new Object[] { uuid };
894    
895                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
896                                    this);
897    
898                    if (count == null) {
899                            StringBundler query = new StringBundler(2);
900    
901                            query.append(_SQL_COUNT_PASSWORDPOLICY_WHERE);
902    
903                            boolean bindUuid = false;
904    
905                            if (uuid == null) {
906                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
907                            }
908                            else if (uuid.equals(StringPool.BLANK)) {
909                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
910                            }
911                            else {
912                                    bindUuid = true;
913    
914                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
915                            }
916    
917                            String sql = query.toString();
918    
919                            Session session = null;
920    
921                            try {
922                                    session = openSession();
923    
924                                    Query q = session.createQuery(sql);
925    
926                                    QueryPos qPos = QueryPos.getInstance(q);
927    
928                                    if (bindUuid) {
929                                            qPos.add(uuid);
930                                    }
931    
932                                    count = (Long)q.uniqueResult();
933    
934                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
935                            }
936                            catch (Exception e) {
937                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
938    
939                                    throw processException(e);
940                            }
941                            finally {
942                                    closeSession(session);
943                            }
944                    }
945    
946                    return count.intValue();
947            }
948    
949            /**
950             * Returns the number of password policies that the user has permission to view where uuid = &#63;.
951             *
952             * @param uuid the uuid
953             * @return the number of matching password policies that the user has permission to view
954             */
955            @Override
956            public int filterCountByUuid(String uuid) {
957                    if (!InlineSQLHelperUtil.isEnabled()) {
958                            return countByUuid(uuid);
959                    }
960    
961                    StringBundler query = new StringBundler(2);
962    
963                    query.append(_FILTER_SQL_COUNT_PASSWORDPOLICY_WHERE);
964    
965                    boolean bindUuid = false;
966    
967                    if (uuid == null) {
968                            query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
969                    }
970                    else if (uuid.equals(StringPool.BLANK)) {
971                            query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
972                    }
973                    else {
974                            bindUuid = true;
975    
976                            query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
977                    }
978    
979                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
980                                    PasswordPolicy.class.getName(),
981                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
982    
983                    Session session = null;
984    
985                    try {
986                            session = openSession();
987    
988                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
989    
990                            q.addScalar(COUNT_COLUMN_NAME,
991                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
992    
993                            QueryPos qPos = QueryPos.getInstance(q);
994    
995                            if (bindUuid) {
996                                    qPos.add(uuid);
997                            }
998    
999                            Long count = (Long)q.uniqueResult();
1000    
1001                            return count.intValue();
1002                    }
1003                    catch (Exception e) {
1004                            throw processException(e);
1005                    }
1006                    finally {
1007                            closeSession(session);
1008                    }
1009            }
1010    
1011            private static final String _FINDER_COLUMN_UUID_UUID_1 = "passwordPolicy.uuid IS NULL";
1012            private static final String _FINDER_COLUMN_UUID_UUID_2 = "passwordPolicy.uuid = ?";
1013            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(passwordPolicy.uuid IS NULL OR passwordPolicy.uuid = '')";
1014            private static final String _FINDER_COLUMN_UUID_UUID_1_SQL = "passwordPolicy.uuid_ IS NULL";
1015            private static final String _FINDER_COLUMN_UUID_UUID_2_SQL = "passwordPolicy.uuid_ = ?";
1016            private static final String _FINDER_COLUMN_UUID_UUID_3_SQL = "(passwordPolicy.uuid_ IS NULL OR passwordPolicy.uuid_ = '')";
1017            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
1018                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
1019                            PasswordPolicyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1020                            "findByUuid_C",
1021                            new String[] {
1022                                    String.class.getName(), Long.class.getName(),
1023                                    
1024                            Integer.class.getName(), Integer.class.getName(),
1025                                    OrderByComparator.class.getName()
1026                            });
1027            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
1028                    new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
1029                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
1030                            PasswordPolicyImpl.class,
1031                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
1032                            new String[] { String.class.getName(), Long.class.getName() },
1033                            PasswordPolicyModelImpl.UUID_COLUMN_BITMASK |
1034                            PasswordPolicyModelImpl.COMPANYID_COLUMN_BITMASK);
1035            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
1036                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED, Long.class,
1037                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
1038                            new String[] { String.class.getName(), Long.class.getName() });
1039    
1040            /**
1041             * Returns all the password policies where uuid = &#63; and companyId = &#63;.
1042             *
1043             * @param uuid the uuid
1044             * @param companyId the company ID
1045             * @return the matching password policies
1046             */
1047            @Override
1048            public List<PasswordPolicy> findByUuid_C(String uuid, long companyId) {
1049                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1050                            QueryUtil.ALL_POS, null);
1051            }
1052    
1053            /**
1054             * Returns a range of all the password policies where uuid = &#63; and companyId = &#63;.
1055             *
1056             * <p>
1057             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
1058             * </p>
1059             *
1060             * @param uuid the uuid
1061             * @param companyId the company ID
1062             * @param start the lower bound of the range of password policies
1063             * @param end the upper bound of the range of password policies (not inclusive)
1064             * @return the range of matching password policies
1065             */
1066            @Override
1067            public List<PasswordPolicy> findByUuid_C(String uuid, long companyId,
1068                    int start, int end) {
1069                    return findByUuid_C(uuid, companyId, start, end, null);
1070            }
1071    
1072            /**
1073             * Returns an ordered range of all the password policies where uuid = &#63; and companyId = &#63;.
1074             *
1075             * <p>
1076             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
1077             * </p>
1078             *
1079             * @param uuid the uuid
1080             * @param companyId the company ID
1081             * @param start the lower bound of the range of password policies
1082             * @param end the upper bound of the range of password policies (not inclusive)
1083             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1084             * @return the ordered range of matching password policies
1085             */
1086            @Override
1087            public List<PasswordPolicy> findByUuid_C(String uuid, long companyId,
1088                    int start, int end, OrderByComparator<PasswordPolicy> orderByComparator) {
1089                    boolean pagination = true;
1090                    FinderPath finderPath = null;
1091                    Object[] finderArgs = null;
1092    
1093                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1094                                    (orderByComparator == null)) {
1095                            pagination = false;
1096                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1097                            finderArgs = new Object[] { uuid, companyId };
1098                    }
1099                    else {
1100                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1101                            finderArgs = new Object[] {
1102                                            uuid, companyId,
1103                                            
1104                                            start, end, orderByComparator
1105                                    };
1106                    }
1107    
1108                    List<PasswordPolicy> list = (List<PasswordPolicy>)FinderCacheUtil.getResult(finderPath,
1109                                    finderArgs, this);
1110    
1111                    if ((list != null) && !list.isEmpty()) {
1112                            for (PasswordPolicy passwordPolicy : list) {
1113                                    if (!Validator.equals(uuid, passwordPolicy.getUuid()) ||
1114                                                    (companyId != passwordPolicy.getCompanyId())) {
1115                                            list = null;
1116    
1117                                            break;
1118                                    }
1119                            }
1120                    }
1121    
1122                    if (list == null) {
1123                            StringBundler query = null;
1124    
1125                            if (orderByComparator != null) {
1126                                    query = new StringBundler(4 +
1127                                                    (orderByComparator.getOrderByFields().length * 3));
1128                            }
1129                            else {
1130                                    query = new StringBundler(4);
1131                            }
1132    
1133                            query.append(_SQL_SELECT_PASSWORDPOLICY_WHERE);
1134    
1135                            boolean bindUuid = false;
1136    
1137                            if (uuid == null) {
1138                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1139                            }
1140                            else if (uuid.equals(StringPool.BLANK)) {
1141                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1142                            }
1143                            else {
1144                                    bindUuid = true;
1145    
1146                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1147                            }
1148    
1149                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1150    
1151                            if (orderByComparator != null) {
1152                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1153                                            orderByComparator);
1154                            }
1155                            else
1156                             if (pagination) {
1157                                    query.append(PasswordPolicyModelImpl.ORDER_BY_JPQL);
1158                            }
1159    
1160                            String sql = query.toString();
1161    
1162                            Session session = null;
1163    
1164                            try {
1165                                    session = openSession();
1166    
1167                                    Query q = session.createQuery(sql);
1168    
1169                                    QueryPos qPos = QueryPos.getInstance(q);
1170    
1171                                    if (bindUuid) {
1172                                            qPos.add(uuid);
1173                                    }
1174    
1175                                    qPos.add(companyId);
1176    
1177                                    if (!pagination) {
1178                                            list = (List<PasswordPolicy>)QueryUtil.list(q,
1179                                                            getDialect(), start, end, false);
1180    
1181                                            Collections.sort(list);
1182    
1183                                            list = Collections.unmodifiableList(list);
1184                                    }
1185                                    else {
1186                                            list = (List<PasswordPolicy>)QueryUtil.list(q,
1187                                                            getDialect(), start, end);
1188                                    }
1189    
1190                                    cacheResult(list);
1191    
1192                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1193                            }
1194                            catch (Exception e) {
1195                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1196    
1197                                    throw processException(e);
1198                            }
1199                            finally {
1200                                    closeSession(session);
1201                            }
1202                    }
1203    
1204                    return list;
1205            }
1206    
1207            /**
1208             * Returns the first password policy in the ordered set where uuid = &#63; and companyId = &#63;.
1209             *
1210             * @param uuid the uuid
1211             * @param companyId the company ID
1212             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1213             * @return the first matching password policy
1214             * @throws NoSuchPasswordPolicyException if a matching password policy could not be found
1215             */
1216            @Override
1217            public PasswordPolicy findByUuid_C_First(String uuid, long companyId,
1218                    OrderByComparator<PasswordPolicy> orderByComparator)
1219                    throws NoSuchPasswordPolicyException {
1220                    PasswordPolicy passwordPolicy = fetchByUuid_C_First(uuid, companyId,
1221                                    orderByComparator);
1222    
1223                    if (passwordPolicy != null) {
1224                            return passwordPolicy;
1225                    }
1226    
1227                    StringBundler msg = new StringBundler(6);
1228    
1229                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1230    
1231                    msg.append("uuid=");
1232                    msg.append(uuid);
1233    
1234                    msg.append(", companyId=");
1235                    msg.append(companyId);
1236    
1237                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1238    
1239                    throw new NoSuchPasswordPolicyException(msg.toString());
1240            }
1241    
1242            /**
1243             * Returns the first password policy in the ordered set where uuid = &#63; and companyId = &#63;.
1244             *
1245             * @param uuid the uuid
1246             * @param companyId the company ID
1247             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1248             * @return the first matching password policy, or <code>null</code> if a matching password policy could not be found
1249             */
1250            @Override
1251            public PasswordPolicy fetchByUuid_C_First(String uuid, long companyId,
1252                    OrderByComparator<PasswordPolicy> orderByComparator) {
1253                    List<PasswordPolicy> list = findByUuid_C(uuid, companyId, 0, 1,
1254                                    orderByComparator);
1255    
1256                    if (!list.isEmpty()) {
1257                            return list.get(0);
1258                    }
1259    
1260                    return null;
1261            }
1262    
1263            /**
1264             * Returns the last password policy in the ordered set where uuid = &#63; and companyId = &#63;.
1265             *
1266             * @param uuid the uuid
1267             * @param companyId the company ID
1268             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1269             * @return the last matching password policy
1270             * @throws NoSuchPasswordPolicyException if a matching password policy could not be found
1271             */
1272            @Override
1273            public PasswordPolicy findByUuid_C_Last(String uuid, long companyId,
1274                    OrderByComparator<PasswordPolicy> orderByComparator)
1275                    throws NoSuchPasswordPolicyException {
1276                    PasswordPolicy passwordPolicy = fetchByUuid_C_Last(uuid, companyId,
1277                                    orderByComparator);
1278    
1279                    if (passwordPolicy != null) {
1280                            return passwordPolicy;
1281                    }
1282    
1283                    StringBundler msg = new StringBundler(6);
1284    
1285                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1286    
1287                    msg.append("uuid=");
1288                    msg.append(uuid);
1289    
1290                    msg.append(", companyId=");
1291                    msg.append(companyId);
1292    
1293                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1294    
1295                    throw new NoSuchPasswordPolicyException(msg.toString());
1296            }
1297    
1298            /**
1299             * Returns the last password policy in the ordered set where uuid = &#63; and companyId = &#63;.
1300             *
1301             * @param uuid the uuid
1302             * @param companyId the company ID
1303             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1304             * @return the last matching password policy, or <code>null</code> if a matching password policy could not be found
1305             */
1306            @Override
1307            public PasswordPolicy fetchByUuid_C_Last(String uuid, long companyId,
1308                    OrderByComparator<PasswordPolicy> orderByComparator) {
1309                    int count = countByUuid_C(uuid, companyId);
1310    
1311                    if (count == 0) {
1312                            return null;
1313                    }
1314    
1315                    List<PasswordPolicy> list = findByUuid_C(uuid, companyId, count - 1,
1316                                    count, orderByComparator);
1317    
1318                    if (!list.isEmpty()) {
1319                            return list.get(0);
1320                    }
1321    
1322                    return null;
1323            }
1324    
1325            /**
1326             * Returns the password policies before and after the current password policy in the ordered set where uuid = &#63; and companyId = &#63;.
1327             *
1328             * @param passwordPolicyId the primary key of the current password policy
1329             * @param uuid the uuid
1330             * @param companyId the company ID
1331             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1332             * @return the previous, current, and next password policy
1333             * @throws NoSuchPasswordPolicyException if a password policy with the primary key could not be found
1334             */
1335            @Override
1336            public PasswordPolicy[] findByUuid_C_PrevAndNext(long passwordPolicyId,
1337                    String uuid, long companyId,
1338                    OrderByComparator<PasswordPolicy> orderByComparator)
1339                    throws NoSuchPasswordPolicyException {
1340                    PasswordPolicy passwordPolicy = findByPrimaryKey(passwordPolicyId);
1341    
1342                    Session session = null;
1343    
1344                    try {
1345                            session = openSession();
1346    
1347                            PasswordPolicy[] array = new PasswordPolicyImpl[3];
1348    
1349                            array[0] = getByUuid_C_PrevAndNext(session, passwordPolicy, uuid,
1350                                            companyId, orderByComparator, true);
1351    
1352                            array[1] = passwordPolicy;
1353    
1354                            array[2] = getByUuid_C_PrevAndNext(session, passwordPolicy, uuid,
1355                                            companyId, orderByComparator, false);
1356    
1357                            return array;
1358                    }
1359                    catch (Exception e) {
1360                            throw processException(e);
1361                    }
1362                    finally {
1363                            closeSession(session);
1364                    }
1365            }
1366    
1367            protected PasswordPolicy getByUuid_C_PrevAndNext(Session session,
1368                    PasswordPolicy passwordPolicy, String uuid, long companyId,
1369                    OrderByComparator<PasswordPolicy> orderByComparator, boolean previous) {
1370                    StringBundler query = null;
1371    
1372                    if (orderByComparator != null) {
1373                            query = new StringBundler(6 +
1374                                            (orderByComparator.getOrderByFields().length * 6));
1375                    }
1376                    else {
1377                            query = new StringBundler(3);
1378                    }
1379    
1380                    query.append(_SQL_SELECT_PASSWORDPOLICY_WHERE);
1381    
1382                    boolean bindUuid = false;
1383    
1384                    if (uuid == null) {
1385                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1386                    }
1387                    else if (uuid.equals(StringPool.BLANK)) {
1388                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1389                    }
1390                    else {
1391                            bindUuid = true;
1392    
1393                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1394                    }
1395    
1396                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1397    
1398                    if (orderByComparator != null) {
1399                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1400    
1401                            if (orderByConditionFields.length > 0) {
1402                                    query.append(WHERE_AND);
1403                            }
1404    
1405                            for (int i = 0; i < orderByConditionFields.length; i++) {
1406                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1407                                    query.append(orderByConditionFields[i]);
1408    
1409                                    if ((i + 1) < orderByConditionFields.length) {
1410                                            if (orderByComparator.isAscending() ^ previous) {
1411                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1412                                            }
1413                                            else {
1414                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1415                                            }
1416                                    }
1417                                    else {
1418                                            if (orderByComparator.isAscending() ^ previous) {
1419                                                    query.append(WHERE_GREATER_THAN);
1420                                            }
1421                                            else {
1422                                                    query.append(WHERE_LESSER_THAN);
1423                                            }
1424                                    }
1425                            }
1426    
1427                            query.append(ORDER_BY_CLAUSE);
1428    
1429                            String[] orderByFields = orderByComparator.getOrderByFields();
1430    
1431                            for (int i = 0; i < orderByFields.length; i++) {
1432                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1433                                    query.append(orderByFields[i]);
1434    
1435                                    if ((i + 1) < orderByFields.length) {
1436                                            if (orderByComparator.isAscending() ^ previous) {
1437                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1438                                            }
1439                                            else {
1440                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1441                                            }
1442                                    }
1443                                    else {
1444                                            if (orderByComparator.isAscending() ^ previous) {
1445                                                    query.append(ORDER_BY_ASC);
1446                                            }
1447                                            else {
1448                                                    query.append(ORDER_BY_DESC);
1449                                            }
1450                                    }
1451                            }
1452                    }
1453                    else {
1454                            query.append(PasswordPolicyModelImpl.ORDER_BY_JPQL);
1455                    }
1456    
1457                    String sql = query.toString();
1458    
1459                    Query q = session.createQuery(sql);
1460    
1461                    q.setFirstResult(0);
1462                    q.setMaxResults(2);
1463    
1464                    QueryPos qPos = QueryPos.getInstance(q);
1465    
1466                    if (bindUuid) {
1467                            qPos.add(uuid);
1468                    }
1469    
1470                    qPos.add(companyId);
1471    
1472                    if (orderByComparator != null) {
1473                            Object[] values = orderByComparator.getOrderByConditionValues(passwordPolicy);
1474    
1475                            for (Object value : values) {
1476                                    qPos.add(value);
1477                            }
1478                    }
1479    
1480                    List<PasswordPolicy> list = q.list();
1481    
1482                    if (list.size() == 2) {
1483                            return list.get(1);
1484                    }
1485                    else {
1486                            return null;
1487                    }
1488            }
1489    
1490            /**
1491             * Returns all the password policies that the user has permission to view where uuid = &#63; and companyId = &#63;.
1492             *
1493             * @param uuid the uuid
1494             * @param companyId the company ID
1495             * @return the matching password policies that the user has permission to view
1496             */
1497            @Override
1498            public List<PasswordPolicy> filterFindByUuid_C(String uuid, long companyId) {
1499                    return filterFindByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1500                            QueryUtil.ALL_POS, null);
1501            }
1502    
1503            /**
1504             * Returns a range of all the password policies that the user has permission to view where uuid = &#63; and companyId = &#63;.
1505             *
1506             * <p>
1507             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
1508             * </p>
1509             *
1510             * @param uuid the uuid
1511             * @param companyId the company ID
1512             * @param start the lower bound of the range of password policies
1513             * @param end the upper bound of the range of password policies (not inclusive)
1514             * @return the range of matching password policies that the user has permission to view
1515             */
1516            @Override
1517            public List<PasswordPolicy> filterFindByUuid_C(String uuid, long companyId,
1518                    int start, int end) {
1519                    return filterFindByUuid_C(uuid, companyId, start, end, null);
1520            }
1521    
1522            /**
1523             * Returns an ordered range of all the password policies that the user has permissions to view where uuid = &#63; and companyId = &#63;.
1524             *
1525             * <p>
1526             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
1527             * </p>
1528             *
1529             * @param uuid the uuid
1530             * @param companyId the company ID
1531             * @param start the lower bound of the range of password policies
1532             * @param end the upper bound of the range of password policies (not inclusive)
1533             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1534             * @return the ordered range of matching password policies that the user has permission to view
1535             */
1536            @Override
1537            public List<PasswordPolicy> filterFindByUuid_C(String uuid, long companyId,
1538                    int start, int end, OrderByComparator<PasswordPolicy> orderByComparator) {
1539                    if (!InlineSQLHelperUtil.isEnabled()) {
1540                            return findByUuid_C(uuid, companyId, start, end, orderByComparator);
1541                    }
1542    
1543                    StringBundler query = null;
1544    
1545                    if (orderByComparator != null) {
1546                            query = new StringBundler(4 +
1547                                            (orderByComparator.getOrderByFields().length * 3));
1548                    }
1549                    else {
1550                            query = new StringBundler(4);
1551                    }
1552    
1553                    if (getDB().isSupportsInlineDistinct()) {
1554                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_WHERE);
1555                    }
1556                    else {
1557                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_1);
1558                    }
1559    
1560                    boolean bindUuid = false;
1561    
1562                    if (uuid == null) {
1563                            query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1564                    }
1565                    else if (uuid.equals(StringPool.BLANK)) {
1566                            query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1567                    }
1568                    else {
1569                            bindUuid = true;
1570    
1571                            query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1572                    }
1573    
1574                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1575    
1576                    if (!getDB().isSupportsInlineDistinct()) {
1577                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_2);
1578                    }
1579    
1580                    if (orderByComparator != null) {
1581                            if (getDB().isSupportsInlineDistinct()) {
1582                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1583                                            orderByComparator, true);
1584                            }
1585                            else {
1586                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1587                                            orderByComparator, true);
1588                            }
1589                    }
1590                    else {
1591                            if (getDB().isSupportsInlineDistinct()) {
1592                                    query.append(PasswordPolicyModelImpl.ORDER_BY_JPQL);
1593                            }
1594                            else {
1595                                    query.append(PasswordPolicyModelImpl.ORDER_BY_SQL);
1596                            }
1597                    }
1598    
1599                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1600                                    PasswordPolicy.class.getName(),
1601                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1602    
1603                    Session session = null;
1604    
1605                    try {
1606                            session = openSession();
1607    
1608                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
1609    
1610                            if (getDB().isSupportsInlineDistinct()) {
1611                                    q.addEntity(_FILTER_ENTITY_ALIAS, PasswordPolicyImpl.class);
1612                            }
1613                            else {
1614                                    q.addEntity(_FILTER_ENTITY_TABLE, PasswordPolicyImpl.class);
1615                            }
1616    
1617                            QueryPos qPos = QueryPos.getInstance(q);
1618    
1619                            if (bindUuid) {
1620                                    qPos.add(uuid);
1621                            }
1622    
1623                            qPos.add(companyId);
1624    
1625                            return (List<PasswordPolicy>)QueryUtil.list(q, getDialect(), start,
1626                                    end);
1627                    }
1628                    catch (Exception e) {
1629                            throw processException(e);
1630                    }
1631                    finally {
1632                            closeSession(session);
1633                    }
1634            }
1635    
1636            /**
1637             * Returns the password policies before and after the current password policy in the ordered set of password policies that the user has permission to view where uuid = &#63; and companyId = &#63;.
1638             *
1639             * @param passwordPolicyId the primary key of the current password policy
1640             * @param uuid the uuid
1641             * @param companyId the company ID
1642             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1643             * @return the previous, current, and next password policy
1644             * @throws NoSuchPasswordPolicyException if a password policy with the primary key could not be found
1645             */
1646            @Override
1647            public PasswordPolicy[] filterFindByUuid_C_PrevAndNext(
1648                    long passwordPolicyId, String uuid, long companyId,
1649                    OrderByComparator<PasswordPolicy> orderByComparator)
1650                    throws NoSuchPasswordPolicyException {
1651                    if (!InlineSQLHelperUtil.isEnabled()) {
1652                            return findByUuid_C_PrevAndNext(passwordPolicyId, uuid, companyId,
1653                                    orderByComparator);
1654                    }
1655    
1656                    PasswordPolicy passwordPolicy = findByPrimaryKey(passwordPolicyId);
1657    
1658                    Session session = null;
1659    
1660                    try {
1661                            session = openSession();
1662    
1663                            PasswordPolicy[] array = new PasswordPolicyImpl[3];
1664    
1665                            array[0] = filterGetByUuid_C_PrevAndNext(session, passwordPolicy,
1666                                            uuid, companyId, orderByComparator, true);
1667    
1668                            array[1] = passwordPolicy;
1669    
1670                            array[2] = filterGetByUuid_C_PrevAndNext(session, passwordPolicy,
1671                                            uuid, companyId, orderByComparator, false);
1672    
1673                            return array;
1674                    }
1675                    catch (Exception e) {
1676                            throw processException(e);
1677                    }
1678                    finally {
1679                            closeSession(session);
1680                    }
1681            }
1682    
1683            protected PasswordPolicy filterGetByUuid_C_PrevAndNext(Session session,
1684                    PasswordPolicy passwordPolicy, String uuid, long companyId,
1685                    OrderByComparator<PasswordPolicy> orderByComparator, boolean previous) {
1686                    StringBundler query = null;
1687    
1688                    if (orderByComparator != null) {
1689                            query = new StringBundler(6 +
1690                                            (orderByComparator.getOrderByFields().length * 6));
1691                    }
1692                    else {
1693                            query = new StringBundler(3);
1694                    }
1695    
1696                    if (getDB().isSupportsInlineDistinct()) {
1697                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_WHERE);
1698                    }
1699                    else {
1700                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_1);
1701                    }
1702    
1703                    boolean bindUuid = false;
1704    
1705                    if (uuid == null) {
1706                            query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1707                    }
1708                    else if (uuid.equals(StringPool.BLANK)) {
1709                            query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1710                    }
1711                    else {
1712                            bindUuid = true;
1713    
1714                            query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1715                    }
1716    
1717                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1718    
1719                    if (!getDB().isSupportsInlineDistinct()) {
1720                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_2);
1721                    }
1722    
1723                    if (orderByComparator != null) {
1724                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1725    
1726                            if (orderByConditionFields.length > 0) {
1727                                    query.append(WHERE_AND);
1728                            }
1729    
1730                            for (int i = 0; i < orderByConditionFields.length; i++) {
1731                                    if (getDB().isSupportsInlineDistinct()) {
1732                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1733                                    }
1734                                    else {
1735                                            query.append(_ORDER_BY_ENTITY_TABLE);
1736                                    }
1737    
1738                                    query.append(orderByConditionFields[i]);
1739    
1740                                    if ((i + 1) < orderByConditionFields.length) {
1741                                            if (orderByComparator.isAscending() ^ previous) {
1742                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1743                                            }
1744                                            else {
1745                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1746                                            }
1747                                    }
1748                                    else {
1749                                            if (orderByComparator.isAscending() ^ previous) {
1750                                                    query.append(WHERE_GREATER_THAN);
1751                                            }
1752                                            else {
1753                                                    query.append(WHERE_LESSER_THAN);
1754                                            }
1755                                    }
1756                            }
1757    
1758                            query.append(ORDER_BY_CLAUSE);
1759    
1760                            String[] orderByFields = orderByComparator.getOrderByFields();
1761    
1762                            for (int i = 0; i < orderByFields.length; i++) {
1763                                    if (getDB().isSupportsInlineDistinct()) {
1764                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1765                                    }
1766                                    else {
1767                                            query.append(_ORDER_BY_ENTITY_TABLE);
1768                                    }
1769    
1770                                    query.append(orderByFields[i]);
1771    
1772                                    if ((i + 1) < orderByFields.length) {
1773                                            if (orderByComparator.isAscending() ^ previous) {
1774                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1775                                            }
1776                                            else {
1777                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1778                                            }
1779                                    }
1780                                    else {
1781                                            if (orderByComparator.isAscending() ^ previous) {
1782                                                    query.append(ORDER_BY_ASC);
1783                                            }
1784                                            else {
1785                                                    query.append(ORDER_BY_DESC);
1786                                            }
1787                                    }
1788                            }
1789                    }
1790                    else {
1791                            if (getDB().isSupportsInlineDistinct()) {
1792                                    query.append(PasswordPolicyModelImpl.ORDER_BY_JPQL);
1793                            }
1794                            else {
1795                                    query.append(PasswordPolicyModelImpl.ORDER_BY_SQL);
1796                            }
1797                    }
1798    
1799                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1800                                    PasswordPolicy.class.getName(),
1801                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1802    
1803                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
1804    
1805                    q.setFirstResult(0);
1806                    q.setMaxResults(2);
1807    
1808                    if (getDB().isSupportsInlineDistinct()) {
1809                            q.addEntity(_FILTER_ENTITY_ALIAS, PasswordPolicyImpl.class);
1810                    }
1811                    else {
1812                            q.addEntity(_FILTER_ENTITY_TABLE, PasswordPolicyImpl.class);
1813                    }
1814    
1815                    QueryPos qPos = QueryPos.getInstance(q);
1816    
1817                    if (bindUuid) {
1818                            qPos.add(uuid);
1819                    }
1820    
1821                    qPos.add(companyId);
1822    
1823                    if (orderByComparator != null) {
1824                            Object[] values = orderByComparator.getOrderByConditionValues(passwordPolicy);
1825    
1826                            for (Object value : values) {
1827                                    qPos.add(value);
1828                            }
1829                    }
1830    
1831                    List<PasswordPolicy> list = q.list();
1832    
1833                    if (list.size() == 2) {
1834                            return list.get(1);
1835                    }
1836                    else {
1837                            return null;
1838                    }
1839            }
1840    
1841            /**
1842             * Removes all the password policies where uuid = &#63; and companyId = &#63; from the database.
1843             *
1844             * @param uuid the uuid
1845             * @param companyId the company ID
1846             */
1847            @Override
1848            public void removeByUuid_C(String uuid, long companyId) {
1849                    for (PasswordPolicy passwordPolicy : findByUuid_C(uuid, companyId,
1850                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1851                            remove(passwordPolicy);
1852                    }
1853            }
1854    
1855            /**
1856             * Returns the number of password policies where uuid = &#63; and companyId = &#63;.
1857             *
1858             * @param uuid the uuid
1859             * @param companyId the company ID
1860             * @return the number of matching password policies
1861             */
1862            @Override
1863            public int countByUuid_C(String uuid, long companyId) {
1864                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1865    
1866                    Object[] finderArgs = new Object[] { uuid, companyId };
1867    
1868                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1869                                    this);
1870    
1871                    if (count == null) {
1872                            StringBundler query = new StringBundler(3);
1873    
1874                            query.append(_SQL_COUNT_PASSWORDPOLICY_WHERE);
1875    
1876                            boolean bindUuid = false;
1877    
1878                            if (uuid == null) {
1879                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1880                            }
1881                            else if (uuid.equals(StringPool.BLANK)) {
1882                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1883                            }
1884                            else {
1885                                    bindUuid = true;
1886    
1887                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1888                            }
1889    
1890                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1891    
1892                            String sql = query.toString();
1893    
1894                            Session session = null;
1895    
1896                            try {
1897                                    session = openSession();
1898    
1899                                    Query q = session.createQuery(sql);
1900    
1901                                    QueryPos qPos = QueryPos.getInstance(q);
1902    
1903                                    if (bindUuid) {
1904                                            qPos.add(uuid);
1905                                    }
1906    
1907                                    qPos.add(companyId);
1908    
1909                                    count = (Long)q.uniqueResult();
1910    
1911                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1912                            }
1913                            catch (Exception e) {
1914                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1915    
1916                                    throw processException(e);
1917                            }
1918                            finally {
1919                                    closeSession(session);
1920                            }
1921                    }
1922    
1923                    return count.intValue();
1924            }
1925    
1926            /**
1927             * Returns the number of password policies that the user has permission to view where uuid = &#63; and companyId = &#63;.
1928             *
1929             * @param uuid the uuid
1930             * @param companyId the company ID
1931             * @return the number of matching password policies that the user has permission to view
1932             */
1933            @Override
1934            public int filterCountByUuid_C(String uuid, long companyId) {
1935                    if (!InlineSQLHelperUtil.isEnabled()) {
1936                            return countByUuid_C(uuid, companyId);
1937                    }
1938    
1939                    StringBundler query = new StringBundler(3);
1940    
1941                    query.append(_FILTER_SQL_COUNT_PASSWORDPOLICY_WHERE);
1942    
1943                    boolean bindUuid = false;
1944    
1945                    if (uuid == null) {
1946                            query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1947                    }
1948                    else if (uuid.equals(StringPool.BLANK)) {
1949                            query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1950                    }
1951                    else {
1952                            bindUuid = true;
1953    
1954                            query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1955                    }
1956    
1957                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1958    
1959                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1960                                    PasswordPolicy.class.getName(),
1961                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1962    
1963                    Session session = null;
1964    
1965                    try {
1966                            session = openSession();
1967    
1968                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
1969    
1970                            q.addScalar(COUNT_COLUMN_NAME,
1971                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1972    
1973                            QueryPos qPos = QueryPos.getInstance(q);
1974    
1975                            if (bindUuid) {
1976                                    qPos.add(uuid);
1977                            }
1978    
1979                            qPos.add(companyId);
1980    
1981                            Long count = (Long)q.uniqueResult();
1982    
1983                            return count.intValue();
1984                    }
1985                    catch (Exception e) {
1986                            throw processException(e);
1987                    }
1988                    finally {
1989                            closeSession(session);
1990                    }
1991            }
1992    
1993            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "passwordPolicy.uuid IS NULL AND ";
1994            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "passwordPolicy.uuid = ? AND ";
1995            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(passwordPolicy.uuid IS NULL OR passwordPolicy.uuid = '') AND ";
1996            private static final String _FINDER_COLUMN_UUID_C_UUID_1_SQL = "passwordPolicy.uuid_ IS NULL AND ";
1997            private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL = "passwordPolicy.uuid_ = ? AND ";
1998            private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL = "(passwordPolicy.uuid_ IS NULL OR passwordPolicy.uuid_ = '') AND ";
1999            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "passwordPolicy.companyId = ?";
2000            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2001                    new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
2002                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
2003                            PasswordPolicyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2004                            "findByCompanyId",
2005                            new String[] {
2006                                    Long.class.getName(),
2007                                    
2008                            Integer.class.getName(), Integer.class.getName(),
2009                                    OrderByComparator.class.getName()
2010                            });
2011            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2012                    new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
2013                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
2014                            PasswordPolicyImpl.class,
2015                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2016                            new String[] { Long.class.getName() },
2017                            PasswordPolicyModelImpl.COMPANYID_COLUMN_BITMASK);
2018            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
2019                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED, Long.class,
2020                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2021                            new String[] { Long.class.getName() });
2022    
2023            /**
2024             * Returns all the password policies where companyId = &#63;.
2025             *
2026             * @param companyId the company ID
2027             * @return the matching password policies
2028             */
2029            @Override
2030            public List<PasswordPolicy> findByCompanyId(long companyId) {
2031                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2032                            null);
2033            }
2034    
2035            /**
2036             * Returns a range of all the password policies where companyId = &#63;.
2037             *
2038             * <p>
2039             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
2040             * </p>
2041             *
2042             * @param companyId the company ID
2043             * @param start the lower bound of the range of password policies
2044             * @param end the upper bound of the range of password policies (not inclusive)
2045             * @return the range of matching password policies
2046             */
2047            @Override
2048            public List<PasswordPolicy> findByCompanyId(long companyId, int start,
2049                    int end) {
2050                    return findByCompanyId(companyId, start, end, null);
2051            }
2052    
2053            /**
2054             * Returns an ordered range of all the password policies where companyId = &#63;.
2055             *
2056             * <p>
2057             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
2058             * </p>
2059             *
2060             * @param companyId the company ID
2061             * @param start the lower bound of the range of password policies
2062             * @param end the upper bound of the range of password policies (not inclusive)
2063             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2064             * @return the ordered range of matching password policies
2065             */
2066            @Override
2067            public List<PasswordPolicy> findByCompanyId(long companyId, int start,
2068                    int end, OrderByComparator<PasswordPolicy> orderByComparator) {
2069                    boolean pagination = true;
2070                    FinderPath finderPath = null;
2071                    Object[] finderArgs = null;
2072    
2073                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2074                                    (orderByComparator == null)) {
2075                            pagination = false;
2076                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2077                            finderArgs = new Object[] { companyId };
2078                    }
2079                    else {
2080                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2081                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2082                    }
2083    
2084                    List<PasswordPolicy> list = (List<PasswordPolicy>)FinderCacheUtil.getResult(finderPath,
2085                                    finderArgs, this);
2086    
2087                    if ((list != null) && !list.isEmpty()) {
2088                            for (PasswordPolicy passwordPolicy : list) {
2089                                    if ((companyId != passwordPolicy.getCompanyId())) {
2090                                            list = null;
2091    
2092                                            break;
2093                                    }
2094                            }
2095                    }
2096    
2097                    if (list == null) {
2098                            StringBundler query = null;
2099    
2100                            if (orderByComparator != null) {
2101                                    query = new StringBundler(3 +
2102                                                    (orderByComparator.getOrderByFields().length * 3));
2103                            }
2104                            else {
2105                                    query = new StringBundler(3);
2106                            }
2107    
2108                            query.append(_SQL_SELECT_PASSWORDPOLICY_WHERE);
2109    
2110                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2111    
2112                            if (orderByComparator != null) {
2113                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2114                                            orderByComparator);
2115                            }
2116                            else
2117                             if (pagination) {
2118                                    query.append(PasswordPolicyModelImpl.ORDER_BY_JPQL);
2119                            }
2120    
2121                            String sql = query.toString();
2122    
2123                            Session session = null;
2124    
2125                            try {
2126                                    session = openSession();
2127    
2128                                    Query q = session.createQuery(sql);
2129    
2130                                    QueryPos qPos = QueryPos.getInstance(q);
2131    
2132                                    qPos.add(companyId);
2133    
2134                                    if (!pagination) {
2135                                            list = (List<PasswordPolicy>)QueryUtil.list(q,
2136                                                            getDialect(), start, end, false);
2137    
2138                                            Collections.sort(list);
2139    
2140                                            list = Collections.unmodifiableList(list);
2141                                    }
2142                                    else {
2143                                            list = (List<PasswordPolicy>)QueryUtil.list(q,
2144                                                            getDialect(), start, end);
2145                                    }
2146    
2147                                    cacheResult(list);
2148    
2149                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2150                            }
2151                            catch (Exception e) {
2152                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2153    
2154                                    throw processException(e);
2155                            }
2156                            finally {
2157                                    closeSession(session);
2158                            }
2159                    }
2160    
2161                    return list;
2162            }
2163    
2164            /**
2165             * Returns the first password policy in the ordered set where companyId = &#63;.
2166             *
2167             * @param companyId the company ID
2168             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2169             * @return the first matching password policy
2170             * @throws NoSuchPasswordPolicyException if a matching password policy could not be found
2171             */
2172            @Override
2173            public PasswordPolicy findByCompanyId_First(long companyId,
2174                    OrderByComparator<PasswordPolicy> orderByComparator)
2175                    throws NoSuchPasswordPolicyException {
2176                    PasswordPolicy passwordPolicy = fetchByCompanyId_First(companyId,
2177                                    orderByComparator);
2178    
2179                    if (passwordPolicy != null) {
2180                            return passwordPolicy;
2181                    }
2182    
2183                    StringBundler msg = new StringBundler(4);
2184    
2185                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2186    
2187                    msg.append("companyId=");
2188                    msg.append(companyId);
2189    
2190                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2191    
2192                    throw new NoSuchPasswordPolicyException(msg.toString());
2193            }
2194    
2195            /**
2196             * Returns the first password policy in the ordered set where companyId = &#63;.
2197             *
2198             * @param companyId the company ID
2199             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2200             * @return the first matching password policy, or <code>null</code> if a matching password policy could not be found
2201             */
2202            @Override
2203            public PasswordPolicy fetchByCompanyId_First(long companyId,
2204                    OrderByComparator<PasswordPolicy> orderByComparator) {
2205                    List<PasswordPolicy> list = findByCompanyId(companyId, 0, 1,
2206                                    orderByComparator);
2207    
2208                    if (!list.isEmpty()) {
2209                            return list.get(0);
2210                    }
2211    
2212                    return null;
2213            }
2214    
2215            /**
2216             * Returns the last password policy in the ordered set where companyId = &#63;.
2217             *
2218             * @param companyId the company ID
2219             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2220             * @return the last matching password policy
2221             * @throws NoSuchPasswordPolicyException if a matching password policy could not be found
2222             */
2223            @Override
2224            public PasswordPolicy findByCompanyId_Last(long companyId,
2225                    OrderByComparator<PasswordPolicy> orderByComparator)
2226                    throws NoSuchPasswordPolicyException {
2227                    PasswordPolicy passwordPolicy = fetchByCompanyId_Last(companyId,
2228                                    orderByComparator);
2229    
2230                    if (passwordPolicy != null) {
2231                            return passwordPolicy;
2232                    }
2233    
2234                    StringBundler msg = new StringBundler(4);
2235    
2236                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2237    
2238                    msg.append("companyId=");
2239                    msg.append(companyId);
2240    
2241                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2242    
2243                    throw new NoSuchPasswordPolicyException(msg.toString());
2244            }
2245    
2246            /**
2247             * Returns the last password policy in the ordered set where companyId = &#63;.
2248             *
2249             * @param companyId the company ID
2250             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2251             * @return the last matching password policy, or <code>null</code> if a matching password policy could not be found
2252             */
2253            @Override
2254            public PasswordPolicy fetchByCompanyId_Last(long companyId,
2255                    OrderByComparator<PasswordPolicy> orderByComparator) {
2256                    int count = countByCompanyId(companyId);
2257    
2258                    if (count == 0) {
2259                            return null;
2260                    }
2261    
2262                    List<PasswordPolicy> list = findByCompanyId(companyId, count - 1,
2263                                    count, orderByComparator);
2264    
2265                    if (!list.isEmpty()) {
2266                            return list.get(0);
2267                    }
2268    
2269                    return null;
2270            }
2271    
2272            /**
2273             * Returns the password policies before and after the current password policy in the ordered set where companyId = &#63;.
2274             *
2275             * @param passwordPolicyId the primary key of the current password policy
2276             * @param companyId the company ID
2277             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2278             * @return the previous, current, and next password policy
2279             * @throws NoSuchPasswordPolicyException if a password policy with the primary key could not be found
2280             */
2281            @Override
2282            public PasswordPolicy[] findByCompanyId_PrevAndNext(long passwordPolicyId,
2283                    long companyId, OrderByComparator<PasswordPolicy> orderByComparator)
2284                    throws NoSuchPasswordPolicyException {
2285                    PasswordPolicy passwordPolicy = findByPrimaryKey(passwordPolicyId);
2286    
2287                    Session session = null;
2288    
2289                    try {
2290                            session = openSession();
2291    
2292                            PasswordPolicy[] array = new PasswordPolicyImpl[3];
2293    
2294                            array[0] = getByCompanyId_PrevAndNext(session, passwordPolicy,
2295                                            companyId, orderByComparator, true);
2296    
2297                            array[1] = passwordPolicy;
2298    
2299                            array[2] = getByCompanyId_PrevAndNext(session, passwordPolicy,
2300                                            companyId, orderByComparator, false);
2301    
2302                            return array;
2303                    }
2304                    catch (Exception e) {
2305                            throw processException(e);
2306                    }
2307                    finally {
2308                            closeSession(session);
2309                    }
2310            }
2311    
2312            protected PasswordPolicy getByCompanyId_PrevAndNext(Session session,
2313                    PasswordPolicy passwordPolicy, long companyId,
2314                    OrderByComparator<PasswordPolicy> orderByComparator, boolean previous) {
2315                    StringBundler query = null;
2316    
2317                    if (orderByComparator != null) {
2318                            query = new StringBundler(6 +
2319                                            (orderByComparator.getOrderByFields().length * 6));
2320                    }
2321                    else {
2322                            query = new StringBundler(3);
2323                    }
2324    
2325                    query.append(_SQL_SELECT_PASSWORDPOLICY_WHERE);
2326    
2327                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2328    
2329                    if (orderByComparator != null) {
2330                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2331    
2332                            if (orderByConditionFields.length > 0) {
2333                                    query.append(WHERE_AND);
2334                            }
2335    
2336                            for (int i = 0; i < orderByConditionFields.length; i++) {
2337                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2338                                    query.append(orderByConditionFields[i]);
2339    
2340                                    if ((i + 1) < orderByConditionFields.length) {
2341                                            if (orderByComparator.isAscending() ^ previous) {
2342                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2343                                            }
2344                                            else {
2345                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2346                                            }
2347                                    }
2348                                    else {
2349                                            if (orderByComparator.isAscending() ^ previous) {
2350                                                    query.append(WHERE_GREATER_THAN);
2351                                            }
2352                                            else {
2353                                                    query.append(WHERE_LESSER_THAN);
2354                                            }
2355                                    }
2356                            }
2357    
2358                            query.append(ORDER_BY_CLAUSE);
2359    
2360                            String[] orderByFields = orderByComparator.getOrderByFields();
2361    
2362                            for (int i = 0; i < orderByFields.length; i++) {
2363                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2364                                    query.append(orderByFields[i]);
2365    
2366                                    if ((i + 1) < orderByFields.length) {
2367                                            if (orderByComparator.isAscending() ^ previous) {
2368                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2369                                            }
2370                                            else {
2371                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2372                                            }
2373                                    }
2374                                    else {
2375                                            if (orderByComparator.isAscending() ^ previous) {
2376                                                    query.append(ORDER_BY_ASC);
2377                                            }
2378                                            else {
2379                                                    query.append(ORDER_BY_DESC);
2380                                            }
2381                                    }
2382                            }
2383                    }
2384                    else {
2385                            query.append(PasswordPolicyModelImpl.ORDER_BY_JPQL);
2386                    }
2387    
2388                    String sql = query.toString();
2389    
2390                    Query q = session.createQuery(sql);
2391    
2392                    q.setFirstResult(0);
2393                    q.setMaxResults(2);
2394    
2395                    QueryPos qPos = QueryPos.getInstance(q);
2396    
2397                    qPos.add(companyId);
2398    
2399                    if (orderByComparator != null) {
2400                            Object[] values = orderByComparator.getOrderByConditionValues(passwordPolicy);
2401    
2402                            for (Object value : values) {
2403                                    qPos.add(value);
2404                            }
2405                    }
2406    
2407                    List<PasswordPolicy> list = q.list();
2408    
2409                    if (list.size() == 2) {
2410                            return list.get(1);
2411                    }
2412                    else {
2413                            return null;
2414                    }
2415            }
2416    
2417            /**
2418             * Returns all the password policies that the user has permission to view where companyId = &#63;.
2419             *
2420             * @param companyId the company ID
2421             * @return the matching password policies that the user has permission to view
2422             */
2423            @Override
2424            public List<PasswordPolicy> filterFindByCompanyId(long companyId) {
2425                    return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
2426                            QueryUtil.ALL_POS, null);
2427            }
2428    
2429            /**
2430             * Returns a range of all the password policies that the user has permission to view where companyId = &#63;.
2431             *
2432             * <p>
2433             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
2434             * </p>
2435             *
2436             * @param companyId the company ID
2437             * @param start the lower bound of the range of password policies
2438             * @param end the upper bound of the range of password policies (not inclusive)
2439             * @return the range of matching password policies that the user has permission to view
2440             */
2441            @Override
2442            public List<PasswordPolicy> filterFindByCompanyId(long companyId,
2443                    int start, int end) {
2444                    return filterFindByCompanyId(companyId, start, end, null);
2445            }
2446    
2447            /**
2448             * Returns an ordered range of all the password policies that the user has permissions to view where companyId = &#63;.
2449             *
2450             * <p>
2451             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
2452             * </p>
2453             *
2454             * @param companyId the company ID
2455             * @param start the lower bound of the range of password policies
2456             * @param end the upper bound of the range of password policies (not inclusive)
2457             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2458             * @return the ordered range of matching password policies that the user has permission to view
2459             */
2460            @Override
2461            public List<PasswordPolicy> filterFindByCompanyId(long companyId,
2462                    int start, int end, OrderByComparator<PasswordPolicy> orderByComparator) {
2463                    if (!InlineSQLHelperUtil.isEnabled()) {
2464                            return findByCompanyId(companyId, start, end, orderByComparator);
2465                    }
2466    
2467                    StringBundler query = null;
2468    
2469                    if (orderByComparator != null) {
2470                            query = new StringBundler(3 +
2471                                            (orderByComparator.getOrderByFields().length * 3));
2472                    }
2473                    else {
2474                            query = new StringBundler(3);
2475                    }
2476    
2477                    if (getDB().isSupportsInlineDistinct()) {
2478                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_WHERE);
2479                    }
2480                    else {
2481                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_1);
2482                    }
2483    
2484                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2485    
2486                    if (!getDB().isSupportsInlineDistinct()) {
2487                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_2);
2488                    }
2489    
2490                    if (orderByComparator != null) {
2491                            if (getDB().isSupportsInlineDistinct()) {
2492                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2493                                            orderByComparator, true);
2494                            }
2495                            else {
2496                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2497                                            orderByComparator, true);
2498                            }
2499                    }
2500                    else {
2501                            if (getDB().isSupportsInlineDistinct()) {
2502                                    query.append(PasswordPolicyModelImpl.ORDER_BY_JPQL);
2503                            }
2504                            else {
2505                                    query.append(PasswordPolicyModelImpl.ORDER_BY_SQL);
2506                            }
2507                    }
2508    
2509                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2510                                    PasswordPolicy.class.getName(),
2511                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2512    
2513                    Session session = null;
2514    
2515                    try {
2516                            session = openSession();
2517    
2518                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2519    
2520                            if (getDB().isSupportsInlineDistinct()) {
2521                                    q.addEntity(_FILTER_ENTITY_ALIAS, PasswordPolicyImpl.class);
2522                            }
2523                            else {
2524                                    q.addEntity(_FILTER_ENTITY_TABLE, PasswordPolicyImpl.class);
2525                            }
2526    
2527                            QueryPos qPos = QueryPos.getInstance(q);
2528    
2529                            qPos.add(companyId);
2530    
2531                            return (List<PasswordPolicy>)QueryUtil.list(q, getDialect(), start,
2532                                    end);
2533                    }
2534                    catch (Exception e) {
2535                            throw processException(e);
2536                    }
2537                    finally {
2538                            closeSession(session);
2539                    }
2540            }
2541    
2542            /**
2543             * Returns the password policies before and after the current password policy in the ordered set of password policies that the user has permission to view where companyId = &#63;.
2544             *
2545             * @param passwordPolicyId the primary key of the current password policy
2546             * @param companyId the company ID
2547             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2548             * @return the previous, current, and next password policy
2549             * @throws NoSuchPasswordPolicyException if a password policy with the primary key could not be found
2550             */
2551            @Override
2552            public PasswordPolicy[] filterFindByCompanyId_PrevAndNext(
2553                    long passwordPolicyId, long companyId,
2554                    OrderByComparator<PasswordPolicy> orderByComparator)
2555                    throws NoSuchPasswordPolicyException {
2556                    if (!InlineSQLHelperUtil.isEnabled()) {
2557                            return findByCompanyId_PrevAndNext(passwordPolicyId, companyId,
2558                                    orderByComparator);
2559                    }
2560    
2561                    PasswordPolicy passwordPolicy = findByPrimaryKey(passwordPolicyId);
2562    
2563                    Session session = null;
2564    
2565                    try {
2566                            session = openSession();
2567    
2568                            PasswordPolicy[] array = new PasswordPolicyImpl[3];
2569    
2570                            array[0] = filterGetByCompanyId_PrevAndNext(session,
2571                                            passwordPolicy, companyId, orderByComparator, true);
2572    
2573                            array[1] = passwordPolicy;
2574    
2575                            array[2] = filterGetByCompanyId_PrevAndNext(session,
2576                                            passwordPolicy, companyId, orderByComparator, false);
2577    
2578                            return array;
2579                    }
2580                    catch (Exception e) {
2581                            throw processException(e);
2582                    }
2583                    finally {
2584                            closeSession(session);
2585                    }
2586            }
2587    
2588            protected PasswordPolicy filterGetByCompanyId_PrevAndNext(Session session,
2589                    PasswordPolicy passwordPolicy, long companyId,
2590                    OrderByComparator<PasswordPolicy> orderByComparator, boolean previous) {
2591                    StringBundler query = null;
2592    
2593                    if (orderByComparator != null) {
2594                            query = new StringBundler(6 +
2595                                            (orderByComparator.getOrderByFields().length * 6));
2596                    }
2597                    else {
2598                            query = new StringBundler(3);
2599                    }
2600    
2601                    if (getDB().isSupportsInlineDistinct()) {
2602                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_WHERE);
2603                    }
2604                    else {
2605                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_1);
2606                    }
2607    
2608                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2609    
2610                    if (!getDB().isSupportsInlineDistinct()) {
2611                            query.append(_FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_2);
2612                    }
2613    
2614                    if (orderByComparator != null) {
2615                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2616    
2617                            if (orderByConditionFields.length > 0) {
2618                                    query.append(WHERE_AND);
2619                            }
2620    
2621                            for (int i = 0; i < orderByConditionFields.length; i++) {
2622                                    if (getDB().isSupportsInlineDistinct()) {
2623                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2624                                    }
2625                                    else {
2626                                            query.append(_ORDER_BY_ENTITY_TABLE);
2627                                    }
2628    
2629                                    query.append(orderByConditionFields[i]);
2630    
2631                                    if ((i + 1) < orderByConditionFields.length) {
2632                                            if (orderByComparator.isAscending() ^ previous) {
2633                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2634                                            }
2635                                            else {
2636                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2637                                            }
2638                                    }
2639                                    else {
2640                                            if (orderByComparator.isAscending() ^ previous) {
2641                                                    query.append(WHERE_GREATER_THAN);
2642                                            }
2643                                            else {
2644                                                    query.append(WHERE_LESSER_THAN);
2645                                            }
2646                                    }
2647                            }
2648    
2649                            query.append(ORDER_BY_CLAUSE);
2650    
2651                            String[] orderByFields = orderByComparator.getOrderByFields();
2652    
2653                            for (int i = 0; i < orderByFields.length; i++) {
2654                                    if (getDB().isSupportsInlineDistinct()) {
2655                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2656                                    }
2657                                    else {
2658                                            query.append(_ORDER_BY_ENTITY_TABLE);
2659                                    }
2660    
2661                                    query.append(orderByFields[i]);
2662    
2663                                    if ((i + 1) < orderByFields.length) {
2664                                            if (orderByComparator.isAscending() ^ previous) {
2665                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2666                                            }
2667                                            else {
2668                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2669                                            }
2670                                    }
2671                                    else {
2672                                            if (orderByComparator.isAscending() ^ previous) {
2673                                                    query.append(ORDER_BY_ASC);
2674                                            }
2675                                            else {
2676                                                    query.append(ORDER_BY_DESC);
2677                                            }
2678                                    }
2679                            }
2680                    }
2681                    else {
2682                            if (getDB().isSupportsInlineDistinct()) {
2683                                    query.append(PasswordPolicyModelImpl.ORDER_BY_JPQL);
2684                            }
2685                            else {
2686                                    query.append(PasswordPolicyModelImpl.ORDER_BY_SQL);
2687                            }
2688                    }
2689    
2690                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2691                                    PasswordPolicy.class.getName(),
2692                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2693    
2694                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2695    
2696                    q.setFirstResult(0);
2697                    q.setMaxResults(2);
2698    
2699                    if (getDB().isSupportsInlineDistinct()) {
2700                            q.addEntity(_FILTER_ENTITY_ALIAS, PasswordPolicyImpl.class);
2701                    }
2702                    else {
2703                            q.addEntity(_FILTER_ENTITY_TABLE, PasswordPolicyImpl.class);
2704                    }
2705    
2706                    QueryPos qPos = QueryPos.getInstance(q);
2707    
2708                    qPos.add(companyId);
2709    
2710                    if (orderByComparator != null) {
2711                            Object[] values = orderByComparator.getOrderByConditionValues(passwordPolicy);
2712    
2713                            for (Object value : values) {
2714                                    qPos.add(value);
2715                            }
2716                    }
2717    
2718                    List<PasswordPolicy> list = q.list();
2719    
2720                    if (list.size() == 2) {
2721                            return list.get(1);
2722                    }
2723                    else {
2724                            return null;
2725                    }
2726            }
2727    
2728            /**
2729             * Removes all the password policies where companyId = &#63; from the database.
2730             *
2731             * @param companyId the company ID
2732             */
2733            @Override
2734            public void removeByCompanyId(long companyId) {
2735                    for (PasswordPolicy passwordPolicy : findByCompanyId(companyId,
2736                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2737                            remove(passwordPolicy);
2738                    }
2739            }
2740    
2741            /**
2742             * Returns the number of password policies where companyId = &#63;.
2743             *
2744             * @param companyId the company ID
2745             * @return the number of matching password policies
2746             */
2747            @Override
2748            public int countByCompanyId(long companyId) {
2749                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2750    
2751                    Object[] finderArgs = new Object[] { companyId };
2752    
2753                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2754                                    this);
2755    
2756                    if (count == null) {
2757                            StringBundler query = new StringBundler(2);
2758    
2759                            query.append(_SQL_COUNT_PASSWORDPOLICY_WHERE);
2760    
2761                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2762    
2763                            String sql = query.toString();
2764    
2765                            Session session = null;
2766    
2767                            try {
2768                                    session = openSession();
2769    
2770                                    Query q = session.createQuery(sql);
2771    
2772                                    QueryPos qPos = QueryPos.getInstance(q);
2773    
2774                                    qPos.add(companyId);
2775    
2776                                    count = (Long)q.uniqueResult();
2777    
2778                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2779                            }
2780                            catch (Exception e) {
2781                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2782    
2783                                    throw processException(e);
2784                            }
2785                            finally {
2786                                    closeSession(session);
2787                            }
2788                    }
2789    
2790                    return count.intValue();
2791            }
2792    
2793            /**
2794             * Returns the number of password policies that the user has permission to view where companyId = &#63;.
2795             *
2796             * @param companyId the company ID
2797             * @return the number of matching password policies that the user has permission to view
2798             */
2799            @Override
2800            public int filterCountByCompanyId(long companyId) {
2801                    if (!InlineSQLHelperUtil.isEnabled()) {
2802                            return countByCompanyId(companyId);
2803                    }
2804    
2805                    StringBundler query = new StringBundler(2);
2806    
2807                    query.append(_FILTER_SQL_COUNT_PASSWORDPOLICY_WHERE);
2808    
2809                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2810    
2811                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2812                                    PasswordPolicy.class.getName(),
2813                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2814    
2815                    Session session = null;
2816    
2817                    try {
2818                            session = openSession();
2819    
2820                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2821    
2822                            q.addScalar(COUNT_COLUMN_NAME,
2823                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2824    
2825                            QueryPos qPos = QueryPos.getInstance(q);
2826    
2827                            qPos.add(companyId);
2828    
2829                            Long count = (Long)q.uniqueResult();
2830    
2831                            return count.intValue();
2832                    }
2833                    catch (Exception e) {
2834                            throw processException(e);
2835                    }
2836                    finally {
2837                            closeSession(session);
2838                    }
2839            }
2840    
2841            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "passwordPolicy.companyId = ?";
2842            public static final FinderPath FINDER_PATH_FETCH_BY_C_DP = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
2843                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
2844                            PasswordPolicyImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByC_DP",
2845                            new String[] { Long.class.getName(), Boolean.class.getName() },
2846                            PasswordPolicyModelImpl.COMPANYID_COLUMN_BITMASK |
2847                            PasswordPolicyModelImpl.DEFAULTPOLICY_COLUMN_BITMASK);
2848            public static final FinderPath FINDER_PATH_COUNT_BY_C_DP = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
2849                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED, Long.class,
2850                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_DP",
2851                            new String[] { Long.class.getName(), Boolean.class.getName() });
2852    
2853            /**
2854             * Returns the password policy where companyId = &#63; and defaultPolicy = &#63; or throws a {@link NoSuchPasswordPolicyException} if it could not be found.
2855             *
2856             * @param companyId the company ID
2857             * @param defaultPolicy the default policy
2858             * @return the matching password policy
2859             * @throws NoSuchPasswordPolicyException if a matching password policy could not be found
2860             */
2861            @Override
2862            public PasswordPolicy findByC_DP(long companyId, boolean defaultPolicy)
2863                    throws NoSuchPasswordPolicyException {
2864                    PasswordPolicy passwordPolicy = fetchByC_DP(companyId, defaultPolicy);
2865    
2866                    if (passwordPolicy == null) {
2867                            StringBundler msg = new StringBundler(6);
2868    
2869                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2870    
2871                            msg.append("companyId=");
2872                            msg.append(companyId);
2873    
2874                            msg.append(", defaultPolicy=");
2875                            msg.append(defaultPolicy);
2876    
2877                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2878    
2879                            if (_log.isWarnEnabled()) {
2880                                    _log.warn(msg.toString());
2881                            }
2882    
2883                            throw new NoSuchPasswordPolicyException(msg.toString());
2884                    }
2885    
2886                    return passwordPolicy;
2887            }
2888    
2889            /**
2890             * Returns the password policy where companyId = &#63; and defaultPolicy = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2891             *
2892             * @param companyId the company ID
2893             * @param defaultPolicy the default policy
2894             * @return the matching password policy, or <code>null</code> if a matching password policy could not be found
2895             */
2896            @Override
2897            public PasswordPolicy fetchByC_DP(long companyId, boolean defaultPolicy) {
2898                    return fetchByC_DP(companyId, defaultPolicy, true);
2899            }
2900    
2901            /**
2902             * Returns the password policy where companyId = &#63; and defaultPolicy = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2903             *
2904             * @param companyId the company ID
2905             * @param defaultPolicy the default policy
2906             * @param retrieveFromCache whether to use the finder cache
2907             * @return the matching password policy, or <code>null</code> if a matching password policy could not be found
2908             */
2909            @Override
2910            public PasswordPolicy fetchByC_DP(long companyId, boolean defaultPolicy,
2911                    boolean retrieveFromCache) {
2912                    Object[] finderArgs = new Object[] { companyId, defaultPolicy };
2913    
2914                    Object result = null;
2915    
2916                    if (retrieveFromCache) {
2917                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_DP,
2918                                            finderArgs, this);
2919                    }
2920    
2921                    if (result instanceof PasswordPolicy) {
2922                            PasswordPolicy passwordPolicy = (PasswordPolicy)result;
2923    
2924                            if ((companyId != passwordPolicy.getCompanyId()) ||
2925                                            (defaultPolicy != passwordPolicy.getDefaultPolicy())) {
2926                                    result = null;
2927                            }
2928                    }
2929    
2930                    if (result == null) {
2931                            StringBundler query = new StringBundler(4);
2932    
2933                            query.append(_SQL_SELECT_PASSWORDPOLICY_WHERE);
2934    
2935                            query.append(_FINDER_COLUMN_C_DP_COMPANYID_2);
2936    
2937                            query.append(_FINDER_COLUMN_C_DP_DEFAULTPOLICY_2);
2938    
2939                            String sql = query.toString();
2940    
2941                            Session session = null;
2942    
2943                            try {
2944                                    session = openSession();
2945    
2946                                    Query q = session.createQuery(sql);
2947    
2948                                    QueryPos qPos = QueryPos.getInstance(q);
2949    
2950                                    qPos.add(companyId);
2951    
2952                                    qPos.add(defaultPolicy);
2953    
2954                                    List<PasswordPolicy> list = q.list();
2955    
2956                                    if (list.isEmpty()) {
2957                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DP,
2958                                                    finderArgs, list);
2959                                    }
2960                                    else {
2961                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
2962                                                    _log.warn(
2963                                                            "PasswordPolicyPersistenceImpl.fetchByC_DP(long, boolean, boolean) with parameters (" +
2964                                                            StringUtil.merge(finderArgs) +
2965                                                            ") 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.");
2966                                            }
2967    
2968                                            PasswordPolicy passwordPolicy = list.get(0);
2969    
2970                                            result = passwordPolicy;
2971    
2972                                            cacheResult(passwordPolicy);
2973    
2974                                            if ((passwordPolicy.getCompanyId() != companyId) ||
2975                                                            (passwordPolicy.getDefaultPolicy() != defaultPolicy)) {
2976                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DP,
2977                                                            finderArgs, passwordPolicy);
2978                                            }
2979                                    }
2980                            }
2981                            catch (Exception e) {
2982                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DP,
2983                                            finderArgs);
2984    
2985                                    throw processException(e);
2986                            }
2987                            finally {
2988                                    closeSession(session);
2989                            }
2990                    }
2991    
2992                    if (result instanceof List<?>) {
2993                            return null;
2994                    }
2995                    else {
2996                            return (PasswordPolicy)result;
2997                    }
2998            }
2999    
3000            /**
3001             * Removes the password policy where companyId = &#63; and defaultPolicy = &#63; from the database.
3002             *
3003             * @param companyId the company ID
3004             * @param defaultPolicy the default policy
3005             * @return the password policy that was removed
3006             */
3007            @Override
3008            public PasswordPolicy removeByC_DP(long companyId, boolean defaultPolicy)
3009                    throws NoSuchPasswordPolicyException {
3010                    PasswordPolicy passwordPolicy = findByC_DP(companyId, defaultPolicy);
3011    
3012                    return remove(passwordPolicy);
3013            }
3014    
3015            /**
3016             * Returns the number of password policies where companyId = &#63; and defaultPolicy = &#63;.
3017             *
3018             * @param companyId the company ID
3019             * @param defaultPolicy the default policy
3020             * @return the number of matching password policies
3021             */
3022            @Override
3023            public int countByC_DP(long companyId, boolean defaultPolicy) {
3024                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_DP;
3025    
3026                    Object[] finderArgs = new Object[] { companyId, defaultPolicy };
3027    
3028                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3029                                    this);
3030    
3031                    if (count == null) {
3032                            StringBundler query = new StringBundler(3);
3033    
3034                            query.append(_SQL_COUNT_PASSWORDPOLICY_WHERE);
3035    
3036                            query.append(_FINDER_COLUMN_C_DP_COMPANYID_2);
3037    
3038                            query.append(_FINDER_COLUMN_C_DP_DEFAULTPOLICY_2);
3039    
3040                            String sql = query.toString();
3041    
3042                            Session session = null;
3043    
3044                            try {
3045                                    session = openSession();
3046    
3047                                    Query q = session.createQuery(sql);
3048    
3049                                    QueryPos qPos = QueryPos.getInstance(q);
3050    
3051                                    qPos.add(companyId);
3052    
3053                                    qPos.add(defaultPolicy);
3054    
3055                                    count = (Long)q.uniqueResult();
3056    
3057                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3058                            }
3059                            catch (Exception e) {
3060                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3061    
3062                                    throw processException(e);
3063                            }
3064                            finally {
3065                                    closeSession(session);
3066                            }
3067                    }
3068    
3069                    return count.intValue();
3070            }
3071    
3072            private static final String _FINDER_COLUMN_C_DP_COMPANYID_2 = "passwordPolicy.companyId = ? AND ";
3073            private static final String _FINDER_COLUMN_C_DP_DEFAULTPOLICY_2 = "passwordPolicy.defaultPolicy = ?";
3074            public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
3075                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
3076                            PasswordPolicyImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
3077                            new String[] { Long.class.getName(), String.class.getName() },
3078                            PasswordPolicyModelImpl.COMPANYID_COLUMN_BITMASK |
3079                            PasswordPolicyModelImpl.NAME_COLUMN_BITMASK);
3080            public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
3081                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED, Long.class,
3082                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
3083                            new String[] { Long.class.getName(), String.class.getName() });
3084    
3085            /**
3086             * Returns the password policy where companyId = &#63; and name = &#63; or throws a {@link NoSuchPasswordPolicyException} if it could not be found.
3087             *
3088             * @param companyId the company ID
3089             * @param name the name
3090             * @return the matching password policy
3091             * @throws NoSuchPasswordPolicyException if a matching password policy could not be found
3092             */
3093            @Override
3094            public PasswordPolicy findByC_N(long companyId, String name)
3095                    throws NoSuchPasswordPolicyException {
3096                    PasswordPolicy passwordPolicy = fetchByC_N(companyId, name);
3097    
3098                    if (passwordPolicy == null) {
3099                            StringBundler msg = new StringBundler(6);
3100    
3101                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3102    
3103                            msg.append("companyId=");
3104                            msg.append(companyId);
3105    
3106                            msg.append(", name=");
3107                            msg.append(name);
3108    
3109                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3110    
3111                            if (_log.isWarnEnabled()) {
3112                                    _log.warn(msg.toString());
3113                            }
3114    
3115                            throw new NoSuchPasswordPolicyException(msg.toString());
3116                    }
3117    
3118                    return passwordPolicy;
3119            }
3120    
3121            /**
3122             * Returns the password policy where companyId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
3123             *
3124             * @param companyId the company ID
3125             * @param name the name
3126             * @return the matching password policy, or <code>null</code> if a matching password policy could not be found
3127             */
3128            @Override
3129            public PasswordPolicy fetchByC_N(long companyId, String name) {
3130                    return fetchByC_N(companyId, name, true);
3131            }
3132    
3133            /**
3134             * Returns the password policy where companyId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
3135             *
3136             * @param companyId the company ID
3137             * @param name the name
3138             * @param retrieveFromCache whether to use the finder cache
3139             * @return the matching password policy, or <code>null</code> if a matching password policy could not be found
3140             */
3141            @Override
3142            public PasswordPolicy fetchByC_N(long companyId, String name,
3143                    boolean retrieveFromCache) {
3144                    Object[] finderArgs = new Object[] { companyId, name };
3145    
3146                    Object result = null;
3147    
3148                    if (retrieveFromCache) {
3149                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
3150                                            finderArgs, this);
3151                    }
3152    
3153                    if (result instanceof PasswordPolicy) {
3154                            PasswordPolicy passwordPolicy = (PasswordPolicy)result;
3155    
3156                            if ((companyId != passwordPolicy.getCompanyId()) ||
3157                                            !Validator.equals(name, passwordPolicy.getName())) {
3158                                    result = null;
3159                            }
3160                    }
3161    
3162                    if (result == null) {
3163                            StringBundler query = new StringBundler(4);
3164    
3165                            query.append(_SQL_SELECT_PASSWORDPOLICY_WHERE);
3166    
3167                            query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
3168    
3169                            boolean bindName = false;
3170    
3171                            if (name == null) {
3172                                    query.append(_FINDER_COLUMN_C_N_NAME_1);
3173                            }
3174                            else if (name.equals(StringPool.BLANK)) {
3175                                    query.append(_FINDER_COLUMN_C_N_NAME_3);
3176                            }
3177                            else {
3178                                    bindName = true;
3179    
3180                                    query.append(_FINDER_COLUMN_C_N_NAME_2);
3181                            }
3182    
3183                            String sql = query.toString();
3184    
3185                            Session session = null;
3186    
3187                            try {
3188                                    session = openSession();
3189    
3190                                    Query q = session.createQuery(sql);
3191    
3192                                    QueryPos qPos = QueryPos.getInstance(q);
3193    
3194                                    qPos.add(companyId);
3195    
3196                                    if (bindName) {
3197                                            qPos.add(name);
3198                                    }
3199    
3200                                    List<PasswordPolicy> list = q.list();
3201    
3202                                    if (list.isEmpty()) {
3203                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
3204                                                    finderArgs, list);
3205                                    }
3206                                    else {
3207                                            PasswordPolicy passwordPolicy = list.get(0);
3208    
3209                                            result = passwordPolicy;
3210    
3211                                            cacheResult(passwordPolicy);
3212    
3213                                            if ((passwordPolicy.getCompanyId() != companyId) ||
3214                                                            (passwordPolicy.getName() == null) ||
3215                                                            !passwordPolicy.getName().equals(name)) {
3216                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
3217                                                            finderArgs, passwordPolicy);
3218                                            }
3219                                    }
3220                            }
3221                            catch (Exception e) {
3222                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
3223                                            finderArgs);
3224    
3225                                    throw processException(e);
3226                            }
3227                            finally {
3228                                    closeSession(session);
3229                            }
3230                    }
3231    
3232                    if (result instanceof List<?>) {
3233                            return null;
3234                    }
3235                    else {
3236                            return (PasswordPolicy)result;
3237                    }
3238            }
3239    
3240            /**
3241             * Removes the password policy where companyId = &#63; and name = &#63; from the database.
3242             *
3243             * @param companyId the company ID
3244             * @param name the name
3245             * @return the password policy that was removed
3246             */
3247            @Override
3248            public PasswordPolicy removeByC_N(long companyId, String name)
3249                    throws NoSuchPasswordPolicyException {
3250                    PasswordPolicy passwordPolicy = findByC_N(companyId, name);
3251    
3252                    return remove(passwordPolicy);
3253            }
3254    
3255            /**
3256             * Returns the number of password policies where companyId = &#63; and name = &#63;.
3257             *
3258             * @param companyId the company ID
3259             * @param name the name
3260             * @return the number of matching password policies
3261             */
3262            @Override
3263            public int countByC_N(long companyId, String name) {
3264                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_N;
3265    
3266                    Object[] finderArgs = new Object[] { companyId, name };
3267    
3268                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3269                                    this);
3270    
3271                    if (count == null) {
3272                            StringBundler query = new StringBundler(3);
3273    
3274                            query.append(_SQL_COUNT_PASSWORDPOLICY_WHERE);
3275    
3276                            query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
3277    
3278                            boolean bindName = false;
3279    
3280                            if (name == null) {
3281                                    query.append(_FINDER_COLUMN_C_N_NAME_1);
3282                            }
3283                            else if (name.equals(StringPool.BLANK)) {
3284                                    query.append(_FINDER_COLUMN_C_N_NAME_3);
3285                            }
3286                            else {
3287                                    bindName = true;
3288    
3289                                    query.append(_FINDER_COLUMN_C_N_NAME_2);
3290                            }
3291    
3292                            String sql = query.toString();
3293    
3294                            Session session = null;
3295    
3296                            try {
3297                                    session = openSession();
3298    
3299                                    Query q = session.createQuery(sql);
3300    
3301                                    QueryPos qPos = QueryPos.getInstance(q);
3302    
3303                                    qPos.add(companyId);
3304    
3305                                    if (bindName) {
3306                                            qPos.add(name);
3307                                    }
3308    
3309                                    count = (Long)q.uniqueResult();
3310    
3311                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3312                            }
3313                            catch (Exception e) {
3314                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3315    
3316                                    throw processException(e);
3317                            }
3318                            finally {
3319                                    closeSession(session);
3320                            }
3321                    }
3322    
3323                    return count.intValue();
3324            }
3325    
3326            private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "passwordPolicy.companyId = ? AND ";
3327            private static final String _FINDER_COLUMN_C_N_NAME_1 = "passwordPolicy.name IS NULL";
3328            private static final String _FINDER_COLUMN_C_N_NAME_2 = "passwordPolicy.name = ?";
3329            private static final String _FINDER_COLUMN_C_N_NAME_3 = "(passwordPolicy.name IS NULL OR passwordPolicy.name = '')";
3330    
3331            public PasswordPolicyPersistenceImpl() {
3332                    setModelClass(PasswordPolicy.class);
3333            }
3334    
3335            /**
3336             * Caches the password policy in the entity cache if it is enabled.
3337             *
3338             * @param passwordPolicy the password policy
3339             */
3340            @Override
3341            public void cacheResult(PasswordPolicy passwordPolicy) {
3342                    EntityCacheUtil.putResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
3343                            PasswordPolicyImpl.class, passwordPolicy.getPrimaryKey(),
3344                            passwordPolicy);
3345    
3346                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DP,
3347                            new Object[] {
3348                                    passwordPolicy.getCompanyId(), passwordPolicy.getDefaultPolicy()
3349                            }, passwordPolicy);
3350    
3351                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
3352                            new Object[] { passwordPolicy.getCompanyId(), passwordPolicy.getName() },
3353                            passwordPolicy);
3354    
3355                    passwordPolicy.resetOriginalValues();
3356            }
3357    
3358            /**
3359             * Caches the password policies in the entity cache if it is enabled.
3360             *
3361             * @param passwordPolicies the password policies
3362             */
3363            @Override
3364            public void cacheResult(List<PasswordPolicy> passwordPolicies) {
3365                    for (PasswordPolicy passwordPolicy : passwordPolicies) {
3366                            if (EntityCacheUtil.getResult(
3367                                                    PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
3368                                                    PasswordPolicyImpl.class, passwordPolicy.getPrimaryKey()) == null) {
3369                                    cacheResult(passwordPolicy);
3370                            }
3371                            else {
3372                                    passwordPolicy.resetOriginalValues();
3373                            }
3374                    }
3375            }
3376    
3377            /**
3378             * Clears the cache for all password policies.
3379             *
3380             * <p>
3381             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
3382             * </p>
3383             */
3384            @Override
3385            public void clearCache() {
3386                    EntityCacheUtil.clearCache(PasswordPolicyImpl.class);
3387    
3388                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
3389                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3390                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3391            }
3392    
3393            /**
3394             * Clears the cache for the password policy.
3395             *
3396             * <p>
3397             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
3398             * </p>
3399             */
3400            @Override
3401            public void clearCache(PasswordPolicy passwordPolicy) {
3402                    EntityCacheUtil.removeResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
3403                            PasswordPolicyImpl.class, passwordPolicy.getPrimaryKey());
3404    
3405                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3406                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3407    
3408                    clearUniqueFindersCache(passwordPolicy);
3409            }
3410    
3411            @Override
3412            public void clearCache(List<PasswordPolicy> passwordPolicies) {
3413                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3414                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3415    
3416                    for (PasswordPolicy passwordPolicy : passwordPolicies) {
3417                            EntityCacheUtil.removeResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
3418                                    PasswordPolicyImpl.class, passwordPolicy.getPrimaryKey());
3419    
3420                            clearUniqueFindersCache(passwordPolicy);
3421                    }
3422            }
3423    
3424            protected void cacheUniqueFindersCache(PasswordPolicy passwordPolicy) {
3425                    if (passwordPolicy.isNew()) {
3426                            Object[] args = new Object[] {
3427                                            passwordPolicy.getCompanyId(),
3428                                            passwordPolicy.getDefaultPolicy()
3429                                    };
3430    
3431                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_DP, args,
3432                                    Long.valueOf(1));
3433                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DP, args,
3434                                    passwordPolicy);
3435    
3436                            args = new Object[] {
3437                                            passwordPolicy.getCompanyId(), passwordPolicy.getName()
3438                                    };
3439    
3440                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
3441                                    Long.valueOf(1));
3442                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args,
3443                                    passwordPolicy);
3444                    }
3445                    else {
3446                            PasswordPolicyModelImpl passwordPolicyModelImpl = (PasswordPolicyModelImpl)passwordPolicy;
3447    
3448                            if ((passwordPolicyModelImpl.getColumnBitmask() &
3449                                            FINDER_PATH_FETCH_BY_C_DP.getColumnBitmask()) != 0) {
3450                                    Object[] args = new Object[] {
3451                                                    passwordPolicy.getCompanyId(),
3452                                                    passwordPolicy.getDefaultPolicy()
3453                                            };
3454    
3455                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_DP, args,
3456                                            Long.valueOf(1));
3457                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DP, args,
3458                                            passwordPolicy);
3459                            }
3460    
3461                            if ((passwordPolicyModelImpl.getColumnBitmask() &
3462                                            FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
3463                                    Object[] args = new Object[] {
3464                                                    passwordPolicy.getCompanyId(), passwordPolicy.getName()
3465                                            };
3466    
3467                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
3468                                            Long.valueOf(1));
3469                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args,
3470                                            passwordPolicy);
3471                            }
3472                    }
3473            }
3474    
3475            protected void clearUniqueFindersCache(PasswordPolicy passwordPolicy) {
3476                    PasswordPolicyModelImpl passwordPolicyModelImpl = (PasswordPolicyModelImpl)passwordPolicy;
3477    
3478                    Object[] args = new Object[] {
3479                                    passwordPolicy.getCompanyId(), passwordPolicy.getDefaultPolicy()
3480                            };
3481    
3482                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_DP, args);
3483                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DP, args);
3484    
3485                    if ((passwordPolicyModelImpl.getColumnBitmask() &
3486                                    FINDER_PATH_FETCH_BY_C_DP.getColumnBitmask()) != 0) {
3487                            args = new Object[] {
3488                                            passwordPolicyModelImpl.getOriginalCompanyId(),
3489                                            passwordPolicyModelImpl.getOriginalDefaultPolicy()
3490                                    };
3491    
3492                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_DP, args);
3493                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DP, args);
3494                    }
3495    
3496                    args = new Object[] {
3497                                    passwordPolicy.getCompanyId(), passwordPolicy.getName()
3498                            };
3499    
3500                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
3501                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
3502    
3503                    if ((passwordPolicyModelImpl.getColumnBitmask() &
3504                                    FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
3505                            args = new Object[] {
3506                                            passwordPolicyModelImpl.getOriginalCompanyId(),
3507                                            passwordPolicyModelImpl.getOriginalName()
3508                                    };
3509    
3510                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
3511                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
3512                    }
3513            }
3514    
3515            /**
3516             * Creates a new password policy with the primary key. Does not add the password policy to the database.
3517             *
3518             * @param passwordPolicyId the primary key for the new password policy
3519             * @return the new password policy
3520             */
3521            @Override
3522            public PasswordPolicy create(long passwordPolicyId) {
3523                    PasswordPolicy passwordPolicy = new PasswordPolicyImpl();
3524    
3525                    passwordPolicy.setNew(true);
3526                    passwordPolicy.setPrimaryKey(passwordPolicyId);
3527    
3528                    String uuid = PortalUUIDUtil.generate();
3529    
3530                    passwordPolicy.setUuid(uuid);
3531    
3532                    return passwordPolicy;
3533            }
3534    
3535            /**
3536             * Removes the password policy with the primary key from the database. Also notifies the appropriate model listeners.
3537             *
3538             * @param passwordPolicyId the primary key of the password policy
3539             * @return the password policy that was removed
3540             * @throws NoSuchPasswordPolicyException if a password policy with the primary key could not be found
3541             */
3542            @Override
3543            public PasswordPolicy remove(long passwordPolicyId)
3544                    throws NoSuchPasswordPolicyException {
3545                    return remove((Serializable)passwordPolicyId);
3546            }
3547    
3548            /**
3549             * Removes the password policy with the primary key from the database. Also notifies the appropriate model listeners.
3550             *
3551             * @param primaryKey the primary key of the password policy
3552             * @return the password policy that was removed
3553             * @throws NoSuchPasswordPolicyException if a password policy with the primary key could not be found
3554             */
3555            @Override
3556            public PasswordPolicy remove(Serializable primaryKey)
3557                    throws NoSuchPasswordPolicyException {
3558                    Session session = null;
3559    
3560                    try {
3561                            session = openSession();
3562    
3563                            PasswordPolicy passwordPolicy = (PasswordPolicy)session.get(PasswordPolicyImpl.class,
3564                                            primaryKey);
3565    
3566                            if (passwordPolicy == null) {
3567                                    if (_log.isWarnEnabled()) {
3568                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3569                                    }
3570    
3571                                    throw new NoSuchPasswordPolicyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3572                                            primaryKey);
3573                            }
3574    
3575                            return remove(passwordPolicy);
3576                    }
3577                    catch (NoSuchPasswordPolicyException nsee) {
3578                            throw nsee;
3579                    }
3580                    catch (Exception e) {
3581                            throw processException(e);
3582                    }
3583                    finally {
3584                            closeSession(session);
3585                    }
3586            }
3587    
3588            @Override
3589            protected PasswordPolicy removeImpl(PasswordPolicy passwordPolicy) {
3590                    passwordPolicy = toUnwrappedModel(passwordPolicy);
3591    
3592                    Session session = null;
3593    
3594                    try {
3595                            session = openSession();
3596    
3597                            if (!session.contains(passwordPolicy)) {
3598                                    passwordPolicy = (PasswordPolicy)session.get(PasswordPolicyImpl.class,
3599                                                    passwordPolicy.getPrimaryKeyObj());
3600                            }
3601    
3602                            if (passwordPolicy != null) {
3603                                    session.delete(passwordPolicy);
3604                            }
3605                    }
3606                    catch (Exception e) {
3607                            throw processException(e);
3608                    }
3609                    finally {
3610                            closeSession(session);
3611                    }
3612    
3613                    if (passwordPolicy != null) {
3614                            clearCache(passwordPolicy);
3615                    }
3616    
3617                    return passwordPolicy;
3618            }
3619    
3620            @Override
3621            public PasswordPolicy updateImpl(PasswordPolicy passwordPolicy) {
3622                    passwordPolicy = toUnwrappedModel(passwordPolicy);
3623    
3624                    boolean isNew = passwordPolicy.isNew();
3625    
3626                    PasswordPolicyModelImpl passwordPolicyModelImpl = (PasswordPolicyModelImpl)passwordPolicy;
3627    
3628                    if (Validator.isNull(passwordPolicy.getUuid())) {
3629                            String uuid = PortalUUIDUtil.generate();
3630    
3631                            passwordPolicy.setUuid(uuid);
3632                    }
3633    
3634                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
3635    
3636                    Date now = new Date();
3637    
3638                    if (isNew && (passwordPolicy.getCreateDate() == null)) {
3639                            if (serviceContext == null) {
3640                                    passwordPolicy.setCreateDate(now);
3641                            }
3642                            else {
3643                                    passwordPolicy.setCreateDate(serviceContext.getCreateDate(now));
3644                            }
3645                    }
3646    
3647                    if (!passwordPolicyModelImpl.hasSetModifiedDate()) {
3648                            if (serviceContext == null) {
3649                                    passwordPolicy.setModifiedDate(now);
3650                            }
3651                            else {
3652                                    passwordPolicy.setModifiedDate(serviceContext.getModifiedDate(
3653                                                    now));
3654                            }
3655                    }
3656    
3657                    Session session = null;
3658    
3659                    try {
3660                            session = openSession();
3661    
3662                            if (passwordPolicy.isNew()) {
3663                                    session.save(passwordPolicy);
3664    
3665                                    passwordPolicy.setNew(false);
3666                            }
3667                            else {
3668                                    session.merge(passwordPolicy);
3669                            }
3670                    }
3671                    catch (Exception e) {
3672                            throw processException(e);
3673                    }
3674                    finally {
3675                            closeSession(session);
3676                    }
3677    
3678                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3679    
3680                    if (isNew || !PasswordPolicyModelImpl.COLUMN_BITMASK_ENABLED) {
3681                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3682                    }
3683    
3684                    else {
3685                            if ((passwordPolicyModelImpl.getColumnBitmask() &
3686                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
3687                                    Object[] args = new Object[] {
3688                                                    passwordPolicyModelImpl.getOriginalUuid()
3689                                            };
3690    
3691                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3692                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3693                                            args);
3694    
3695                                    args = new Object[] { passwordPolicyModelImpl.getUuid() };
3696    
3697                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3698                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3699                                            args);
3700                            }
3701    
3702                            if ((passwordPolicyModelImpl.getColumnBitmask() &
3703                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
3704                                    Object[] args = new Object[] {
3705                                                    passwordPolicyModelImpl.getOriginalUuid(),
3706                                                    passwordPolicyModelImpl.getOriginalCompanyId()
3707                                            };
3708    
3709                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3710                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3711                                            args);
3712    
3713                                    args = new Object[] {
3714                                                    passwordPolicyModelImpl.getUuid(),
3715                                                    passwordPolicyModelImpl.getCompanyId()
3716                                            };
3717    
3718                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3719                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3720                                            args);
3721                            }
3722    
3723                            if ((passwordPolicyModelImpl.getColumnBitmask() &
3724                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
3725                                    Object[] args = new Object[] {
3726                                                    passwordPolicyModelImpl.getOriginalCompanyId()
3727                                            };
3728    
3729                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
3730                                            args);
3731                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3732                                            args);
3733    
3734                                    args = new Object[] { passwordPolicyModelImpl.getCompanyId() };
3735    
3736                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
3737                                            args);
3738                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3739                                            args);
3740                            }
3741                    }
3742    
3743                    EntityCacheUtil.putResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
3744                            PasswordPolicyImpl.class, passwordPolicy.getPrimaryKey(),
3745                            passwordPolicy, false);
3746    
3747                    clearUniqueFindersCache(passwordPolicy);
3748                    cacheUniqueFindersCache(passwordPolicy);
3749    
3750                    passwordPolicy.resetOriginalValues();
3751    
3752                    return passwordPolicy;
3753            }
3754    
3755            protected PasswordPolicy toUnwrappedModel(PasswordPolicy passwordPolicy) {
3756                    if (passwordPolicy instanceof PasswordPolicyImpl) {
3757                            return passwordPolicy;
3758                    }
3759    
3760                    PasswordPolicyImpl passwordPolicyImpl = new PasswordPolicyImpl();
3761    
3762                    passwordPolicyImpl.setNew(passwordPolicy.isNew());
3763                    passwordPolicyImpl.setPrimaryKey(passwordPolicy.getPrimaryKey());
3764    
3765                    passwordPolicyImpl.setMvccVersion(passwordPolicy.getMvccVersion());
3766                    passwordPolicyImpl.setUuid(passwordPolicy.getUuid());
3767                    passwordPolicyImpl.setPasswordPolicyId(passwordPolicy.getPasswordPolicyId());
3768                    passwordPolicyImpl.setCompanyId(passwordPolicy.getCompanyId());
3769                    passwordPolicyImpl.setUserId(passwordPolicy.getUserId());
3770                    passwordPolicyImpl.setUserName(passwordPolicy.getUserName());
3771                    passwordPolicyImpl.setCreateDate(passwordPolicy.getCreateDate());
3772                    passwordPolicyImpl.setModifiedDate(passwordPolicy.getModifiedDate());
3773                    passwordPolicyImpl.setDefaultPolicy(passwordPolicy.isDefaultPolicy());
3774                    passwordPolicyImpl.setName(passwordPolicy.getName());
3775                    passwordPolicyImpl.setDescription(passwordPolicy.getDescription());
3776                    passwordPolicyImpl.setChangeable(passwordPolicy.isChangeable());
3777                    passwordPolicyImpl.setChangeRequired(passwordPolicy.isChangeRequired());
3778                    passwordPolicyImpl.setMinAge(passwordPolicy.getMinAge());
3779                    passwordPolicyImpl.setCheckSyntax(passwordPolicy.isCheckSyntax());
3780                    passwordPolicyImpl.setAllowDictionaryWords(passwordPolicy.isAllowDictionaryWords());
3781                    passwordPolicyImpl.setMinAlphanumeric(passwordPolicy.getMinAlphanumeric());
3782                    passwordPolicyImpl.setMinLength(passwordPolicy.getMinLength());
3783                    passwordPolicyImpl.setMinLowerCase(passwordPolicy.getMinLowerCase());
3784                    passwordPolicyImpl.setMinNumbers(passwordPolicy.getMinNumbers());
3785                    passwordPolicyImpl.setMinSymbols(passwordPolicy.getMinSymbols());
3786                    passwordPolicyImpl.setMinUpperCase(passwordPolicy.getMinUpperCase());
3787                    passwordPolicyImpl.setRegex(passwordPolicy.getRegex());
3788                    passwordPolicyImpl.setHistory(passwordPolicy.isHistory());
3789                    passwordPolicyImpl.setHistoryCount(passwordPolicy.getHistoryCount());
3790                    passwordPolicyImpl.setExpireable(passwordPolicy.isExpireable());
3791                    passwordPolicyImpl.setMaxAge(passwordPolicy.getMaxAge());
3792                    passwordPolicyImpl.setWarningTime(passwordPolicy.getWarningTime());
3793                    passwordPolicyImpl.setGraceLimit(passwordPolicy.getGraceLimit());
3794                    passwordPolicyImpl.setLockout(passwordPolicy.isLockout());
3795                    passwordPolicyImpl.setMaxFailure(passwordPolicy.getMaxFailure());
3796                    passwordPolicyImpl.setLockoutDuration(passwordPolicy.getLockoutDuration());
3797                    passwordPolicyImpl.setRequireUnlock(passwordPolicy.isRequireUnlock());
3798                    passwordPolicyImpl.setResetFailureCount(passwordPolicy.getResetFailureCount());
3799                    passwordPolicyImpl.setResetTicketMaxAge(passwordPolicy.getResetTicketMaxAge());
3800    
3801                    return passwordPolicyImpl;
3802            }
3803    
3804            /**
3805             * Returns the password policy with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
3806             *
3807             * @param primaryKey the primary key of the password policy
3808             * @return the password policy
3809             * @throws NoSuchPasswordPolicyException if a password policy with the primary key could not be found
3810             */
3811            @Override
3812            public PasswordPolicy findByPrimaryKey(Serializable primaryKey)
3813                    throws NoSuchPasswordPolicyException {
3814                    PasswordPolicy passwordPolicy = fetchByPrimaryKey(primaryKey);
3815    
3816                    if (passwordPolicy == null) {
3817                            if (_log.isWarnEnabled()) {
3818                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3819                            }
3820    
3821                            throw new NoSuchPasswordPolicyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3822                                    primaryKey);
3823                    }
3824    
3825                    return passwordPolicy;
3826            }
3827    
3828            /**
3829             * Returns the password policy with the primary key or throws a {@link NoSuchPasswordPolicyException} if it could not be found.
3830             *
3831             * @param passwordPolicyId the primary key of the password policy
3832             * @return the password policy
3833             * @throws NoSuchPasswordPolicyException if a password policy with the primary key could not be found
3834             */
3835            @Override
3836            public PasswordPolicy findByPrimaryKey(long passwordPolicyId)
3837                    throws NoSuchPasswordPolicyException {
3838                    return findByPrimaryKey((Serializable)passwordPolicyId);
3839            }
3840    
3841            /**
3842             * Returns the password policy with the primary key or returns <code>null</code> if it could not be found.
3843             *
3844             * @param primaryKey the primary key of the password policy
3845             * @return the password policy, or <code>null</code> if a password policy with the primary key could not be found
3846             */
3847            @Override
3848            public PasswordPolicy fetchByPrimaryKey(Serializable primaryKey) {
3849                    PasswordPolicy passwordPolicy = (PasswordPolicy)EntityCacheUtil.getResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
3850                                    PasswordPolicyImpl.class, primaryKey);
3851    
3852                    if (passwordPolicy == _nullPasswordPolicy) {
3853                            return null;
3854                    }
3855    
3856                    if (passwordPolicy == null) {
3857                            Session session = null;
3858    
3859                            try {
3860                                    session = openSession();
3861    
3862                                    passwordPolicy = (PasswordPolicy)session.get(PasswordPolicyImpl.class,
3863                                                    primaryKey);
3864    
3865                                    if (passwordPolicy != null) {
3866                                            cacheResult(passwordPolicy);
3867                                    }
3868                                    else {
3869                                            EntityCacheUtil.putResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
3870                                                    PasswordPolicyImpl.class, primaryKey,
3871                                                    _nullPasswordPolicy);
3872                                    }
3873                            }
3874                            catch (Exception e) {
3875                                    EntityCacheUtil.removeResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
3876                                            PasswordPolicyImpl.class, primaryKey);
3877    
3878                                    throw processException(e);
3879                            }
3880                            finally {
3881                                    closeSession(session);
3882                            }
3883                    }
3884    
3885                    return passwordPolicy;
3886            }
3887    
3888            /**
3889             * Returns the password policy with the primary key or returns <code>null</code> if it could not be found.
3890             *
3891             * @param passwordPolicyId the primary key of the password policy
3892             * @return the password policy, or <code>null</code> if a password policy with the primary key could not be found
3893             */
3894            @Override
3895            public PasswordPolicy fetchByPrimaryKey(long passwordPolicyId) {
3896                    return fetchByPrimaryKey((Serializable)passwordPolicyId);
3897            }
3898    
3899            @Override
3900            public Map<Serializable, PasswordPolicy> fetchByPrimaryKeys(
3901                    Set<Serializable> primaryKeys) {
3902                    if (primaryKeys.isEmpty()) {
3903                            return Collections.emptyMap();
3904                    }
3905    
3906                    Map<Serializable, PasswordPolicy> map = new HashMap<Serializable, PasswordPolicy>();
3907    
3908                    if (primaryKeys.size() == 1) {
3909                            Iterator<Serializable> iterator = primaryKeys.iterator();
3910    
3911                            Serializable primaryKey = iterator.next();
3912    
3913                            PasswordPolicy passwordPolicy = fetchByPrimaryKey(primaryKey);
3914    
3915                            if (passwordPolicy != null) {
3916                                    map.put(primaryKey, passwordPolicy);
3917                            }
3918    
3919                            return map;
3920                    }
3921    
3922                    Set<Serializable> uncachedPrimaryKeys = null;
3923    
3924                    for (Serializable primaryKey : primaryKeys) {
3925                            PasswordPolicy passwordPolicy = (PasswordPolicy)EntityCacheUtil.getResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
3926                                            PasswordPolicyImpl.class, primaryKey);
3927    
3928                            if (passwordPolicy == null) {
3929                                    if (uncachedPrimaryKeys == null) {
3930                                            uncachedPrimaryKeys = new HashSet<Serializable>();
3931                                    }
3932    
3933                                    uncachedPrimaryKeys.add(primaryKey);
3934                            }
3935                            else {
3936                                    map.put(primaryKey, passwordPolicy);
3937                            }
3938                    }
3939    
3940                    if (uncachedPrimaryKeys == null) {
3941                            return map;
3942                    }
3943    
3944                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
3945                                    1);
3946    
3947                    query.append(_SQL_SELECT_PASSWORDPOLICY_WHERE_PKS_IN);
3948    
3949                    for (Serializable primaryKey : uncachedPrimaryKeys) {
3950                            query.append(String.valueOf(primaryKey));
3951    
3952                            query.append(StringPool.COMMA);
3953                    }
3954    
3955                    query.setIndex(query.index() - 1);
3956    
3957                    query.append(StringPool.CLOSE_PARENTHESIS);
3958    
3959                    String sql = query.toString();
3960    
3961                    Session session = null;
3962    
3963                    try {
3964                            session = openSession();
3965    
3966                            Query q = session.createQuery(sql);
3967    
3968                            for (PasswordPolicy passwordPolicy : (List<PasswordPolicy>)q.list()) {
3969                                    map.put(passwordPolicy.getPrimaryKeyObj(), passwordPolicy);
3970    
3971                                    cacheResult(passwordPolicy);
3972    
3973                                    uncachedPrimaryKeys.remove(passwordPolicy.getPrimaryKeyObj());
3974                            }
3975    
3976                            for (Serializable primaryKey : uncachedPrimaryKeys) {
3977                                    EntityCacheUtil.putResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
3978                                            PasswordPolicyImpl.class, primaryKey, _nullPasswordPolicy);
3979                            }
3980                    }
3981                    catch (Exception e) {
3982                            throw processException(e);
3983                    }
3984                    finally {
3985                            closeSession(session);
3986                    }
3987    
3988                    return map;
3989            }
3990    
3991            /**
3992             * Returns all the password policies.
3993             *
3994             * @return the password policies
3995             */
3996            @Override
3997            public List<PasswordPolicy> findAll() {
3998                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3999            }
4000    
4001            /**
4002             * Returns a range of all the password policies.
4003             *
4004             * <p>
4005             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
4006             * </p>
4007             *
4008             * @param start the lower bound of the range of password policies
4009             * @param end the upper bound of the range of password policies (not inclusive)
4010             * @return the range of password policies
4011             */
4012            @Override
4013            public List<PasswordPolicy> findAll(int start, int end) {
4014                    return findAll(start, end, null);
4015            }
4016    
4017            /**
4018             * Returns an ordered range of all the password policies.
4019             *
4020             * <p>
4021             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PasswordPolicyModelImpl}. 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.
4022             * </p>
4023             *
4024             * @param start the lower bound of the range of password policies
4025             * @param end the upper bound of the range of password policies (not inclusive)
4026             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4027             * @return the ordered range of password policies
4028             */
4029            @Override
4030            public List<PasswordPolicy> findAll(int start, int end,
4031                    OrderByComparator<PasswordPolicy> orderByComparator) {
4032                    boolean pagination = true;
4033                    FinderPath finderPath = null;
4034                    Object[] finderArgs = null;
4035    
4036                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4037                                    (orderByComparator == null)) {
4038                            pagination = false;
4039                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4040                            finderArgs = FINDER_ARGS_EMPTY;
4041                    }
4042                    else {
4043                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4044                            finderArgs = new Object[] { start, end, orderByComparator };
4045                    }
4046    
4047                    List<PasswordPolicy> list = (List<PasswordPolicy>)FinderCacheUtil.getResult(finderPath,
4048                                    finderArgs, this);
4049    
4050                    if (list == null) {
4051                            StringBundler query = null;
4052                            String sql = null;
4053    
4054                            if (orderByComparator != null) {
4055                                    query = new StringBundler(2 +
4056                                                    (orderByComparator.getOrderByFields().length * 3));
4057    
4058                                    query.append(_SQL_SELECT_PASSWORDPOLICY);
4059    
4060                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4061                                            orderByComparator);
4062    
4063                                    sql = query.toString();
4064                            }
4065                            else {
4066                                    sql = _SQL_SELECT_PASSWORDPOLICY;
4067    
4068                                    if (pagination) {
4069                                            sql = sql.concat(PasswordPolicyModelImpl.ORDER_BY_JPQL);
4070                                    }
4071                            }
4072    
4073                            Session session = null;
4074    
4075                            try {
4076                                    session = openSession();
4077    
4078                                    Query q = session.createQuery(sql);
4079    
4080                                    if (!pagination) {
4081                                            list = (List<PasswordPolicy>)QueryUtil.list(q,
4082                                                            getDialect(), start, end, false);
4083    
4084                                            Collections.sort(list);
4085    
4086                                            list = Collections.unmodifiableList(list);
4087                                    }
4088                                    else {
4089                                            list = (List<PasswordPolicy>)QueryUtil.list(q,
4090                                                            getDialect(), start, end);
4091                                    }
4092    
4093                                    cacheResult(list);
4094    
4095                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4096                            }
4097                            catch (Exception e) {
4098                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4099    
4100                                    throw processException(e);
4101                            }
4102                            finally {
4103                                    closeSession(session);
4104                            }
4105                    }
4106    
4107                    return list;
4108            }
4109    
4110            /**
4111             * Removes all the password policies from the database.
4112             *
4113             */
4114            @Override
4115            public void removeAll() {
4116                    for (PasswordPolicy passwordPolicy : findAll()) {
4117                            remove(passwordPolicy);
4118                    }
4119            }
4120    
4121            /**
4122             * Returns the number of password policies.
4123             *
4124             * @return the number of password policies
4125             */
4126            @Override
4127            public int countAll() {
4128                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4129                                    FINDER_ARGS_EMPTY, this);
4130    
4131                    if (count == null) {
4132                            Session session = null;
4133    
4134                            try {
4135                                    session = openSession();
4136    
4137                                    Query q = session.createQuery(_SQL_COUNT_PASSWORDPOLICY);
4138    
4139                                    count = (Long)q.uniqueResult();
4140    
4141                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4142                                            FINDER_ARGS_EMPTY, count);
4143                            }
4144                            catch (Exception e) {
4145                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
4146                                            FINDER_ARGS_EMPTY);
4147    
4148                                    throw processException(e);
4149                            }
4150                            finally {
4151                                    closeSession(session);
4152                            }
4153                    }
4154    
4155                    return count.intValue();
4156            }
4157    
4158            @Override
4159            protected Set<String> getBadColumnNames() {
4160                    return _badColumnNames;
4161            }
4162    
4163            /**
4164             * Initializes the password policy persistence.
4165             */
4166            public void afterPropertiesSet() {
4167            }
4168    
4169            public void destroy() {
4170                    EntityCacheUtil.removeCache(PasswordPolicyImpl.class.getName());
4171                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4172                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4173                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4174            }
4175    
4176            private static final String _SQL_SELECT_PASSWORDPOLICY = "SELECT passwordPolicy FROM PasswordPolicy passwordPolicy";
4177            private static final String _SQL_SELECT_PASSWORDPOLICY_WHERE_PKS_IN = "SELECT passwordPolicy FROM PasswordPolicy passwordPolicy WHERE passwordPolicyId IN (";
4178            private static final String _SQL_SELECT_PASSWORDPOLICY_WHERE = "SELECT passwordPolicy FROM PasswordPolicy passwordPolicy WHERE ";
4179            private static final String _SQL_COUNT_PASSWORDPOLICY = "SELECT COUNT(passwordPolicy) FROM PasswordPolicy passwordPolicy";
4180            private static final String _SQL_COUNT_PASSWORDPOLICY_WHERE = "SELECT COUNT(passwordPolicy) FROM PasswordPolicy passwordPolicy WHERE ";
4181            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "passwordPolicy.passwordPolicyId";
4182            private static final String _FILTER_SQL_SELECT_PASSWORDPOLICY_WHERE = "SELECT DISTINCT {passwordPolicy.*} FROM PasswordPolicy passwordPolicy WHERE ";
4183            private static final String _FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_1 =
4184                    "SELECT {PasswordPolicy.*} FROM (SELECT DISTINCT passwordPolicy.passwordPolicyId FROM PasswordPolicy passwordPolicy WHERE ";
4185            private static final String _FILTER_SQL_SELECT_PASSWORDPOLICY_NO_INLINE_DISTINCT_WHERE_2 =
4186                    ") TEMP_TABLE INNER JOIN PasswordPolicy ON TEMP_TABLE.passwordPolicyId = PasswordPolicy.passwordPolicyId";
4187            private static final String _FILTER_SQL_COUNT_PASSWORDPOLICY_WHERE = "SELECT COUNT(DISTINCT passwordPolicy.passwordPolicyId) AS COUNT_VALUE FROM PasswordPolicy passwordPolicy WHERE ";
4188            private static final String _FILTER_ENTITY_ALIAS = "passwordPolicy";
4189            private static final String _FILTER_ENTITY_TABLE = "PasswordPolicy";
4190            private static final String _ORDER_BY_ENTITY_ALIAS = "passwordPolicy.";
4191            private static final String _ORDER_BY_ENTITY_TABLE = "PasswordPolicy.";
4192            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PasswordPolicy exists with the primary key ";
4193            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PasswordPolicy exists with the key {";
4194            private static final Log _log = LogFactoryUtil.getLog(PasswordPolicyPersistenceImpl.class);
4195            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
4196                                    "uuid"
4197                            });
4198            private static final PasswordPolicy _nullPasswordPolicy = new PasswordPolicyImpl() {
4199                            @Override
4200                            public Object clone() {
4201                                    return this;
4202                            }
4203    
4204                            @Override
4205                            public CacheModel<PasswordPolicy> toCacheModel() {
4206                                    return _nullPasswordPolicyCacheModel;
4207                            }
4208                    };
4209    
4210            private static final CacheModel<PasswordPolicy> _nullPasswordPolicyCacheModel =
4211                    new NullCacheModel();
4212    
4213            private static class NullCacheModel implements CacheModel<PasswordPolicy>,
4214                    MVCCModel {
4215                    @Override
4216                    public long getMvccVersion() {
4217                            return -1;
4218                    }
4219    
4220                    @Override
4221                    public void setMvccVersion(long mvccVersion) {
4222                    }
4223    
4224                    @Override
4225                    public PasswordPolicy toEntityModel() {
4226                            return _nullPasswordPolicy;
4227                    }
4228            }
4229    }