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