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