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