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
320 @Override
321 public void cacheResult(WebDAVProps webDAVProps) {
322 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
323 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
324
325 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
326 new Object[] { webDAVProps.getClassNameId(), webDAVProps.getClassPK() },
327 webDAVProps);
328
329 webDAVProps.resetOriginalValues();
330 }
331
332
337 @Override
338 public void cacheResult(List<WebDAVProps> webDAVPropses) {
339 for (WebDAVProps webDAVProps : webDAVPropses) {
340 if (EntityCacheUtil.getResult(
341 WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
342 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey()) == null) {
343 cacheResult(webDAVProps);
344 }
345 else {
346 webDAVProps.resetOriginalValues();
347 }
348 }
349 }
350
351
358 @Override
359 public void clearCache() {
360 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
361 CacheRegistryUtil.clear(WebDAVPropsImpl.class.getName());
362 }
363
364 EntityCacheUtil.clearCache(WebDAVPropsImpl.class.getName());
365
366 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
367 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
368 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
369 }
370
371
378 @Override
379 public void clearCache(WebDAVProps webDAVProps) {
380 EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
381 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
382
383 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
384 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
385
386 clearUniqueFindersCache(webDAVProps);
387 }
388
389 @Override
390 public void clearCache(List<WebDAVProps> webDAVPropses) {
391 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
392 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
393
394 for (WebDAVProps webDAVProps : webDAVPropses) {
395 EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
396 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
397
398 clearUniqueFindersCache(webDAVProps);
399 }
400 }
401
402 protected void cacheUniqueFindersCache(WebDAVProps webDAVProps) {
403 if (webDAVProps.isNew()) {
404 Object[] args = new Object[] {
405 webDAVProps.getClassNameId(), webDAVProps.getClassPK()
406 };
407
408 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
409 Long.valueOf(1));
410 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
411 webDAVProps);
412 }
413 else {
414 WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
415
416 if ((webDAVPropsModelImpl.getColumnBitmask() &
417 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
418 Object[] args = new Object[] {
419 webDAVProps.getClassNameId(), webDAVProps.getClassPK()
420 };
421
422 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
423 Long.valueOf(1));
424 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
425 webDAVProps);
426 }
427 }
428 }
429
430 protected void clearUniqueFindersCache(WebDAVProps webDAVProps) {
431 WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
432
433 Object[] args = new Object[] {
434 webDAVProps.getClassNameId(), webDAVProps.getClassPK()
435 };
436
437 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
438 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
439
440 if ((webDAVPropsModelImpl.getColumnBitmask() &
441 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
442 args = new Object[] {
443 webDAVPropsModelImpl.getOriginalClassNameId(),
444 webDAVPropsModelImpl.getOriginalClassPK()
445 };
446
447 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
448 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
449 }
450 }
451
452
458 @Override
459 public WebDAVProps create(long webDavPropsId) {
460 WebDAVProps webDAVProps = new WebDAVPropsImpl();
461
462 webDAVProps.setNew(true);
463 webDAVProps.setPrimaryKey(webDavPropsId);
464
465 return webDAVProps;
466 }
467
468
476 @Override
477 public WebDAVProps remove(long webDavPropsId)
478 throws NoSuchWebDAVPropsException, SystemException {
479 return remove((Serializable)webDavPropsId);
480 }
481
482
490 @Override
491 public WebDAVProps remove(Serializable primaryKey)
492 throws NoSuchWebDAVPropsException, SystemException {
493 Session session = null;
494
495 try {
496 session = openSession();
497
498 WebDAVProps webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
499 primaryKey);
500
501 if (webDAVProps == null) {
502 if (_log.isWarnEnabled()) {
503 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
504 }
505
506 throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
507 primaryKey);
508 }
509
510 return remove(webDAVProps);
511 }
512 catch (NoSuchWebDAVPropsException nsee) {
513 throw nsee;
514 }
515 catch (Exception e) {
516 throw processException(e);
517 }
518 finally {
519 closeSession(session);
520 }
521 }
522
523 @Override
524 protected WebDAVProps removeImpl(WebDAVProps webDAVProps)
525 throws SystemException {
526 webDAVProps = toUnwrappedModel(webDAVProps);
527
528 Session session = null;
529
530 try {
531 session = openSession();
532
533 if (!session.contains(webDAVProps)) {
534 webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
535 webDAVProps.getPrimaryKeyObj());
536 }
537
538 if (webDAVProps != null) {
539 session.delete(webDAVProps);
540 }
541 }
542 catch (Exception e) {
543 throw processException(e);
544 }
545 finally {
546 closeSession(session);
547 }
548
549 if (webDAVProps != null) {
550 clearCache(webDAVProps);
551 }
552
553 return webDAVProps;
554 }
555
556 @Override
557 public WebDAVProps updateImpl(
558 com.liferay.portal.model.WebDAVProps webDAVProps)
559 throws SystemException {
560 webDAVProps = toUnwrappedModel(webDAVProps);
561
562 boolean isNew = webDAVProps.isNew();
563
564 Session session = null;
565
566 try {
567 session = openSession();
568
569 if (webDAVProps.isNew()) {
570 session.save(webDAVProps);
571
572 webDAVProps.setNew(false);
573 }
574 else {
575 session.merge(webDAVProps);
576 }
577 }
578 catch (Exception e) {
579 throw processException(e);
580 }
581 finally {
582 closeSession(session);
583 }
584
585 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
586
587 if (isNew || !WebDAVPropsModelImpl.COLUMN_BITMASK_ENABLED) {
588 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
589 }
590
591 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
592 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
593
594 clearUniqueFindersCache(webDAVProps);
595 cacheUniqueFindersCache(webDAVProps);
596
597 return webDAVProps;
598 }
599
600 protected WebDAVProps toUnwrappedModel(WebDAVProps webDAVProps) {
601 if (webDAVProps instanceof WebDAVPropsImpl) {
602 return webDAVProps;
603 }
604
605 WebDAVPropsImpl webDAVPropsImpl = new WebDAVPropsImpl();
606
607 webDAVPropsImpl.setNew(webDAVProps.isNew());
608 webDAVPropsImpl.setPrimaryKey(webDAVProps.getPrimaryKey());
609
610 webDAVPropsImpl.setWebDavPropsId(webDAVProps.getWebDavPropsId());
611 webDAVPropsImpl.setCompanyId(webDAVProps.getCompanyId());
612 webDAVPropsImpl.setCreateDate(webDAVProps.getCreateDate());
613 webDAVPropsImpl.setModifiedDate(webDAVProps.getModifiedDate());
614 webDAVPropsImpl.setClassNameId(webDAVProps.getClassNameId());
615 webDAVPropsImpl.setClassPK(webDAVProps.getClassPK());
616 webDAVPropsImpl.setProps(webDAVProps.getProps());
617
618 return webDAVPropsImpl;
619 }
620
621
629 @Override
630 public WebDAVProps findByPrimaryKey(Serializable primaryKey)
631 throws NoSuchWebDAVPropsException, SystemException {
632 WebDAVProps webDAVProps = fetchByPrimaryKey(primaryKey);
633
634 if (webDAVProps == null) {
635 if (_log.isWarnEnabled()) {
636 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
637 }
638
639 throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
640 primaryKey);
641 }
642
643 return webDAVProps;
644 }
645
646
654 @Override
655 public WebDAVProps findByPrimaryKey(long webDavPropsId)
656 throws NoSuchWebDAVPropsException, SystemException {
657 return findByPrimaryKey((Serializable)webDavPropsId);
658 }
659
660
667 @Override
668 public WebDAVProps fetchByPrimaryKey(Serializable primaryKey)
669 throws SystemException {
670 WebDAVProps webDAVProps = (WebDAVProps)EntityCacheUtil.getResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
671 WebDAVPropsImpl.class, primaryKey);
672
673 if (webDAVProps == _nullWebDAVProps) {
674 return null;
675 }
676
677 if (webDAVProps == null) {
678 Session session = null;
679
680 try {
681 session = openSession();
682
683 webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
684 primaryKey);
685
686 if (webDAVProps != null) {
687 cacheResult(webDAVProps);
688 }
689 else {
690 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
691 WebDAVPropsImpl.class, primaryKey, _nullWebDAVProps);
692 }
693 }
694 catch (Exception e) {
695 EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
696 WebDAVPropsImpl.class, primaryKey);
697
698 throw processException(e);
699 }
700 finally {
701 closeSession(session);
702 }
703 }
704
705 return webDAVProps;
706 }
707
708
715 @Override
716 public WebDAVProps fetchByPrimaryKey(long webDavPropsId)
717 throws SystemException {
718 return fetchByPrimaryKey((Serializable)webDavPropsId);
719 }
720
721
727 @Override
728 public List<WebDAVProps> findAll() throws SystemException {
729 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
730 }
731
732
744 @Override
745 public List<WebDAVProps> findAll(int start, int end)
746 throws SystemException {
747 return findAll(start, end, null);
748 }
749
750
763 @Override
764 public List<WebDAVProps> findAll(int start, int end,
765 OrderByComparator orderByComparator) throws SystemException {
766 boolean pagination = true;
767 FinderPath finderPath = null;
768 Object[] finderArgs = null;
769
770 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
771 (orderByComparator == null)) {
772 pagination = false;
773 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
774 finderArgs = FINDER_ARGS_EMPTY;
775 }
776 else {
777 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
778 finderArgs = new Object[] { start, end, orderByComparator };
779 }
780
781 List<WebDAVProps> list = (List<WebDAVProps>)FinderCacheUtil.getResult(finderPath,
782 finderArgs, this);
783
784 if (list == null) {
785 StringBundler query = null;
786 String sql = null;
787
788 if (orderByComparator != null) {
789 query = new StringBundler(2 +
790 (orderByComparator.getOrderByFields().length * 3));
791
792 query.append(_SQL_SELECT_WEBDAVPROPS);
793
794 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
795 orderByComparator);
796
797 sql = query.toString();
798 }
799 else {
800 sql = _SQL_SELECT_WEBDAVPROPS;
801
802 if (pagination) {
803 sql = sql.concat(WebDAVPropsModelImpl.ORDER_BY_JPQL);
804 }
805 }
806
807 Session session = null;
808
809 try {
810 session = openSession();
811
812 Query q = session.createQuery(sql);
813
814 if (!pagination) {
815 list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
816 start, end, false);
817
818 Collections.sort(list);
819
820 list = new UnmodifiableList<WebDAVProps>(list);
821 }
822 else {
823 list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
824 start, end);
825 }
826
827 cacheResult(list);
828
829 FinderCacheUtil.putResult(finderPath, finderArgs, list);
830 }
831 catch (Exception e) {
832 FinderCacheUtil.removeResult(finderPath, finderArgs);
833
834 throw processException(e);
835 }
836 finally {
837 closeSession(session);
838 }
839 }
840
841 return list;
842 }
843
844
849 @Override
850 public void removeAll() throws SystemException {
851 for (WebDAVProps webDAVProps : findAll()) {
852 remove(webDAVProps);
853 }
854 }
855
856
862 @Override
863 public int countAll() throws SystemException {
864 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
865 FINDER_ARGS_EMPTY, this);
866
867 if (count == null) {
868 Session session = null;
869
870 try {
871 session = openSession();
872
873 Query q = session.createQuery(_SQL_COUNT_WEBDAVPROPS);
874
875 count = (Long)q.uniqueResult();
876
877 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
878 FINDER_ARGS_EMPTY, count);
879 }
880 catch (Exception e) {
881 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
882 FINDER_ARGS_EMPTY);
883
884 throw processException(e);
885 }
886 finally {
887 closeSession(session);
888 }
889 }
890
891 return count.intValue();
892 }
893
894
897 public void afterPropertiesSet() {
898 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
899 com.liferay.portal.util.PropsUtil.get(
900 "value.object.listener.com.liferay.portal.model.WebDAVProps")));
901
902 if (listenerClassNames.length > 0) {
903 try {
904 List<ModelListener<WebDAVProps>> listenersList = new ArrayList<ModelListener<WebDAVProps>>();
905
906 for (String listenerClassName : listenerClassNames) {
907 listenersList.add((ModelListener<WebDAVProps>)InstanceFactory.newInstance(
908 getClassLoader(), listenerClassName));
909 }
910
911 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
912 }
913 catch (Exception e) {
914 _log.error(e);
915 }
916 }
917 }
918
919 public void destroy() {
920 EntityCacheUtil.removeCache(WebDAVPropsImpl.class.getName());
921 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
922 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
923 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
924 }
925
926 private static final String _SQL_SELECT_WEBDAVPROPS = "SELECT webDAVProps FROM WebDAVProps webDAVProps";
927 private static final String _SQL_SELECT_WEBDAVPROPS_WHERE = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE ";
928 private static final String _SQL_COUNT_WEBDAVPROPS = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps";
929 private static final String _SQL_COUNT_WEBDAVPROPS_WHERE = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps WHERE ";
930 private static final String _ORDER_BY_ENTITY_ALIAS = "webDAVProps.";
931 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WebDAVProps exists with the primary key ";
932 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WebDAVProps exists with the key {";
933 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
934 private static Log _log = LogFactoryUtil.getLog(WebDAVPropsPersistenceImpl.class);
935 private static WebDAVProps _nullWebDAVProps = new WebDAVPropsImpl() {
936 @Override
937 public Object clone() {
938 return this;
939 }
940
941 @Override
942 public CacheModel<WebDAVProps> toCacheModel() {
943 return _nullWebDAVPropsCacheModel;
944 }
945 };
946
947 private static CacheModel<WebDAVProps> _nullWebDAVPropsCacheModel = new CacheModel<WebDAVProps>() {
948 @Override
949 public WebDAVProps toEntityModel() {
950 return _nullWebDAVProps;
951 }
952 };
953 }