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.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.OrderByComparator;
030 import com.liferay.portal.kernel.util.StringBundler;
031 import com.liferay.portal.kernel.util.StringPool;
032 import com.liferay.portal.model.CacheModel;
033 import com.liferay.portal.model.MVCCModel;
034 import com.liferay.portal.model.WebDAVProps;
035 import com.liferay.portal.model.impl.WebDAVPropsImpl;
036 import com.liferay.portal.model.impl.WebDAVPropsModelImpl;
037 import com.liferay.portal.service.ServiceContext;
038 import com.liferay.portal.service.ServiceContextThreadLocal;
039 import com.liferay.portal.service.persistence.WebDAVPropsPersistence;
040
041 import java.io.Serializable;
042
043 import java.util.Collections;
044 import java.util.Date;
045 import java.util.HashMap;
046 import java.util.HashSet;
047 import java.util.Iterator;
048 import java.util.List;
049 import java.util.Map;
050 import java.util.Set;
051
052
064 @ProviderType
065 public class WebDAVPropsPersistenceImpl extends BasePersistenceImpl<WebDAVProps>
066 implements WebDAVPropsPersistence {
067
072 public static final String FINDER_CLASS_NAME_ENTITY = WebDAVPropsImpl.class.getName();
073 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List1";
075 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List2";
077 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
078 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
079 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
080 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
081 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
082 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
083 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
084 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, Long.class,
085 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
086 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
087 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class,
088 FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
089 new String[] { Long.class.getName(), Long.class.getName() },
090 WebDAVPropsModelImpl.CLASSNAMEID_COLUMN_BITMASK |
091 WebDAVPropsModelImpl.CLASSPK_COLUMN_BITMASK);
092 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
093 WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, Long.class,
094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
095 new String[] { Long.class.getName(), Long.class.getName() });
096
097
105 @Override
106 public WebDAVProps findByC_C(long classNameId, long classPK)
107 throws NoSuchWebDAVPropsException {
108 WebDAVProps webDAVProps = fetchByC_C(classNameId, classPK);
109
110 if (webDAVProps == null) {
111 StringBundler msg = new StringBundler(6);
112
113 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
114
115 msg.append("classNameId=");
116 msg.append(classNameId);
117
118 msg.append(", classPK=");
119 msg.append(classPK);
120
121 msg.append(StringPool.CLOSE_CURLY_BRACE);
122
123 if (_log.isWarnEnabled()) {
124 _log.warn(msg.toString());
125 }
126
127 throw new NoSuchWebDAVPropsException(msg.toString());
128 }
129
130 return webDAVProps;
131 }
132
133
140 @Override
141 public WebDAVProps fetchByC_C(long classNameId, long classPK) {
142 return fetchByC_C(classNameId, classPK, true);
143 }
144
145
153 @Override
154 public WebDAVProps fetchByC_C(long classNameId, long classPK,
155 boolean retrieveFromCache) {
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
244 @Override
245 public WebDAVProps removeByC_C(long classNameId, long classPK)
246 throws NoSuchWebDAVPropsException {
247 WebDAVProps webDAVProps = findByC_C(classNameId, classPK);
248
249 return remove(webDAVProps);
250 }
251
252
259 @Override
260 public int countByC_C(long classNameId, long classPK) {
261 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
262
263 Object[] finderArgs = new Object[] { classNameId, classPK };
264
265 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
266 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 FinderCacheUtil.putResult(finderPath, finderArgs, count);
295 }
296 catch (Exception e) {
297 FinderCacheUtil.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 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
324 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps);
325
326 FinderCacheUtil.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 (EntityCacheUtil.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 EntityCacheUtil.clearCache(WebDAVPropsImpl.class);
362
363 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
364 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
365 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
366 }
367
368
375 @Override
376 public void clearCache(WebDAVProps webDAVProps) {
377 EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
378 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
379
380 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
381 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
382
383 clearUniqueFindersCache(webDAVProps);
384 }
385
386 @Override
387 public void clearCache(List<WebDAVProps> webDAVPropses) {
388 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
389 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
390
391 for (WebDAVProps webDAVProps : webDAVPropses) {
392 EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
393 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey());
394
395 clearUniqueFindersCache(webDAVProps);
396 }
397 }
398
399 protected void cacheUniqueFindersCache(WebDAVProps webDAVProps) {
400 if (webDAVProps.isNew()) {
401 Object[] args = new Object[] {
402 webDAVProps.getClassNameId(), webDAVProps.getClassPK()
403 };
404
405 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
406 Long.valueOf(1));
407 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
408 webDAVProps);
409 }
410 else {
411 WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
412
413 if ((webDAVPropsModelImpl.getColumnBitmask() &
414 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
415 Object[] args = new Object[] {
416 webDAVProps.getClassNameId(), webDAVProps.getClassPK()
417 };
418
419 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
420 Long.valueOf(1));
421 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
422 webDAVProps);
423 }
424 }
425 }
426
427 protected void clearUniqueFindersCache(WebDAVProps webDAVProps) {
428 WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
429
430 Object[] args = new Object[] {
431 webDAVProps.getClassNameId(), webDAVProps.getClassPK()
432 };
433
434 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
435 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
436
437 if ((webDAVPropsModelImpl.getColumnBitmask() &
438 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
439 args = new Object[] {
440 webDAVPropsModelImpl.getOriginalClassNameId(),
441 webDAVPropsModelImpl.getOriginalClassPK()
442 };
443
444 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
445 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
446 }
447 }
448
449
455 @Override
456 public WebDAVProps create(long webDavPropsId) {
457 WebDAVProps webDAVProps = new WebDAVPropsImpl();
458
459 webDAVProps.setNew(true);
460 webDAVProps.setPrimaryKey(webDavPropsId);
461
462 return webDAVProps;
463 }
464
465
472 @Override
473 public WebDAVProps remove(long webDavPropsId)
474 throws NoSuchWebDAVPropsException {
475 return remove((Serializable)webDavPropsId);
476 }
477
478
485 @Override
486 public WebDAVProps remove(Serializable primaryKey)
487 throws NoSuchWebDAVPropsException {
488 Session session = null;
489
490 try {
491 session = openSession();
492
493 WebDAVProps webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
494 primaryKey);
495
496 if (webDAVProps == null) {
497 if (_log.isWarnEnabled()) {
498 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
499 }
500
501 throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
502 primaryKey);
503 }
504
505 return remove(webDAVProps);
506 }
507 catch (NoSuchWebDAVPropsException nsee) {
508 throw nsee;
509 }
510 catch (Exception e) {
511 throw processException(e);
512 }
513 finally {
514 closeSession(session);
515 }
516 }
517
518 @Override
519 protected WebDAVProps removeImpl(WebDAVProps webDAVProps) {
520 webDAVProps = toUnwrappedModel(webDAVProps);
521
522 Session session = null;
523
524 try {
525 session = openSession();
526
527 if (!session.contains(webDAVProps)) {
528 webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
529 webDAVProps.getPrimaryKeyObj());
530 }
531
532 if (webDAVProps != null) {
533 session.delete(webDAVProps);
534 }
535 }
536 catch (Exception e) {
537 throw processException(e);
538 }
539 finally {
540 closeSession(session);
541 }
542
543 if (webDAVProps != null) {
544 clearCache(webDAVProps);
545 }
546
547 return webDAVProps;
548 }
549
550 @Override
551 public WebDAVProps updateImpl(WebDAVProps webDAVProps) {
552 webDAVProps = toUnwrappedModel(webDAVProps);
553
554 boolean isNew = webDAVProps.isNew();
555
556 WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps;
557
558 ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
559
560 Date now = new Date();
561
562 if (isNew && (webDAVProps.getCreateDate() == null)) {
563 if (serviceContext == null) {
564 webDAVProps.setCreateDate(now);
565 }
566 else {
567 webDAVProps.setCreateDate(serviceContext.getCreateDate(now));
568 }
569 }
570
571 if (!webDAVPropsModelImpl.hasSetModifiedDate()) {
572 if (serviceContext == null) {
573 webDAVProps.setModifiedDate(now);
574 }
575 else {
576 webDAVProps.setModifiedDate(serviceContext.getModifiedDate(now));
577 }
578 }
579
580 Session session = null;
581
582 try {
583 session = openSession();
584
585 if (webDAVProps.isNew()) {
586 session.save(webDAVProps);
587
588 webDAVProps.setNew(false);
589 }
590 else {
591 session.merge(webDAVProps);
592 }
593 }
594 catch (Exception e) {
595 throw processException(e);
596 }
597 finally {
598 closeSession(session);
599 }
600
601 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
602
603 if (isNew || !WebDAVPropsModelImpl.COLUMN_BITMASK_ENABLED) {
604 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
605 }
606
607 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
608 WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps,
609 false);
610
611 clearUniqueFindersCache(webDAVProps);
612 cacheUniqueFindersCache(webDAVProps);
613
614 webDAVProps.resetOriginalValues();
615
616 return webDAVProps;
617 }
618
619 protected WebDAVProps toUnwrappedModel(WebDAVProps webDAVProps) {
620 if (webDAVProps instanceof WebDAVPropsImpl) {
621 return webDAVProps;
622 }
623
624 WebDAVPropsImpl webDAVPropsImpl = new WebDAVPropsImpl();
625
626 webDAVPropsImpl.setNew(webDAVProps.isNew());
627 webDAVPropsImpl.setPrimaryKey(webDAVProps.getPrimaryKey());
628
629 webDAVPropsImpl.setMvccVersion(webDAVProps.getMvccVersion());
630 webDAVPropsImpl.setWebDavPropsId(webDAVProps.getWebDavPropsId());
631 webDAVPropsImpl.setCompanyId(webDAVProps.getCompanyId());
632 webDAVPropsImpl.setCreateDate(webDAVProps.getCreateDate());
633 webDAVPropsImpl.setModifiedDate(webDAVProps.getModifiedDate());
634 webDAVPropsImpl.setClassNameId(webDAVProps.getClassNameId());
635 webDAVPropsImpl.setClassPK(webDAVProps.getClassPK());
636 webDAVPropsImpl.setProps(webDAVProps.getProps());
637
638 return webDAVPropsImpl;
639 }
640
641
648 @Override
649 public WebDAVProps findByPrimaryKey(Serializable primaryKey)
650 throws NoSuchWebDAVPropsException {
651 WebDAVProps webDAVProps = fetchByPrimaryKey(primaryKey);
652
653 if (webDAVProps == null) {
654 if (_log.isWarnEnabled()) {
655 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
656 }
657
658 throw new NoSuchWebDAVPropsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
659 primaryKey);
660 }
661
662 return webDAVProps;
663 }
664
665
672 @Override
673 public WebDAVProps findByPrimaryKey(long webDavPropsId)
674 throws NoSuchWebDAVPropsException {
675 return findByPrimaryKey((Serializable)webDavPropsId);
676 }
677
678
684 @Override
685 public WebDAVProps fetchByPrimaryKey(Serializable primaryKey) {
686 WebDAVProps webDAVProps = (WebDAVProps)EntityCacheUtil.getResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
687 WebDAVPropsImpl.class, primaryKey);
688
689 if (webDAVProps == _nullWebDAVProps) {
690 return null;
691 }
692
693 if (webDAVProps == null) {
694 Session session = null;
695
696 try {
697 session = openSession();
698
699 webDAVProps = (WebDAVProps)session.get(WebDAVPropsImpl.class,
700 primaryKey);
701
702 if (webDAVProps != null) {
703 cacheResult(webDAVProps);
704 }
705 else {
706 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
707 WebDAVPropsImpl.class, primaryKey, _nullWebDAVProps);
708 }
709 }
710 catch (Exception e) {
711 EntityCacheUtil.removeResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
712 WebDAVPropsImpl.class, primaryKey);
713
714 throw processException(e);
715 }
716 finally {
717 closeSession(session);
718 }
719 }
720
721 return webDAVProps;
722 }
723
724
730 @Override
731 public WebDAVProps fetchByPrimaryKey(long webDavPropsId) {
732 return fetchByPrimaryKey((Serializable)webDavPropsId);
733 }
734
735 @Override
736 public Map<Serializable, WebDAVProps> fetchByPrimaryKeys(
737 Set<Serializable> primaryKeys) {
738 if (primaryKeys.isEmpty()) {
739 return Collections.emptyMap();
740 }
741
742 Map<Serializable, WebDAVProps> map = new HashMap<Serializable, WebDAVProps>();
743
744 if (primaryKeys.size() == 1) {
745 Iterator<Serializable> iterator = primaryKeys.iterator();
746
747 Serializable primaryKey = iterator.next();
748
749 WebDAVProps webDAVProps = fetchByPrimaryKey(primaryKey);
750
751 if (webDAVProps != null) {
752 map.put(primaryKey, webDAVProps);
753 }
754
755 return map;
756 }
757
758 Set<Serializable> uncachedPrimaryKeys = null;
759
760 for (Serializable primaryKey : primaryKeys) {
761 WebDAVProps webDAVProps = (WebDAVProps)EntityCacheUtil.getResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
762 WebDAVPropsImpl.class, primaryKey);
763
764 if (webDAVProps == null) {
765 if (uncachedPrimaryKeys == null) {
766 uncachedPrimaryKeys = new HashSet<Serializable>();
767 }
768
769 uncachedPrimaryKeys.add(primaryKey);
770 }
771 else {
772 map.put(primaryKey, webDAVProps);
773 }
774 }
775
776 if (uncachedPrimaryKeys == null) {
777 return map;
778 }
779
780 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
781 1);
782
783 query.append(_SQL_SELECT_WEBDAVPROPS_WHERE_PKS_IN);
784
785 for (Serializable primaryKey : uncachedPrimaryKeys) {
786 query.append(String.valueOf(primaryKey));
787
788 query.append(StringPool.COMMA);
789 }
790
791 query.setIndex(query.index() - 1);
792
793 query.append(StringPool.CLOSE_PARENTHESIS);
794
795 String sql = query.toString();
796
797 Session session = null;
798
799 try {
800 session = openSession();
801
802 Query q = session.createQuery(sql);
803
804 for (WebDAVProps webDAVProps : (List<WebDAVProps>)q.list()) {
805 map.put(webDAVProps.getPrimaryKeyObj(), webDAVProps);
806
807 cacheResult(webDAVProps);
808
809 uncachedPrimaryKeys.remove(webDAVProps.getPrimaryKeyObj());
810 }
811
812 for (Serializable primaryKey : uncachedPrimaryKeys) {
813 EntityCacheUtil.putResult(WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
814 WebDAVPropsImpl.class, primaryKey, _nullWebDAVProps);
815 }
816 }
817 catch (Exception e) {
818 throw processException(e);
819 }
820 finally {
821 closeSession(session);
822 }
823
824 return map;
825 }
826
827
832 @Override
833 public List<WebDAVProps> findAll() {
834 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
835 }
836
837
848 @Override
849 public List<WebDAVProps> findAll(int start, int end) {
850 return findAll(start, end, null);
851 }
852
853
865 @Override
866 public List<WebDAVProps> findAll(int start, int end,
867 OrderByComparator<WebDAVProps> orderByComparator) {
868 boolean pagination = true;
869 FinderPath finderPath = null;
870 Object[] finderArgs = null;
871
872 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
873 (orderByComparator == null)) {
874 pagination = false;
875 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
876 finderArgs = FINDER_ARGS_EMPTY;
877 }
878 else {
879 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
880 finderArgs = new Object[] { start, end, orderByComparator };
881 }
882
883 List<WebDAVProps> list = (List<WebDAVProps>)FinderCacheUtil.getResult(finderPath,
884 finderArgs, this);
885
886 if (list == null) {
887 StringBundler query = null;
888 String sql = null;
889
890 if (orderByComparator != null) {
891 query = new StringBundler(2 +
892 (orderByComparator.getOrderByFields().length * 3));
893
894 query.append(_SQL_SELECT_WEBDAVPROPS);
895
896 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
897 orderByComparator);
898
899 sql = query.toString();
900 }
901 else {
902 sql = _SQL_SELECT_WEBDAVPROPS;
903
904 if (pagination) {
905 sql = sql.concat(WebDAVPropsModelImpl.ORDER_BY_JPQL);
906 }
907 }
908
909 Session session = null;
910
911 try {
912 session = openSession();
913
914 Query q = session.createQuery(sql);
915
916 if (!pagination) {
917 list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
918 start, end, false);
919
920 Collections.sort(list);
921
922 list = Collections.unmodifiableList(list);
923 }
924 else {
925 list = (List<WebDAVProps>)QueryUtil.list(q, getDialect(),
926 start, end);
927 }
928
929 cacheResult(list);
930
931 FinderCacheUtil.putResult(finderPath, finderArgs, list);
932 }
933 catch (Exception e) {
934 FinderCacheUtil.removeResult(finderPath, finderArgs);
935
936 throw processException(e);
937 }
938 finally {
939 closeSession(session);
940 }
941 }
942
943 return list;
944 }
945
946
950 @Override
951 public void removeAll() {
952 for (WebDAVProps webDAVProps : findAll()) {
953 remove(webDAVProps);
954 }
955 }
956
957
962 @Override
963 public int countAll() {
964 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
965 FINDER_ARGS_EMPTY, this);
966
967 if (count == null) {
968 Session session = null;
969
970 try {
971 session = openSession();
972
973 Query q = session.createQuery(_SQL_COUNT_WEBDAVPROPS);
974
975 count = (Long)q.uniqueResult();
976
977 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
978 FINDER_ARGS_EMPTY, count);
979 }
980 catch (Exception e) {
981 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
982 FINDER_ARGS_EMPTY);
983
984 throw processException(e);
985 }
986 finally {
987 closeSession(session);
988 }
989 }
990
991 return count.intValue();
992 }
993
994
997 public void afterPropertiesSet() {
998 }
999
1000 public void destroy() {
1001 EntityCacheUtil.removeCache(WebDAVPropsImpl.class.getName());
1002 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1003 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1004 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1005 }
1006
1007 private static final String _SQL_SELECT_WEBDAVPROPS = "SELECT webDAVProps FROM WebDAVProps webDAVProps";
1008 private static final String _SQL_SELECT_WEBDAVPROPS_WHERE_PKS_IN = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE webDavPropsId IN (";
1009 private static final String _SQL_SELECT_WEBDAVPROPS_WHERE = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE ";
1010 private static final String _SQL_COUNT_WEBDAVPROPS = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps";
1011 private static final String _SQL_COUNT_WEBDAVPROPS_WHERE = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps WHERE ";
1012 private static final String _ORDER_BY_ENTITY_ALIAS = "webDAVProps.";
1013 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WebDAVProps exists with the primary key ";
1014 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WebDAVProps exists with the key {";
1015 private static final Log _log = LogFactoryUtil.getLog(WebDAVPropsPersistenceImpl.class);
1016 private static final WebDAVProps _nullWebDAVProps = new WebDAVPropsImpl() {
1017 @Override
1018 public Object clone() {
1019 return this;
1020 }
1021
1022 @Override
1023 public CacheModel<WebDAVProps> toCacheModel() {
1024 return _nullWebDAVPropsCacheModel;
1025 }
1026 };
1027
1028 private static final CacheModel<WebDAVProps> _nullWebDAVPropsCacheModel = new NullCacheModel();
1029
1030 private static class NullCacheModel implements CacheModel<WebDAVProps>,
1031 MVCCModel {
1032 @Override
1033 public long getMvccVersion() {
1034 return -1;
1035 }
1036
1037 @Override
1038 public void setMvccVersion(long mvccVersion) {
1039 }
1040
1041 @Override
1042 public WebDAVProps toEntityModel() {
1043 return _nullWebDAVProps;
1044 }
1045 }
1046 }