001
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
061 public class WebDAVPropsPersistenceImpl extends BasePersistenceImpl<WebDAVProps>
062 implements WebDAVPropsPersistence {
063
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
102 @Override
103 public WebDAVProps findByC_C(long classNameId, long classPK)
104 throws NoSuchWebDAVPropsException, SystemException {
105 WebDAVProps webDAVProps = fetchByC_C(classNameId, classPK);
106
107 if (webDAVProps == null) {
108 StringBundler msg = new StringBundler(6);
109
110 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
111
112 msg.append("classNameId=");
113 msg.append(classNameId);
114
115 msg.append(", classPK=");
116 msg.append(classPK);
117
118 msg.append(StringPool.CLOSE_CURLY_BRACE);
119
120 if (_log.isWarnEnabled()) {
121 _log.warn(msg.toString());
122 }
123
124 throw new NoSuchWebDAVPropsException(msg.toString());
125 }
126
127 return webDAVProps;
128 }
129
130
138 @Override
139 public WebDAVProps fetchByC_C(long classNameId, long classPK)
140 throws SystemException {
141 return fetchByC_C(classNameId, classPK, true);
142 }
143
144
153 @Override
154 public WebDAVProps fetchByC_C(long classNameId, long classPK,
155 boolean retrieveFromCache) throws SystemException {
156 Object[] finderArgs = new Object[] { classNameId, classPK };
157
158 Object result = null;
159
160 if (retrieveFromCache) {
161 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
162 finderArgs, this);
163 }
164
165 if (result instanceof WebDAVProps) {
166 WebDAVProps webDAVProps = (WebDAVProps)result;
167
168 if ((classNameId != webDAVProps.getClassNameId()) ||
169 (classPK != webDAVProps.getClassPK())) {
170 result = null;
171 }
172 }
173
174 if (result == null) {
175 StringBundler query = new StringBundler(4);
176
177 query.append(_SQL_SELECT_WEBDAVPROPS_WHERE);
178
179 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
180
181 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
182
183 String sql = query.toString();
184
185 Session session = null;
186
187 try {
188 session = openSession();
189
190 Query q = session.createQuery(sql);
191
192 QueryPos qPos = QueryPos.getInstance(q);
193
194 qPos.add(classNameId);
195
196 qPos.add(classPK);
197
198 List<WebDAVProps> list = q.list();
199
200 if (list.isEmpty()) {
201 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
202 finderArgs, list);
203 }
204 else {
205 WebDAVProps webDAVProps = list.get(0);
206
207 result = webDAVProps;
208
209 cacheResult(webDAVProps);
210
211 if ((webDAVProps.getClassNameId() != classNameId) ||
212 (webDAVProps.getClassPK() != classPK)) {
213 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
214 finderArgs, webDAVProps);
215 }
216 }
217 }
218 catch (Exception e) {
219 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
220 finderArgs);
221
222 throw processException(e);
223 }
224 finally {
225 closeSession(session);
226 }
227 }
228
229 if (result instanceof List<?>) {
230 return null;
231 }
232 else {
233 return (WebDAVProps)result;
234 }
235 }
236
237
245 @Override
246 public WebDAVProps removeByC_C(long classNameId, long classPK)
247 throws NoSuchWebDAVPropsException, SystemException {
248 WebDAVProps webDAVProps = findByC_C(classNameId, classPK);
249
250 return remove(webDAVProps);
251 }
252
253
261 @Override
262 public int countByC_C(long classNameId, long classPK)
263 throws SystemException {
264 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
265
266 Object[] finderArgs = new Object[] { classNameId, classPK };
267
268 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
269 this);
270
271 if (count == null) {
272 StringBundler query = new StringBundler(3);
273
274 query.append(_SQL_COUNT_WEBDAVPROPS_WHERE);
275
276 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
277
278 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
279
280 String sql = query.toString();
281
282 Session session = null;
283
284 try {
285 session = openSession();
286
287 Query q = session.createQuery(sql);
288
289 QueryPos qPos = QueryPos.getInstance(q);
290
291 qPos.add(classNameId);
292
293 qPos.add(classPK);
294
295 count = (Long)q.uniqueResult();
296
297 FinderCacheUtil.putResult(finderPath, finderArgs, count);
298 }
299 catch (Exception e) {
300 FinderCacheUtil.removeResult(finderPath, finderArgs);
301
302 throw processException(e);
303 }
304 finally {
305 closeSession(session);
306 }
307 }
308
309 return count.intValue();
310 }
311
312 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "webDAVProps.classNameId = ? AND ";
313 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "webDAVProps.classPK = ?";
314
315 public WebDAVPropsPersistenceImpl() {
316 setModelClass(WebDAVProps.class);
317 }
318
319
324 @Override
325 public void cacheResult(WebDAVProps webDAVProps) {
326 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
327 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
328
329 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
330 new Object[] { webDAVProps.getClassNameId(), webDAVProps.getClassPK() },
331 webDAVProps);
332
333 webDAVProps.resetOriginalValues();
334 }
335
336
341 @Override
342 public void cacheResult(List<WebDAVProps> webDAVPropses) {
343 for (WebDAVProps webDAVProps : webDAVPropses) {
344 if (EntityCacheUtil.getResult(
345 WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
346 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey()) == null) {
347 cacheResult(webDAVProps);
348 }
349 else {
350 webDAVProps.resetOriginalValues();
351 }
352 }
353 }
354
355
362 @Override
363 public void clearCache() {
364 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
365 CacheRegistryUtil.clear(WebDAVPropsImpl.class.getName());
366 }
367
368 EntityCacheUtil.clearCache(WebDAVPropsImpl.class.getName());
369
370 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
371 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
372 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
373 }
374
375
382 @Override
383 public void clearCache(WebDAVProps webDAVProps) {
384 EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
385 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
386
387 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
388 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
389
390 clearUniqueFindersCache(webDAVProps);
391 }
392
393 @Override
394 public void clearCache(List<WebDAVProps> webDAVPropses) {
395 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
396 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
397
398 for (WebDAVProps webDAVProps : webDAVPropses) {
399 EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
400 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
401
402 clearUniqueFindersCache(webDAVProps);
403 }
404 }
405
406 protected void cacheUniqueFindersCache(WebDAVProps webDAVProps) {
407 if (webDAVProps.isNew()) {
408 Object[] args = new Object[] {
409 webDAVProps.getClassNameId(), webDAVProps.getClassPK()
410 };
411
412 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
413 Long.valueOf(1));
414 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
415 webDAVProps);
416 }
417 else {
418 WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
419
420 if ((webDAVPropsModelImpl.getColumnBitmask() &
421 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
422 Object[] args = new Object[] {
423 webDAVProps.getClassNameId(), webDAVProps.getClassPK()
424 };
425
426 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
427 Long.valueOf(1));
428 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
429 webDAVProps);
430 }
431 }
432 }
433
434 protected void clearUniqueFindersCache(WebDAVProps webDAVProps) {
435 WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
436
437 Object[] args = new Object[] {
438 webDAVProps.getClassNameId(), webDAVProps.getClassPK()
439 };
440
441 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
442 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
443
444 if ((webDAVPropsModelImpl.getColumnBitmask() &
445 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
446 args = new Object[] {
447 webDAVPropsModelImpl.getOriginalClassNameId(),
448 webDAVPropsModelImpl.getOriginalClassPK()
449 };
450
451 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
452 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
453 }
454 }
455
456
462 @Override
463 public WebDAVProps create(long webDavPropsId) {
464 WebDAVProps webDAVProps = new WebDAVPropsImpl();
465
466 webDAVProps.setNew(true);
467 webDAVProps.setPrimaryKey(webDavPropsId);
468
469 return webDAVProps;
470 }
471
472
480 @Override
481 public WebDAVProps remove(long webDavPropsId)
482 throws NoSuchWebDAVPropsException, SystemException {
483 return remove((Serializable)webDavPropsId);
484 }
485
486
494 @Override
495 public WebDAVProps remove(Serializable primaryKey)
496 throws NoSuchWebDAVPropsException, SystemException {
497 Session session = null;
498
499 try {
500 session = openSession();
501
502 WebDAVProps webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
503 primaryKey);
504
505 if (webDAVProps == null) {
506 if (_log.isWarnEnabled()) {
507 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
508 }
509
510 throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
511 primaryKey);
512 }
513
514 return remove(webDAVProps);
515 }
516 catch (NoSuchWebDAVPropsException nsee) {
517 throw nsee;
518 }
519 catch (Exception e) {
520 throw processException(e);
521 }
522 finally {
523 closeSession(session);
524 }
525 }
526
527 @Override
528 protected WebDAVProps removeImpl(WebDAVProps webDAVProps)
529 throws SystemException {
530 webDAVProps = toUnwrappedModel(webDAVProps);
531
532 Session session = null;
533
534 try {
535 session = openSession();
536
537 if (!session.contains(webDAVProps)) {
538 webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
539 webDAVProps.getPrimaryKeyObj());
540 }
541
542 if (webDAVProps != null) {
543 session.delete(webDAVProps);
544 }
545 }
546 catch (Exception e) {
547 throw processException(e);
548 }
549 finally {
550 closeSession(session);
551 }
552
553 if (webDAVProps != null) {
554 clearCache(webDAVProps);
555 }
556
557 return webDAVProps;
558 }
559
560 @Override
561 public WebDAVProps updateImpl(
562 com.liferay.portal.model.WebDAVProps webDAVProps)
563 throws SystemException {
564 webDAVProps = toUnwrappedModel(webDAVProps);
565
566 boolean isNew = webDAVProps.isNew();
567
568 Session session = null;
569
570 try {
571 session = openSession();
572
573 if (webDAVProps.isNew()) {
574 session.save(webDAVProps);
575
576 webDAVProps.setNew(false);
577 }
578 else {
579 session.merge(webDAVProps);
580 }
581 }
582 catch (Exception e) {
583 throw processException(e);
584 }
585 finally {
586 closeSession(session);
587 }
588
589 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
590
591 if (isNew || !WebDAVPropsModelImpl.COLUMN_BITMASK_ENABLED) {
592 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
593 }
594
595 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
596 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
597
598 clearUniqueFindersCache(webDAVProps);
599 cacheUniqueFindersCache(webDAVProps);
600
601 return webDAVProps;
602 }
603
604 protected WebDAVProps toUnwrappedModel(WebDAVProps webDAVProps) {
605 if (webDAVProps instanceof WebDAVPropsImpl) {
606 return webDAVProps;
607 }
608
609 WebDAVPropsImpl webDAVPropsImpl = new WebDAVPropsImpl();
610
611 webDAVPropsImpl.setNew(webDAVProps.isNew());
612 webDAVPropsImpl.setPrimaryKey(webDAVProps.getPrimaryKey());
613
614 webDAVPropsImpl.setWebDavPropsId(webDAVProps.getWebDavPropsId());
615 webDAVPropsImpl.setCompanyId(webDAVProps.getCompanyId());
616 webDAVPropsImpl.setCreateDate(webDAVProps.getCreateDate());
617 webDAVPropsImpl.setModifiedDate(webDAVProps.getModifiedDate());
618 webDAVPropsImpl.setClassNameId(webDAVProps.getClassNameId());
619 webDAVPropsImpl.setClassPK(webDAVProps.getClassPK());
620 webDAVPropsImpl.setProps(webDAVProps.getProps());
621
622 return webDAVPropsImpl;
623 }
624
625
633 @Override
634 public WebDAVProps findByPrimaryKey(Serializable primaryKey)
635 throws NoSuchWebDAVPropsException, SystemException {
636 WebDAVProps webDAVProps = fetchByPrimaryKey(primaryKey);
637
638 if (webDAVProps == null) {
639 if (_log.isWarnEnabled()) {
640 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
641 }
642
643 throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
644 primaryKey);
645 }
646
647 return webDAVProps;
648 }
649
650
658 @Override
659 public WebDAVProps findByPrimaryKey(long webDavPropsId)
660 throws NoSuchWebDAVPropsException, SystemException {
661 return findByPrimaryKey((Serializable)webDavPropsId);
662 }
663
664
671 @Override
672 public WebDAVProps fetchByPrimaryKey(Serializable primaryKey)
673 throws SystemException {
674 WebDAVProps webDAVProps = (WebDAVProps)EntityCacheUtil.getResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
675 WebDAVPropsImpl.class, primaryKey);
676
677 if (webDAVProps == _nullWebDAVProps) {
678 return null;
679 }
680
681 if (webDAVProps == null) {
682 Session session = null;
683
684 try {
685 session = openSession();
686
687 webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
688 primaryKey);
689
690 if (webDAVProps != null) {
691 cacheResult(webDAVProps);
692 }
693 else {
694 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
695 WebDAVPropsImpl.class, primaryKey, _nullWebDAVProps);
696 }
697 }
698 catch (Exception e) {
699 EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
700 WebDAVPropsImpl.class, primaryKey);
701
702 throw processException(e);
703 }
704 finally {
705 closeSession(session);
706 }
707 }
708
709 return webDAVProps;
710 }
711
712
719 @Override
720 public WebDAVProps fetchByPrimaryKey(long webDavPropsId)
721 throws SystemException {
722 return fetchByPrimaryKey((Serializable)webDavPropsId);
723 }
724
725
731 @Override
732 public List<WebDAVProps> findAll() throws SystemException {
733 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
734 }
735
736
748 @Override
749 public List<WebDAVProps> findAll(int start, int end)
750 throws SystemException {
751 return findAll(start, end, null);
752 }
753
754
767 @Override
768 public List<WebDAVProps> findAll(int start, int end,
769 OrderByComparator orderByComparator) throws SystemException {
770 boolean pagination = true;
771 FinderPath finderPath = null;
772 Object[] finderArgs = null;
773
774 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
775 (orderByComparator == null)) {
776 pagination = false;
777 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
778 finderArgs = FINDER_ARGS_EMPTY;
779 }
780 else {
781 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
782 finderArgs = new Object[] { start, end, orderByComparator };
783 }
784
785 List<WebDAVProps> list = (List<WebDAVProps>)FinderCacheUtil.getResult(finderPath,
786 finderArgs, this);
787
788 if (list == null) {
789 StringBundler query = null;
790 String sql = null;
791
792 if (orderByComparator != null) {
793 query = new StringBundler(2 +
794 (orderByComparator.getOrderByFields().length * 3));
795
796 query.append(_SQL_SELECT_WEBDAVPROPS);
797
798 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
799 orderByComparator);
800
801 sql = query.toString();
802 }
803 else {
804 sql = _SQL_SELECT_WEBDAVPROPS;
805
806 if (pagination) {
807 sql = sql.concat(WebDAVPropsModelImpl.ORDER_BY_JPQL);
808 }
809 }
810
811 Session session = null;
812
813 try {
814 session = openSession();
815
816 Query q = session.createQuery(sql);
817
818 if (!pagination) {
819 list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
820 start, end, false);
821
822 Collections.sort(list);
823
824 list = new UnmodifiableList<WebDAVProps>(list);
825 }
826 else {
827 list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
828 start, end);
829 }
830
831 cacheResult(list);
832
833 FinderCacheUtil.putResult(finderPath, finderArgs, list);
834 }
835 catch (Exception e) {
836 FinderCacheUtil.removeResult(finderPath, finderArgs);
837
838 throw processException(e);
839 }
840 finally {
841 closeSession(session);
842 }
843 }
844
845 return list;
846 }
847
848
853 @Override
854 public void removeAll() throws SystemException {
855 for (WebDAVProps webDAVProps : findAll()) {
856 remove(webDAVProps);
857 }
858 }
859
860
866 @Override
867 public int countAll() throws SystemException {
868 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
869 FINDER_ARGS_EMPTY, this);
870
871 if (count == null) {
872 Session session = null;
873
874 try {
875 session = openSession();
876
877 Query q = session.createQuery(_SQL_COUNT_WEBDAVPROPS);
878
879 count = (Long)q.uniqueResult();
880
881 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
882 FINDER_ARGS_EMPTY, count);
883 }
884 catch (Exception e) {
885 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
886 FINDER_ARGS_EMPTY);
887
888 throw processException(e);
889 }
890 finally {
891 closeSession(session);
892 }
893 }
894
895 return count.intValue();
896 }
897
898
901 public void afterPropertiesSet() {
902 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
903 com.liferay.portal.util.PropsUtil.get(
904 "value.object.listener.com.liferay.portal.model.WebDAVProps")));
905
906 if (listenerClassNames.length > 0) {
907 try {
908 List<ModelListener<WebDAVProps>> listenersList = new ArrayList<ModelListener<WebDAVProps>>();
909
910 for (String listenerClassName : listenerClassNames) {
911 listenersList.add((ModelListener<WebDAVProps>)InstanceFactory.newInstance(
912 getClassLoader(), listenerClassName));
913 }
914
915 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
916 }
917 catch (Exception e) {
918 _log.error(e);
919 }
920 }
921 }
922
923 public void destroy() {
924 EntityCacheUtil.removeCache(WebDAVPropsImpl.class.getName());
925 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
926 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
927 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
928 }
929
930 private static final String _SQL_SELECT_WEBDAVPROPS = "SELECT webDAVProps FROM WebDAVProps webDAVProps";
931 private static final String _SQL_SELECT_WEBDAVPROPS_WHERE = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE ";
932 private static final String _SQL_COUNT_WEBDAVPROPS = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps";
933 private static final String _SQL_COUNT_WEBDAVPROPS_WHERE = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps WHERE ";
934 private static final String _ORDER_BY_ENTITY_ALIAS = "webDAVProps.";
935 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WebDAVProps exists with the primary key ";
936 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WebDAVProps exists with the key {";
937 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
938 private static Log _log = LogFactoryUtil.getLog(WebDAVPropsPersistenceImpl.class);
939 private static WebDAVProps _nullWebDAVProps = new WebDAVPropsImpl() {
940 @Override
941 public Object clone() {
942 return this;
943 }
944
945 @Override
946 public CacheModel<WebDAVProps> toCacheModel() {
947 return _nullWebDAVPropsCacheModel;
948 }
949 };
950
951 private static CacheModel<WebDAVProps> _nullWebDAVPropsCacheModel = new CacheModel<WebDAVProps>() {
952 @Override
953 public WebDAVProps toEntityModel() {
954 return _nullWebDAVProps;
955 }
956 };
957 }