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