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