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.NoSuchWebDAVPropsException;
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.WebDAVProps;
040    import com.liferay.portal.model.impl.WebDAVPropsImpl;
041    import com.liferay.portal.model.impl.WebDAVPropsModelImpl;
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 web d a v props 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 WebDAVPropsPersistence
059     * @see WebDAVPropsUtil
060     * @generated
061     */
062    public class WebDAVPropsPersistenceImpl extends BasePersistenceImpl<WebDAVProps>
063            implements WebDAVPropsPersistence {
064            /*
065             * NOTE FOR DEVELOPERS:
066             *
067             * Never modify or reference this class directly. Always use {@link WebDAVPropsUtil} to access the web d a v props persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
068             */
069            public static final String FINDER_CLASS_NAME_ENTITY = WebDAVPropsImpl.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_C = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
075                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
076                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
077                            new String[] { Long.class.getName(), Long.class.getName() },
078                            WebDAVPropsModelImpl.CLASSNAMEID_COLUMN_BITMASK |
079                            WebDAVPropsModelImpl.CLASSPK_COLUMN_BITMASK);
080            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
081                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, Long.class,
082                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
083                            new String[] { Long.class.getName(), Long.class.getName() });
084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
085                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
086                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
087            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
088                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
089                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
090            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
091                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, Long.class,
092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
093    
094            /**
095             * Caches the web d a v props in the entity cache if it is enabled.
096             *
097             * @param webDAVProps the web d a v props
098             */
099            public void cacheResult(WebDAVProps webDAVProps) {
100                    EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
101                            WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
102    
103                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
104                            new Object[] {
105                                    Long.valueOf(webDAVProps.getClassNameId()),
106                                    Long.valueOf(webDAVProps.getClassPK())
107                            }, webDAVProps);
108    
109                    webDAVProps.resetOriginalValues();
110            }
111    
112            /**
113             * Caches the web d a v propses in the entity cache if it is enabled.
114             *
115             * @param webDAVPropses the web d a v propses
116             */
117            public void cacheResult(List<WebDAVProps> webDAVPropses) {
118                    for (WebDAVProps webDAVProps : webDAVPropses) {
119                            if (EntityCacheUtil.getResult(
120                                                    WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
121                                                    WebDAVPropsImpl.class, webDAVProps.getPrimaryKey()) == null) {
122                                    cacheResult(webDAVProps);
123                            }
124                            else {
125                                    webDAVProps.resetOriginalValues();
126                            }
127                    }
128            }
129    
130            /**
131             * Clears the cache for all web d a v propses.
132             *
133             * <p>
134             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
135             * </p>
136             */
137            @Override
138            public void clearCache() {
139                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
140                            CacheRegistryUtil.clear(WebDAVPropsImpl.class.getName());
141                    }
142    
143                    EntityCacheUtil.clearCache(WebDAVPropsImpl.class.getName());
144    
145                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
146                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
147                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
148            }
149    
150            /**
151             * Clears the cache for the web d a v props.
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(WebDAVProps webDAVProps) {
159                    EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
160                            WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
161    
162                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
163                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
164    
165                    clearUniqueFindersCache(webDAVProps);
166            }
167    
168            @Override
169            public void clearCache(List<WebDAVProps> webDAVPropses) {
170                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
171                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
172    
173                    for (WebDAVProps webDAVProps : webDAVPropses) {
174                            EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
175                                    WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
176    
177                            clearUniqueFindersCache(webDAVProps);
178                    }
179            }
180    
181            protected void cacheUniqueFindersCache(WebDAVProps webDAVProps) {
182                    if (webDAVProps.isNew()) {
183                            Object[] args = new Object[] {
184                                            Long.valueOf(webDAVProps.getClassNameId()),
185                                            Long.valueOf(webDAVProps.getClassPK())
186                                    };
187    
188                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
189                                    Long.valueOf(1));
190                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
191                                    webDAVProps);
192                    }
193                    else {
194                            WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
195    
196                            if ((webDAVPropsModelImpl.getColumnBitmask() &
197                                            FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
198                                    Object[] args = new Object[] {
199                                                    Long.valueOf(webDAVProps.getClassNameId()),
200                                                    Long.valueOf(webDAVProps.getClassPK())
201                                            };
202    
203                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
204                                            Long.valueOf(1));
205                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
206                                            webDAVProps);
207                            }
208                    }
209            }
210    
211            protected void clearUniqueFindersCache(WebDAVProps webDAVProps) {
212                    WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
213    
214                    Object[] args = new Object[] {
215                                    Long.valueOf(webDAVProps.getClassNameId()),
216                                    Long.valueOf(webDAVProps.getClassPK())
217                            };
218    
219                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
220                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
221    
222                    if ((webDAVPropsModelImpl.getColumnBitmask() &
223                                    FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
224                            args = new Object[] {
225                                            Long.valueOf(webDAVPropsModelImpl.getOriginalClassNameId()),
226                                            Long.valueOf(webDAVPropsModelImpl.getOriginalClassPK())
227                                    };
228    
229                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
230                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
231                    }
232            }
233    
234            /**
235             * Creates a new web d a v props with the primary key. Does not add the web d a v props to the database.
236             *
237             * @param webDavPropsId the primary key for the new web d a v props
238             * @return the new web d a v props
239             */
240            public WebDAVProps create(long webDavPropsId) {
241                    WebDAVProps webDAVProps = new WebDAVPropsImpl();
242    
243                    webDAVProps.setNew(true);
244                    webDAVProps.setPrimaryKey(webDavPropsId);
245    
246                    return webDAVProps;
247            }
248    
249            /**
250             * Removes the web d a v props with the primary key from the database. Also notifies the appropriate model listeners.
251             *
252             * @param webDavPropsId the primary key of the web d a v props
253             * @return the web d a v props that was removed
254             * @throws com.liferay.portal.NoSuchWebDAVPropsException if a web d a v props with the primary key could not be found
255             * @throws SystemException if a system exception occurred
256             */
257            public WebDAVProps remove(long webDavPropsId)
258                    throws NoSuchWebDAVPropsException, SystemException {
259                    return remove(Long.valueOf(webDavPropsId));
260            }
261    
262            /**
263             * Removes the web d a v props with the primary key from the database. Also notifies the appropriate model listeners.
264             *
265             * @param primaryKey the primary key of the web d a v props
266             * @return the web d a v props that was removed
267             * @throws com.liferay.portal.NoSuchWebDAVPropsException if a web d a v props with the primary key could not be found
268             * @throws SystemException if a system exception occurred
269             */
270            @Override
271            public WebDAVProps remove(Serializable primaryKey)
272                    throws NoSuchWebDAVPropsException, SystemException {
273                    Session session = null;
274    
275                    try {
276                            session = openSession();
277    
278                            WebDAVProps webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
279                                            primaryKey);
280    
281                            if (webDAVProps == null) {
282                                    if (_log.isWarnEnabled()) {
283                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
284                                    }
285    
286                                    throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
287                                            primaryKey);
288                            }
289    
290                            return remove(webDAVProps);
291                    }
292                    catch (NoSuchWebDAVPropsException nsee) {
293                            throw nsee;
294                    }
295                    catch (Exception e) {
296                            throw processException(e);
297                    }
298                    finally {
299                            closeSession(session);
300                    }
301            }
302    
303            @Override
304            protected WebDAVProps removeImpl(WebDAVProps webDAVProps)
305                    throws SystemException {
306                    webDAVProps = toUnwrappedModel(webDAVProps);
307    
308                    Session session = null;
309    
310                    try {
311                            session = openSession();
312    
313                            BatchSessionUtil.delete(session, webDAVProps);
314                    }
315                    catch (Exception e) {
316                            throw processException(e);
317                    }
318                    finally {
319                            closeSession(session);
320                    }
321    
322                    clearCache(webDAVProps);
323    
324                    return webDAVProps;
325            }
326    
327            @Override
328            public WebDAVProps updateImpl(
329                    com.liferay.portal.model.WebDAVProps webDAVProps, boolean merge)
330                    throws SystemException {
331                    webDAVProps = toUnwrappedModel(webDAVProps);
332    
333                    boolean isNew = webDAVProps.isNew();
334    
335                    Session session = null;
336    
337                    try {
338                            session = openSession();
339    
340                            BatchSessionUtil.update(session, webDAVProps, merge);
341    
342                            webDAVProps.setNew(false);
343                    }
344                    catch (Exception e) {
345                            throw processException(e);
346                    }
347                    finally {
348                            closeSession(session);
349                    }
350    
351                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
352    
353                    if (isNew || !WebDAVPropsModelImpl.COLUMN_BITMASK_ENABLED) {
354                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
355                    }
356    
357                    EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
358                            WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
359    
360                    clearUniqueFindersCache(webDAVProps);
361                    cacheUniqueFindersCache(webDAVProps);
362    
363                    return webDAVProps;
364            }
365    
366            protected WebDAVProps toUnwrappedModel(WebDAVProps webDAVProps) {
367                    if (webDAVProps instanceof WebDAVPropsImpl) {
368                            return webDAVProps;
369                    }
370    
371                    WebDAVPropsImpl webDAVPropsImpl = new WebDAVPropsImpl();
372    
373                    webDAVPropsImpl.setNew(webDAVProps.isNew());
374                    webDAVPropsImpl.setPrimaryKey(webDAVProps.getPrimaryKey());
375    
376                    webDAVPropsImpl.setWebDavPropsId(webDAVProps.getWebDavPropsId());
377                    webDAVPropsImpl.setCompanyId(webDAVProps.getCompanyId());
378                    webDAVPropsImpl.setCreateDate(webDAVProps.getCreateDate());
379                    webDAVPropsImpl.setModifiedDate(webDAVProps.getModifiedDate());
380                    webDAVPropsImpl.setClassNameId(webDAVProps.getClassNameId());
381                    webDAVPropsImpl.setClassPK(webDAVProps.getClassPK());
382                    webDAVPropsImpl.setProps(webDAVProps.getProps());
383    
384                    return webDAVPropsImpl;
385            }
386    
387            /**
388             * Returns the web d a v props with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
389             *
390             * @param primaryKey the primary key of the web d a v props
391             * @return the web d a v props
392             * @throws com.liferay.portal.NoSuchModelException if a web d a v props with the primary key could not be found
393             * @throws SystemException if a system exception occurred
394             */
395            @Override
396            public WebDAVProps findByPrimaryKey(Serializable primaryKey)
397                    throws NoSuchModelException, SystemException {
398                    return findByPrimaryKey(((Long)primaryKey).longValue());
399            }
400    
401            /**
402             * Returns the web d a v props with the primary key or throws a {@link com.liferay.portal.NoSuchWebDAVPropsException} if it could not be found.
403             *
404             * @param webDavPropsId the primary key of the web d a v props
405             * @return the web d a v props
406             * @throws com.liferay.portal.NoSuchWebDAVPropsException if a web d a v props with the primary key could not be found
407             * @throws SystemException if a system exception occurred
408             */
409            public WebDAVProps findByPrimaryKey(long webDavPropsId)
410                    throws NoSuchWebDAVPropsException, SystemException {
411                    WebDAVProps webDAVProps = fetchByPrimaryKey(webDavPropsId);
412    
413                    if (webDAVProps == null) {
414                            if (_log.isWarnEnabled()) {
415                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + webDavPropsId);
416                            }
417    
418                            throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
419                                    webDavPropsId);
420                    }
421    
422                    return webDAVProps;
423            }
424    
425            /**
426             * Returns the web d a v props with the primary key or returns <code>null</code> if it could not be found.
427             *
428             * @param primaryKey the primary key of the web d a v props
429             * @return the web d a v props, or <code>null</code> if a web d a v props with the primary key could not be found
430             * @throws SystemException if a system exception occurred
431             */
432            @Override
433            public WebDAVProps fetchByPrimaryKey(Serializable primaryKey)
434                    throws SystemException {
435                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
436            }
437    
438            /**
439             * Returns the web d a v props with the primary key or returns <code>null</code> if it could not be found.
440             *
441             * @param webDavPropsId the primary key of the web d a v props
442             * @return the web d a v props, or <code>null</code> if a web d a v props with the primary key could not be found
443             * @throws SystemException if a system exception occurred
444             */
445            public WebDAVProps fetchByPrimaryKey(long webDavPropsId)
446                    throws SystemException {
447                    WebDAVProps webDAVProps = (WebDAVProps)EntityCacheUtil.getResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
448                                    WebDAVPropsImpl.class, webDavPropsId);
449    
450                    if (webDAVProps == _nullWebDAVProps) {
451                            return null;
452                    }
453    
454                    if (webDAVProps == null) {
455                            Session session = null;
456    
457                            boolean hasException = false;
458    
459                            try {
460                                    session = openSession();
461    
462                                    webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
463                                                    Long.valueOf(webDavPropsId));
464                            }
465                            catch (Exception e) {
466                                    hasException = true;
467    
468                                    throw processException(e);
469                            }
470                            finally {
471                                    if (webDAVProps != null) {
472                                            cacheResult(webDAVProps);
473                                    }
474                                    else if (!hasException) {
475                                            EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
476                                                    WebDAVPropsImpl.class, webDavPropsId, _nullWebDAVProps);
477                                    }
478    
479                                    closeSession(session);
480                            }
481                    }
482    
483                    return webDAVProps;
484            }
485    
486            /**
487             * Returns the web d a v props where classNameId = &#63; and classPK = &#63; or throws a {@link com.liferay.portal.NoSuchWebDAVPropsException} if it could not be found.
488             *
489             * @param classNameId the class name ID
490             * @param classPK the class p k
491             * @return the matching web d a v props
492             * @throws com.liferay.portal.NoSuchWebDAVPropsException if a matching web d a v props could not be found
493             * @throws SystemException if a system exception occurred
494             */
495            public WebDAVProps findByC_C(long classNameId, long classPK)
496                    throws NoSuchWebDAVPropsException, SystemException {
497                    WebDAVProps webDAVProps = fetchByC_C(classNameId, classPK);
498    
499                    if (webDAVProps == null) {
500                            StringBundler msg = new StringBundler(6);
501    
502                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
503    
504                            msg.append("classNameId=");
505                            msg.append(classNameId);
506    
507                            msg.append(", classPK=");
508                            msg.append(classPK);
509    
510                            msg.append(StringPool.CLOSE_CURLY_BRACE);
511    
512                            if (_log.isWarnEnabled()) {
513                                    _log.warn(msg.toString());
514                            }
515    
516                            throw new NoSuchWebDAVPropsException(msg.toString());
517                    }
518    
519                    return webDAVProps;
520            }
521    
522            /**
523             * Returns the web d a v props where classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
524             *
525             * @param classNameId the class name ID
526             * @param classPK the class p k
527             * @return the matching web d a v props, or <code>null</code> if a matching web d a v props could not be found
528             * @throws SystemException if a system exception occurred
529             */
530            public WebDAVProps fetchByC_C(long classNameId, long classPK)
531                    throws SystemException {
532                    return fetchByC_C(classNameId, classPK, true);
533            }
534    
535            /**
536             * Returns the web d a v props where classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
537             *
538             * @param classNameId the class name ID
539             * @param classPK the class p k
540             * @param retrieveFromCache whether to use the finder cache
541             * @return the matching web d a v props, or <code>null</code> if a matching web d a v props could not be found
542             * @throws SystemException if a system exception occurred
543             */
544            public WebDAVProps fetchByC_C(long classNameId, long classPK,
545                    boolean retrieveFromCache) throws SystemException {
546                    Object[] finderArgs = new Object[] { classNameId, classPK };
547    
548                    Object result = null;
549    
550                    if (retrieveFromCache) {
551                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
552                                            finderArgs, this);
553                    }
554    
555                    if (result instanceof WebDAVProps) {
556                            WebDAVProps webDAVProps = (WebDAVProps)result;
557    
558                            if ((classNameId != webDAVProps.getClassNameId()) ||
559                                            (classPK != webDAVProps.getClassPK())) {
560                                    result = null;
561                            }
562                    }
563    
564                    if (result == null) {
565                            StringBundler query = new StringBundler(3);
566    
567                            query.append(_SQL_SELECT_WEBDAVPROPS_WHERE);
568    
569                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
570    
571                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
572    
573                            String sql = query.toString();
574    
575                            Session session = null;
576    
577                            try {
578                                    session = openSession();
579    
580                                    Query q = session.createQuery(sql);
581    
582                                    QueryPos qPos = QueryPos.getInstance(q);
583    
584                                    qPos.add(classNameId);
585    
586                                    qPos.add(classPK);
587    
588                                    List<WebDAVProps> list = q.list();
589    
590                                    result = list;
591    
592                                    WebDAVProps webDAVProps = null;
593    
594                                    if (list.isEmpty()) {
595                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
596                                                    finderArgs, list);
597                                    }
598                                    else {
599                                            webDAVProps = list.get(0);
600    
601                                            cacheResult(webDAVProps);
602    
603                                            if ((webDAVProps.getClassNameId() != classNameId) ||
604                                                            (webDAVProps.getClassPK() != classPK)) {
605                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
606                                                            finderArgs, webDAVProps);
607                                            }
608                                    }
609    
610                                    return webDAVProps;
611                            }
612                            catch (Exception e) {
613                                    throw processException(e);
614                            }
615                            finally {
616                                    if (result == null) {
617                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
618                                                    finderArgs);
619                                    }
620    
621                                    closeSession(session);
622                            }
623                    }
624                    else {
625                            if (result instanceof List<?>) {
626                                    return null;
627                            }
628                            else {
629                                    return (WebDAVProps)result;
630                            }
631                    }
632            }
633    
634            /**
635             * Returns all the web d a v propses.
636             *
637             * @return the web d a v propses
638             * @throws SystemException if a system exception occurred
639             */
640            public List<WebDAVProps> findAll() throws SystemException {
641                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
642            }
643    
644            /**
645             * Returns a range of all the web d a v propses.
646             *
647             * <p>
648             * 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.
649             * </p>
650             *
651             * @param start the lower bound of the range of web d a v propses
652             * @param end the upper bound of the range of web d a v propses (not inclusive)
653             * @return the range of web d a v propses
654             * @throws SystemException if a system exception occurred
655             */
656            public List<WebDAVProps> findAll(int start, int end)
657                    throws SystemException {
658                    return findAll(start, end, null);
659            }
660    
661            /**
662             * Returns an ordered range of all the web d a v propses.
663             *
664             * <p>
665             * 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.
666             * </p>
667             *
668             * @param start the lower bound of the range of web d a v propses
669             * @param end the upper bound of the range of web d a v propses (not inclusive)
670             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
671             * @return the ordered range of web d a v propses
672             * @throws SystemException if a system exception occurred
673             */
674            public List<WebDAVProps> findAll(int start, int end,
675                    OrderByComparator orderByComparator) throws SystemException {
676                    FinderPath finderPath = null;
677                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
678    
679                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
680                                    (orderByComparator == null)) {
681                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
682                            finderArgs = FINDER_ARGS_EMPTY;
683                    }
684                    else {
685                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
686                            finderArgs = new Object[] { start, end, orderByComparator };
687                    }
688    
689                    List<WebDAVProps> list = (List<WebDAVProps>)FinderCacheUtil.getResult(finderPath,
690                                    finderArgs, this);
691    
692                    if (list == null) {
693                            StringBundler query = null;
694                            String sql = null;
695    
696                            if (orderByComparator != null) {
697                                    query = new StringBundler(2 +
698                                                    (orderByComparator.getOrderByFields().length * 3));
699    
700                                    query.append(_SQL_SELECT_WEBDAVPROPS);
701    
702                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
703                                            orderByComparator);
704    
705                                    sql = query.toString();
706                            }
707                            else {
708                                    sql = _SQL_SELECT_WEBDAVPROPS;
709                            }
710    
711                            Session session = null;
712    
713                            try {
714                                    session = openSession();
715    
716                                    Query q = session.createQuery(sql);
717    
718                                    if (orderByComparator == null) {
719                                            list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
720                                                            start, end, false);
721    
722                                            Collections.sort(list);
723                                    }
724                                    else {
725                                            list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
726                                                            start, end);
727                                    }
728                            }
729                            catch (Exception e) {
730                                    throw processException(e);
731                            }
732                            finally {
733                                    if (list == null) {
734                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
735                                    }
736                                    else {
737                                            cacheResult(list);
738    
739                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
740                                    }
741    
742                                    closeSession(session);
743                            }
744                    }
745    
746                    return list;
747            }
748    
749            /**
750             * Removes the web d a v props where classNameId = &#63; and classPK = &#63; from the database.
751             *
752             * @param classNameId the class name ID
753             * @param classPK the class p k
754             * @return the web d a v props that was removed
755             * @throws SystemException if a system exception occurred
756             */
757            public WebDAVProps removeByC_C(long classNameId, long classPK)
758                    throws NoSuchWebDAVPropsException, SystemException {
759                    WebDAVProps webDAVProps = findByC_C(classNameId, classPK);
760    
761                    return remove(webDAVProps);
762            }
763    
764            /**
765             * Removes all the web d a v propses from the database.
766             *
767             * @throws SystemException if a system exception occurred
768             */
769            public void removeAll() throws SystemException {
770                    for (WebDAVProps webDAVProps : findAll()) {
771                            remove(webDAVProps);
772                    }
773            }
774    
775            /**
776             * Returns the number of web d a v propses where classNameId = &#63; and classPK = &#63;.
777             *
778             * @param classNameId the class name ID
779             * @param classPK the class p k
780             * @return the number of matching web d a v propses
781             * @throws SystemException if a system exception occurred
782             */
783            public int countByC_C(long classNameId, long classPK)
784                    throws SystemException {
785                    Object[] finderArgs = new Object[] { classNameId, classPK };
786    
787                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
788                                    finderArgs, this);
789    
790                    if (count == null) {
791                            StringBundler query = new StringBundler(3);
792    
793                            query.append(_SQL_COUNT_WEBDAVPROPS_WHERE);
794    
795                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
796    
797                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
798    
799                            String sql = query.toString();
800    
801                            Session session = null;
802    
803                            try {
804                                    session = openSession();
805    
806                                    Query q = session.createQuery(sql);
807    
808                                    QueryPos qPos = QueryPos.getInstance(q);
809    
810                                    qPos.add(classNameId);
811    
812                                    qPos.add(classPK);
813    
814                                    count = (Long)q.uniqueResult();
815                            }
816                            catch (Exception e) {
817                                    throw processException(e);
818                            }
819                            finally {
820                                    if (count == null) {
821                                            count = Long.valueOf(0);
822                                    }
823    
824                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
825                                            count);
826    
827                                    closeSession(session);
828                            }
829                    }
830    
831                    return count.intValue();
832            }
833    
834            /**
835             * Returns the number of web d a v propses.
836             *
837             * @return the number of web d a v propses
838             * @throws SystemException if a system exception occurred
839             */
840            public int countAll() throws SystemException {
841                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
842                                    FINDER_ARGS_EMPTY, this);
843    
844                    if (count == null) {
845                            Session session = null;
846    
847                            try {
848                                    session = openSession();
849    
850                                    Query q = session.createQuery(_SQL_COUNT_WEBDAVPROPS);
851    
852                                    count = (Long)q.uniqueResult();
853                            }
854                            catch (Exception e) {
855                                    throw processException(e);
856                            }
857                            finally {
858                                    if (count == null) {
859                                            count = Long.valueOf(0);
860                                    }
861    
862                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
863                                            FINDER_ARGS_EMPTY, count);
864    
865                                    closeSession(session);
866                            }
867                    }
868    
869                    return count.intValue();
870            }
871    
872            /**
873             * Initializes the web d a v props persistence.
874             */
875            public void afterPropertiesSet() {
876                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
877                                            com.liferay.portal.util.PropsUtil.get(
878                                                    "value.object.listener.com.liferay.portal.model.WebDAVProps")));
879    
880                    if (listenerClassNames.length > 0) {
881                            try {
882                                    List<ModelListener<WebDAVProps>> listenersList = new ArrayList<ModelListener<WebDAVProps>>();
883    
884                                    for (String listenerClassName : listenerClassNames) {
885                                            Class<?> clazz = getClass();
886    
887                                            listenersList.add((ModelListener<WebDAVProps>)InstanceFactory.newInstance(
888                                                            clazz.getClassLoader(), listenerClassName));
889                                    }
890    
891                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
892                            }
893                            catch (Exception e) {
894                                    _log.error(e);
895                            }
896                    }
897            }
898    
899            public void destroy() {
900                    EntityCacheUtil.removeCache(WebDAVPropsImpl.class.getName());
901                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
902                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
903            }
904    
905            @BeanReference(type = AccountPersistence.class)
906            protected AccountPersistence accountPersistence;
907            @BeanReference(type = AddressPersistence.class)
908            protected AddressPersistence addressPersistence;
909            @BeanReference(type = BrowserTrackerPersistence.class)
910            protected BrowserTrackerPersistence browserTrackerPersistence;
911            @BeanReference(type = ClassNamePersistence.class)
912            protected ClassNamePersistence classNamePersistence;
913            @BeanReference(type = ClusterGroupPersistence.class)
914            protected ClusterGroupPersistence clusterGroupPersistence;
915            @BeanReference(type = CompanyPersistence.class)
916            protected CompanyPersistence companyPersistence;
917            @BeanReference(type = ContactPersistence.class)
918            protected ContactPersistence contactPersistence;
919            @BeanReference(type = CountryPersistence.class)
920            protected CountryPersistence countryPersistence;
921            @BeanReference(type = EmailAddressPersistence.class)
922            protected EmailAddressPersistence emailAddressPersistence;
923            @BeanReference(type = GroupPersistence.class)
924            protected GroupPersistence groupPersistence;
925            @BeanReference(type = ImagePersistence.class)
926            protected ImagePersistence imagePersistence;
927            @BeanReference(type = LayoutPersistence.class)
928            protected LayoutPersistence layoutPersistence;
929            @BeanReference(type = LayoutBranchPersistence.class)
930            protected LayoutBranchPersistence layoutBranchPersistence;
931            @BeanReference(type = LayoutPrototypePersistence.class)
932            protected LayoutPrototypePersistence layoutPrototypePersistence;
933            @BeanReference(type = LayoutRevisionPersistence.class)
934            protected LayoutRevisionPersistence layoutRevisionPersistence;
935            @BeanReference(type = LayoutSetPersistence.class)
936            protected LayoutSetPersistence layoutSetPersistence;
937            @BeanReference(type = LayoutSetBranchPersistence.class)
938            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
939            @BeanReference(type = LayoutSetPrototypePersistence.class)
940            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
941            @BeanReference(type = ListTypePersistence.class)
942            protected ListTypePersistence listTypePersistence;
943            @BeanReference(type = LockPersistence.class)
944            protected LockPersistence lockPersistence;
945            @BeanReference(type = MembershipRequestPersistence.class)
946            protected MembershipRequestPersistence membershipRequestPersistence;
947            @BeanReference(type = OrganizationPersistence.class)
948            protected OrganizationPersistence organizationPersistence;
949            @BeanReference(type = OrgGroupPermissionPersistence.class)
950            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
951            @BeanReference(type = OrgGroupRolePersistence.class)
952            protected OrgGroupRolePersistence orgGroupRolePersistence;
953            @BeanReference(type = OrgLaborPersistence.class)
954            protected OrgLaborPersistence orgLaborPersistence;
955            @BeanReference(type = PasswordPolicyPersistence.class)
956            protected PasswordPolicyPersistence passwordPolicyPersistence;
957            @BeanReference(type = PasswordPolicyRelPersistence.class)
958            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
959            @BeanReference(type = PasswordTrackerPersistence.class)
960            protected PasswordTrackerPersistence passwordTrackerPersistence;
961            @BeanReference(type = PermissionPersistence.class)
962            protected PermissionPersistence permissionPersistence;
963            @BeanReference(type = PhonePersistence.class)
964            protected PhonePersistence phonePersistence;
965            @BeanReference(type = PluginSettingPersistence.class)
966            protected PluginSettingPersistence pluginSettingPersistence;
967            @BeanReference(type = PortalPreferencesPersistence.class)
968            protected PortalPreferencesPersistence portalPreferencesPersistence;
969            @BeanReference(type = PortletPersistence.class)
970            protected PortletPersistence portletPersistence;
971            @BeanReference(type = PortletItemPersistence.class)
972            protected PortletItemPersistence portletItemPersistence;
973            @BeanReference(type = PortletPreferencesPersistence.class)
974            protected PortletPreferencesPersistence portletPreferencesPersistence;
975            @BeanReference(type = RegionPersistence.class)
976            protected RegionPersistence regionPersistence;
977            @BeanReference(type = ReleasePersistence.class)
978            protected ReleasePersistence releasePersistence;
979            @BeanReference(type = RepositoryPersistence.class)
980            protected RepositoryPersistence repositoryPersistence;
981            @BeanReference(type = RepositoryEntryPersistence.class)
982            protected RepositoryEntryPersistence repositoryEntryPersistence;
983            @BeanReference(type = ResourcePersistence.class)
984            protected ResourcePersistence resourcePersistence;
985            @BeanReference(type = ResourceActionPersistence.class)
986            protected ResourceActionPersistence resourceActionPersistence;
987            @BeanReference(type = ResourceBlockPersistence.class)
988            protected ResourceBlockPersistence resourceBlockPersistence;
989            @BeanReference(type = ResourceBlockPermissionPersistence.class)
990            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
991            @BeanReference(type = ResourceCodePersistence.class)
992            protected ResourceCodePersistence resourceCodePersistence;
993            @BeanReference(type = ResourcePermissionPersistence.class)
994            protected ResourcePermissionPersistence resourcePermissionPersistence;
995            @BeanReference(type = ResourceTypePermissionPersistence.class)
996            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
997            @BeanReference(type = RolePersistence.class)
998            protected RolePersistence rolePersistence;
999            @BeanReference(type = ServiceComponentPersistence.class)
1000            protected ServiceComponentPersistence serviceComponentPersistence;
1001            @BeanReference(type = ShardPersistence.class)
1002            protected ShardPersistence shardPersistence;
1003            @BeanReference(type = SubscriptionPersistence.class)
1004            protected SubscriptionPersistence subscriptionPersistence;
1005            @BeanReference(type = TeamPersistence.class)
1006            protected TeamPersistence teamPersistence;
1007            @BeanReference(type = TicketPersistence.class)
1008            protected TicketPersistence ticketPersistence;
1009            @BeanReference(type = UserPersistence.class)
1010            protected UserPersistence userPersistence;
1011            @BeanReference(type = UserGroupPersistence.class)
1012            protected UserGroupPersistence userGroupPersistence;
1013            @BeanReference(type = UserGroupGroupRolePersistence.class)
1014            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1015            @BeanReference(type = UserGroupRolePersistence.class)
1016            protected UserGroupRolePersistence userGroupRolePersistence;
1017            @BeanReference(type = UserIdMapperPersistence.class)
1018            protected UserIdMapperPersistence userIdMapperPersistence;
1019            @BeanReference(type = UserNotificationEventPersistence.class)
1020            protected UserNotificationEventPersistence userNotificationEventPersistence;
1021            @BeanReference(type = UserTrackerPersistence.class)
1022            protected UserTrackerPersistence userTrackerPersistence;
1023            @BeanReference(type = UserTrackerPathPersistence.class)
1024            protected UserTrackerPathPersistence userTrackerPathPersistence;
1025            @BeanReference(type = VirtualHostPersistence.class)
1026            protected VirtualHostPersistence virtualHostPersistence;
1027            @BeanReference(type = WebDAVPropsPersistence.class)
1028            protected WebDAVPropsPersistence webDAVPropsPersistence;
1029            @BeanReference(type = WebsitePersistence.class)
1030            protected WebsitePersistence websitePersistence;
1031            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1032            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1033            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1034            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1035            private static final String _SQL_SELECT_WEBDAVPROPS = "SELECT webDAVProps FROM WebDAVProps webDAVProps";
1036            private static final String _SQL_SELECT_WEBDAVPROPS_WHERE = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE ";
1037            private static final String _SQL_COUNT_WEBDAVPROPS = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps";
1038            private static final String _SQL_COUNT_WEBDAVPROPS_WHERE = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps WHERE ";
1039            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "webDAVProps.classNameId = ? AND ";
1040            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "webDAVProps.classPK = ?";
1041            private static final String _ORDER_BY_ENTITY_ALIAS = "webDAVProps.";
1042            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WebDAVProps exists with the primary key ";
1043            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WebDAVProps exists with the key {";
1044            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1045            private static Log _log = LogFactoryUtil.getLog(WebDAVPropsPersistenceImpl.class);
1046            private static WebDAVProps _nullWebDAVProps = new WebDAVPropsImpl() {
1047                            @Override
1048                            public Object clone() {
1049                                    return this;
1050                            }
1051    
1052                            @Override
1053                            public CacheModel<WebDAVProps> toCacheModel() {
1054                                    return _nullWebDAVPropsCacheModel;
1055                            }
1056                    };
1057    
1058            private static CacheModel<WebDAVProps> _nullWebDAVPropsCacheModel = new CacheModel<WebDAVProps>() {
1059                            public WebDAVProps toEntityModel() {
1060                                    return _nullWebDAVProps;
1061                            }
1062                    };
1063    }