001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchPasswordPolicyException;
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.model.PasswordPolicy;
041    import com.liferay.portal.model.impl.PasswordPolicyImpl;
042    import com.liferay.portal.model.impl.PasswordPolicyModelImpl;
043    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044    
045    import java.io.Serializable;
046    
047    import java.util.ArrayList;
048    import java.util.Collections;
049    import java.util.List;
050    
051    /**
052     * The persistence implementation for the password policy service.
053     *
054     * <p>
055     * Caching information and settings can be found in <code>portal.properties</code>
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see PasswordPolicyPersistence
060     * @see PasswordPolicyUtil
061     * @generated
062     */
063    public class PasswordPolicyPersistenceImpl extends BasePersistenceImpl<PasswordPolicy>
064            implements PasswordPolicyPersistence {
065            /*
066             * NOTE FOR DEVELOPERS:
067             *
068             * 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.
069             */
070            public static final String FINDER_CLASS_NAME_ENTITY = PasswordPolicyImpl.class.getName();
071            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072                    ".List1";
073            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List2";
075            public static final FinderPath FINDER_PATH_FETCH_BY_C_DP = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
076                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
077                            PasswordPolicyImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByC_DP",
078                            new String[] { Long.class.getName(), Boolean.class.getName() },
079                            PasswordPolicyModelImpl.COMPANYID_COLUMN_BITMASK |
080                            PasswordPolicyModelImpl.DEFAULTPOLICY_COLUMN_BITMASK);
081            public static final FinderPath FINDER_PATH_COUNT_BY_C_DP = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
082                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED, Long.class,
083                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_DP",
084                            new String[] { Long.class.getName(), Boolean.class.getName() });
085            public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
086                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
087                            PasswordPolicyImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
088                            new String[] { Long.class.getName(), String.class.getName() },
089                            PasswordPolicyModelImpl.COMPANYID_COLUMN_BITMASK |
090                            PasswordPolicyModelImpl.NAME_COLUMN_BITMASK);
091            public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
092                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED, Long.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
094                            new String[] { Long.class.getName(), String.class.getName() });
095            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
096                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
097                            PasswordPolicyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
098                            "findAll", new String[0]);
099            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
100                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED,
101                            PasswordPolicyImpl.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
103            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
104                            PasswordPolicyModelImpl.FINDER_CACHE_ENABLED, Long.class,
105                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
106    
107            /**
108             * Caches the password policy in the entity cache if it is enabled.
109             *
110             * @param passwordPolicy the password policy
111             */
112            public void cacheResult(PasswordPolicy passwordPolicy) {
113                    EntityCacheUtil.putResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
114                            PasswordPolicyImpl.class, passwordPolicy.getPrimaryKey(),
115                            passwordPolicy);
116    
117                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DP,
118                            new Object[] {
119                                    Long.valueOf(passwordPolicy.getCompanyId()),
120                                    Boolean.valueOf(passwordPolicy.getDefaultPolicy())
121                            }, passwordPolicy);
122    
123                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
124                            new Object[] {
125                                    Long.valueOf(passwordPolicy.getCompanyId()),
126                                    
127                            passwordPolicy.getName()
128                            }, passwordPolicy);
129    
130                    passwordPolicy.resetOriginalValues();
131            }
132    
133            /**
134             * Caches the password policies in the entity cache if it is enabled.
135             *
136             * @param passwordPolicies the password policies
137             */
138            public void cacheResult(List<PasswordPolicy> passwordPolicies) {
139                    for (PasswordPolicy passwordPolicy : passwordPolicies) {
140                            if (EntityCacheUtil.getResult(
141                                                    PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
142                                                    PasswordPolicyImpl.class, passwordPolicy.getPrimaryKey()) == null) {
143                                    cacheResult(passwordPolicy);
144                            }
145                            else {
146                                    passwordPolicy.resetOriginalValues();
147                            }
148                    }
149            }
150    
151            /**
152             * Clears the cache for all password policies.
153             *
154             * <p>
155             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
156             * </p>
157             */
158            @Override
159            public void clearCache() {
160                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
161                            CacheRegistryUtil.clear(PasswordPolicyImpl.class.getName());
162                    }
163    
164                    EntityCacheUtil.clearCache(PasswordPolicyImpl.class.getName());
165    
166                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
167                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
168                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
169            }
170    
171            /**
172             * Clears the cache for the password policy.
173             *
174             * <p>
175             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
176             * </p>
177             */
178            @Override
179            public void clearCache(PasswordPolicy passwordPolicy) {
180                    EntityCacheUtil.removeResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
181                            PasswordPolicyImpl.class, passwordPolicy.getPrimaryKey());
182    
183                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
184                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
185    
186                    clearUniqueFindersCache(passwordPolicy);
187            }
188    
189            @Override
190            public void clearCache(List<PasswordPolicy> passwordPolicies) {
191                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
192                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
193    
194                    for (PasswordPolicy passwordPolicy : passwordPolicies) {
195                            EntityCacheUtil.removeResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
196                                    PasswordPolicyImpl.class, passwordPolicy.getPrimaryKey());
197    
198                            clearUniqueFindersCache(passwordPolicy);
199                    }
200            }
201    
202            protected void clearUniqueFindersCache(PasswordPolicy passwordPolicy) {
203                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DP,
204                            new Object[] {
205                                    Long.valueOf(passwordPolicy.getCompanyId()),
206                                    Boolean.valueOf(passwordPolicy.getDefaultPolicy())
207                            });
208    
209                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
210                            new Object[] {
211                                    Long.valueOf(passwordPolicy.getCompanyId()),
212                                    
213                            passwordPolicy.getName()
214                            });
215            }
216    
217            /**
218             * Creates a new password policy with the primary key. Does not add the password policy to the database.
219             *
220             * @param passwordPolicyId the primary key for the new password policy
221             * @return the new password policy
222             */
223            public PasswordPolicy create(long passwordPolicyId) {
224                    PasswordPolicy passwordPolicy = new PasswordPolicyImpl();
225    
226                    passwordPolicy.setNew(true);
227                    passwordPolicy.setPrimaryKey(passwordPolicyId);
228    
229                    return passwordPolicy;
230            }
231    
232            /**
233             * Removes the password policy with the primary key from the database. Also notifies the appropriate model listeners.
234             *
235             * @param passwordPolicyId the primary key of the password policy
236             * @return the password policy that was removed
237             * @throws com.liferay.portal.NoSuchPasswordPolicyException if a password policy with the primary key could not be found
238             * @throws SystemException if a system exception occurred
239             */
240            public PasswordPolicy remove(long passwordPolicyId)
241                    throws NoSuchPasswordPolicyException, SystemException {
242                    return remove(Long.valueOf(passwordPolicyId));
243            }
244    
245            /**
246             * Removes the password policy with the primary key from the database. Also notifies the appropriate model listeners.
247             *
248             * @param primaryKey the primary key of the password policy
249             * @return the password policy that was removed
250             * @throws com.liferay.portal.NoSuchPasswordPolicyException if a password policy with the primary key could not be found
251             * @throws SystemException if a system exception occurred
252             */
253            @Override
254            public PasswordPolicy remove(Serializable primaryKey)
255                    throws NoSuchPasswordPolicyException, SystemException {
256                    Session session = null;
257    
258                    try {
259                            session = openSession();
260    
261                            PasswordPolicy passwordPolicy = (PasswordPolicy)session.get(PasswordPolicyImpl.class,
262                                            primaryKey);
263    
264                            if (passwordPolicy == null) {
265                                    if (_log.isWarnEnabled()) {
266                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
267                                    }
268    
269                                    throw new NoSuchPasswordPolicyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
270                                            primaryKey);
271                            }
272    
273                            return remove(passwordPolicy);
274                    }
275                    catch (NoSuchPasswordPolicyException nsee) {
276                            throw nsee;
277                    }
278                    catch (Exception e) {
279                            throw processException(e);
280                    }
281                    finally {
282                            closeSession(session);
283                    }
284            }
285    
286            @Override
287            protected PasswordPolicy removeImpl(PasswordPolicy passwordPolicy)
288                    throws SystemException {
289                    passwordPolicy = toUnwrappedModel(passwordPolicy);
290    
291                    Session session = null;
292    
293                    try {
294                            session = openSession();
295    
296                            if (passwordPolicy.isCachedModel()) {
297                                    passwordPolicy = (PasswordPolicy)session.get(PasswordPolicyImpl.class,
298                                                    passwordPolicy.getPrimaryKeyObj());
299                            }
300    
301                            session.delete(passwordPolicy);
302                    }
303                    catch (Exception e) {
304                            throw processException(e);
305                    }
306                    finally {
307                            closeSession(session);
308                    }
309    
310                    clearCache(passwordPolicy);
311    
312                    return passwordPolicy;
313            }
314    
315            @Override
316            public PasswordPolicy updateImpl(
317                    com.liferay.portal.model.PasswordPolicy passwordPolicy)
318                    throws SystemException {
319                    passwordPolicy = toUnwrappedModel(passwordPolicy);
320    
321                    boolean isNew = passwordPolicy.isNew();
322    
323                    PasswordPolicyModelImpl passwordPolicyModelImpl = (PasswordPolicyModelImpl)passwordPolicy;
324    
325                    Session session = null;
326    
327                    try {
328                            session = openSession();
329    
330                            if (passwordPolicy.isNew()) {
331                                    session.save(passwordPolicy);
332    
333                                    passwordPolicy.setNew(false);
334                            }
335                            else {
336                                    session.merge(passwordPolicy);
337                            }
338                    }
339                    catch (Exception e) {
340                            throw processException(e);
341                    }
342                    finally {
343                            closeSession(session);
344                    }
345    
346                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
347    
348                    if (isNew || !PasswordPolicyModelImpl.COLUMN_BITMASK_ENABLED) {
349                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
350                    }
351    
352                    EntityCacheUtil.putResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
353                            PasswordPolicyImpl.class, passwordPolicy.getPrimaryKey(),
354                            passwordPolicy);
355    
356                    if (isNew) {
357                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DP,
358                                    new Object[] {
359                                            Long.valueOf(passwordPolicy.getCompanyId()),
360                                            Boolean.valueOf(passwordPolicy.getDefaultPolicy())
361                                    }, passwordPolicy);
362    
363                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
364                                    new Object[] {
365                                            Long.valueOf(passwordPolicy.getCompanyId()),
366                                            
367                                    passwordPolicy.getName()
368                                    }, passwordPolicy);
369                    }
370                    else {
371                            if ((passwordPolicyModelImpl.getColumnBitmask() &
372                                            FINDER_PATH_FETCH_BY_C_DP.getColumnBitmask()) != 0) {
373                                    Object[] args = new Object[] {
374                                                    Long.valueOf(passwordPolicyModelImpl.getOriginalCompanyId()),
375                                                    Boolean.valueOf(passwordPolicyModelImpl.getOriginalDefaultPolicy())
376                                            };
377    
378                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_DP, args);
379    
380                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DP, args);
381    
382                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DP,
383                                            new Object[] {
384                                                    Long.valueOf(passwordPolicy.getCompanyId()),
385                                                    Boolean.valueOf(passwordPolicy.getDefaultPolicy())
386                                            }, passwordPolicy);
387                            }
388    
389                            if ((passwordPolicyModelImpl.getColumnBitmask() &
390                                            FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
391                                    Object[] args = new Object[] {
392                                                    Long.valueOf(passwordPolicyModelImpl.getOriginalCompanyId()),
393                                                    
394                                                    passwordPolicyModelImpl.getOriginalName()
395                                            };
396    
397                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
398    
399                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
400    
401                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
402                                            new Object[] {
403                                                    Long.valueOf(passwordPolicy.getCompanyId()),
404                                                    
405                                            passwordPolicy.getName()
406                                            }, passwordPolicy);
407                            }
408                    }
409    
410                    return passwordPolicy;
411            }
412    
413            protected PasswordPolicy toUnwrappedModel(PasswordPolicy passwordPolicy) {
414                    if (passwordPolicy instanceof PasswordPolicyImpl) {
415                            return passwordPolicy;
416                    }
417    
418                    PasswordPolicyImpl passwordPolicyImpl = new PasswordPolicyImpl();
419    
420                    passwordPolicyImpl.setNew(passwordPolicy.isNew());
421                    passwordPolicyImpl.setPrimaryKey(passwordPolicy.getPrimaryKey());
422    
423                    passwordPolicyImpl.setPasswordPolicyId(passwordPolicy.getPasswordPolicyId());
424                    passwordPolicyImpl.setCompanyId(passwordPolicy.getCompanyId());
425                    passwordPolicyImpl.setUserId(passwordPolicy.getUserId());
426                    passwordPolicyImpl.setUserName(passwordPolicy.getUserName());
427                    passwordPolicyImpl.setCreateDate(passwordPolicy.getCreateDate());
428                    passwordPolicyImpl.setModifiedDate(passwordPolicy.getModifiedDate());
429                    passwordPolicyImpl.setDefaultPolicy(passwordPolicy.isDefaultPolicy());
430                    passwordPolicyImpl.setName(passwordPolicy.getName());
431                    passwordPolicyImpl.setDescription(passwordPolicy.getDescription());
432                    passwordPolicyImpl.setChangeable(passwordPolicy.isChangeable());
433                    passwordPolicyImpl.setChangeRequired(passwordPolicy.isChangeRequired());
434                    passwordPolicyImpl.setMinAge(passwordPolicy.getMinAge());
435                    passwordPolicyImpl.setCheckSyntax(passwordPolicy.isCheckSyntax());
436                    passwordPolicyImpl.setAllowDictionaryWords(passwordPolicy.isAllowDictionaryWords());
437                    passwordPolicyImpl.setMinAlphanumeric(passwordPolicy.getMinAlphanumeric());
438                    passwordPolicyImpl.setMinLength(passwordPolicy.getMinLength());
439                    passwordPolicyImpl.setMinLowerCase(passwordPolicy.getMinLowerCase());
440                    passwordPolicyImpl.setMinNumbers(passwordPolicy.getMinNumbers());
441                    passwordPolicyImpl.setMinSymbols(passwordPolicy.getMinSymbols());
442                    passwordPolicyImpl.setMinUpperCase(passwordPolicy.getMinUpperCase());
443                    passwordPolicyImpl.setHistory(passwordPolicy.isHistory());
444                    passwordPolicyImpl.setHistoryCount(passwordPolicy.getHistoryCount());
445                    passwordPolicyImpl.setExpireable(passwordPolicy.isExpireable());
446                    passwordPolicyImpl.setMaxAge(passwordPolicy.getMaxAge());
447                    passwordPolicyImpl.setWarningTime(passwordPolicy.getWarningTime());
448                    passwordPolicyImpl.setGraceLimit(passwordPolicy.getGraceLimit());
449                    passwordPolicyImpl.setLockout(passwordPolicy.isLockout());
450                    passwordPolicyImpl.setMaxFailure(passwordPolicy.getMaxFailure());
451                    passwordPolicyImpl.setLockoutDuration(passwordPolicy.getLockoutDuration());
452                    passwordPolicyImpl.setRequireUnlock(passwordPolicy.isRequireUnlock());
453                    passwordPolicyImpl.setResetFailureCount(passwordPolicy.getResetFailureCount());
454                    passwordPolicyImpl.setResetTicketMaxAge(passwordPolicy.getResetTicketMaxAge());
455    
456                    return passwordPolicyImpl;
457            }
458    
459            /**
460             * Returns the password policy with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
461             *
462             * @param primaryKey the primary key of the password policy
463             * @return the password policy
464             * @throws com.liferay.portal.NoSuchModelException if a password policy with the primary key could not be found
465             * @throws SystemException if a system exception occurred
466             */
467            @Override
468            public PasswordPolicy findByPrimaryKey(Serializable primaryKey)
469                    throws NoSuchModelException, SystemException {
470                    return findByPrimaryKey(((Long)primaryKey).longValue());
471            }
472    
473            /**
474             * Returns the password policy with the primary key or throws a {@link com.liferay.portal.NoSuchPasswordPolicyException} if it could not be found.
475             *
476             * @param passwordPolicyId the primary key of the password policy
477             * @return the password policy
478             * @throws com.liferay.portal.NoSuchPasswordPolicyException if a password policy with the primary key could not be found
479             * @throws SystemException if a system exception occurred
480             */
481            public PasswordPolicy findByPrimaryKey(long passwordPolicyId)
482                    throws NoSuchPasswordPolicyException, SystemException {
483                    PasswordPolicy passwordPolicy = fetchByPrimaryKey(passwordPolicyId);
484    
485                    if (passwordPolicy == null) {
486                            if (_log.isWarnEnabled()) {
487                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + passwordPolicyId);
488                            }
489    
490                            throw new NoSuchPasswordPolicyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
491                                    passwordPolicyId);
492                    }
493    
494                    return passwordPolicy;
495            }
496    
497            /**
498             * Returns the password policy with the primary key or returns <code>null</code> if it could not be found.
499             *
500             * @param primaryKey the primary key of the password policy
501             * @return the password policy, or <code>null</code> if a password policy with the primary key could not be found
502             * @throws SystemException if a system exception occurred
503             */
504            @Override
505            public PasswordPolicy fetchByPrimaryKey(Serializable primaryKey)
506                    throws SystemException {
507                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
508            }
509    
510            /**
511             * Returns the password policy with the primary key or returns <code>null</code> if it could not be found.
512             *
513             * @param passwordPolicyId the primary key of the password policy
514             * @return the password policy, or <code>null</code> if a password policy with the primary key could not be found
515             * @throws SystemException if a system exception occurred
516             */
517            public PasswordPolicy fetchByPrimaryKey(long passwordPolicyId)
518                    throws SystemException {
519                    PasswordPolicy passwordPolicy = (PasswordPolicy)EntityCacheUtil.getResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
520                                    PasswordPolicyImpl.class, passwordPolicyId);
521    
522                    if (passwordPolicy == _nullPasswordPolicy) {
523                            return null;
524                    }
525    
526                    if (passwordPolicy == null) {
527                            Session session = null;
528    
529                            boolean hasException = false;
530    
531                            try {
532                                    session = openSession();
533    
534                                    passwordPolicy = (PasswordPolicy)session.get(PasswordPolicyImpl.class,
535                                                    Long.valueOf(passwordPolicyId));
536                            }
537                            catch (Exception e) {
538                                    hasException = true;
539    
540                                    throw processException(e);
541                            }
542                            finally {
543                                    if (passwordPolicy != null) {
544                                            cacheResult(passwordPolicy);
545                                    }
546                                    else if (!hasException) {
547                                            EntityCacheUtil.putResult(PasswordPolicyModelImpl.ENTITY_CACHE_ENABLED,
548                                                    PasswordPolicyImpl.class, passwordPolicyId,
549                                                    _nullPasswordPolicy);
550                                    }
551    
552                                    closeSession(session);
553                            }
554                    }
555    
556                    return passwordPolicy;
557            }
558    
559            /**
560             * Returns the password policy where companyId = &#63; and defaultPolicy = &#63; or throws a {@link com.liferay.portal.NoSuchPasswordPolicyException} if it could not be found.
561             *
562             * @param companyId the company ID
563             * @param defaultPolicy the default policy
564             * @return the matching password policy
565             * @throws com.liferay.portal.NoSuchPasswordPolicyException if a matching password policy could not be found
566             * @throws SystemException if a system exception occurred
567             */
568            public PasswordPolicy findByC_DP(long companyId, boolean defaultPolicy)
569                    throws NoSuchPasswordPolicyException, SystemException {
570                    PasswordPolicy passwordPolicy = fetchByC_DP(companyId, defaultPolicy);
571    
572                    if (passwordPolicy == null) {
573                            StringBundler msg = new StringBundler(6);
574    
575                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
576    
577                            msg.append("companyId=");
578                            msg.append(companyId);
579    
580                            msg.append(", defaultPolicy=");
581                            msg.append(defaultPolicy);
582    
583                            msg.append(StringPool.CLOSE_CURLY_BRACE);
584    
585                            if (_log.isWarnEnabled()) {
586                                    _log.warn(msg.toString());
587                            }
588    
589                            throw new NoSuchPasswordPolicyException(msg.toString());
590                    }
591    
592                    return passwordPolicy;
593            }
594    
595            /**
596             * 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.
597             *
598             * @param companyId the company ID
599             * @param defaultPolicy the default policy
600             * @return the matching password policy, or <code>null</code> if a matching password policy could not be found
601             * @throws SystemException if a system exception occurred
602             */
603            public PasswordPolicy fetchByC_DP(long companyId, boolean defaultPolicy)
604                    throws SystemException {
605                    return fetchByC_DP(companyId, defaultPolicy, true);
606            }
607    
608            /**
609             * 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.
610             *
611             * @param companyId the company ID
612             * @param defaultPolicy the default policy
613             * @param retrieveFromCache whether to use the finder cache
614             * @return the matching password policy, or <code>null</code> if a matching password policy could not be found
615             * @throws SystemException if a system exception occurred
616             */
617            public PasswordPolicy fetchByC_DP(long companyId, boolean defaultPolicy,
618                    boolean retrieveFromCache) throws SystemException {
619                    Object[] finderArgs = new Object[] { companyId, defaultPolicy };
620    
621                    Object result = null;
622    
623                    if (retrieveFromCache) {
624                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_DP,
625                                            finderArgs, this);
626                    }
627    
628                    if (result instanceof PasswordPolicy) {
629                            PasswordPolicy passwordPolicy = (PasswordPolicy)result;
630    
631                            if ((companyId != passwordPolicy.getCompanyId()) ||
632                                            (defaultPolicy != passwordPolicy.getDefaultPolicy())) {
633                                    result = null;
634                            }
635                    }
636    
637                    if (result == null) {
638                            StringBundler query = new StringBundler(3);
639    
640                            query.append(_SQL_SELECT_PASSWORDPOLICY_WHERE);
641    
642                            query.append(_FINDER_COLUMN_C_DP_COMPANYID_2);
643    
644                            query.append(_FINDER_COLUMN_C_DP_DEFAULTPOLICY_2);
645    
646                            String sql = query.toString();
647    
648                            Session session = null;
649    
650                            try {
651                                    session = openSession();
652    
653                                    Query q = session.createQuery(sql);
654    
655                                    QueryPos qPos = QueryPos.getInstance(q);
656    
657                                    qPos.add(companyId);
658    
659                                    qPos.add(defaultPolicy);
660    
661                                    List<PasswordPolicy> list = q.list();
662    
663                                    result = list;
664    
665                                    PasswordPolicy passwordPolicy = null;
666    
667                                    if (list.isEmpty()) {
668                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DP,
669                                                    finderArgs, list);
670                                    }
671                                    else {
672                                            passwordPolicy = list.get(0);
673    
674                                            cacheResult(passwordPolicy);
675    
676                                            if ((passwordPolicy.getCompanyId() != companyId) ||
677                                                            (passwordPolicy.getDefaultPolicy() != defaultPolicy)) {
678                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DP,
679                                                            finderArgs, passwordPolicy);
680                                            }
681                                    }
682    
683                                    return passwordPolicy;
684                            }
685                            catch (Exception e) {
686                                    throw processException(e);
687                            }
688                            finally {
689                                    if (result == null) {
690                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DP,
691                                                    finderArgs);
692                                    }
693    
694                                    closeSession(session);
695                            }
696                    }
697                    else {
698                            if (result instanceof List<?>) {
699                                    return null;
700                            }
701                            else {
702                                    return (PasswordPolicy)result;
703                            }
704                    }
705            }
706    
707            /**
708             * Returns the password policy where companyId = &#63; and name = &#63; or throws a {@link com.liferay.portal.NoSuchPasswordPolicyException} if it could not be found.
709             *
710             * @param companyId the company ID
711             * @param name the name
712             * @return the matching password policy
713             * @throws com.liferay.portal.NoSuchPasswordPolicyException if a matching password policy could not be found
714             * @throws SystemException if a system exception occurred
715             */
716            public PasswordPolicy findByC_N(long companyId, String name)
717                    throws NoSuchPasswordPolicyException, SystemException {
718                    PasswordPolicy passwordPolicy = fetchByC_N(companyId, name);
719    
720                    if (passwordPolicy == null) {
721                            StringBundler msg = new StringBundler(6);
722    
723                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
724    
725                            msg.append("companyId=");
726                            msg.append(companyId);
727    
728                            msg.append(", name=");
729                            msg.append(name);
730    
731                            msg.append(StringPool.CLOSE_CURLY_BRACE);
732    
733                            if (_log.isWarnEnabled()) {
734                                    _log.warn(msg.toString());
735                            }
736    
737                            throw new NoSuchPasswordPolicyException(msg.toString());
738                    }
739    
740                    return passwordPolicy;
741            }
742    
743            /**
744             * 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.
745             *
746             * @param companyId the company ID
747             * @param name the name
748             * @return the matching password policy, or <code>null</code> if a matching password policy could not be found
749             * @throws SystemException if a system exception occurred
750             */
751            public PasswordPolicy fetchByC_N(long companyId, String name)
752                    throws SystemException {
753                    return fetchByC_N(companyId, name, true);
754            }
755    
756            /**
757             * 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.
758             *
759             * @param companyId the company ID
760             * @param name the name
761             * @param retrieveFromCache whether to use the finder cache
762             * @return the matching password policy, or <code>null</code> if a matching password policy could not be found
763             * @throws SystemException if a system exception occurred
764             */
765            public PasswordPolicy fetchByC_N(long companyId, String name,
766                    boolean retrieveFromCache) throws SystemException {
767                    Object[] finderArgs = new Object[] { companyId, name };
768    
769                    Object result = null;
770    
771                    if (retrieveFromCache) {
772                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
773                                            finderArgs, this);
774                    }
775    
776                    if (result instanceof PasswordPolicy) {
777                            PasswordPolicy passwordPolicy = (PasswordPolicy)result;
778    
779                            if ((companyId != passwordPolicy.getCompanyId()) ||
780                                            !Validator.equals(name, passwordPolicy.getName())) {
781                                    result = null;
782                            }
783                    }
784    
785                    if (result == null) {
786                            StringBundler query = new StringBundler(3);
787    
788                            query.append(_SQL_SELECT_PASSWORDPOLICY_WHERE);
789    
790                            query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
791    
792                            if (name == null) {
793                                    query.append(_FINDER_COLUMN_C_N_NAME_1);
794                            }
795                            else {
796                                    if (name.equals(StringPool.BLANK)) {
797                                            query.append(_FINDER_COLUMN_C_N_NAME_3);
798                                    }
799                                    else {
800                                            query.append(_FINDER_COLUMN_C_N_NAME_2);
801                                    }
802                            }
803    
804                            String sql = query.toString();
805    
806                            Session session = null;
807    
808                            try {
809                                    session = openSession();
810    
811                                    Query q = session.createQuery(sql);
812    
813                                    QueryPos qPos = QueryPos.getInstance(q);
814    
815                                    qPos.add(companyId);
816    
817                                    if (name != null) {
818                                            qPos.add(name);
819                                    }
820    
821                                    List<PasswordPolicy> list = q.list();
822    
823                                    result = list;
824    
825                                    PasswordPolicy passwordPolicy = null;
826    
827                                    if (list.isEmpty()) {
828                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
829                                                    finderArgs, list);
830                                    }
831                                    else {
832                                            passwordPolicy = list.get(0);
833    
834                                            cacheResult(passwordPolicy);
835    
836                                            if ((passwordPolicy.getCompanyId() != companyId) ||
837                                                            (passwordPolicy.getName() == null) ||
838                                                            !passwordPolicy.getName().equals(name)) {
839                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
840                                                            finderArgs, passwordPolicy);
841                                            }
842                                    }
843    
844                                    return passwordPolicy;
845                            }
846                            catch (Exception e) {
847                                    throw processException(e);
848                            }
849                            finally {
850                                    if (result == null) {
851                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
852                                                    finderArgs);
853                                    }
854    
855                                    closeSession(session);
856                            }
857                    }
858                    else {
859                            if (result instanceof List<?>) {
860                                    return null;
861                            }
862                            else {
863                                    return (PasswordPolicy)result;
864                            }
865                    }
866            }
867    
868            /**
869             * Returns all the password policies.
870             *
871             * @return the password policies
872             * @throws SystemException if a system exception occurred
873             */
874            public List<PasswordPolicy> findAll() throws SystemException {
875                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
876            }
877    
878            /**
879             * Returns a range of all the password policies.
880             *
881             * <p>
882             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
883             * </p>
884             *
885             * @param start the lower bound of the range of password policies
886             * @param end the upper bound of the range of password policies (not inclusive)
887             * @return the range of password policies
888             * @throws SystemException if a system exception occurred
889             */
890            public List<PasswordPolicy> findAll(int start, int end)
891                    throws SystemException {
892                    return findAll(start, end, null);
893            }
894    
895            /**
896             * Returns an ordered range of all the password policies.
897             *
898             * <p>
899             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
900             * </p>
901             *
902             * @param start the lower bound of the range of password policies
903             * @param end the upper bound of the range of password policies (not inclusive)
904             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
905             * @return the ordered range of password policies
906             * @throws SystemException if a system exception occurred
907             */
908            public List<PasswordPolicy> findAll(int start, int end,
909                    OrderByComparator orderByComparator) throws SystemException {
910                    FinderPath finderPath = null;
911                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
912    
913                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
914                                    (orderByComparator == null)) {
915                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
916                            finderArgs = FINDER_ARGS_EMPTY;
917                    }
918                    else {
919                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
920                            finderArgs = new Object[] { start, end, orderByComparator };
921                    }
922    
923                    List<PasswordPolicy> list = (List<PasswordPolicy>)FinderCacheUtil.getResult(finderPath,
924                                    finderArgs, this);
925    
926                    if (list == null) {
927                            StringBundler query = null;
928                            String sql = null;
929    
930                            if (orderByComparator != null) {
931                                    query = new StringBundler(2 +
932                                                    (orderByComparator.getOrderByFields().length * 3));
933    
934                                    query.append(_SQL_SELECT_PASSWORDPOLICY);
935    
936                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
937                                            orderByComparator);
938    
939                                    sql = query.toString();
940                            }
941                            else {
942                                    sql = _SQL_SELECT_PASSWORDPOLICY;
943                            }
944    
945                            Session session = null;
946    
947                            try {
948                                    session = openSession();
949    
950                                    Query q = session.createQuery(sql);
951    
952                                    if (orderByComparator == null) {
953                                            list = (List<PasswordPolicy>)QueryUtil.list(q,
954                                                            getDialect(), start, end, false);
955    
956                                            Collections.sort(list);
957                                    }
958                                    else {
959                                            list = (List<PasswordPolicy>)QueryUtil.list(q,
960                                                            getDialect(), start, end);
961                                    }
962                            }
963                            catch (Exception e) {
964                                    throw processException(e);
965                            }
966                            finally {
967                                    if (list == null) {
968                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
969                                    }
970                                    else {
971                                            cacheResult(list);
972    
973                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
974                                    }
975    
976                                    closeSession(session);
977                            }
978                    }
979    
980                    return list;
981            }
982    
983            /**
984             * Removes the password policy where companyId = &#63; and defaultPolicy = &#63; from the database.
985             *
986             * @param companyId the company ID
987             * @param defaultPolicy the default policy
988             * @return the password policy that was removed
989             * @throws SystemException if a system exception occurred
990             */
991            public PasswordPolicy removeByC_DP(long companyId, boolean defaultPolicy)
992                    throws NoSuchPasswordPolicyException, SystemException {
993                    PasswordPolicy passwordPolicy = findByC_DP(companyId, defaultPolicy);
994    
995                    return remove(passwordPolicy);
996            }
997    
998            /**
999             * Removes the password policy where companyId = &#63; and name = &#63; from the database.
1000             *
1001             * @param companyId the company ID
1002             * @param name the name
1003             * @return the password policy that was removed
1004             * @throws SystemException if a system exception occurred
1005             */
1006            public PasswordPolicy removeByC_N(long companyId, String name)
1007                    throws NoSuchPasswordPolicyException, SystemException {
1008                    PasswordPolicy passwordPolicy = findByC_N(companyId, name);
1009    
1010                    return remove(passwordPolicy);
1011            }
1012    
1013            /**
1014             * Removes all the password policies from the database.
1015             *
1016             * @throws SystemException if a system exception occurred
1017             */
1018            public void removeAll() throws SystemException {
1019                    for (PasswordPolicy passwordPolicy : findAll()) {
1020                            remove(passwordPolicy);
1021                    }
1022            }
1023    
1024            /**
1025             * Returns the number of password policies where companyId = &#63; and defaultPolicy = &#63;.
1026             *
1027             * @param companyId the company ID
1028             * @param defaultPolicy the default policy
1029             * @return the number of matching password policies
1030             * @throws SystemException if a system exception occurred
1031             */
1032            public int countByC_DP(long companyId, boolean defaultPolicy)
1033                    throws SystemException {
1034                    Object[] finderArgs = new Object[] { companyId, defaultPolicy };
1035    
1036                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_DP,
1037                                    finderArgs, this);
1038    
1039                    if (count == null) {
1040                            StringBundler query = new StringBundler(3);
1041    
1042                            query.append(_SQL_COUNT_PASSWORDPOLICY_WHERE);
1043    
1044                            query.append(_FINDER_COLUMN_C_DP_COMPANYID_2);
1045    
1046                            query.append(_FINDER_COLUMN_C_DP_DEFAULTPOLICY_2);
1047    
1048                            String sql = query.toString();
1049    
1050                            Session session = null;
1051    
1052                            try {
1053                                    session = openSession();
1054    
1055                                    Query q = session.createQuery(sql);
1056    
1057                                    QueryPos qPos = QueryPos.getInstance(q);
1058    
1059                                    qPos.add(companyId);
1060    
1061                                    qPos.add(defaultPolicy);
1062    
1063                                    count = (Long)q.uniqueResult();
1064                            }
1065                            catch (Exception e) {
1066                                    throw processException(e);
1067                            }
1068                            finally {
1069                                    if (count == null) {
1070                                            count = Long.valueOf(0);
1071                                    }
1072    
1073                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_DP,
1074                                            finderArgs, count);
1075    
1076                                    closeSession(session);
1077                            }
1078                    }
1079    
1080                    return count.intValue();
1081            }
1082    
1083            /**
1084             * Returns the number of password policies where companyId = &#63; and name = &#63;.
1085             *
1086             * @param companyId the company ID
1087             * @param name the name
1088             * @return the number of matching password policies
1089             * @throws SystemException if a system exception occurred
1090             */
1091            public int countByC_N(long companyId, String name)
1092                    throws SystemException {
1093                    Object[] finderArgs = new Object[] { companyId, name };
1094    
1095                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
1096                                    finderArgs, this);
1097    
1098                    if (count == null) {
1099                            StringBundler query = new StringBundler(3);
1100    
1101                            query.append(_SQL_COUNT_PASSWORDPOLICY_WHERE);
1102    
1103                            query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1104    
1105                            if (name == null) {
1106                                    query.append(_FINDER_COLUMN_C_N_NAME_1);
1107                            }
1108                            else {
1109                                    if (name.equals(StringPool.BLANK)) {
1110                                            query.append(_FINDER_COLUMN_C_N_NAME_3);
1111                                    }
1112                                    else {
1113                                            query.append(_FINDER_COLUMN_C_N_NAME_2);
1114                                    }
1115                            }
1116    
1117                            String sql = query.toString();
1118    
1119                            Session session = null;
1120    
1121                            try {
1122                                    session = openSession();
1123    
1124                                    Query q = session.createQuery(sql);
1125    
1126                                    QueryPos qPos = QueryPos.getInstance(q);
1127    
1128                                    qPos.add(companyId);
1129    
1130                                    if (name != null) {
1131                                            qPos.add(name);
1132                                    }
1133    
1134                                    count = (Long)q.uniqueResult();
1135                            }
1136                            catch (Exception e) {
1137                                    throw processException(e);
1138                            }
1139                            finally {
1140                                    if (count == null) {
1141                                            count = Long.valueOf(0);
1142                                    }
1143    
1144                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
1145                                            count);
1146    
1147                                    closeSession(session);
1148                            }
1149                    }
1150    
1151                    return count.intValue();
1152            }
1153    
1154            /**
1155             * Returns the number of password policies.
1156             *
1157             * @return the number of password policies
1158             * @throws SystemException if a system exception occurred
1159             */
1160            public int countAll() throws SystemException {
1161                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1162                                    FINDER_ARGS_EMPTY, this);
1163    
1164                    if (count == null) {
1165                            Session session = null;
1166    
1167                            try {
1168                                    session = openSession();
1169    
1170                                    Query q = session.createQuery(_SQL_COUNT_PASSWORDPOLICY);
1171    
1172                                    count = (Long)q.uniqueResult();
1173                            }
1174                            catch (Exception e) {
1175                                    throw processException(e);
1176                            }
1177                            finally {
1178                                    if (count == null) {
1179                                            count = Long.valueOf(0);
1180                                    }
1181    
1182                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1183                                            FINDER_ARGS_EMPTY, count);
1184    
1185                                    closeSession(session);
1186                            }
1187                    }
1188    
1189                    return count.intValue();
1190            }
1191    
1192            /**
1193             * Initializes the password policy persistence.
1194             */
1195            public void afterPropertiesSet() {
1196                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1197                                            com.liferay.portal.util.PropsUtil.get(
1198                                                    "value.object.listener.com.liferay.portal.model.PasswordPolicy")));
1199    
1200                    if (listenerClassNames.length > 0) {
1201                            try {
1202                                    List<ModelListener<PasswordPolicy>> listenersList = new ArrayList<ModelListener<PasswordPolicy>>();
1203    
1204                                    for (String listenerClassName : listenerClassNames) {
1205                                            listenersList.add((ModelListener<PasswordPolicy>)InstanceFactory.newInstance(
1206                                                            listenerClassName));
1207                                    }
1208    
1209                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1210                            }
1211                            catch (Exception e) {
1212                                    _log.error(e);
1213                            }
1214                    }
1215            }
1216    
1217            public void destroy() {
1218                    EntityCacheUtil.removeCache(PasswordPolicyImpl.class.getName());
1219                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1220                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1221            }
1222    
1223            @BeanReference(type = AccountPersistence.class)
1224            protected AccountPersistence accountPersistence;
1225            @BeanReference(type = AddressPersistence.class)
1226            protected AddressPersistence addressPersistence;
1227            @BeanReference(type = BrowserTrackerPersistence.class)
1228            protected BrowserTrackerPersistence browserTrackerPersistence;
1229            @BeanReference(type = ClassNamePersistence.class)
1230            protected ClassNamePersistence classNamePersistence;
1231            @BeanReference(type = ClusterGroupPersistence.class)
1232            protected ClusterGroupPersistence clusterGroupPersistence;
1233            @BeanReference(type = CompanyPersistence.class)
1234            protected CompanyPersistence companyPersistence;
1235            @BeanReference(type = ContactPersistence.class)
1236            protected ContactPersistence contactPersistence;
1237            @BeanReference(type = CountryPersistence.class)
1238            protected CountryPersistence countryPersistence;
1239            @BeanReference(type = EmailAddressPersistence.class)
1240            protected EmailAddressPersistence emailAddressPersistence;
1241            @BeanReference(type = GroupPersistence.class)
1242            protected GroupPersistence groupPersistence;
1243            @BeanReference(type = ImagePersistence.class)
1244            protected ImagePersistence imagePersistence;
1245            @BeanReference(type = LayoutPersistence.class)
1246            protected LayoutPersistence layoutPersistence;
1247            @BeanReference(type = LayoutBranchPersistence.class)
1248            protected LayoutBranchPersistence layoutBranchPersistence;
1249            @BeanReference(type = LayoutPrototypePersistence.class)
1250            protected LayoutPrototypePersistence layoutPrototypePersistence;
1251            @BeanReference(type = LayoutRevisionPersistence.class)
1252            protected LayoutRevisionPersistence layoutRevisionPersistence;
1253            @BeanReference(type = LayoutSetPersistence.class)
1254            protected LayoutSetPersistence layoutSetPersistence;
1255            @BeanReference(type = LayoutSetBranchPersistence.class)
1256            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1257            @BeanReference(type = LayoutSetPrototypePersistence.class)
1258            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1259            @BeanReference(type = ListTypePersistence.class)
1260            protected ListTypePersistence listTypePersistence;
1261            @BeanReference(type = LockPersistence.class)
1262            protected LockPersistence lockPersistence;
1263            @BeanReference(type = MembershipRequestPersistence.class)
1264            protected MembershipRequestPersistence membershipRequestPersistence;
1265            @BeanReference(type = OrganizationPersistence.class)
1266            protected OrganizationPersistence organizationPersistence;
1267            @BeanReference(type = OrgGroupRolePersistence.class)
1268            protected OrgGroupRolePersistence orgGroupRolePersistence;
1269            @BeanReference(type = OrgLaborPersistence.class)
1270            protected OrgLaborPersistence orgLaborPersistence;
1271            @BeanReference(type = PasswordPolicyPersistence.class)
1272            protected PasswordPolicyPersistence passwordPolicyPersistence;
1273            @BeanReference(type = PasswordPolicyRelPersistence.class)
1274            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1275            @BeanReference(type = PasswordTrackerPersistence.class)
1276            protected PasswordTrackerPersistence passwordTrackerPersistence;
1277            @BeanReference(type = PhonePersistence.class)
1278            protected PhonePersistence phonePersistence;
1279            @BeanReference(type = PluginSettingPersistence.class)
1280            protected PluginSettingPersistence pluginSettingPersistence;
1281            @BeanReference(type = PortalPreferencesPersistence.class)
1282            protected PortalPreferencesPersistence portalPreferencesPersistence;
1283            @BeanReference(type = PortletPersistence.class)
1284            protected PortletPersistence portletPersistence;
1285            @BeanReference(type = PortletItemPersistence.class)
1286            protected PortletItemPersistence portletItemPersistence;
1287            @BeanReference(type = PortletPreferencesPersistence.class)
1288            protected PortletPreferencesPersistence portletPreferencesPersistence;
1289            @BeanReference(type = RegionPersistence.class)
1290            protected RegionPersistence regionPersistence;
1291            @BeanReference(type = ReleasePersistence.class)
1292            protected ReleasePersistence releasePersistence;
1293            @BeanReference(type = RepositoryPersistence.class)
1294            protected RepositoryPersistence repositoryPersistence;
1295            @BeanReference(type = RepositoryEntryPersistence.class)
1296            protected RepositoryEntryPersistence repositoryEntryPersistence;
1297            @BeanReference(type = ResourceActionPersistence.class)
1298            protected ResourceActionPersistence resourceActionPersistence;
1299            @BeanReference(type = ResourceBlockPersistence.class)
1300            protected ResourceBlockPersistence resourceBlockPersistence;
1301            @BeanReference(type = ResourceBlockPermissionPersistence.class)
1302            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1303            @BeanReference(type = ResourcePermissionPersistence.class)
1304            protected ResourcePermissionPersistence resourcePermissionPersistence;
1305            @BeanReference(type = ResourceTypePermissionPersistence.class)
1306            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1307            @BeanReference(type = RolePersistence.class)
1308            protected RolePersistence rolePersistence;
1309            @BeanReference(type = ServiceComponentPersistence.class)
1310            protected ServiceComponentPersistence serviceComponentPersistence;
1311            @BeanReference(type = ShardPersistence.class)
1312            protected ShardPersistence shardPersistence;
1313            @BeanReference(type = SubscriptionPersistence.class)
1314            protected SubscriptionPersistence subscriptionPersistence;
1315            @BeanReference(type = TeamPersistence.class)
1316            protected TeamPersistence teamPersistence;
1317            @BeanReference(type = TicketPersistence.class)
1318            protected TicketPersistence ticketPersistence;
1319            @BeanReference(type = UserPersistence.class)
1320            protected UserPersistence userPersistence;
1321            @BeanReference(type = UserGroupPersistence.class)
1322            protected UserGroupPersistence userGroupPersistence;
1323            @BeanReference(type = UserGroupGroupRolePersistence.class)
1324            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1325            @BeanReference(type = UserGroupRolePersistence.class)
1326            protected UserGroupRolePersistence userGroupRolePersistence;
1327            @BeanReference(type = UserIdMapperPersistence.class)
1328            protected UserIdMapperPersistence userIdMapperPersistence;
1329            @BeanReference(type = UserNotificationEventPersistence.class)
1330            protected UserNotificationEventPersistence userNotificationEventPersistence;
1331            @BeanReference(type = UserTrackerPersistence.class)
1332            protected UserTrackerPersistence userTrackerPersistence;
1333            @BeanReference(type = UserTrackerPathPersistence.class)
1334            protected UserTrackerPathPersistence userTrackerPathPersistence;
1335            @BeanReference(type = VirtualHostPersistence.class)
1336            protected VirtualHostPersistence virtualHostPersistence;
1337            @BeanReference(type = WebDAVPropsPersistence.class)
1338            protected WebDAVPropsPersistence webDAVPropsPersistence;
1339            @BeanReference(type = WebsitePersistence.class)
1340            protected WebsitePersistence websitePersistence;
1341            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1342            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1343            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1344            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1345            private static final String _SQL_SELECT_PASSWORDPOLICY = "SELECT passwordPolicy FROM PasswordPolicy passwordPolicy";
1346            private static final String _SQL_SELECT_PASSWORDPOLICY_WHERE = "SELECT passwordPolicy FROM PasswordPolicy passwordPolicy WHERE ";
1347            private static final String _SQL_COUNT_PASSWORDPOLICY = "SELECT COUNT(passwordPolicy) FROM PasswordPolicy passwordPolicy";
1348            private static final String _SQL_COUNT_PASSWORDPOLICY_WHERE = "SELECT COUNT(passwordPolicy) FROM PasswordPolicy passwordPolicy WHERE ";
1349            private static final String _FINDER_COLUMN_C_DP_COMPANYID_2 = "passwordPolicy.companyId = ? AND ";
1350            private static final String _FINDER_COLUMN_C_DP_DEFAULTPOLICY_2 = "passwordPolicy.defaultPolicy = ?";
1351            private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "passwordPolicy.companyId = ? AND ";
1352            private static final String _FINDER_COLUMN_C_N_NAME_1 = "passwordPolicy.name IS NULL";
1353            private static final String _FINDER_COLUMN_C_N_NAME_2 = "passwordPolicy.name = ?";
1354            private static final String _FINDER_COLUMN_C_N_NAME_3 = "(passwordPolicy.name IS NULL OR passwordPolicy.name = ?)";
1355            private static final String _ORDER_BY_ENTITY_ALIAS = "passwordPolicy.";
1356            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PasswordPolicy exists with the primary key ";
1357            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PasswordPolicy exists with the key {";
1358            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1359            private static Log _log = LogFactoryUtil.getLog(PasswordPolicyPersistenceImpl.class);
1360            private static PasswordPolicy _nullPasswordPolicy = new PasswordPolicyImpl() {
1361                            @Override
1362                            public Object clone() {
1363                                    return this;
1364                            }
1365    
1366                            @Override
1367                            public CacheModel<PasswordPolicy> toCacheModel() {
1368                                    return _nullPasswordPolicyCacheModel;
1369                            }
1370                    };
1371    
1372            private static CacheModel<PasswordPolicy> _nullPasswordPolicyCacheModel = new CacheModel<PasswordPolicy>() {
1373                            public PasswordPolicy toEntityModel() {
1374                                    return _nullPasswordPolicy;
1375                            }
1376                    };
1377    }