001    /**
002     * Copyright (c) 2000-2013 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.NoSuchWebDAVPropsException;
018    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.Session;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.GetterUtil;
030    import com.liferay.portal.kernel.util.InstanceFactory;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.StringUtil;
035    import com.liferay.portal.kernel.util.UnmodifiableList;
036    import com.liferay.portal.model.CacheModel;
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     * Caching information and settings can be found in <code>portal.properties</code>
054     * </p>
055     *
056     * @author Brian Wing Shun Chan
057     * @see WebDAVPropsPersistence
058     * @see WebDAVPropsUtil
059     * @generated
060     */
061    public class WebDAVPropsPersistenceImpl extends BasePersistenceImpl<WebDAVProps>
062            implements WebDAVPropsPersistence {
063            /*
064             * NOTE FOR DEVELOPERS:
065             *
066             * 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.
067             */
068            public static final String FINDER_CLASS_NAME_ENTITY = WebDAVPropsImpl.class.getName();
069            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
070                    ".List1";
071            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072                    ".List2";
073            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
074                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
075                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
076            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
077                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
078                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
079            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
080                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, Long.class,
081                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
082            public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
083                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
084                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
085                            new String[] { Long.class.getName(), Long.class.getName() },
086                            WebDAVPropsModelImpl.CLASSNAMEID_COLUMN_BITMASK |
087                            WebDAVPropsModelImpl.CLASSPK_COLUMN_BITMASK);
088            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
089                            WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, Long.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
091                            new String[] { Long.class.getName(), Long.class.getName() });
092    
093            /**
094             * Returns the web d a v props where classNameId = &#63; and classPK = &#63; or throws a {@link com.liferay.portal.NoSuchWebDAVPropsException} if it could not be found.
095             *
096             * @param classNameId the class name ID
097             * @param classPK the class p k
098             * @return the matching web d a v props
099             * @throws com.liferay.portal.NoSuchWebDAVPropsException if a matching web d a v props could not be found
100             * @throws SystemException if a system exception occurred
101             */
102            public WebDAVProps findByC_C(long classNameId, long classPK)
103                    throws NoSuchWebDAVPropsException, SystemException {
104                    WebDAVProps webDAVProps = fetchByC_C(classNameId, classPK);
105    
106                    if (webDAVProps == null) {
107                            StringBundler msg = new StringBundler(6);
108    
109                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
110    
111                            msg.append("classNameId=");
112                            msg.append(classNameId);
113    
114                            msg.append(", classPK=");
115                            msg.append(classPK);
116    
117                            msg.append(StringPool.CLOSE_CURLY_BRACE);
118    
119                            if (_log.isWarnEnabled()) {
120                                    _log.warn(msg.toString());
121                            }
122    
123                            throw new NoSuchWebDAVPropsException(msg.toString());
124                    }
125    
126                    return webDAVProps;
127            }
128    
129            /**
130             * Returns the web d a v props where classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
131             *
132             * @param classNameId the class name ID
133             * @param classPK the class p k
134             * @return the matching web d a v props, or <code>null</code> if a matching web d a v props could not be found
135             * @throws SystemException if a system exception occurred
136             */
137            public WebDAVProps fetchByC_C(long classNameId, long classPK)
138                    throws SystemException {
139                    return fetchByC_C(classNameId, classPK, true);
140            }
141    
142            /**
143             * Returns the web d a v props where classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
144             *
145             * @param classNameId the class name ID
146             * @param classPK the class p k
147             * @param retrieveFromCache whether to use the finder cache
148             * @return the matching web d a v props, or <code>null</code> if a matching web d a v props could not be found
149             * @throws SystemException if a system exception occurred
150             */
151            public WebDAVProps fetchByC_C(long classNameId, long classPK,
152                    boolean retrieveFromCache) throws SystemException {
153                    Object[] finderArgs = new Object[] { classNameId, classPK };
154    
155                    Object result = null;
156    
157                    if (retrieveFromCache) {
158                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
159                                            finderArgs, this);
160                    }
161    
162                    if (result instanceof WebDAVProps) {
163                            WebDAVProps webDAVProps = (WebDAVProps)result;
164    
165                            if ((classNameId != webDAVProps.getClassNameId()) ||
166                                            (classPK != webDAVProps.getClassPK())) {
167                                    result = null;
168                            }
169                    }
170    
171                    if (result == null) {
172                            StringBundler query = new StringBundler(4);
173    
174                            query.append(_SQL_SELECT_WEBDAVPROPS_WHERE);
175    
176                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
177    
178                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
179    
180                            String sql = query.toString();
181    
182                            Session session = null;
183    
184                            try {
185                                    session = openSession();
186    
187                                    Query q = session.createQuery(sql);
188    
189                                    QueryPos qPos = QueryPos.getInstance(q);
190    
191                                    qPos.add(classNameId);
192    
193                                    qPos.add(classPK);
194    
195                                    List<WebDAVProps> list = q.list();
196    
197                                    if (list.isEmpty()) {
198                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
199                                                    finderArgs, list);
200                                    }
201                                    else {
202                                            WebDAVProps webDAVProps = list.get(0);
203    
204                                            result = webDAVProps;
205    
206                                            cacheResult(webDAVProps);
207    
208                                            if ((webDAVProps.getClassNameId() != classNameId) ||
209                                                            (webDAVProps.getClassPK() != classPK)) {
210                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
211                                                            finderArgs, webDAVProps);
212                                            }
213                                    }
214                            }
215                            catch (Exception e) {
216                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
217                                            finderArgs);
218    
219                                    throw processException(e);
220                            }
221                            finally {
222                                    closeSession(session);
223                            }
224                    }
225    
226                    if (result instanceof List<?>) {
227                            return null;
228                    }
229                    else {
230                            return (WebDAVProps)result;
231                    }
232            }
233    
234            /**
235             * Removes the web d a v props where classNameId = &#63; and classPK = &#63; from the database.
236             *
237             * @param classNameId the class name ID
238             * @param classPK the class p k
239             * @return the web d a v props that was removed
240             * @throws SystemException if a system exception occurred
241             */
242            public WebDAVProps removeByC_C(long classNameId, long classPK)
243                    throws NoSuchWebDAVPropsException, SystemException {
244                    WebDAVProps webDAVProps = findByC_C(classNameId, classPK);
245    
246                    return remove(webDAVProps);
247            }
248    
249            /**
250             * Returns the number of web d a v propses where classNameId = &#63; and classPK = &#63;.
251             *
252             * @param classNameId the class name ID
253             * @param classPK the class p k
254             * @return the number of matching web d a v propses
255             * @throws SystemException if a system exception occurred
256             */
257            public int countByC_C(long classNameId, long classPK)
258                    throws SystemException {
259                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
260    
261                    Object[] finderArgs = new Object[] { classNameId, classPK };
262    
263                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
264                                    this);
265    
266                    if (count == null) {
267                            StringBundler query = new StringBundler(3);
268    
269                            query.append(_SQL_COUNT_WEBDAVPROPS_WHERE);
270    
271                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
272    
273                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
274    
275                            String sql = query.toString();
276    
277                            Session session = null;
278    
279                            try {
280                                    session = openSession();
281    
282                                    Query q = session.createQuery(sql);
283    
284                                    QueryPos qPos = QueryPos.getInstance(q);
285    
286                                    qPos.add(classNameId);
287    
288                                    qPos.add(classPK);
289    
290                                    count = (Long)q.uniqueResult();
291    
292                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
293                            }
294                            catch (Exception e) {
295                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
296    
297                                    throw processException(e);
298                            }
299                            finally {
300                                    closeSession(session);
301                            }
302                    }
303    
304                    return count.intValue();
305            }
306    
307            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "webDAVProps.classNameId = ? AND ";
308            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "webDAVProps.classPK = ?";
309    
310            /**
311             * Caches the web d a v props in the entity cache if it is enabled.
312             *
313             * @param webDAVProps the web d a v props
314             */
315            public void cacheResult(WebDAVProps webDAVProps) {
316                    EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
317                            WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
318    
319                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
320                            new Object[] { webDAVProps.getClassNameId(), webDAVProps.getClassPK() },
321                            webDAVProps);
322    
323                    webDAVProps.resetOriginalValues();
324            }
325    
326            /**
327             * Caches the web d a v propses in the entity cache if it is enabled.
328             *
329             * @param webDAVPropses the web d a v propses
330             */
331            public void cacheResult(List<WebDAVProps> webDAVPropses) {
332                    for (WebDAVProps webDAVProps : webDAVPropses) {
333                            if (EntityCacheUtil.getResult(
334                                                    WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
335                                                    WebDAVPropsImpl.class, webDAVProps.getPrimaryKey()) == null) {
336                                    cacheResult(webDAVProps);
337                            }
338                            else {
339                                    webDAVProps.resetOriginalValues();
340                            }
341                    }
342            }
343    
344            /**
345             * Clears the cache for all web d a v propses.
346             *
347             * <p>
348             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
349             * </p>
350             */
351            @Override
352            public void clearCache() {
353                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
354                            CacheRegistryUtil.clear(WebDAVPropsImpl.class.getName());
355                    }
356    
357                    EntityCacheUtil.clearCache(WebDAVPropsImpl.class.getName());
358    
359                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
360                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
361                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
362            }
363    
364            /**
365             * Clears the cache for the web d a v props.
366             *
367             * <p>
368             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
369             * </p>
370             */
371            @Override
372            public void clearCache(WebDAVProps webDAVProps) {
373                    EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
374                            WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
375    
376                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
377                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
378    
379                    clearUniqueFindersCache(webDAVProps);
380            }
381    
382            @Override
383            public void clearCache(List<WebDAVProps> webDAVPropses) {
384                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
385                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
386    
387                    for (WebDAVProps webDAVProps : webDAVPropses) {
388                            EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
389                                    WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
390    
391                            clearUniqueFindersCache(webDAVProps);
392                    }
393            }
394    
395            protected void cacheUniqueFindersCache(WebDAVProps webDAVProps) {
396                    if (webDAVProps.isNew()) {
397                            Object[] args = new Object[] {
398                                            webDAVProps.getClassNameId(), webDAVProps.getClassPK()
399                                    };
400    
401                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
402                                    Long.valueOf(1));
403                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
404                                    webDAVProps);
405                    }
406                    else {
407                            WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
408    
409                            if ((webDAVPropsModelImpl.getColumnBitmask() &
410                                            FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
411                                    Object[] args = new Object[] {
412                                                    webDAVProps.getClassNameId(), webDAVProps.getClassPK()
413                                            };
414    
415                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
416                                            Long.valueOf(1));
417                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
418                                            webDAVProps);
419                            }
420                    }
421            }
422    
423            protected void clearUniqueFindersCache(WebDAVProps webDAVProps) {
424                    WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
425    
426                    Object[] args = new Object[] {
427                                    webDAVProps.getClassNameId(), webDAVProps.getClassPK()
428                            };
429    
430                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
431                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
432    
433                    if ((webDAVPropsModelImpl.getColumnBitmask() &
434                                    FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
435                            args = new Object[] {
436                                            webDAVPropsModelImpl.getOriginalClassNameId(),
437                                            webDAVPropsModelImpl.getOriginalClassPK()
438                                    };
439    
440                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
441                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
442                    }
443            }
444    
445            /**
446             * Creates a new web d a v props with the primary key. Does not add the web d a v props to the database.
447             *
448             * @param webDavPropsId the primary key for the new web d a v props
449             * @return the new web d a v props
450             */
451            public WebDAVProps create(long webDavPropsId) {
452                    WebDAVProps webDAVProps = new WebDAVPropsImpl();
453    
454                    webDAVProps.setNew(true);
455                    webDAVProps.setPrimaryKey(webDavPropsId);
456    
457                    return webDAVProps;
458            }
459    
460            /**
461             * Removes the web d a v props with the primary key from the database. Also notifies the appropriate model listeners.
462             *
463             * @param webDavPropsId the primary key of the web d a v props
464             * @return the web d a v props that was removed
465             * @throws com.liferay.portal.NoSuchWebDAVPropsException if a web d a v props with the primary key could not be found
466             * @throws SystemException if a system exception occurred
467             */
468            public WebDAVProps remove(long webDavPropsId)
469                    throws NoSuchWebDAVPropsException, SystemException {
470                    return remove((Serializable)webDavPropsId);
471            }
472    
473            /**
474             * Removes the web d a v props with the primary key from the database. Also notifies the appropriate model listeners.
475             *
476             * @param primaryKey the primary key of the web d a v props
477             * @return the web d a v props that was removed
478             * @throws com.liferay.portal.NoSuchWebDAVPropsException if a web d a v props with the primary key could not be found
479             * @throws SystemException if a system exception occurred
480             */
481            @Override
482            public WebDAVProps remove(Serializable primaryKey)
483                    throws NoSuchWebDAVPropsException, SystemException {
484                    Session session = null;
485    
486                    try {
487                            session = openSession();
488    
489                            WebDAVProps webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
490                                            primaryKey);
491    
492                            if (webDAVProps == null) {
493                                    if (_log.isWarnEnabled()) {
494                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
495                                    }
496    
497                                    throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
498                                            primaryKey);
499                            }
500    
501                            return remove(webDAVProps);
502                    }
503                    catch (NoSuchWebDAVPropsException nsee) {
504                            throw nsee;
505                    }
506                    catch (Exception e) {
507                            throw processException(e);
508                    }
509                    finally {
510                            closeSession(session);
511                    }
512            }
513    
514            @Override
515            protected WebDAVProps removeImpl(WebDAVProps webDAVProps)
516                    throws SystemException {
517                    webDAVProps = toUnwrappedModel(webDAVProps);
518    
519                    Session session = null;
520    
521                    try {
522                            session = openSession();
523    
524                            if (!session.contains(webDAVProps)) {
525                                    webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
526                                                    webDAVProps.getPrimaryKeyObj());
527                            }
528    
529                            if (webDAVProps != null) {
530                                    session.delete(webDAVProps);
531                            }
532                    }
533                    catch (Exception e) {
534                            throw processException(e);
535                    }
536                    finally {
537                            closeSession(session);
538                    }
539    
540                    if (webDAVProps != null) {
541                            clearCache(webDAVProps);
542                    }
543    
544                    return webDAVProps;
545            }
546    
547            @Override
548            public WebDAVProps updateImpl(
549                    com.liferay.portal.model.WebDAVProps webDAVProps)
550                    throws SystemException {
551                    webDAVProps = toUnwrappedModel(webDAVProps);
552    
553                    boolean isNew = webDAVProps.isNew();
554    
555                    Session session = null;
556    
557                    try {
558                            session = openSession();
559    
560                            if (webDAVProps.isNew()) {
561                                    session.save(webDAVProps);
562    
563                                    webDAVProps.setNew(false);
564                            }
565                            else {
566                                    session.merge(webDAVProps);
567                            }
568                    }
569                    catch (Exception e) {
570                            throw processException(e);
571                    }
572                    finally {
573                            closeSession(session);
574                    }
575    
576                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
577    
578                    if (isNew || !WebDAVPropsModelImpl.COLUMN_BITMASK_ENABLED) {
579                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
580                    }
581    
582                    EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
583                            WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
584    
585                    clearUniqueFindersCache(webDAVProps);
586                    cacheUniqueFindersCache(webDAVProps);
587    
588                    return webDAVProps;
589            }
590    
591            protected WebDAVProps toUnwrappedModel(WebDAVProps webDAVProps) {
592                    if (webDAVProps instanceof WebDAVPropsImpl) {
593                            return webDAVProps;
594                    }
595    
596                    WebDAVPropsImpl webDAVPropsImpl = new WebDAVPropsImpl();
597    
598                    webDAVPropsImpl.setNew(webDAVProps.isNew());
599                    webDAVPropsImpl.setPrimaryKey(webDAVProps.getPrimaryKey());
600    
601                    webDAVPropsImpl.setWebDavPropsId(webDAVProps.getWebDavPropsId());
602                    webDAVPropsImpl.setCompanyId(webDAVProps.getCompanyId());
603                    webDAVPropsImpl.setCreateDate(webDAVProps.getCreateDate());
604                    webDAVPropsImpl.setModifiedDate(webDAVProps.getModifiedDate());
605                    webDAVPropsImpl.setClassNameId(webDAVProps.getClassNameId());
606                    webDAVPropsImpl.setClassPK(webDAVProps.getClassPK());
607                    webDAVPropsImpl.setProps(webDAVProps.getProps());
608    
609                    return webDAVPropsImpl;
610            }
611    
612            /**
613             * Returns the web d a v props with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
614             *
615             * @param primaryKey the primary key of the web d a v props
616             * @return the web d a v props
617             * @throws com.liferay.portal.NoSuchWebDAVPropsException if a web d a v props with the primary key could not be found
618             * @throws SystemException if a system exception occurred
619             */
620            @Override
621            public WebDAVProps findByPrimaryKey(Serializable primaryKey)
622                    throws NoSuchWebDAVPropsException, SystemException {
623                    WebDAVProps webDAVProps = fetchByPrimaryKey(primaryKey);
624    
625                    if (webDAVProps == null) {
626                            if (_log.isWarnEnabled()) {
627                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
628                            }
629    
630                            throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
631                                    primaryKey);
632                    }
633    
634                    return webDAVProps;
635            }
636    
637            /**
638             * Returns the web d a v props with the primary key or throws a {@link com.liferay.portal.NoSuchWebDAVPropsException} if it could not be found.
639             *
640             * @param webDavPropsId the primary key of the web d a v props
641             * @return the web d a v props
642             * @throws com.liferay.portal.NoSuchWebDAVPropsException if a web d a v props with the primary key could not be found
643             * @throws SystemException if a system exception occurred
644             */
645            public WebDAVProps findByPrimaryKey(long webDavPropsId)
646                    throws NoSuchWebDAVPropsException, SystemException {
647                    return findByPrimaryKey((Serializable)webDavPropsId);
648            }
649    
650            /**
651             * Returns the web d a v props with the primary key or returns <code>null</code> if it could not be found.
652             *
653             * @param primaryKey the primary key of the web d a v props
654             * @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
655             * @throws SystemException if a system exception occurred
656             */
657            @Override
658            public WebDAVProps fetchByPrimaryKey(Serializable primaryKey)
659                    throws SystemException {
660                    WebDAVProps webDAVProps = (WebDAVProps)EntityCacheUtil.getResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
661                                    WebDAVPropsImpl.class, primaryKey);
662    
663                    if (webDAVProps == _nullWebDAVProps) {
664                            return null;
665                    }
666    
667                    if (webDAVProps == null) {
668                            Session session = null;
669    
670                            try {
671                                    session = openSession();
672    
673                                    webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
674                                                    primaryKey);
675    
676                                    if (webDAVProps != null) {
677                                            cacheResult(webDAVProps);
678                                    }
679                                    else {
680                                            EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
681                                                    WebDAVPropsImpl.class, primaryKey, _nullWebDAVProps);
682                                    }
683                            }
684                            catch (Exception e) {
685                                    EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
686                                            WebDAVPropsImpl.class, primaryKey);
687    
688                                    throw processException(e);
689                            }
690                            finally {
691                                    closeSession(session);
692                            }
693                    }
694    
695                    return webDAVProps;
696            }
697    
698            /**
699             * Returns the web d a v props with the primary key or returns <code>null</code> if it could not be found.
700             *
701             * @param webDavPropsId the primary key of the web d a v props
702             * @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
703             * @throws SystemException if a system exception occurred
704             */
705            public WebDAVProps fetchByPrimaryKey(long webDavPropsId)
706                    throws SystemException {
707                    return fetchByPrimaryKey((Serializable)webDavPropsId);
708            }
709    
710            /**
711             * Returns all the web d a v propses.
712             *
713             * @return the web d a v propses
714             * @throws SystemException if a system exception occurred
715             */
716            public List<WebDAVProps> findAll() throws SystemException {
717                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
718            }
719    
720            /**
721             * Returns a range of all the web d a v propses.
722             *
723             * <p>
724             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.WebDAVPropsModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
725             * </p>
726             *
727             * @param start the lower bound of the range of web d a v propses
728             * @param end the upper bound of the range of web d a v propses (not inclusive)
729             * @return the range of web d a v propses
730             * @throws SystemException if a system exception occurred
731             */
732            public List<WebDAVProps> findAll(int start, int end)
733                    throws SystemException {
734                    return findAll(start, end, null);
735            }
736    
737            /**
738             * Returns an ordered range of all the web d a v propses.
739             *
740             * <p>
741             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.WebDAVPropsModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
742             * </p>
743             *
744             * @param start the lower bound of the range of web d a v propses
745             * @param end the upper bound of the range of web d a v propses (not inclusive)
746             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
747             * @return the ordered range of web d a v propses
748             * @throws SystemException if a system exception occurred
749             */
750            public List<WebDAVProps> findAll(int start, int end,
751                    OrderByComparator orderByComparator) throws SystemException {
752                    boolean pagination = true;
753                    FinderPath finderPath = null;
754                    Object[] finderArgs = null;
755    
756                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
757                                    (orderByComparator == null)) {
758                            pagination = false;
759                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
760                            finderArgs = FINDER_ARGS_EMPTY;
761                    }
762                    else {
763                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
764                            finderArgs = new Object[] { start, end, orderByComparator };
765                    }
766    
767                    List<WebDAVProps> list = (List<WebDAVProps>)FinderCacheUtil.getResult(finderPath,
768                                    finderArgs, this);
769    
770                    if (list == null) {
771                            StringBundler query = null;
772                            String sql = null;
773    
774                            if (orderByComparator != null) {
775                                    query = new StringBundler(2 +
776                                                    (orderByComparator.getOrderByFields().length * 3));
777    
778                                    query.append(_SQL_SELECT_WEBDAVPROPS);
779    
780                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
781                                            orderByComparator);
782    
783                                    sql = query.toString();
784                            }
785                            else {
786                                    sql = _SQL_SELECT_WEBDAVPROPS;
787    
788                                    if (pagination) {
789                                            sql = sql.concat(WebDAVPropsModelImpl.ORDER_BY_JPQL);
790                                    }
791                            }
792    
793                            Session session = null;
794    
795                            try {
796                                    session = openSession();
797    
798                                    Query q = session.createQuery(sql);
799    
800                                    if (!pagination) {
801                                            list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
802                                                            start, end, false);
803    
804                                            Collections.sort(list);
805    
806                                            list = new UnmodifiableList<WebDAVProps>(list);
807                                    }
808                                    else {
809                                            list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
810                                                            start, end);
811                                    }
812    
813                                    cacheResult(list);
814    
815                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
816                            }
817                            catch (Exception e) {
818                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
819    
820                                    throw processException(e);
821                            }
822                            finally {
823                                    closeSession(session);
824                            }
825                    }
826    
827                    return list;
828            }
829    
830            /**
831             * Removes all the web d a v propses from the database.
832             *
833             * @throws SystemException if a system exception occurred
834             */
835            public void removeAll() throws SystemException {
836                    for (WebDAVProps webDAVProps : findAll()) {
837                            remove(webDAVProps);
838                    }
839            }
840    
841            /**
842             * Returns the number of web d a v propses.
843             *
844             * @return the number of web d a v propses
845             * @throws SystemException if a system exception occurred
846             */
847            public int countAll() throws SystemException {
848                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
849                                    FINDER_ARGS_EMPTY, this);
850    
851                    if (count == null) {
852                            Session session = null;
853    
854                            try {
855                                    session = openSession();
856    
857                                    Query q = session.createQuery(_SQL_COUNT_WEBDAVPROPS);
858    
859                                    count = (Long)q.uniqueResult();
860    
861                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
862                                            FINDER_ARGS_EMPTY, count);
863                            }
864                            catch (Exception e) {
865                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
866                                            FINDER_ARGS_EMPTY);
867    
868                                    throw processException(e);
869                            }
870                            finally {
871                                    closeSession(session);
872                            }
873                    }
874    
875                    return count.intValue();
876            }
877    
878            /**
879             * Initializes the web d a v props persistence.
880             */
881            public void afterPropertiesSet() {
882                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
883                                            com.liferay.portal.util.PropsUtil.get(
884                                                    "value.object.listener.com.liferay.portal.model.WebDAVProps")));
885    
886                    if (listenerClassNames.length > 0) {
887                            try {
888                                    List<ModelListener<WebDAVProps>> listenersList = new ArrayList<ModelListener<WebDAVProps>>();
889    
890                                    for (String listenerClassName : listenerClassNames) {
891                                            listenersList.add((ModelListener<WebDAVProps>)InstanceFactory.newInstance(
892                                                            getClassLoader(), listenerClassName));
893                                    }
894    
895                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
896                            }
897                            catch (Exception e) {
898                                    _log.error(e);
899                            }
900                    }
901            }
902    
903            public void destroy() {
904                    EntityCacheUtil.removeCache(WebDAVPropsImpl.class.getName());
905                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
906                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
907                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
908            }
909    
910            private static final String _SQL_SELECT_WEBDAVPROPS = "SELECT webDAVProps FROM WebDAVProps webDAVProps";
911            private static final String _SQL_SELECT_WEBDAVPROPS_WHERE = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE ";
912            private static final String _SQL_COUNT_WEBDAVPROPS = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps";
913            private static final String _SQL_COUNT_WEBDAVPROPS_WHERE = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps WHERE ";
914            private static final String _ORDER_BY_ENTITY_ALIAS = "webDAVProps.";
915            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WebDAVProps exists with the primary key ";
916            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WebDAVProps exists with the key {";
917            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
918            private static Log _log = LogFactoryUtil.getLog(WebDAVPropsPersistenceImpl.class);
919            private static WebDAVProps _nullWebDAVProps = new WebDAVPropsImpl() {
920                            @Override
921                            public Object clone() {
922                                    return this;
923                            }
924    
925                            @Override
926                            public CacheModel<WebDAVProps> toCacheModel() {
927                                    return _nullWebDAVPropsCacheModel;
928                            }
929                    };
930    
931            private static CacheModel<WebDAVProps> _nullWebDAVPropsCacheModel = new CacheModel<WebDAVProps>() {
932                            public WebDAVProps toEntityModel() {
933                                    return _nullWebDAVProps;
934                            }
935                    };
936    }