001
014
015 package com.liferay.portal.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.NoSuchWebDAVPropsException;
020 import com.liferay.portal.kernel.dao.orm.EntityCache;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCache;
023 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024 import com.liferay.portal.kernel.dao.orm.FinderPath;
025 import com.liferay.portal.kernel.dao.orm.Query;
026 import com.liferay.portal.kernel.dao.orm.QueryPos;
027 import com.liferay.portal.kernel.dao.orm.QueryUtil;
028 import com.liferay.portal.kernel.dao.orm.Session;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
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.model.CacheModel;
035 import com.liferay.portal.model.MVCCModel;
036 import com.liferay.portal.model.WebDAVProps;
037 import com.liferay.portal.model.impl.WebDAVPropsImpl;
038 import com.liferay.portal.model.impl.WebDAVPropsModelImpl;
039 import com.liferay.portal.service.ServiceContext;
040 import com.liferay.portal.service.ServiceContextThreadLocal;
041 import com.liferay.portal.service.persistence.WebDAVPropsPersistence;
042
043 import java.io.Serializable;
044
045 import java.util.Collections;
046 import java.util.Date;
047 import java.util.HashMap;
048 import java.util.HashSet;
049 import java.util.Iterator;
050 import java.util.List;
051 import java.util.Map;
052 import java.util.Set;
053
054
066 @ProviderType
067 public class WebDAVPropsPersistenceImpl extends BasePersistenceImpl<WebDAVProps>
068 implements WebDAVPropsPersistence {
069
074 public static final String FINDER_CLASS_NAME_ENTITY = WebDAVPropsImpl.class.getName();
075 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List1";
077 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List2";
079 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
080 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
081 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
082 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
083 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
084 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
086 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, Long.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
089 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
090 FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
091 new String[] { Long.class.getName(), Long.class.getName() },
092 WebDAVPropsModelImpl.CLASSNAMEID_COLUMN_BITMASK |
093 WebDAVPropsModelImpl.CLASSPK_COLUMN_BITMASK);
094 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
095 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, Long.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
097 new String[] { Long.class.getName(), Long.class.getName() });
098
099
107 @Override
108 public WebDAVProps findByC_C(long classNameId, long classPK)
109 throws NoSuchWebDAVPropsException {
110 WebDAVProps webDAVProps = fetchByC_C(classNameId, classPK);
111
112 if (webDAVProps == null) {
113 StringBundler msg = new StringBundler(6);
114
115 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
116
117 msg.append("classNameId=");
118 msg.append(classNameId);
119
120 msg.append(", classPK=");
121 msg.append(classPK);
122
123 msg.append(StringPool.CLOSE_CURLY_BRACE);
124
125 if (_log.isWarnEnabled()) {
126 _log.warn(msg.toString());
127 }
128
129 throw new NoSuchWebDAVPropsException(msg.toString());
130 }
131
132 return webDAVProps;
133 }
134
135
142 @Override
143 public WebDAVProps fetchByC_C(long classNameId, long classPK) {
144 return fetchByC_C(classNameId, classPK, true);
145 }
146
147
155 @Override
156 public WebDAVProps fetchByC_C(long classNameId, long classPK,
157 boolean retrieveFromCache) {
158 Object[] finderArgs = new Object[] { classNameId, classPK };
159
160 Object result = null;
161
162 if (retrieveFromCache) {
163 result = finderCache.getResult(FINDER_PATH_FETCH_BY_C_C,
164 finderArgs, this);
165 }
166
167 if (result instanceof WebDAVProps) {
168 WebDAVProps webDAVProps = (WebDAVProps)result;
169
170 if ((classNameId != webDAVProps.getClassNameId()) ||
171 (classPK != webDAVProps.getClassPK())) {
172 result = null;
173 }
174 }
175
176 if (result == null) {
177 StringBundler query = new StringBundler(4);
178
179 query.append(_SQL_SELECT_WEBDAVPROPS_WHERE);
180
181 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
182
183 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
184
185 String sql = query.toString();
186
187 Session session = null;
188
189 try {
190 session = openSession();
191
192 Query q = session.createQuery(sql);
193
194 QueryPos qPos = QueryPos.getInstance(q);
195
196 qPos.add(classNameId);
197
198 qPos.add(classPK);
199
200 List<WebDAVProps> list = q.list();
201
202 if (list.isEmpty()) {
203 finderCache.putResult(FINDER_PATH_FETCH_BY_C_C, finderArgs,
204 list);
205 }
206 else {
207 WebDAVProps webDAVProps = list.get(0);
208
209 result = webDAVProps;
210
211 cacheResult(webDAVProps);
212
213 if ((webDAVProps.getClassNameId() != classNameId) ||
214 (webDAVProps.getClassPK() != classPK)) {
215 finderCache.putResult(FINDER_PATH_FETCH_BY_C_C,
216 finderArgs, webDAVProps);
217 }
218 }
219 }
220 catch (Exception e) {
221 finderCache.removeResult(FINDER_PATH_FETCH_BY_C_C, finderArgs);
222
223 throw processException(e);
224 }
225 finally {
226 closeSession(session);
227 }
228 }
229
230 if (result instanceof List<?>) {
231 return null;
232 }
233 else {
234 return (WebDAVProps)result;
235 }
236 }
237
238
245 @Override
246 public WebDAVProps removeByC_C(long classNameId, long classPK)
247 throws NoSuchWebDAVPropsException {
248 WebDAVProps webDAVProps = findByC_C(classNameId, classPK);
249
250 return remove(webDAVProps);
251 }
252
253
260 @Override
261 public int countByC_C(long classNameId, long classPK) {
262 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
263
264 Object[] finderArgs = new Object[] { classNameId, classPK };
265
266 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
267
268 if (count == null) {
269 StringBundler query = new StringBundler(3);
270
271 query.append(_SQL_COUNT_WEBDAVPROPS_WHERE);
272
273 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
274
275 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
276
277 String sql = query.toString();
278
279 Session session = null;
280
281 try {
282 session = openSession();
283
284 Query q = session.createQuery(sql);
285
286 QueryPos qPos = QueryPos.getInstance(q);
287
288 qPos.add(classNameId);
289
290 qPos.add(classPK);
291
292 count = (Long)q.uniqueResult();
293
294 finderCache.putResult(finderPath, finderArgs, count);
295 }
296 catch (Exception e) {
297 finderCache.removeResult(finderPath, finderArgs);
298
299 throw processException(e);
300 }
301 finally {
302 closeSession(session);
303 }
304 }
305
306 return count.intValue();
307 }
308
309 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "webDAVProps.classNameId = ? AND ";
310 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "webDAVProps.classPK = ?";
311
312 public WebDAVPropsPersistenceImpl() {
313 setModelClass(WebDAVProps.class);
314 }
315
316
321 @Override
322 public void cacheResult(WebDAVProps webDAVProps) {
323 entityCache.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
324 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
325
326 finderCache.putResult(FINDER_PATH_FETCH_BY_C_C,
327 new Object[] { webDAVProps.getClassNameId(), webDAVProps.getClassPK() },
328 webDAVProps);
329
330 webDAVProps.resetOriginalValues();
331 }
332
333
338 @Override
339 public void cacheResult(List<WebDAVProps> webDAVPropses) {
340 for (WebDAVProps webDAVProps : webDAVPropses) {
341 if (entityCache.getResult(
342 WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
343 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey()) == null) {
344 cacheResult(webDAVProps);
345 }
346 else {
347 webDAVProps.resetOriginalValues();
348 }
349 }
350 }
351
352
359 @Override
360 public void clearCache() {
361 entityCache.clearCache(WebDAVPropsImpl.class);
362
363 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
364 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
365 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
366 }
367
368
375 @Override
376 public void clearCache(WebDAVProps webDAVProps) {
377 entityCache.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
378 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
379
380 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
381 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
382
383 clearUniqueFindersCache((WebDAVPropsModelImpl)webDAVProps);
384 }
385
386 @Override
387 public void clearCache(List<WebDAVProps> webDAVPropses) {
388 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
389 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
390
391 for (WebDAVProps webDAVProps : webDAVPropses) {
392 entityCache.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
393 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
394
395 clearUniqueFindersCache((WebDAVPropsModelImpl)webDAVProps);
396 }
397 }
398
399 protected void cacheUniqueFindersCache(
400 WebDAVPropsModelImpl webDAVPropsModelImpl, boolean isNew) {
401 if (isNew) {
402 Object[] args = new Object[] {
403 webDAVPropsModelImpl.getClassNameId(),
404 webDAVPropsModelImpl.getClassPK()
405 };
406
407 finderCache.putResult(FINDER_PATH_COUNT_BY_C_C, args,
408 Long.valueOf(1));
409 finderCache.putResult(FINDER_PATH_FETCH_BY_C_C, args,
410 webDAVPropsModelImpl);
411 }
412 else {
413 if ((webDAVPropsModelImpl.getColumnBitmask() &
414 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
415 Object[] args = new Object[] {
416 webDAVPropsModelImpl.getClassNameId(),
417 webDAVPropsModelImpl.getClassPK()
418 };
419
420 finderCache.putResult(FINDER_PATH_COUNT_BY_C_C, args,
421 Long.valueOf(1));
422 finderCache.putResult(FINDER_PATH_FETCH_BY_C_C, args,
423 webDAVPropsModelImpl);
424 }
425 }
426 }
427
428 protected void clearUniqueFindersCache(
429 WebDAVPropsModelImpl webDAVPropsModelImpl) {
430 Object[] args = new Object[] {
431 webDAVPropsModelImpl.getClassNameId(),
432 webDAVPropsModelImpl.getClassPK()
433 };
434
435 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
436 finderCache.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
437
438 if ((webDAVPropsModelImpl.getColumnBitmask() &
439 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
440 args = new Object[] {
441 webDAVPropsModelImpl.getOriginalClassNameId(),
442 webDAVPropsModelImpl.getOriginalClassPK()
443 };
444
445 finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
446 finderCache.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
447 }
448 }
449
450
456 @Override
457 public WebDAVProps create(long webDavPropsId) {
458 WebDAVProps webDAVProps = new WebDAVPropsImpl();
459
460 webDAVProps.setNew(true);
461 webDAVProps.setPrimaryKey(webDavPropsId);
462
463 return webDAVProps;
464 }
465
466
473 @Override
474 public WebDAVProps remove(long webDavPropsId)
475 throws NoSuchWebDAVPropsException {
476 return remove((Serializable)webDavPropsId);
477 }
478
479
486 @Override
487 public WebDAVProps remove(Serializable primaryKey)
488 throws NoSuchWebDAVPropsException {
489 Session session = null;
490
491 try {
492 session = openSession();
493
494 WebDAVProps webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
495 primaryKey);
496
497 if (webDAVProps == null) {
498 if (_log.isWarnEnabled()) {
499 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
500 }
501
502 throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
503 primaryKey);
504 }
505
506 return remove(webDAVProps);
507 }
508 catch (NoSuchWebDAVPropsException nsee) {
509 throw nsee;
510 }
511 catch (Exception e) {
512 throw processException(e);
513 }
514 finally {
515 closeSession(session);
516 }
517 }
518
519 @Override
520 protected WebDAVProps removeImpl(WebDAVProps webDAVProps) {
521 webDAVProps = toUnwrappedModel(webDAVProps);
522
523 Session session = null;
524
525 try {
526 session = openSession();
527
528 if (!session.contains(webDAVProps)) {
529 webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
530 webDAVProps.getPrimaryKeyObj());
531 }
532
533 if (webDAVProps != null) {
534 session.delete(webDAVProps);
535 }
536 }
537 catch (Exception e) {
538 throw processException(e);
539 }
540 finally {
541 closeSession(session);
542 }
543
544 if (webDAVProps != null) {
545 clearCache(webDAVProps);
546 }
547
548 return webDAVProps;
549 }
550
551 @Override
552 public WebDAVProps updateImpl(WebDAVProps webDAVProps) {
553 webDAVProps = toUnwrappedModel(webDAVProps);
554
555 boolean isNew = webDAVProps.isNew();
556
557 WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
558
559 ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
560
561 Date now = new Date();
562
563 if (isNew && (webDAVProps.getCreateDate() == null)) {
564 if (serviceContext == null) {
565 webDAVProps.setCreateDate(now);
566 }
567 else {
568 webDAVProps.setCreateDate(serviceContext.getCreateDate(now));
569 }
570 }
571
572 if (!webDAVPropsModelImpl.hasSetModifiedDate()) {
573 if (serviceContext == null) {
574 webDAVProps.setModifiedDate(now);
575 }
576 else {
577 webDAVProps.setModifiedDate(serviceContext.getModifiedDate(now));
578 }
579 }
580
581 Session session = null;
582
583 try {
584 session = openSession();
585
586 if (webDAVProps.isNew()) {
587 session.save(webDAVProps);
588
589 webDAVProps.setNew(false);
590 }
591 else {
592 webDAVProps = (WebDAVProps)session.merge(webDAVProps);
593 }
594 }
595 catch (Exception e) {
596 throw processException(e);
597 }
598 finally {
599 closeSession(session);
600 }
601
602 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
603
604 if (isNew || !WebDAVPropsModelImpl.COLUMN_BITMASK_ENABLED) {
605 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
606 }
607
608 entityCache.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
609 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps,
610 false);
611
612 clearUniqueFindersCache(webDAVPropsModelImpl);
613 cacheUniqueFindersCache(webDAVPropsModelImpl, isNew);
614
615 webDAVProps.resetOriginalValues();
616
617 return webDAVProps;
618 }
619
620 protected WebDAVProps toUnwrappedModel(WebDAVProps webDAVProps) {
621 if (webDAVProps instanceof WebDAVPropsImpl) {
622 return webDAVProps;
623 }
624
625 WebDAVPropsImpl webDAVPropsImpl = new WebDAVPropsImpl();
626
627 webDAVPropsImpl.setNew(webDAVProps.isNew());
628 webDAVPropsImpl.setPrimaryKey(webDAVProps.getPrimaryKey());
629
630 webDAVPropsImpl.setMvccVersion(webDAVProps.getMvccVersion());
631 webDAVPropsImpl.setWebDavPropsId(webDAVProps.getWebDavPropsId());
632 webDAVPropsImpl.setCompanyId(webDAVProps.getCompanyId());
633 webDAVPropsImpl.setCreateDate(webDAVProps.getCreateDate());
634 webDAVPropsImpl.setModifiedDate(webDAVProps.getModifiedDate());
635 webDAVPropsImpl.setClassNameId(webDAVProps.getClassNameId());
636 webDAVPropsImpl.setClassPK(webDAVProps.getClassPK());
637 webDAVPropsImpl.setProps(webDAVProps.getProps());
638
639 return webDAVPropsImpl;
640 }
641
642
649 @Override
650 public WebDAVProps findByPrimaryKey(Serializable primaryKey)
651 throws NoSuchWebDAVPropsException {
652 WebDAVProps webDAVProps = fetchByPrimaryKey(primaryKey);
653
654 if (webDAVProps == null) {
655 if (_log.isWarnEnabled()) {
656 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
657 }
658
659 throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
660 primaryKey);
661 }
662
663 return webDAVProps;
664 }
665
666
673 @Override
674 public WebDAVProps findByPrimaryKey(long webDavPropsId)
675 throws NoSuchWebDAVPropsException {
676 return findByPrimaryKey((Serializable)webDavPropsId);
677 }
678
679
685 @Override
686 public WebDAVProps fetchByPrimaryKey(Serializable primaryKey) {
687 WebDAVProps webDAVProps = (WebDAVProps)entityCache.getResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
688 WebDAVPropsImpl.class, primaryKey);
689
690 if (webDAVProps == _nullWebDAVProps) {
691 return null;
692 }
693
694 if (webDAVProps == null) {
695 Session session = null;
696
697 try {
698 session = openSession();
699
700 webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
701 primaryKey);
702
703 if (webDAVProps != null) {
704 cacheResult(webDAVProps);
705 }
706 else {
707 entityCache.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
708 WebDAVPropsImpl.class, primaryKey, _nullWebDAVProps);
709 }
710 }
711 catch (Exception e) {
712 entityCache.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
713 WebDAVPropsImpl.class, primaryKey);
714
715 throw processException(e);
716 }
717 finally {
718 closeSession(session);
719 }
720 }
721
722 return webDAVProps;
723 }
724
725
731 @Override
732 public WebDAVProps fetchByPrimaryKey(long webDavPropsId) {
733 return fetchByPrimaryKey((Serializable)webDavPropsId);
734 }
735
736 @Override
737 public Map<Serializable, WebDAVProps> fetchByPrimaryKeys(
738 Set<Serializable> primaryKeys) {
739 if (primaryKeys.isEmpty()) {
740 return Collections.emptyMap();
741 }
742
743 Map<Serializable, WebDAVProps> map = new HashMap<Serializable, WebDAVProps>();
744
745 if (primaryKeys.size() == 1) {
746 Iterator<Serializable> iterator = primaryKeys.iterator();
747
748 Serializable primaryKey = iterator.next();
749
750 WebDAVProps webDAVProps = fetchByPrimaryKey(primaryKey);
751
752 if (webDAVProps != null) {
753 map.put(primaryKey, webDAVProps);
754 }
755
756 return map;
757 }
758
759 Set<Serializable> uncachedPrimaryKeys = null;
760
761 for (Serializable primaryKey : primaryKeys) {
762 WebDAVProps webDAVProps = (WebDAVProps)entityCache.getResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
763 WebDAVPropsImpl.class, primaryKey);
764
765 if (webDAVProps == null) {
766 if (uncachedPrimaryKeys == null) {
767 uncachedPrimaryKeys = new HashSet<Serializable>();
768 }
769
770 uncachedPrimaryKeys.add(primaryKey);
771 }
772 else {
773 map.put(primaryKey, webDAVProps);
774 }
775 }
776
777 if (uncachedPrimaryKeys == null) {
778 return map;
779 }
780
781 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
782 1);
783
784 query.append(_SQL_SELECT_WEBDAVPROPS_WHERE_PKS_IN);
785
786 for (Serializable primaryKey : uncachedPrimaryKeys) {
787 query.append(String.valueOf(primaryKey));
788
789 query.append(StringPool.COMMA);
790 }
791
792 query.setIndex(query.index() - 1);
793
794 query.append(StringPool.CLOSE_PARENTHESIS);
795
796 String sql = query.toString();
797
798 Session session = null;
799
800 try {
801 session = openSession();
802
803 Query q = session.createQuery(sql);
804
805 for (WebDAVProps webDAVProps : (List<WebDAVProps>)q.list()) {
806 map.put(webDAVProps.getPrimaryKeyObj(), webDAVProps);
807
808 cacheResult(webDAVProps);
809
810 uncachedPrimaryKeys.remove(webDAVProps.getPrimaryKeyObj());
811 }
812
813 for (Serializable primaryKey : uncachedPrimaryKeys) {
814 entityCache.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
815 WebDAVPropsImpl.class, primaryKey, _nullWebDAVProps);
816 }
817 }
818 catch (Exception e) {
819 throw processException(e);
820 }
821 finally {
822 closeSession(session);
823 }
824
825 return map;
826 }
827
828
833 @Override
834 public List<WebDAVProps> findAll() {
835 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
836 }
837
838
849 @Override
850 public List<WebDAVProps> findAll(int start, int end) {
851 return findAll(start, end, null);
852 }
853
854
866 @Override
867 public List<WebDAVProps> findAll(int start, int end,
868 OrderByComparator<WebDAVProps> orderByComparator) {
869 return findAll(start, end, orderByComparator, true);
870 }
871
872
885 @Override
886 public List<WebDAVProps> findAll(int start, int end,
887 OrderByComparator<WebDAVProps> orderByComparator,
888 boolean retrieveFromCache) {
889 boolean pagination = true;
890 FinderPath finderPath = null;
891 Object[] finderArgs = null;
892
893 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
894 (orderByComparator == null)) {
895 pagination = false;
896 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
897 finderArgs = FINDER_ARGS_EMPTY;
898 }
899 else {
900 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
901 finderArgs = new Object[] { start, end, orderByComparator };
902 }
903
904 List<WebDAVProps> list = null;
905
906 if (retrieveFromCache) {
907 list = (List<WebDAVProps>)finderCache.getResult(finderPath,
908 finderArgs, this);
909 }
910
911 if (list == null) {
912 StringBundler query = null;
913 String sql = null;
914
915 if (orderByComparator != null) {
916 query = new StringBundler(2 +
917 (orderByComparator.getOrderByFields().length * 3));
918
919 query.append(_SQL_SELECT_WEBDAVPROPS);
920
921 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
922 orderByComparator);
923
924 sql = query.toString();
925 }
926 else {
927 sql = _SQL_SELECT_WEBDAVPROPS;
928
929 if (pagination) {
930 sql = sql.concat(WebDAVPropsModelImpl.ORDER_BY_JPQL);
931 }
932 }
933
934 Session session = null;
935
936 try {
937 session = openSession();
938
939 Query q = session.createQuery(sql);
940
941 if (!pagination) {
942 list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
943 start, end, false);
944
945 Collections.sort(list);
946
947 list = Collections.unmodifiableList(list);
948 }
949 else {
950 list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
951 start, end);
952 }
953
954 cacheResult(list);
955
956 finderCache.putResult(finderPath, finderArgs, list);
957 }
958 catch (Exception e) {
959 finderCache.removeResult(finderPath, finderArgs);
960
961 throw processException(e);
962 }
963 finally {
964 closeSession(session);
965 }
966 }
967
968 return list;
969 }
970
971
975 @Override
976 public void removeAll() {
977 for (WebDAVProps webDAVProps : findAll()) {
978 remove(webDAVProps);
979 }
980 }
981
982
987 @Override
988 public int countAll() {
989 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
990 FINDER_ARGS_EMPTY, this);
991
992 if (count == null) {
993 Session session = null;
994
995 try {
996 session = openSession();
997
998 Query q = session.createQuery(_SQL_COUNT_WEBDAVPROPS);
999
1000 count = (Long)q.uniqueResult();
1001
1002 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
1003 count);
1004 }
1005 catch (Exception e) {
1006 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
1007 FINDER_ARGS_EMPTY);
1008
1009 throw processException(e);
1010 }
1011 finally {
1012 closeSession(session);
1013 }
1014 }
1015
1016 return count.intValue();
1017 }
1018
1019 @Override
1020 protected Map<String, Integer> getTableColumnsMap() {
1021 return WebDAVPropsModelImpl.TABLE_COLUMNS_MAP;
1022 }
1023
1024
1027 public void afterPropertiesSet() {
1028 }
1029
1030 public void destroy() {
1031 entityCache.removeCache(WebDAVPropsImpl.class.getName());
1032 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1033 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1034 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1035 }
1036
1037 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1038 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1039 private static final String _SQL_SELECT_WEBDAVPROPS = "SELECT webDAVProps FROM WebDAVProps webDAVProps";
1040 private static final String _SQL_SELECT_WEBDAVPROPS_WHERE_PKS_IN = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE webDavPropsId IN (";
1041 private static final String _SQL_SELECT_WEBDAVPROPS_WHERE = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE ";
1042 private static final String _SQL_COUNT_WEBDAVPROPS = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps";
1043 private static final String _SQL_COUNT_WEBDAVPROPS_WHERE = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps WHERE ";
1044 private static final String _ORDER_BY_ENTITY_ALIAS = "webDAVProps.";
1045 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WebDAVProps exists with the primary key ";
1046 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WebDAVProps exists with the key {";
1047 private static final Log _log = LogFactoryUtil.getLog(WebDAVPropsPersistenceImpl.class);
1048 private static final WebDAVProps _nullWebDAVProps = new WebDAVPropsImpl() {
1049 @Override
1050 public Object clone() {
1051 return this;
1052 }
1053
1054 @Override
1055 public CacheModel<WebDAVProps> toCacheModel() {
1056 return _nullWebDAVPropsCacheModel;
1057 }
1058 };
1059
1060 private static final CacheModel<WebDAVProps> _nullWebDAVPropsCacheModel = new NullCacheModel();
1061
1062 private static class NullCacheModel implements CacheModel<WebDAVProps>,
1063 MVCCModel {
1064 @Override
1065 public long getMvccVersion() {
1066 return -1;
1067 }
1068
1069 @Override
1070 public void setMvccVersion(long mvccVersion) {
1071 }
1072
1073 @Override
1074 public WebDAVProps toEntityModel() {
1075 return _nullWebDAVProps;
1076 }
1077 }
1078 }