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.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.OrderByComparator;
031 import com.liferay.portal.kernel.util.StringBundler;
032 import com.liferay.portal.kernel.util.StringPool;
033 import com.liferay.portal.model.CacheModel;
034 import com.liferay.portal.model.MVCCModel;
035 import com.liferay.portal.model.WebDAVProps;
036 import com.liferay.portal.model.impl.WebDAVPropsImpl;
037 import com.liferay.portal.model.impl.WebDAVPropsModelImpl;
038 import com.liferay.portal.service.persistence.WebDAVPropsPersistence;
039
040 import java.io.Serializable;
041
042 import java.util.Collections;
043 import java.util.HashMap;
044 import java.util.HashSet;
045 import java.util.Iterator;
046 import java.util.List;
047 import java.util.Map;
048 import java.util.Set;
049
050
062 @ProviderType
063 public class WebDAVPropsPersistenceImpl extends BasePersistenceImpl<WebDAVProps>
064 implements WebDAVPropsPersistence {
065
070 public static final String FINDER_CLASS_NAME_ENTITY = WebDAVPropsImpl.class.getName();
071 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List1";
073 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List2";
075 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
076 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
077 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
078 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
079 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
080 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
081 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
082 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, Long.class,
083 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
084 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
085 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
086 FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
087 new String[] { Long.class.getName(), Long.class.getName() },
088 WebDAVPropsModelImpl.CLASSNAMEID_COLUMN_BITMASK |
089 WebDAVPropsModelImpl.CLASSPK_COLUMN_BITMASK);
090 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
091 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, Long.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
093 new String[] { Long.class.getName(), Long.class.getName() });
094
095
103 @Override
104 public WebDAVProps findByC_C(long classNameId, long classPK)
105 throws NoSuchWebDAVPropsException {
106 WebDAVProps webDAVProps = fetchByC_C(classNameId, classPK);
107
108 if (webDAVProps == null) {
109 StringBundler msg = new StringBundler(6);
110
111 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
112
113 msg.append("classNameId=");
114 msg.append(classNameId);
115
116 msg.append(", classPK=");
117 msg.append(classPK);
118
119 msg.append(StringPool.CLOSE_CURLY_BRACE);
120
121 if (_log.isWarnEnabled()) {
122 _log.warn(msg.toString());
123 }
124
125 throw new NoSuchWebDAVPropsException(msg.toString());
126 }
127
128 return webDAVProps;
129 }
130
131
138 @Override
139 public WebDAVProps fetchByC_C(long classNameId, long classPK) {
140 return fetchByC_C(classNameId, classPK, true);
141 }
142
143
151 @Override
152 public WebDAVProps fetchByC_C(long classNameId, long classPK,
153 boolean retrieveFromCache) {
154 Object[] finderArgs = new Object[] { classNameId, classPK };
155
156 Object result = null;
157
158 if (retrieveFromCache) {
159 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
160 finderArgs, this);
161 }
162
163 if (result instanceof WebDAVProps) {
164 WebDAVProps webDAVProps = (WebDAVProps)result;
165
166 if ((classNameId != webDAVProps.getClassNameId()) ||
167 (classPK != webDAVProps.getClassPK())) {
168 result = null;
169 }
170 }
171
172 if (result == null) {
173 StringBundler query = new StringBundler(4);
174
175 query.append(_SQL_SELECT_WEBDAVPROPS_WHERE);
176
177 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
178
179 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
180
181 String sql = query.toString();
182
183 Session session = null;
184
185 try {
186 session = openSession();
187
188 Query q = session.createQuery(sql);
189
190 QueryPos qPos = QueryPos.getInstance(q);
191
192 qPos.add(classNameId);
193
194 qPos.add(classPK);
195
196 List<WebDAVProps> list = q.list();
197
198 if (list.isEmpty()) {
199 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
200 finderArgs, list);
201 }
202 else {
203 WebDAVProps webDAVProps = list.get(0);
204
205 result = webDAVProps;
206
207 cacheResult(webDAVProps);
208
209 if ((webDAVProps.getClassNameId() != classNameId) ||
210 (webDAVProps.getClassPK() != classPK)) {
211 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
212 finderArgs, webDAVProps);
213 }
214 }
215 }
216 catch (Exception e) {
217 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
218 finderArgs);
219
220 throw processException(e);
221 }
222 finally {
223 closeSession(session);
224 }
225 }
226
227 if (result instanceof List<?>) {
228 return null;
229 }
230 else {
231 return (WebDAVProps)result;
232 }
233 }
234
235
242 @Override
243 public WebDAVProps removeByC_C(long classNameId, long classPK)
244 throws NoSuchWebDAVPropsException {
245 WebDAVProps webDAVProps = findByC_C(classNameId, classPK);
246
247 return remove(webDAVProps);
248 }
249
250
257 @Override
258 public int countByC_C(long classNameId, long classPK) {
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 public WebDAVPropsPersistenceImpl() {
311 setModelClass(WebDAVProps.class);
312 }
313
314
319 @Override
320 public void cacheResult(WebDAVProps webDAVProps) {
321 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
322 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
323
324 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
325 new Object[] { webDAVProps.getClassNameId(), webDAVProps.getClassPK() },
326 webDAVProps);
327
328 webDAVProps.resetOriginalValues();
329 }
330
331
336 @Override
337 public void cacheResult(List<WebDAVProps> webDAVPropses) {
338 for (WebDAVProps webDAVProps : webDAVPropses) {
339 if (EntityCacheUtil.getResult(
340 WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
341 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey()) == null) {
342 cacheResult(webDAVProps);
343 }
344 else {
345 webDAVProps.resetOriginalValues();
346 }
347 }
348 }
349
350
357 @Override
358 public void clearCache() {
359 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
360 CacheRegistryUtil.clear(WebDAVPropsImpl.class.getName());
361 }
362
363 EntityCacheUtil.clearCache(WebDAVPropsImpl.class);
364
365 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
366 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
367 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
368 }
369
370
377 @Override
378 public void clearCache(WebDAVProps webDAVProps) {
379 EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
380 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
381
382 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
383 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
384
385 clearUniqueFindersCache(webDAVProps);
386 }
387
388 @Override
389 public void clearCache(List<WebDAVProps> webDAVPropses) {
390 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
391 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
392
393 for (WebDAVProps webDAVProps : webDAVPropses) {
394 EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
395 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
396
397 clearUniqueFindersCache(webDAVProps);
398 }
399 }
400
401 protected void cacheUniqueFindersCache(WebDAVProps webDAVProps) {
402 if (webDAVProps.isNew()) {
403 Object[] args = new Object[] {
404 webDAVProps.getClassNameId(), webDAVProps.getClassPK()
405 };
406
407 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
408 Long.valueOf(1));
409 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
410 webDAVProps);
411 }
412 else {
413 WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
414
415 if ((webDAVPropsModelImpl.getColumnBitmask() &
416 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
417 Object[] args = new Object[] {
418 webDAVProps.getClassNameId(), webDAVProps.getClassPK()
419 };
420
421 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
422 Long.valueOf(1));
423 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
424 webDAVProps);
425 }
426 }
427 }
428
429 protected void clearUniqueFindersCache(WebDAVProps webDAVProps) {
430 WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
431
432 Object[] args = new Object[] {
433 webDAVProps.getClassNameId(), webDAVProps.getClassPK()
434 };
435
436 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
437 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
438
439 if ((webDAVPropsModelImpl.getColumnBitmask() &
440 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
441 args = new Object[] {
442 webDAVPropsModelImpl.getOriginalClassNameId(),
443 webDAVPropsModelImpl.getOriginalClassPK()
444 };
445
446 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
447 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
448 }
449 }
450
451
457 @Override
458 public WebDAVProps create(long webDavPropsId) {
459 WebDAVProps webDAVProps = new WebDAVPropsImpl();
460
461 webDAVProps.setNew(true);
462 webDAVProps.setPrimaryKey(webDavPropsId);
463
464 return webDAVProps;
465 }
466
467
474 @Override
475 public WebDAVProps remove(long webDavPropsId)
476 throws NoSuchWebDAVPropsException {
477 return remove((Serializable)webDavPropsId);
478 }
479
480
487 @Override
488 public WebDAVProps remove(Serializable primaryKey)
489 throws NoSuchWebDAVPropsException {
490 Session session = null;
491
492 try {
493 session = openSession();
494
495 WebDAVProps webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
496 primaryKey);
497
498 if (webDAVProps == null) {
499 if (_log.isWarnEnabled()) {
500 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
501 }
502
503 throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
504 primaryKey);
505 }
506
507 return remove(webDAVProps);
508 }
509 catch (NoSuchWebDAVPropsException nsee) {
510 throw nsee;
511 }
512 catch (Exception e) {
513 throw processException(e);
514 }
515 finally {
516 closeSession(session);
517 }
518 }
519
520 @Override
521 protected WebDAVProps removeImpl(WebDAVProps webDAVProps) {
522 webDAVProps = toUnwrappedModel(webDAVProps);
523
524 Session session = null;
525
526 try {
527 session = openSession();
528
529 if (!session.contains(webDAVProps)) {
530 webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
531 webDAVProps.getPrimaryKeyObj());
532 }
533
534 if (webDAVProps != null) {
535 session.delete(webDAVProps);
536 }
537 }
538 catch (Exception e) {
539 throw processException(e);
540 }
541 finally {
542 closeSession(session);
543 }
544
545 if (webDAVProps != null) {
546 clearCache(webDAVProps);
547 }
548
549 return webDAVProps;
550 }
551
552 @Override
553 public WebDAVProps updateImpl(
554 com.liferay.portal.model.WebDAVProps webDAVProps) {
555 webDAVProps = toUnwrappedModel(webDAVProps);
556
557 boolean isNew = webDAVProps.isNew();
558
559 Session session = null;
560
561 try {
562 session = openSession();
563
564 if (webDAVProps.isNew()) {
565 session.save(webDAVProps);
566
567 webDAVProps.setNew(false);
568 }
569 else {
570 session.merge(webDAVProps);
571 }
572 }
573 catch (Exception e) {
574 throw processException(e);
575 }
576 finally {
577 closeSession(session);
578 }
579
580 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
581
582 if (isNew || !WebDAVPropsModelImpl.COLUMN_BITMASK_ENABLED) {
583 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
584 }
585
586 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
587 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps,
588 false);
589
590 clearUniqueFindersCache(webDAVProps);
591 cacheUniqueFindersCache(webDAVProps);
592
593 webDAVProps.resetOriginalValues();
594
595 return webDAVProps;
596 }
597
598 protected WebDAVProps toUnwrappedModel(WebDAVProps webDAVProps) {
599 if (webDAVProps instanceof WebDAVPropsImpl) {
600 return webDAVProps;
601 }
602
603 WebDAVPropsImpl webDAVPropsImpl = new WebDAVPropsImpl();
604
605 webDAVPropsImpl.setNew(webDAVProps.isNew());
606 webDAVPropsImpl.setPrimaryKey(webDAVProps.getPrimaryKey());
607
608 webDAVPropsImpl.setMvccVersion(webDAVProps.getMvccVersion());
609 webDAVPropsImpl.setWebDavPropsId(webDAVProps.getWebDavPropsId());
610 webDAVPropsImpl.setCompanyId(webDAVProps.getCompanyId());
611 webDAVPropsImpl.setCreateDate(webDAVProps.getCreateDate());
612 webDAVPropsImpl.setModifiedDate(webDAVProps.getModifiedDate());
613 webDAVPropsImpl.setClassNameId(webDAVProps.getClassNameId());
614 webDAVPropsImpl.setClassPK(webDAVProps.getClassPK());
615 webDAVPropsImpl.setProps(webDAVProps.getProps());
616
617 return webDAVPropsImpl;
618 }
619
620
627 @Override
628 public WebDAVProps findByPrimaryKey(Serializable primaryKey)
629 throws NoSuchWebDAVPropsException {
630 WebDAVProps webDAVProps = fetchByPrimaryKey(primaryKey);
631
632 if (webDAVProps == null) {
633 if (_log.isWarnEnabled()) {
634 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
635 }
636
637 throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
638 primaryKey);
639 }
640
641 return webDAVProps;
642 }
643
644
651 @Override
652 public WebDAVProps findByPrimaryKey(long webDavPropsId)
653 throws NoSuchWebDAVPropsException {
654 return findByPrimaryKey((Serializable)webDavPropsId);
655 }
656
657
663 @Override
664 public WebDAVProps fetchByPrimaryKey(Serializable primaryKey) {
665 WebDAVProps webDAVProps = (WebDAVProps)EntityCacheUtil.getResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
666 WebDAVPropsImpl.class, primaryKey);
667
668 if (webDAVProps == _nullWebDAVProps) {
669 return null;
670 }
671
672 if (webDAVProps == null) {
673 Session session = null;
674
675 try {
676 session = openSession();
677
678 webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
679 primaryKey);
680
681 if (webDAVProps != null) {
682 cacheResult(webDAVProps);
683 }
684 else {
685 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
686 WebDAVPropsImpl.class, primaryKey, _nullWebDAVProps);
687 }
688 }
689 catch (Exception e) {
690 EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
691 WebDAVPropsImpl.class, primaryKey);
692
693 throw processException(e);
694 }
695 finally {
696 closeSession(session);
697 }
698 }
699
700 return webDAVProps;
701 }
702
703
709 @Override
710 public WebDAVProps fetchByPrimaryKey(long webDavPropsId) {
711 return fetchByPrimaryKey((Serializable)webDavPropsId);
712 }
713
714 @Override
715 public Map<Serializable, WebDAVProps> fetchByPrimaryKeys(
716 Set<Serializable> primaryKeys) {
717 if (primaryKeys.isEmpty()) {
718 return Collections.emptyMap();
719 }
720
721 Map<Serializable, WebDAVProps> map = new HashMap<Serializable, WebDAVProps>();
722
723 if (primaryKeys.size() == 1) {
724 Iterator<Serializable> iterator = primaryKeys.iterator();
725
726 Serializable primaryKey = iterator.next();
727
728 WebDAVProps webDAVProps = fetchByPrimaryKey(primaryKey);
729
730 if (webDAVProps != null) {
731 map.put(primaryKey, webDAVProps);
732 }
733
734 return map;
735 }
736
737 Set<Serializable> uncachedPrimaryKeys = null;
738
739 for (Serializable primaryKey : primaryKeys) {
740 WebDAVProps webDAVProps = (WebDAVProps)EntityCacheUtil.getResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
741 WebDAVPropsImpl.class, primaryKey);
742
743 if (webDAVProps == null) {
744 if (uncachedPrimaryKeys == null) {
745 uncachedPrimaryKeys = new HashSet<Serializable>();
746 }
747
748 uncachedPrimaryKeys.add(primaryKey);
749 }
750 else {
751 map.put(primaryKey, webDAVProps);
752 }
753 }
754
755 if (uncachedPrimaryKeys == null) {
756 return map;
757 }
758
759 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
760 1);
761
762 query.append(_SQL_SELECT_WEBDAVPROPS_WHERE_PKS_IN);
763
764 for (Serializable primaryKey : uncachedPrimaryKeys) {
765 query.append(String.valueOf(primaryKey));
766
767 query.append(StringPool.COMMA);
768 }
769
770 query.setIndex(query.index() - 1);
771
772 query.append(StringPool.CLOSE_PARENTHESIS);
773
774 String sql = query.toString();
775
776 Session session = null;
777
778 try {
779 session = openSession();
780
781 Query q = session.createQuery(sql);
782
783 for (WebDAVProps webDAVProps : (List<WebDAVProps>)q.list()) {
784 map.put(webDAVProps.getPrimaryKeyObj(), webDAVProps);
785
786 cacheResult(webDAVProps);
787
788 uncachedPrimaryKeys.remove(webDAVProps.getPrimaryKeyObj());
789 }
790
791 for (Serializable primaryKey : uncachedPrimaryKeys) {
792 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
793 WebDAVPropsImpl.class, primaryKey, _nullWebDAVProps);
794 }
795 }
796 catch (Exception e) {
797 throw processException(e);
798 }
799 finally {
800 closeSession(session);
801 }
802
803 return map;
804 }
805
806
811 @Override
812 public List<WebDAVProps> findAll() {
813 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
814 }
815
816
827 @Override
828 public List<WebDAVProps> findAll(int start, int end) {
829 return findAll(start, end, null);
830 }
831
832
844 @Override
845 public List<WebDAVProps> findAll(int start, int end,
846 OrderByComparator<WebDAVProps> orderByComparator) {
847 boolean pagination = true;
848 FinderPath finderPath = null;
849 Object[] finderArgs = null;
850
851 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
852 (orderByComparator == null)) {
853 pagination = false;
854 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
855 finderArgs = FINDER_ARGS_EMPTY;
856 }
857 else {
858 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
859 finderArgs = new Object[] { start, end, orderByComparator };
860 }
861
862 List<WebDAVProps> list = (List<WebDAVProps>)FinderCacheUtil.getResult(finderPath,
863 finderArgs, this);
864
865 if (list == null) {
866 StringBundler query = null;
867 String sql = null;
868
869 if (orderByComparator != null) {
870 query = new StringBundler(2 +
871 (orderByComparator.getOrderByFields().length * 3));
872
873 query.append(_SQL_SELECT_WEBDAVPROPS);
874
875 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
876 orderByComparator);
877
878 sql = query.toString();
879 }
880 else {
881 sql = _SQL_SELECT_WEBDAVPROPS;
882
883 if (pagination) {
884 sql = sql.concat(WebDAVPropsModelImpl.ORDER_BY_JPQL);
885 }
886 }
887
888 Session session = null;
889
890 try {
891 session = openSession();
892
893 Query q = session.createQuery(sql);
894
895 if (!pagination) {
896 list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
897 start, end, false);
898
899 Collections.sort(list);
900
901 list = Collections.unmodifiableList(list);
902 }
903 else {
904 list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
905 start, end);
906 }
907
908 cacheResult(list);
909
910 FinderCacheUtil.putResult(finderPath, finderArgs, list);
911 }
912 catch (Exception e) {
913 FinderCacheUtil.removeResult(finderPath, finderArgs);
914
915 throw processException(e);
916 }
917 finally {
918 closeSession(session);
919 }
920 }
921
922 return list;
923 }
924
925
929 @Override
930 public void removeAll() {
931 for (WebDAVProps webDAVProps : findAll()) {
932 remove(webDAVProps);
933 }
934 }
935
936
941 @Override
942 public int countAll() {
943 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
944 FINDER_ARGS_EMPTY, this);
945
946 if (count == null) {
947 Session session = null;
948
949 try {
950 session = openSession();
951
952 Query q = session.createQuery(_SQL_COUNT_WEBDAVPROPS);
953
954 count = (Long)q.uniqueResult();
955
956 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
957 FINDER_ARGS_EMPTY, count);
958 }
959 catch (Exception e) {
960 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
961 FINDER_ARGS_EMPTY);
962
963 throw processException(e);
964 }
965 finally {
966 closeSession(session);
967 }
968 }
969
970 return count.intValue();
971 }
972
973
976 public void afterPropertiesSet() {
977 }
978
979 public void destroy() {
980 EntityCacheUtil.removeCache(WebDAVPropsImpl.class.getName());
981 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
982 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
983 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
984 }
985
986 private static final String _SQL_SELECT_WEBDAVPROPS = "SELECT webDAVProps FROM WebDAVProps webDAVProps";
987 private static final String _SQL_SELECT_WEBDAVPROPS_WHERE_PKS_IN = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE webDavPropsId IN (";
988 private static final String _SQL_SELECT_WEBDAVPROPS_WHERE = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE ";
989 private static final String _SQL_COUNT_WEBDAVPROPS = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps";
990 private static final String _SQL_COUNT_WEBDAVPROPS_WHERE = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps WHERE ";
991 private static final String _ORDER_BY_ENTITY_ALIAS = "webDAVProps.";
992 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WebDAVProps exists with the primary key ";
993 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WebDAVProps exists with the key {";
994 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
995 private static final Log _log = LogFactoryUtil.getLog(WebDAVPropsPersistenceImpl.class);
996 private static final WebDAVProps _nullWebDAVProps = new WebDAVPropsImpl() {
997 @Override
998 public Object clone() {
999 return this;
1000 }
1001
1002 @Override
1003 public CacheModel<WebDAVProps> toCacheModel() {
1004 return _nullWebDAVPropsCacheModel;
1005 }
1006 };
1007
1008 private static final CacheModel<WebDAVProps> _nullWebDAVPropsCacheModel = new NullCacheModel();
1009
1010 private static class NullCacheModel implements CacheModel<WebDAVProps>,
1011 MVCCModel {
1012 @Override
1013 public long getMvccVersion() {
1014 return -1;
1015 }
1016
1017 @Override
1018 public void setMvccVersion(long mvccVersion) {
1019 }
1020
1021 @Override
1022 public WebDAVProps toEntityModel() {
1023 return _nullWebDAVProps;
1024 }
1025 }
1026 }