001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchWebDAVPropsException;
019    import com.liferay.portal.kernel.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.getOriginalClassNameId()),
241                                    new Long(webDAVPropsModelImpl.getOriginalClassPK())
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                            Session session = null;
479    
480                            try {
481                                    session = openSession();
482    
483                                    StringBundler query = new StringBundler(3);
484    
485                                    query.append(_SQL_SELECT_WEBDAVPROPS_WHERE);
486    
487                                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
488    
489                                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
490    
491                                    String sql = query.toString();
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.putResult(FINDER_PATH_FETCH_BY_C_C,
531                                                    finderArgs, new ArrayList<WebDAVProps>());
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                            Session session = null;
599    
600                            try {
601                                    session = openSession();
602    
603                                    StringBundler query = null;
604                                    String sql = null;
605    
606                                    if (orderByComparator != null) {
607                                            query = new StringBundler(2 +
608                                                            (orderByComparator.getOrderByFields().length * 3));
609    
610                                            query.append(_SQL_SELECT_WEBDAVPROPS);
611    
612                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
613                                                    orderByComparator);
614    
615                                            sql = query.toString();
616                                    }
617                                    else {
618                                            sql = _SQL_SELECT_WEBDAVPROPS;
619                                    }
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                                            list = new ArrayList<WebDAVProps>();
640                                    }
641    
642                                    cacheResult(list);
643    
644                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
645    
646                                    closeSession(session);
647                            }
648                    }
649    
650                    return list;
651            }
652    
653            /**
654             * Removes the web d a v props where classNameId = &#63; and classPK = &#63; from the database.
655             *
656             * @param classNameId the class name id to search with
657             * @param classPK the class p k to search with
658             * @throws SystemException if a system exception occurred
659             */
660            public void removeByC_C(long classNameId, long classPK)
661                    throws NoSuchWebDAVPropsException, SystemException {
662                    WebDAVProps webDAVProps = findByC_C(classNameId, classPK);
663    
664                    remove(webDAVProps);
665            }
666    
667            /**
668             * Removes all the web d a v propses from the database.
669             *
670             * @throws SystemException if a system exception occurred
671             */
672            public void removeAll() throws SystemException {
673                    for (WebDAVProps webDAVProps : findAll()) {
674                            remove(webDAVProps);
675                    }
676            }
677    
678            /**
679             * Counts all the web d a v propses where classNameId = &#63; and classPK = &#63;.
680             *
681             * @param classNameId the class name id to search with
682             * @param classPK the class p k to search with
683             * @return the number of matching web d a v propses
684             * @throws SystemException if a system exception occurred
685             */
686            public int countByC_C(long classNameId, long classPK)
687                    throws SystemException {
688                    Object[] finderArgs = new Object[] { classNameId, classPK };
689    
690                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
691                                    finderArgs, this);
692    
693                    if (count == null) {
694                            Session session = null;
695    
696                            try {
697                                    session = openSession();
698    
699                                    StringBundler query = new StringBundler(3);
700    
701                                    query.append(_SQL_COUNT_WEBDAVPROPS_WHERE);
702    
703                                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
704    
705                                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
706    
707                                    String sql = query.toString();
708    
709                                    Query q = session.createQuery(sql);
710    
711                                    QueryPos qPos = QueryPos.getInstance(q);
712    
713                                    qPos.add(classNameId);
714    
715                                    qPos.add(classPK);
716    
717                                    count = (Long)q.uniqueResult();
718                            }
719                            catch (Exception e) {
720                                    throw processException(e);
721                            }
722                            finally {
723                                    if (count == null) {
724                                            count = Long.valueOf(0);
725                                    }
726    
727                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
728                                            count);
729    
730                                    closeSession(session);
731                            }
732                    }
733    
734                    return count.intValue();
735            }
736    
737            /**
738             * Counts all the web d a v propses.
739             *
740             * @return the number of web d a v propses
741             * @throws SystemException if a system exception occurred
742             */
743            public int countAll() throws SystemException {
744                    Object[] finderArgs = new Object[0];
745    
746                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
747                                    finderArgs, this);
748    
749                    if (count == null) {
750                            Session session = null;
751    
752                            try {
753                                    session = openSession();
754    
755                                    Query q = session.createQuery(_SQL_COUNT_WEBDAVPROPS);
756    
757                                    count = (Long)q.uniqueResult();
758                            }
759                            catch (Exception e) {
760                                    throw processException(e);
761                            }
762                            finally {
763                                    if (count == null) {
764                                            count = Long.valueOf(0);
765                                    }
766    
767                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
768                                            count);
769    
770                                    closeSession(session);
771                            }
772                    }
773    
774                    return count.intValue();
775            }
776    
777            /**
778             * Initializes the web d a v props persistence.
779             */
780            public void afterPropertiesSet() {
781                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
782                                            com.liferay.portal.util.PropsUtil.get(
783                                                    "value.object.listener.com.liferay.portal.model.WebDAVProps")));
784    
785                    if (listenerClassNames.length > 0) {
786                            try {
787                                    List<ModelListener<WebDAVProps>> listenersList = new ArrayList<ModelListener<WebDAVProps>>();
788    
789                                    for (String listenerClassName : listenerClassNames) {
790                                            listenersList.add((ModelListener<WebDAVProps>)InstanceFactory.newInstance(
791                                                            listenerClassName));
792                                    }
793    
794                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
795                            }
796                            catch (Exception e) {
797                                    _log.error(e);
798                            }
799                    }
800            }
801    
802            public void destroy() {
803                    EntityCacheUtil.removeCache(WebDAVPropsImpl.class.getName());
804                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
805                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
806            }
807    
808            @BeanReference(type = AccountPersistence.class)
809            protected AccountPersistence accountPersistence;
810            @BeanReference(type = AddressPersistence.class)
811            protected AddressPersistence addressPersistence;
812            @BeanReference(type = BrowserTrackerPersistence.class)
813            protected BrowserTrackerPersistence browserTrackerPersistence;
814            @BeanReference(type = ClassNamePersistence.class)
815            protected ClassNamePersistence classNamePersistence;
816            @BeanReference(type = ClusterGroupPersistence.class)
817            protected ClusterGroupPersistence clusterGroupPersistence;
818            @BeanReference(type = CompanyPersistence.class)
819            protected CompanyPersistence companyPersistence;
820            @BeanReference(type = ContactPersistence.class)
821            protected ContactPersistence contactPersistence;
822            @BeanReference(type = CountryPersistence.class)
823            protected CountryPersistence countryPersistence;
824            @BeanReference(type = EmailAddressPersistence.class)
825            protected EmailAddressPersistence emailAddressPersistence;
826            @BeanReference(type = GroupPersistence.class)
827            protected GroupPersistence groupPersistence;
828            @BeanReference(type = ImagePersistence.class)
829            protected ImagePersistence imagePersistence;
830            @BeanReference(type = LayoutPersistence.class)
831            protected LayoutPersistence layoutPersistence;
832            @BeanReference(type = LayoutPrototypePersistence.class)
833            protected LayoutPrototypePersistence layoutPrototypePersistence;
834            @BeanReference(type = LayoutSetPersistence.class)
835            protected LayoutSetPersistence layoutSetPersistence;
836            @BeanReference(type = LayoutSetPrototypePersistence.class)
837            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
838            @BeanReference(type = ListTypePersistence.class)
839            protected ListTypePersistence listTypePersistence;
840            @BeanReference(type = LockPersistence.class)
841            protected LockPersistence lockPersistence;
842            @BeanReference(type = MembershipRequestPersistence.class)
843            protected MembershipRequestPersistence membershipRequestPersistence;
844            @BeanReference(type = OrganizationPersistence.class)
845            protected OrganizationPersistence organizationPersistence;
846            @BeanReference(type = OrgGroupPermissionPersistence.class)
847            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
848            @BeanReference(type = OrgGroupRolePersistence.class)
849            protected OrgGroupRolePersistence orgGroupRolePersistence;
850            @BeanReference(type = OrgLaborPersistence.class)
851            protected OrgLaborPersistence orgLaborPersistence;
852            @BeanReference(type = PasswordPolicyPersistence.class)
853            protected PasswordPolicyPersistence passwordPolicyPersistence;
854            @BeanReference(type = PasswordPolicyRelPersistence.class)
855            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
856            @BeanReference(type = PasswordTrackerPersistence.class)
857            protected PasswordTrackerPersistence passwordTrackerPersistence;
858            @BeanReference(type = PermissionPersistence.class)
859            protected PermissionPersistence permissionPersistence;
860            @BeanReference(type = PhonePersistence.class)
861            protected PhonePersistence phonePersistence;
862            @BeanReference(type = PluginSettingPersistence.class)
863            protected PluginSettingPersistence pluginSettingPersistence;
864            @BeanReference(type = PortletPersistence.class)
865            protected PortletPersistence portletPersistence;
866            @BeanReference(type = PortletItemPersistence.class)
867            protected PortletItemPersistence portletItemPersistence;
868            @BeanReference(type = PortletPreferencesPersistence.class)
869            protected PortletPreferencesPersistence portletPreferencesPersistence;
870            @BeanReference(type = RegionPersistence.class)
871            protected RegionPersistence regionPersistence;
872            @BeanReference(type = ReleasePersistence.class)
873            protected ReleasePersistence releasePersistence;
874            @BeanReference(type = ResourcePersistence.class)
875            protected ResourcePersistence resourcePersistence;
876            @BeanReference(type = ResourceActionPersistence.class)
877            protected ResourceActionPersistence resourceActionPersistence;
878            @BeanReference(type = ResourceCodePersistence.class)
879            protected ResourceCodePersistence resourceCodePersistence;
880            @BeanReference(type = ResourcePermissionPersistence.class)
881            protected ResourcePermissionPersistence resourcePermissionPersistence;
882            @BeanReference(type = RolePersistence.class)
883            protected RolePersistence rolePersistence;
884            @BeanReference(type = ServiceComponentPersistence.class)
885            protected ServiceComponentPersistence serviceComponentPersistence;
886            @BeanReference(type = ShardPersistence.class)
887            protected ShardPersistence shardPersistence;
888            @BeanReference(type = SubscriptionPersistence.class)
889            protected SubscriptionPersistence subscriptionPersistence;
890            @BeanReference(type = TicketPersistence.class)
891            protected TicketPersistence ticketPersistence;
892            @BeanReference(type = TeamPersistence.class)
893            protected TeamPersistence teamPersistence;
894            @BeanReference(type = UserPersistence.class)
895            protected UserPersistence userPersistence;
896            @BeanReference(type = UserGroupPersistence.class)
897            protected UserGroupPersistence userGroupPersistence;
898            @BeanReference(type = UserGroupGroupRolePersistence.class)
899            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
900            @BeanReference(type = UserGroupRolePersistence.class)
901            protected UserGroupRolePersistence userGroupRolePersistence;
902            @BeanReference(type = UserIdMapperPersistence.class)
903            protected UserIdMapperPersistence userIdMapperPersistence;
904            @BeanReference(type = UserTrackerPersistence.class)
905            protected UserTrackerPersistence userTrackerPersistence;
906            @BeanReference(type = UserTrackerPathPersistence.class)
907            protected UserTrackerPathPersistence userTrackerPathPersistence;
908            @BeanReference(type = WebDAVPropsPersistence.class)
909            protected WebDAVPropsPersistence webDAVPropsPersistence;
910            @BeanReference(type = WebsitePersistence.class)
911            protected WebsitePersistence websitePersistence;
912            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
913            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
914            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
915            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
916            private static final String _SQL_SELECT_WEBDAVPROPS = "SELECT webDAVProps FROM WebDAVProps webDAVProps";
917            private static final String _SQL_SELECT_WEBDAVPROPS_WHERE = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE ";
918            private static final String _SQL_COUNT_WEBDAVPROPS = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps";
919            private static final String _SQL_COUNT_WEBDAVPROPS_WHERE = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps WHERE ";
920            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "webDAVProps.classNameId = ? AND ";
921            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "webDAVProps.classPK = ?";
922            private static final String _ORDER_BY_ENTITY_ALIAS = "webDAVProps.";
923            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WebDAVProps exists with the primary key ";
924            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WebDAVProps exists with the key {";
925            private static Log _log = LogFactoryUtil.getLog(WebDAVPropsPersistenceImpl.class);
926    }