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