001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchWebDAVPropsException;
019    import com.liferay.portal.kernel.annotation.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.ModelListener;
038    import com.liferay.portal.model.WebDAVProps;
039    import com.liferay.portal.model.impl.WebDAVPropsImpl;
040    import com.liferay.portal.model.impl.WebDAVPropsModelImpl;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import java.io.Serializable;
044    
045    import java.util.ArrayList;
046    import java.util.Collections;
047    import java.util.List;
048    
049    /**
050     * The persistence implementation for the web d a v props service.
051     *
052     * <p>
053     * 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.
054     * </p>
055     *
056     * <p>
057     * Caching information and settings can be found in <code>portal.properties</code>
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see WebDAVPropsPersistence
062     * @see WebDAVPropsUtil
063     * @generated
064     */
065    public class WebDAVPropsPersistenceImpl extends BasePersistenceImpl<WebDAVProps>
066            implements WebDAVPropsPersistence {
067            public static final String FINDER_CLASS_NAME_ENTITY = WebDAVPropsImpl.class.getName();
068            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
069                    ".List";
070            public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
071                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED,
072                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
073                            new String[] { Long.class.getName(), Long.class.getName() });
074            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
075                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
076                            "countByC_C",
077                            new String[] { Long.class.getName(), Long.class.getName() });
078            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
079                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
080                            "findAll", new String[0]);
081            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
082                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
083                            "countAll", new String[0]);
084    
085            /**
086             * Caches the web d a v props in the entity cache if it is enabled.
087             *
088             * @param webDAVProps the web d a v props to cache
089             */
090            public void cacheResult(WebDAVProps webDAVProps) {
091                    EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
092                            WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
093    
094                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
095                            new Object[] {
096                                    new Long(webDAVProps.getClassNameId()),
097                                    new Long(webDAVProps.getClassPK())
098                            }, webDAVProps);
099            }
100    
101            /**
102             * Caches the web d a v propses in the entity cache if it is enabled.
103             *
104             * @param webDAVPropses the web d a v propses to cache
105             */
106            public void cacheResult(List<WebDAVProps> webDAVPropses) {
107                    for (WebDAVProps webDAVProps : webDAVPropses) {
108                            if (EntityCacheUtil.getResult(
109                                                    WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
110                                                    WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), this) == null) {
111                                    cacheResult(webDAVProps);
112                            }
113                    }
114            }
115    
116            /**
117             * Clears the cache for all web d a v propses.
118             *
119             * <p>
120             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
121             * </p>
122             */
123            public void clearCache() {
124                    CacheRegistryUtil.clear(WebDAVPropsImpl.class.getName());
125                    EntityCacheUtil.clearCache(WebDAVPropsImpl.class.getName());
126                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
127                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
128            }
129    
130            /**
131             * Clears the cache for the web d a v props.
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            public void clearCache(WebDAVProps webDAVProps) {
138                    EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
139                            WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
140    
141                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
142                            new Object[] {
143                                    new Long(webDAVProps.getClassNameId()),
144                                    new Long(webDAVProps.getClassPK())
145                            });
146            }
147    
148            /**
149             * Creates a new web d a v props with the primary key. Does not add the web d a v props to the database.
150             *
151             * @param webDavPropsId the primary key for the new web d a v props
152             * @return the new web d a v props
153             */
154            public WebDAVProps create(long webDavPropsId) {
155                    WebDAVProps webDAVProps = new WebDAVPropsImpl();
156    
157                    webDAVProps.setNew(true);
158                    webDAVProps.setPrimaryKey(webDavPropsId);
159    
160                    return webDAVProps;
161            }
162    
163            /**
164             * Removes the web d a v props with the primary key from the database. Also notifies the appropriate model listeners.
165             *
166             * @param primaryKey the primary key of the web d a v props to remove
167             * @return the web d a v props that was removed
168             * @throws com.liferay.portal.NoSuchModelException if a web d a v props with the primary key could not be found
169             * @throws SystemException if a system exception occurred
170             */
171            public WebDAVProps remove(Serializable primaryKey)
172                    throws NoSuchModelException, SystemException {
173                    return remove(((Long)primaryKey).longValue());
174            }
175    
176            /**
177             * Removes the web d a v props with the primary key from the database. Also notifies the appropriate model listeners.
178             *
179             * @param webDavPropsId the primary key of the web d a v props to remove
180             * @return the web d a v props that was removed
181             * @throws com.liferay.portal.NoSuchWebDAVPropsException if a web d a v props with the primary key could not be found
182             * @throws SystemException if a system exception occurred
183             */
184            public WebDAVProps remove(long webDavPropsId)
185                    throws NoSuchWebDAVPropsException, SystemException {
186                    Session session = null;
187    
188                    try {
189                            session = openSession();
190    
191                            WebDAVProps webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
192                                            new Long(webDavPropsId));
193    
194                            if (webDAVProps == null) {
195                                    if (_log.isWarnEnabled()) {
196                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + webDavPropsId);
197                                    }
198    
199                                    throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
200                                            webDavPropsId);
201                            }
202    
203                            return remove(webDAVProps);
204                    }
205                    catch (NoSuchWebDAVPropsException nsee) {
206                            throw nsee;
207                    }
208                    catch (Exception e) {
209                            throw processException(e);
210                    }
211                    finally {
212                            closeSession(session);
213                    }
214            }
215    
216            protected WebDAVProps removeImpl(WebDAVProps webDAVProps)
217                    throws SystemException {
218                    webDAVProps = toUnwrappedModel(webDAVProps);
219    
220                    Session session = null;
221    
222                    try {
223                            session = openSession();
224    
225                            BatchSessionUtil.delete(session, webDAVProps);
226                    }
227                    catch (Exception e) {
228                            throw processException(e);
229                    }
230                    finally {
231                            closeSession(session);
232                    }
233    
234                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
235    
236                    WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
237    
238                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
239                            new Object[] {
240                                    new Long(webDAVPropsModelImpl.getClassNameId()),
241                                    new Long(webDAVPropsModelImpl.getClassPK())
242                            });
243    
244                    EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
245                            WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
246    
247                    return webDAVProps;
248            }
249    
250            public WebDAVProps updateImpl(
251                    com.liferay.portal.model.WebDAVProps webDAVProps, boolean merge)
252                    throws SystemException {
253                    webDAVProps = toUnwrappedModel(webDAVProps);
254    
255                    boolean isNew = webDAVProps.isNew();
256    
257                    WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
258    
259                    Session session = null;
260    
261                    try {
262                            session = openSession();
263    
264                            BatchSessionUtil.update(session, webDAVProps, merge);
265    
266                            webDAVProps.setNew(false);
267                    }
268                    catch (Exception e) {
269                            throw processException(e);
270                    }
271                    finally {
272                            closeSession(session);
273                    }
274    
275                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
276    
277                    EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
278                            WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
279    
280                    if (!isNew &&
281                                    ((webDAVProps.getClassNameId() != webDAVPropsModelImpl.getOriginalClassNameId()) ||
282                                    (webDAVProps.getClassPK() != webDAVPropsModelImpl.getOriginalClassPK()))) {
283                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
284                                    new Object[] {
285                                            new Long(webDAVPropsModelImpl.getOriginalClassNameId()),
286                                            new Long(webDAVPropsModelImpl.getOriginalClassPK())
287                                    });
288                    }
289    
290                    if (isNew ||
291                                    ((webDAVProps.getClassNameId() != webDAVPropsModelImpl.getOriginalClassNameId()) ||
292                                    (webDAVProps.getClassPK() != webDAVPropsModelImpl.getOriginalClassPK()))) {
293                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
294                                    new Object[] {
295                                            new Long(webDAVProps.getClassNameId()),
296                                            new Long(webDAVProps.getClassPK())
297                                    }, webDAVProps);
298                    }
299    
300                    return webDAVProps;
301            }
302    
303            protected WebDAVProps toUnwrappedModel(WebDAVProps webDAVProps) {
304                    if (webDAVProps instanceof WebDAVPropsImpl) {
305                            return webDAVProps;
306                    }
307    
308                    WebDAVPropsImpl webDAVPropsImpl = new WebDAVPropsImpl();
309    
310                    webDAVPropsImpl.setNew(webDAVProps.isNew());
311                    webDAVPropsImpl.setPrimaryKey(webDAVProps.getPrimaryKey());
312    
313                    webDAVPropsImpl.setWebDavPropsId(webDAVProps.getWebDavPropsId());
314                    webDAVPropsImpl.setCompanyId(webDAVProps.getCompanyId());
315                    webDAVPropsImpl.setCreateDate(webDAVProps.getCreateDate());
316                    webDAVPropsImpl.setModifiedDate(webDAVProps.getModifiedDate());
317                    webDAVPropsImpl.setClassNameId(webDAVProps.getClassNameId());
318                    webDAVPropsImpl.setClassPK(webDAVProps.getClassPK());
319                    webDAVPropsImpl.setProps(webDAVProps.getProps());
320    
321                    return webDAVPropsImpl;
322            }
323    
324            /**
325             * Finds the web d a v props with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
326             *
327             * @param primaryKey the primary key of the web d a v props to find
328             * @return the web d a v props
329             * @throws com.liferay.portal.NoSuchModelException if a web d a v props with the primary key could not be found
330             * @throws SystemException if a system exception occurred
331             */
332            public WebDAVProps findByPrimaryKey(Serializable primaryKey)
333                    throws NoSuchModelException, SystemException {
334                    return findByPrimaryKey(((Long)primaryKey).longValue());
335            }
336    
337            /**
338             * Finds the web d a v props with the primary key or throws a {@link com.liferay.portal.NoSuchWebDAVPropsException} if it could not be found.
339             *
340             * @param webDavPropsId the primary key of the web d a v props to find
341             * @return the web d a v props
342             * @throws com.liferay.portal.NoSuchWebDAVPropsException if a web d a v props with the primary key could not be found
343             * @throws SystemException if a system exception occurred
344             */
345            public WebDAVProps findByPrimaryKey(long webDavPropsId)
346                    throws NoSuchWebDAVPropsException, SystemException {
347                    WebDAVProps webDAVProps = fetchByPrimaryKey(webDavPropsId);
348    
349                    if (webDAVProps == null) {
350                            if (_log.isWarnEnabled()) {
351                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + webDavPropsId);
352                            }
353    
354                            throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
355                                    webDavPropsId);
356                    }
357    
358                    return webDAVProps;
359            }
360    
361            /**
362             * Finds the web d a v props with the primary key or returns <code>null</code> if it could not be found.
363             *
364             * @param primaryKey the primary key of the web d a v props to find
365             * @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
366             * @throws SystemException if a system exception occurred
367             */
368            public WebDAVProps fetchByPrimaryKey(Serializable primaryKey)
369                    throws SystemException {
370                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
371            }
372    
373            /**
374             * Finds the web d a v props with the primary key or returns <code>null</code> if it could not be found.
375             *
376             * @param webDavPropsId the primary key of the web d a v props to find
377             * @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
378             * @throws SystemException if a system exception occurred
379             */
380            public WebDAVProps fetchByPrimaryKey(long webDavPropsId)
381                    throws SystemException {
382                    WebDAVProps webDAVProps = (WebDAVProps)EntityCacheUtil.getResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
383                                    WebDAVPropsImpl.class, webDavPropsId, this);
384    
385                    if (webDAVProps == null) {
386                            Session session = null;
387    
388                            try {
389                                    session = openSession();
390    
391                                    webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
392                                                    new Long(webDavPropsId));
393                            }
394                            catch (Exception e) {
395                                    throw processException(e);
396                            }
397                            finally {
398                                    if (webDAVProps != null) {
399                                            cacheResult(webDAVProps);
400                                    }
401    
402                                    closeSession(session);
403                            }
404                    }
405    
406                    return webDAVProps;
407            }
408    
409            /**
410             * Finds 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.
411             *
412             * @param classNameId the class name id to search with
413             * @param classPK the class p k to search with
414             * @return the matching web d a v props
415             * @throws com.liferay.portal.NoSuchWebDAVPropsException if a matching web d a v props could not be found
416             * @throws SystemException if a system exception occurred
417             */
418            public WebDAVProps findByC_C(long classNameId, long classPK)
419                    throws NoSuchWebDAVPropsException, SystemException {
420                    WebDAVProps webDAVProps = fetchByC_C(classNameId, classPK);
421    
422                    if (webDAVProps == null) {
423                            StringBundler msg = new StringBundler(6);
424    
425                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
426    
427                            msg.append("classNameId=");
428                            msg.append(classNameId);
429    
430                            msg.append(", classPK=");
431                            msg.append(classPK);
432    
433                            msg.append(StringPool.CLOSE_CURLY_BRACE);
434    
435                            if (_log.isWarnEnabled()) {
436                                    _log.warn(msg.toString());
437                            }
438    
439                            throw new NoSuchWebDAVPropsException(msg.toString());
440                    }
441    
442                    return webDAVProps;
443            }
444    
445            /**
446             * Finds 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.
447             *
448             * @param classNameId the class name id to search with
449             * @param classPK the class p k to search with
450             * @return the matching web d a v props, or <code>null</code> if a matching web d a v props could not be found
451             * @throws SystemException if a system exception occurred
452             */
453            public WebDAVProps fetchByC_C(long classNameId, long classPK)
454                    throws SystemException {
455                    return fetchByC_C(classNameId, classPK, true);
456            }
457    
458            /**
459             * Finds 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.
460             *
461             * @param classNameId the class name id to search with
462             * @param classPK the class p k to search with
463             * @return the matching web d a v props, or <code>null</code> if a matching web d a v props could not be found
464             * @throws SystemException if a system exception occurred
465             */
466            public WebDAVProps fetchByC_C(long classNameId, long classPK,
467                    boolean retrieveFromCache) throws SystemException {
468                    Object[] finderArgs = new Object[] { classNameId, classPK };
469    
470                    Object result = null;
471    
472                    if (retrieveFromCache) {
473                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
474                                            finderArgs, this);
475                    }
476    
477                    if (result == null) {
478                            StringBundler query = new StringBundler(3);
479    
480                            query.append(_SQL_SELECT_WEBDAVPROPS_WHERE);
481    
482                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
483    
484                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
485    
486                            String sql = query.toString();
487    
488                            Session session = null;
489    
490                            try {
491                                    session = openSession();
492    
493                                    Query q = session.createQuery(sql);
494    
495                                    QueryPos qPos = QueryPos.getInstance(q);
496    
497                                    qPos.add(classNameId);
498    
499                                    qPos.add(classPK);
500    
501                                    List<WebDAVProps> list = q.list();
502    
503                                    result = list;
504    
505                                    WebDAVProps webDAVProps = null;
506    
507                                    if (list.isEmpty()) {
508                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
509                                                    finderArgs, list);
510                                    }
511                                    else {
512                                            webDAVProps = list.get(0);
513    
514                                            cacheResult(webDAVProps);
515    
516                                            if ((webDAVProps.getClassNameId() != classNameId) ||
517                                                            (webDAVProps.getClassPK() != classPK)) {
518                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
519                                                            finderArgs, webDAVProps);
520                                            }
521                                    }
522    
523                                    return webDAVProps;
524                            }
525                            catch (Exception e) {
526                                    throw processException(e);
527                            }
528                            finally {
529                                    if (result == null) {
530                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
531                                                    finderArgs);
532                                    }
533    
534                                    closeSession(session);
535                            }
536                    }
537                    else {
538                            if (result instanceof List<?>) {
539                                    return null;
540                            }
541                            else {
542                                    return (WebDAVProps)result;
543                            }
544                    }
545            }
546    
547            /**
548             * Finds all the web d a v propses.
549             *
550             * @return the web d a v propses
551             * @throws SystemException if a system exception occurred
552             */
553            public List<WebDAVProps> findAll() throws SystemException {
554                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
555            }
556    
557            /**
558             * Finds a range of all the web d a v propses.
559             *
560             * <p>
561             * 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.
562             * </p>
563             *
564             * @param start the lower bound of the range of web d a v propses to return
565             * @param end the upper bound of the range of web d a v propses to return (not inclusive)
566             * @return the range of web d a v propses
567             * @throws SystemException if a system exception occurred
568             */
569            public List<WebDAVProps> findAll(int start, int end)
570                    throws SystemException {
571                    return findAll(start, end, null);
572            }
573    
574            /**
575             * Finds an ordered range of all the web d a v propses.
576             *
577             * <p>
578             * 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.
579             * </p>
580             *
581             * @param start the lower bound of the range of web d a v propses to return
582             * @param end the upper bound of the range of web d a v propses to return (not inclusive)
583             * @param orderByComparator the comparator to order the results by
584             * @return the ordered range of web d a v propses
585             * @throws SystemException if a system exception occurred
586             */
587            public List<WebDAVProps> findAll(int start, int end,
588                    OrderByComparator orderByComparator) throws SystemException {
589                    Object[] finderArgs = new Object[] {
590                                    String.valueOf(start), String.valueOf(end),
591                                    String.valueOf(orderByComparator)
592                            };
593    
594                    List<WebDAVProps> list = (List<WebDAVProps>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
595                                    finderArgs, this);
596    
597                    if (list == null) {
598                            StringBundler query = null;
599                            String sql = null;
600    
601                            if (orderByComparator != null) {
602                                    query = new StringBundler(2 +
603                                                    (orderByComparator.getOrderByFields().length * 3));
604    
605                                    query.append(_SQL_SELECT_WEBDAVPROPS);
606    
607                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
608                                            orderByComparator);
609    
610                                    sql = query.toString();
611                            }
612                            else {
613                                    sql = _SQL_SELECT_WEBDAVPROPS;
614                            }
615    
616                            Session session = null;
617    
618                            try {
619                                    session = openSession();
620    
621                                    Query q = session.createQuery(sql);
622    
623                                    if (orderByComparator == null) {
624                                            list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
625                                                            start, end, false);
626    
627                                            Collections.sort(list);
628                                    }
629                                    else {
630                                            list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
631                                                            start, end);
632                                    }
633                            }
634                            catch (Exception e) {
635                                    throw processException(e);
636                            }
637                            finally {
638                                    if (list == null) {
639                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
640                                                    finderArgs);
641                                    }
642                                    else {
643                                            cacheResult(list);
644    
645                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
646                                                    list);
647                                    }
648    
649                                    closeSession(session);
650                            }
651                    }
652    
653                    return list;
654            }
655    
656            /**
657             * Removes the web d a v props where classNameId = &#63; and classPK = &#63; from the database.
658             *
659             * @param classNameId the class name id to search with
660             * @param classPK the class p k to search with
661             * @throws SystemException if a system exception occurred
662             */
663            public void removeByC_C(long classNameId, long classPK)
664                    throws NoSuchWebDAVPropsException, SystemException {
665                    WebDAVProps webDAVProps = findByC_C(classNameId, classPK);
666    
667                    remove(webDAVProps);
668            }
669    
670            /**
671             * Removes all the web d a v propses from the database.
672             *
673             * @throws SystemException if a system exception occurred
674             */
675            public void removeAll() throws SystemException {
676                    for (WebDAVProps webDAVProps : findAll()) {
677                            remove(webDAVProps);
678                    }
679            }
680    
681            /**
682             * Counts all the web d a v propses where classNameId = &#63; and classPK = &#63;.
683             *
684             * @param classNameId the class name id to search with
685             * @param classPK the class p k to search with
686             * @return the number of matching web d a v propses
687             * @throws SystemException if a system exception occurred
688             */
689            public int countByC_C(long classNameId, long classPK)
690                    throws SystemException {
691                    Object[] finderArgs = new Object[] { classNameId, classPK };
692    
693                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
694                                    finderArgs, this);
695    
696                    if (count == null) {
697                            StringBundler query = new StringBundler(3);
698    
699                            query.append(_SQL_COUNT_WEBDAVPROPS_WHERE);
700    
701                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
702    
703                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
704    
705                            String sql = query.toString();
706    
707                            Session session = null;
708    
709                            try {
710                                    session = openSession();
711    
712                                    Query q = session.createQuery(sql);
713    
714                                    QueryPos qPos = QueryPos.getInstance(q);
715    
716                                    qPos.add(classNameId);
717    
718                                    qPos.add(classPK);
719    
720                                    count = (Long)q.uniqueResult();
721                            }
722                            catch (Exception e) {
723                                    throw processException(e);
724                            }
725                            finally {
726                                    if (count == null) {
727                                            count = Long.valueOf(0);
728                                    }
729    
730                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
731                                            count);
732    
733                                    closeSession(session);
734                            }
735                    }
736    
737                    return count.intValue();
738            }
739    
740            /**
741             * Counts all the web d a v propses.
742             *
743             * @return the number of web d a v propses
744             * @throws SystemException if a system exception occurred
745             */
746            public int countAll() throws SystemException {
747                    Object[] finderArgs = new Object[0];
748    
749                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
750                                    finderArgs, this);
751    
752                    if (count == null) {
753                            Session session = null;
754    
755                            try {
756                                    session = openSession();
757    
758                                    Query q = session.createQuery(_SQL_COUNT_WEBDAVPROPS);
759    
760                                    count = (Long)q.uniqueResult();
761                            }
762                            catch (Exception e) {
763                                    throw processException(e);
764                            }
765                            finally {
766                                    if (count == null) {
767                                            count = Long.valueOf(0);
768                                    }
769    
770                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
771                                            count);
772    
773                                    closeSession(session);
774                            }
775                    }
776    
777                    return count.intValue();
778            }
779    
780            /**
781             * Initializes the web d a v props persistence.
782             */
783            public void afterPropertiesSet() {
784                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
785                                            com.liferay.portal.util.PropsUtil.get(
786                                                    "value.object.listener.com.liferay.portal.model.WebDAVProps")));
787    
788                    if (listenerClassNames.length > 0) {
789                            try {
790                                    List<ModelListener<WebDAVProps>> listenersList = new ArrayList<ModelListener<WebDAVProps>>();
791    
792                                    for (String listenerClassName : listenerClassNames) {
793                                            listenersList.add((ModelListener<WebDAVProps>)InstanceFactory.newInstance(
794                                                            listenerClassName));
795                                    }
796    
797                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
798                            }
799                            catch (Exception e) {
800                                    _log.error(e);
801                            }
802                    }
803            }
804    
805            public void destroy() {
806                    EntityCacheUtil.removeCache(WebDAVPropsImpl.class.getName());
807                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
808                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
809            }
810    
811            @BeanReference(type = AccountPersistence.class)
812            protected AccountPersistence accountPersistence;
813            @BeanReference(type = AddressPersistence.class)
814            protected AddressPersistence addressPersistence;
815            @BeanReference(type = BrowserTrackerPersistence.class)
816            protected BrowserTrackerPersistence browserTrackerPersistence;
817            @BeanReference(type = ClassNamePersistence.class)
818            protected ClassNamePersistence classNamePersistence;
819            @BeanReference(type = ClusterGroupPersistence.class)
820            protected ClusterGroupPersistence clusterGroupPersistence;
821            @BeanReference(type = CompanyPersistence.class)
822            protected CompanyPersistence companyPersistence;
823            @BeanReference(type = ContactPersistence.class)
824            protected ContactPersistence contactPersistence;
825            @BeanReference(type = CountryPersistence.class)
826            protected CountryPersistence countryPersistence;
827            @BeanReference(type = EmailAddressPersistence.class)
828            protected EmailAddressPersistence emailAddressPersistence;
829            @BeanReference(type = GroupPersistence.class)
830            protected GroupPersistence groupPersistence;
831            @BeanReference(type = ImagePersistence.class)
832            protected ImagePersistence imagePersistence;
833            @BeanReference(type = LayoutPersistence.class)
834            protected LayoutPersistence layoutPersistence;
835            @BeanReference(type = LayoutPrototypePersistence.class)
836            protected LayoutPrototypePersistence layoutPrototypePersistence;
837            @BeanReference(type = LayoutSetPersistence.class)
838            protected LayoutSetPersistence layoutSetPersistence;
839            @BeanReference(type = LayoutSetPrototypePersistence.class)
840            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
841            @BeanReference(type = ListTypePersistence.class)
842            protected ListTypePersistence listTypePersistence;
843            @BeanReference(type = LockPersistence.class)
844            protected LockPersistence lockPersistence;
845            @BeanReference(type = MembershipRequestPersistence.class)
846            protected MembershipRequestPersistence membershipRequestPersistence;
847            @BeanReference(type = OrganizationPersistence.class)
848            protected OrganizationPersistence organizationPersistence;
849            @BeanReference(type = OrgGroupPermissionPersistence.class)
850            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
851            @BeanReference(type = OrgGroupRolePersistence.class)
852            protected OrgGroupRolePersistence orgGroupRolePersistence;
853            @BeanReference(type = OrgLaborPersistence.class)
854            protected OrgLaborPersistence orgLaborPersistence;
855            @BeanReference(type = PasswordPolicyPersistence.class)
856            protected PasswordPolicyPersistence passwordPolicyPersistence;
857            @BeanReference(type = PasswordPolicyRelPersistence.class)
858            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
859            @BeanReference(type = PasswordTrackerPersistence.class)
860            protected PasswordTrackerPersistence passwordTrackerPersistence;
861            @BeanReference(type = PermissionPersistence.class)
862            protected PermissionPersistence permissionPersistence;
863            @BeanReference(type = PhonePersistence.class)
864            protected PhonePersistence phonePersistence;
865            @BeanReference(type = PluginSettingPersistence.class)
866            protected PluginSettingPersistence pluginSettingPersistence;
867            @BeanReference(type = PortletPersistence.class)
868            protected PortletPersistence portletPersistence;
869            @BeanReference(type = PortletItemPersistence.class)
870            protected PortletItemPersistence portletItemPersistence;
871            @BeanReference(type = PortletPreferencesPersistence.class)
872            protected PortletPreferencesPersistence portletPreferencesPersistence;
873            @BeanReference(type = RegionPersistence.class)
874            protected RegionPersistence regionPersistence;
875            @BeanReference(type = ReleasePersistence.class)
876            protected ReleasePersistence releasePersistence;
877            @BeanReference(type = ResourcePersistence.class)
878            protected ResourcePersistence resourcePersistence;
879            @BeanReference(type = ResourceActionPersistence.class)
880            protected ResourceActionPersistence resourceActionPersistence;
881            @BeanReference(type = ResourceCodePersistence.class)
882            protected ResourceCodePersistence resourceCodePersistence;
883            @BeanReference(type = ResourcePermissionPersistence.class)
884            protected ResourcePermissionPersistence resourcePermissionPersistence;
885            @BeanReference(type = RolePersistence.class)
886            protected RolePersistence rolePersistence;
887            @BeanReference(type = ServiceComponentPersistence.class)
888            protected ServiceComponentPersistence serviceComponentPersistence;
889            @BeanReference(type = ShardPersistence.class)
890            protected ShardPersistence shardPersistence;
891            @BeanReference(type = SubscriptionPersistence.class)
892            protected SubscriptionPersistence subscriptionPersistence;
893            @BeanReference(type = TicketPersistence.class)
894            protected TicketPersistence ticketPersistence;
895            @BeanReference(type = TeamPersistence.class)
896            protected TeamPersistence teamPersistence;
897            @BeanReference(type = UserPersistence.class)
898            protected UserPersistence userPersistence;
899            @BeanReference(type = UserGroupPersistence.class)
900            protected UserGroupPersistence userGroupPersistence;
901            @BeanReference(type = UserGroupGroupRolePersistence.class)
902            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
903            @BeanReference(type = UserGroupRolePersistence.class)
904            protected UserGroupRolePersistence userGroupRolePersistence;
905            @BeanReference(type = UserIdMapperPersistence.class)
906            protected UserIdMapperPersistence userIdMapperPersistence;
907            @BeanReference(type = UserTrackerPersistence.class)
908            protected UserTrackerPersistence userTrackerPersistence;
909            @BeanReference(type = UserTrackerPathPersistence.class)
910            protected UserTrackerPathPersistence userTrackerPathPersistence;
911            @BeanReference(type = WebDAVPropsPersistence.class)
912            protected WebDAVPropsPersistence webDAVPropsPersistence;
913            @BeanReference(type = WebsitePersistence.class)
914            protected WebsitePersistence websitePersistence;
915            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
916            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
917            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
918            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
919            private static final String _SQL_SELECT_WEBDAVPROPS = "SELECT webDAVProps FROM WebDAVProps webDAVProps";
920            private static final String _SQL_SELECT_WEBDAVPROPS_WHERE = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE ";
921            private static final String _SQL_COUNT_WEBDAVPROPS = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps";
922            private static final String _SQL_COUNT_WEBDAVPROPS_WHERE = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps WHERE ";
923            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "webDAVProps.classNameId = ? AND ";
924            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "webDAVProps.classPK = ?";
925            private static final String _ORDER_BY_ENTITY_ALIAS = "webDAVProps.";
926            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WebDAVProps exists with the primary key ";
927            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WebDAVProps exists with the key {";
928            private static Log _log = LogFactoryUtil.getLog(WebDAVPropsPersistenceImpl.class);
929    }