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