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