001
014
015 package com.liferay.portal.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.dao.orm.EntityCache;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCache;
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.exception.NoSuchPreferencesException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.model.CacheModel;
032 import com.liferay.portal.kernel.model.MVCCModel;
033 import com.liferay.portal.kernel.model.PortalPreferences;
034 import com.liferay.portal.kernel.service.persistence.PortalPreferencesPersistence;
035 import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
036 import com.liferay.portal.kernel.util.OrderByComparator;
037 import com.liferay.portal.kernel.util.StringBundler;
038 import com.liferay.portal.kernel.util.StringPool;
039 import com.liferay.portal.kernel.util.StringUtil;
040 import com.liferay.portal.model.impl.PortalPreferencesImpl;
041 import com.liferay.portal.model.impl.PortalPreferencesModelImpl;
042
043 import java.io.Serializable;
044
045 import java.util.Collections;
046 import java.util.HashMap;
047 import java.util.HashSet;
048 import java.util.Iterator;
049 import java.util.List;
050 import java.util.Map;
051 import java.util.Set;
052
053
065 @ProviderType
066 public class PortalPreferencesPersistenceImpl extends BasePersistenceImpl<PortalPreferences>
067 implements PortalPreferencesPersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = PortalPreferencesImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List1";
076 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List2";
078 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
079 PortalPreferencesModelImpl.FINDER_CACHE_ENABLED,
080 PortalPreferencesImpl.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(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
083 PortalPreferencesModelImpl.FINDER_CACHE_ENABLED,
084 PortalPreferencesImpl.class,
085 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
086 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
087 PortalPreferencesModelImpl.FINDER_CACHE_ENABLED, Long.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
089 public static final FinderPath FINDER_PATH_FETCH_BY_O_O = new FinderPath(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
090 PortalPreferencesModelImpl.FINDER_CACHE_ENABLED,
091 PortalPreferencesImpl.class, FINDER_CLASS_NAME_ENTITY,
092 "fetchByO_O",
093 new String[] { Long.class.getName(), Integer.class.getName() },
094 PortalPreferencesModelImpl.OWNERID_COLUMN_BITMASK |
095 PortalPreferencesModelImpl.OWNERTYPE_COLUMN_BITMASK);
096 public static final FinderPath FINDER_PATH_COUNT_BY_O_O = new FinderPath(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
097 PortalPreferencesModelImpl.FINDER_CACHE_ENABLED, Long.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByO_O",
099 new String[] { Long.class.getName(), Integer.class.getName() });
100
101
109 @Override
110 public PortalPreferences findByO_O(long ownerId, int ownerType)
111 throws NoSuchPreferencesException {
112 PortalPreferences portalPreferences = fetchByO_O(ownerId, ownerType);
113
114 if (portalPreferences == null) {
115 StringBundler msg = new StringBundler(6);
116
117 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
118
119 msg.append("ownerId=");
120 msg.append(ownerId);
121
122 msg.append(", ownerType=");
123 msg.append(ownerType);
124
125 msg.append(StringPool.CLOSE_CURLY_BRACE);
126
127 if (_log.isDebugEnabled()) {
128 _log.debug(msg.toString());
129 }
130
131 throw new NoSuchPreferencesException(msg.toString());
132 }
133
134 return portalPreferences;
135 }
136
137
144 @Override
145 public PortalPreferences fetchByO_O(long ownerId, int ownerType) {
146 return fetchByO_O(ownerId, ownerType, true);
147 }
148
149
157 @Override
158 public PortalPreferences fetchByO_O(long ownerId, int ownerType,
159 boolean retrieveFromCache) {
160 Object[] finderArgs = new Object[] { ownerId, ownerType };
161
162 Object result = null;
163
164 if (retrieveFromCache) {
165 result = finderCache.getResult(FINDER_PATH_FETCH_BY_O_O,
166 finderArgs, this);
167 }
168
169 if (result instanceof PortalPreferences) {
170 PortalPreferences portalPreferences = (PortalPreferences)result;
171
172 if ((ownerId != portalPreferences.getOwnerId()) ||
173 (ownerType != portalPreferences.getOwnerType())) {
174 result = null;
175 }
176 }
177
178 if (result == null) {
179 StringBundler query = new StringBundler(4);
180
181 query.append(_SQL_SELECT_PORTALPREFERENCES_WHERE);
182
183 query.append(_FINDER_COLUMN_O_O_OWNERID_2);
184
185 query.append(_FINDER_COLUMN_O_O_OWNERTYPE_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(ownerId);
199
200 qPos.add(ownerType);
201
202 List<PortalPreferences> list = q.list();
203
204 if (list.isEmpty()) {
205 finderCache.putResult(FINDER_PATH_FETCH_BY_O_O, finderArgs,
206 list);
207 }
208 else {
209 if ((list.size() > 1) && _log.isWarnEnabled()) {
210 _log.warn(
211 "PortalPreferencesPersistenceImpl.fetchByO_O(long, int, boolean) with parameters (" +
212 StringUtil.merge(finderArgs) +
213 ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
214 }
215
216 PortalPreferences portalPreferences = list.get(0);
217
218 result = portalPreferences;
219
220 cacheResult(portalPreferences);
221
222 if ((portalPreferences.getOwnerId() != ownerId) ||
223 (portalPreferences.getOwnerType() != ownerType)) {
224 finderCache.putResult(FINDER_PATH_FETCH_BY_O_O,
225 finderArgs, portalPreferences);
226 }
227 }
228 }
229 catch (Exception e) {
230 finderCache.removeResult(FINDER_PATH_FETCH_BY_O_O, finderArgs);
231
232 throw processException(e);
233 }
234 finally {
235 closeSession(session);
236 }
237 }
238
239 if (result instanceof List<?>) {
240 return null;
241 }
242 else {
243 return (PortalPreferences)result;
244 }
245 }
246
247
254 @Override
255 public PortalPreferences removeByO_O(long ownerId, int ownerType)
256 throws NoSuchPreferencesException {
257 PortalPreferences portalPreferences = findByO_O(ownerId, ownerType);
258
259 return remove(portalPreferences);
260 }
261
262
269 @Override
270 public int countByO_O(long ownerId, int ownerType) {
271 FinderPath finderPath = FINDER_PATH_COUNT_BY_O_O;
272
273 Object[] finderArgs = new Object[] { ownerId, ownerType };
274
275 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
276
277 if (count == null) {
278 StringBundler query = new StringBundler(3);
279
280 query.append(_SQL_COUNT_PORTALPREFERENCES_WHERE);
281
282 query.append(_FINDER_COLUMN_O_O_OWNERID_2);
283
284 query.append(_FINDER_COLUMN_O_O_OWNERTYPE_2);
285
286 String sql = query.toString();
287
288 Session session = null;
289
290 try {
291 session = openSession();
292
293 Query q = session.createQuery(sql);
294
295 QueryPos qPos = QueryPos.getInstance(q);
296
297 qPos.add(ownerId);
298
299 qPos.add(ownerType);
300
301 count = (Long)q.uniqueResult();
302
303 finderCache.putResult(finderPath, finderArgs, count);
304 }
305 catch (Exception e) {
306 finderCache.removeResult(finderPath, finderArgs);
307
308 throw processException(e);
309 }
310 finally {
311 closeSession(session);
312 }
313 }
314
315 return count.intValue();
316 }
317
318 private static final String _FINDER_COLUMN_O_O_OWNERID_2 = "portalPreferences.ownerId = ? AND ";
319 private static final String _FINDER_COLUMN_O_O_OWNERTYPE_2 = "portalPreferences.ownerType = ?";
320
321 public PortalPreferencesPersistenceImpl() {
322 setModelClass(PortalPreferences.class);
323 }
324
325
330 @Override
331 public void cacheResult(PortalPreferences portalPreferences) {
332 entityCache.putResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
333 PortalPreferencesImpl.class, portalPreferences.getPrimaryKey(),
334 portalPreferences);
335
336 finderCache.putResult(FINDER_PATH_FETCH_BY_O_O,
337 new Object[] {
338 portalPreferences.getOwnerId(), portalPreferences.getOwnerType()
339 }, portalPreferences);
340
341 portalPreferences.resetOriginalValues();
342 }
343
344
349 @Override
350 public void cacheResult(List<PortalPreferences> portalPreferenceses) {
351 for (PortalPreferences portalPreferences : portalPreferenceses) {
352 if (entityCache.getResult(
353 PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
354 PortalPreferencesImpl.class,
355 portalPreferences.getPrimaryKey()) == null) {
356 cacheResult(portalPreferences);
357 }
358 else {
359 portalPreferences.resetOriginalValues();
360 }
361 }
362 }
363
364
371 @Override
372 public void clearCache() {
373 entityCache.clearCache(PortalPreferencesImpl.class);
374
375 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
376 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
377 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
378 }
379
380
387 @Override
388 public void clearCache(PortalPreferences portalPreferences) {
389 entityCache.removeResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
390 PortalPreferencesImpl.class, portalPreferences.getPrimaryKey());
391
392 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
393 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
394
395 clearUniqueFindersCache((PortalPreferencesModelImpl)portalPreferences);
396 }
397
398 @Override
399 public void clearCache(List<PortalPreferences> portalPreferenceses) {
400 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
401 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
402
403 for (PortalPreferences portalPreferences : portalPreferenceses) {
404 entityCache.removeResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
405 PortalPreferencesImpl.class, portalPreferences.getPrimaryKey());
406
407 clearUniqueFindersCache((PortalPreferencesModelImpl)portalPreferences);
408 }
409 }
410
411 protected void cacheUniqueFindersCache(
412 PortalPreferencesModelImpl portalPreferencesModelImpl, boolean isNew) {
413 if (isNew) {
414 Object[] args = new Object[] {
415 portalPreferencesModelImpl.getOwnerId(),
416 portalPreferencesModelImpl.getOwnerType()
417 };
418
419 finderCache.putResult(FINDER_PATH_COUNT_BY_O_O, args,
420 Long.valueOf(1));
421 finderCache.putResult(FINDER_PATH_FETCH_BY_O_O, args,
422 portalPreferencesModelImpl);
423 }
424 else {
425 if ((portalPreferencesModelImpl.getColumnBitmask() &
426 FINDER_PATH_FETCH_BY_O_O.getColumnBitmask()) != 0) {
427 Object[] args = new Object[] {
428 portalPreferencesModelImpl.getOwnerId(),
429 portalPreferencesModelImpl.getOwnerType()
430 };
431
432 finderCache.putResult(FINDER_PATH_COUNT_BY_O_O, args,
433 Long.valueOf(1));
434 finderCache.putResult(FINDER_PATH_FETCH_BY_O_O, args,
435 portalPreferencesModelImpl);
436 }
437 }
438 }
439
440 protected void clearUniqueFindersCache(
441 PortalPreferencesModelImpl portalPreferencesModelImpl) {
442 Object[] args = new Object[] {
443 portalPreferencesModelImpl.getOwnerId(),
444 portalPreferencesModelImpl.getOwnerType()
445 };
446
447 finderCache.removeResult(FINDER_PATH_COUNT_BY_O_O, args);
448 finderCache.removeResult(FINDER_PATH_FETCH_BY_O_O, args);
449
450 if ((portalPreferencesModelImpl.getColumnBitmask() &
451 FINDER_PATH_FETCH_BY_O_O.getColumnBitmask()) != 0) {
452 args = new Object[] {
453 portalPreferencesModelImpl.getOriginalOwnerId(),
454 portalPreferencesModelImpl.getOriginalOwnerType()
455 };
456
457 finderCache.removeResult(FINDER_PATH_COUNT_BY_O_O, args);
458 finderCache.removeResult(FINDER_PATH_FETCH_BY_O_O, args);
459 }
460 }
461
462
468 @Override
469 public PortalPreferences create(long portalPreferencesId) {
470 PortalPreferences portalPreferences = new PortalPreferencesImpl();
471
472 portalPreferences.setNew(true);
473 portalPreferences.setPrimaryKey(portalPreferencesId);
474
475 return portalPreferences;
476 }
477
478
485 @Override
486 public PortalPreferences remove(long portalPreferencesId)
487 throws NoSuchPreferencesException {
488 return remove((Serializable)portalPreferencesId);
489 }
490
491
498 @Override
499 public PortalPreferences remove(Serializable primaryKey)
500 throws NoSuchPreferencesException {
501 Session session = null;
502
503 try {
504 session = openSession();
505
506 PortalPreferences portalPreferences = (PortalPreferences)session.get(PortalPreferencesImpl.class,
507 primaryKey);
508
509 if (portalPreferences == null) {
510 if (_log.isDebugEnabled()) {
511 _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
512 }
513
514 throw new NoSuchPreferencesException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
515 primaryKey);
516 }
517
518 return remove(portalPreferences);
519 }
520 catch (NoSuchPreferencesException nsee) {
521 throw nsee;
522 }
523 catch (Exception e) {
524 throw processException(e);
525 }
526 finally {
527 closeSession(session);
528 }
529 }
530
531 @Override
532 protected PortalPreferences removeImpl(PortalPreferences portalPreferences) {
533 portalPreferences = toUnwrappedModel(portalPreferences);
534
535 Session session = null;
536
537 try {
538 session = openSession();
539
540 if (!session.contains(portalPreferences)) {
541 portalPreferences = (PortalPreferences)session.get(PortalPreferencesImpl.class,
542 portalPreferences.getPrimaryKeyObj());
543 }
544
545 if (portalPreferences != null) {
546 session.delete(portalPreferences);
547 }
548 }
549 catch (Exception e) {
550 throw processException(e);
551 }
552 finally {
553 closeSession(session);
554 }
555
556 if (portalPreferences != null) {
557 clearCache(portalPreferences);
558 }
559
560 return portalPreferences;
561 }
562
563 @Override
564 public PortalPreferences updateImpl(PortalPreferences portalPreferences) {
565 portalPreferences = toUnwrappedModel(portalPreferences);
566
567 boolean isNew = portalPreferences.isNew();
568
569 PortalPreferencesModelImpl portalPreferencesModelImpl = (PortalPreferencesModelImpl)portalPreferences;
570
571 Session session = null;
572
573 try {
574 session = openSession();
575
576 if (portalPreferences.isNew()) {
577 session.save(portalPreferences);
578
579 portalPreferences.setNew(false);
580 }
581 else {
582 portalPreferences = (PortalPreferences)session.merge(portalPreferences);
583 }
584 }
585 catch (Exception e) {
586 throw processException(e);
587 }
588 finally {
589 closeSession(session);
590 }
591
592 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
593
594 if (isNew || !PortalPreferencesModelImpl.COLUMN_BITMASK_ENABLED) {
595 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
596 }
597
598 entityCache.putResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
599 PortalPreferencesImpl.class, portalPreferences.getPrimaryKey(),
600 portalPreferences, false);
601
602 clearUniqueFindersCache(portalPreferencesModelImpl);
603 cacheUniqueFindersCache(portalPreferencesModelImpl, isNew);
604
605 portalPreferences.resetOriginalValues();
606
607 return portalPreferences;
608 }
609
610 protected PortalPreferences toUnwrappedModel(
611 PortalPreferences portalPreferences) {
612 if (portalPreferences instanceof PortalPreferencesImpl) {
613 return portalPreferences;
614 }
615
616 PortalPreferencesImpl portalPreferencesImpl = new PortalPreferencesImpl();
617
618 portalPreferencesImpl.setNew(portalPreferences.isNew());
619 portalPreferencesImpl.setPrimaryKey(portalPreferences.getPrimaryKey());
620
621 portalPreferencesImpl.setMvccVersion(portalPreferences.getMvccVersion());
622 portalPreferencesImpl.setPortalPreferencesId(portalPreferences.getPortalPreferencesId());
623 portalPreferencesImpl.setOwnerId(portalPreferences.getOwnerId());
624 portalPreferencesImpl.setOwnerType(portalPreferences.getOwnerType());
625 portalPreferencesImpl.setPreferences(portalPreferences.getPreferences());
626
627 return portalPreferencesImpl;
628 }
629
630
637 @Override
638 public PortalPreferences findByPrimaryKey(Serializable primaryKey)
639 throws NoSuchPreferencesException {
640 PortalPreferences portalPreferences = fetchByPrimaryKey(primaryKey);
641
642 if (portalPreferences == null) {
643 if (_log.isDebugEnabled()) {
644 _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
645 }
646
647 throw new NoSuchPreferencesException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
648 primaryKey);
649 }
650
651 return portalPreferences;
652 }
653
654
661 @Override
662 public PortalPreferences findByPrimaryKey(long portalPreferencesId)
663 throws NoSuchPreferencesException {
664 return findByPrimaryKey((Serializable)portalPreferencesId);
665 }
666
667
673 @Override
674 public PortalPreferences fetchByPrimaryKey(Serializable primaryKey) {
675 PortalPreferences portalPreferences = (PortalPreferences)entityCache.getResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
676 PortalPreferencesImpl.class, primaryKey);
677
678 if (portalPreferences == _nullPortalPreferences) {
679 return null;
680 }
681
682 if (portalPreferences == null) {
683 Session session = null;
684
685 try {
686 session = openSession();
687
688 portalPreferences = (PortalPreferences)session.get(PortalPreferencesImpl.class,
689 primaryKey);
690
691 if (portalPreferences != null) {
692 cacheResult(portalPreferences);
693 }
694 else {
695 entityCache.putResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
696 PortalPreferencesImpl.class, primaryKey,
697 _nullPortalPreferences);
698 }
699 }
700 catch (Exception e) {
701 entityCache.removeResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
702 PortalPreferencesImpl.class, primaryKey);
703
704 throw processException(e);
705 }
706 finally {
707 closeSession(session);
708 }
709 }
710
711 return portalPreferences;
712 }
713
714
720 @Override
721 public PortalPreferences fetchByPrimaryKey(long portalPreferencesId) {
722 return fetchByPrimaryKey((Serializable)portalPreferencesId);
723 }
724
725 @Override
726 public Map<Serializable, PortalPreferences> fetchByPrimaryKeys(
727 Set<Serializable> primaryKeys) {
728 if (primaryKeys.isEmpty()) {
729 return Collections.emptyMap();
730 }
731
732 Map<Serializable, PortalPreferences> map = new HashMap<Serializable, PortalPreferences>();
733
734 if (primaryKeys.size() == 1) {
735 Iterator<Serializable> iterator = primaryKeys.iterator();
736
737 Serializable primaryKey = iterator.next();
738
739 PortalPreferences portalPreferences = fetchByPrimaryKey(primaryKey);
740
741 if (portalPreferences != null) {
742 map.put(primaryKey, portalPreferences);
743 }
744
745 return map;
746 }
747
748 Set<Serializable> uncachedPrimaryKeys = null;
749
750 for (Serializable primaryKey : primaryKeys) {
751 PortalPreferences portalPreferences = (PortalPreferences)entityCache.getResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
752 PortalPreferencesImpl.class, primaryKey);
753
754 if (portalPreferences == null) {
755 if (uncachedPrimaryKeys == null) {
756 uncachedPrimaryKeys = new HashSet<Serializable>();
757 }
758
759 uncachedPrimaryKeys.add(primaryKey);
760 }
761 else {
762 map.put(primaryKey, portalPreferences);
763 }
764 }
765
766 if (uncachedPrimaryKeys == null) {
767 return map;
768 }
769
770 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
771 1);
772
773 query.append(_SQL_SELECT_PORTALPREFERENCES_WHERE_PKS_IN);
774
775 for (Serializable primaryKey : uncachedPrimaryKeys) {
776 query.append(String.valueOf(primaryKey));
777
778 query.append(StringPool.COMMA);
779 }
780
781 query.setIndex(query.index() - 1);
782
783 query.append(StringPool.CLOSE_PARENTHESIS);
784
785 String sql = query.toString();
786
787 Session session = null;
788
789 try {
790 session = openSession();
791
792 Query q = session.createQuery(sql);
793
794 for (PortalPreferences portalPreferences : (List<PortalPreferences>)q.list()) {
795 map.put(portalPreferences.getPrimaryKeyObj(), portalPreferences);
796
797 cacheResult(portalPreferences);
798
799 uncachedPrimaryKeys.remove(portalPreferences.getPrimaryKeyObj());
800 }
801
802 for (Serializable primaryKey : uncachedPrimaryKeys) {
803 entityCache.putResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
804 PortalPreferencesImpl.class, primaryKey,
805 _nullPortalPreferences);
806 }
807 }
808 catch (Exception e) {
809 throw processException(e);
810 }
811 finally {
812 closeSession(session);
813 }
814
815 return map;
816 }
817
818
823 @Override
824 public List<PortalPreferences> findAll() {
825 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
826 }
827
828
839 @Override
840 public List<PortalPreferences> findAll(int start, int end) {
841 return findAll(start, end, null);
842 }
843
844
856 @Override
857 public List<PortalPreferences> findAll(int start, int end,
858 OrderByComparator<PortalPreferences> orderByComparator) {
859 return findAll(start, end, orderByComparator, true);
860 }
861
862
875 @Override
876 public List<PortalPreferences> findAll(int start, int end,
877 OrderByComparator<PortalPreferences> orderByComparator,
878 boolean retrieveFromCache) {
879 boolean pagination = true;
880 FinderPath finderPath = null;
881 Object[] finderArgs = null;
882
883 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
884 (orderByComparator == null)) {
885 pagination = false;
886 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
887 finderArgs = FINDER_ARGS_EMPTY;
888 }
889 else {
890 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
891 finderArgs = new Object[] { start, end, orderByComparator };
892 }
893
894 List<PortalPreferences> list = null;
895
896 if (retrieveFromCache) {
897 list = (List<PortalPreferences>)finderCache.getResult(finderPath,
898 finderArgs, this);
899 }
900
901 if (list == null) {
902 StringBundler query = null;
903 String sql = null;
904
905 if (orderByComparator != null) {
906 query = new StringBundler(2 +
907 (orderByComparator.getOrderByFields().length * 2));
908
909 query.append(_SQL_SELECT_PORTALPREFERENCES);
910
911 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
912 orderByComparator);
913
914 sql = query.toString();
915 }
916 else {
917 sql = _SQL_SELECT_PORTALPREFERENCES;
918
919 if (pagination) {
920 sql = sql.concat(PortalPreferencesModelImpl.ORDER_BY_JPQL);
921 }
922 }
923
924 Session session = null;
925
926 try {
927 session = openSession();
928
929 Query q = session.createQuery(sql);
930
931 if (!pagination) {
932 list = (List<PortalPreferences>)QueryUtil.list(q,
933 getDialect(), start, end, false);
934
935 Collections.sort(list);
936
937 list = Collections.unmodifiableList(list);
938 }
939 else {
940 list = (List<PortalPreferences>)QueryUtil.list(q,
941 getDialect(), start, end);
942 }
943
944 cacheResult(list);
945
946 finderCache.putResult(finderPath, finderArgs, list);
947 }
948 catch (Exception e) {
949 finderCache.removeResult(finderPath, finderArgs);
950
951 throw processException(e);
952 }
953 finally {
954 closeSession(session);
955 }
956 }
957
958 return list;
959 }
960
961
965 @Override
966 public void removeAll() {
967 for (PortalPreferences portalPreferences : findAll()) {
968 remove(portalPreferences);
969 }
970 }
971
972
977 @Override
978 public int countAll() {
979 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
980 FINDER_ARGS_EMPTY, this);
981
982 if (count == null) {
983 Session session = null;
984
985 try {
986 session = openSession();
987
988 Query q = session.createQuery(_SQL_COUNT_PORTALPREFERENCES);
989
990 count = (Long)q.uniqueResult();
991
992 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
993 count);
994 }
995 catch (Exception e) {
996 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
997 FINDER_ARGS_EMPTY);
998
999 throw processException(e);
1000 }
1001 finally {
1002 closeSession(session);
1003 }
1004 }
1005
1006 return count.intValue();
1007 }
1008
1009 @Override
1010 protected Map<String, Integer> getTableColumnsMap() {
1011 return PortalPreferencesModelImpl.TABLE_COLUMNS_MAP;
1012 }
1013
1014
1017 public void afterPropertiesSet() {
1018 }
1019
1020 public void destroy() {
1021 entityCache.removeCache(PortalPreferencesImpl.class.getName());
1022 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
1023 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1024 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1025 }
1026
1027 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
1028 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
1029 private static final String _SQL_SELECT_PORTALPREFERENCES = "SELECT portalPreferences FROM PortalPreferences portalPreferences";
1030 private static final String _SQL_SELECT_PORTALPREFERENCES_WHERE_PKS_IN = "SELECT portalPreferences FROM PortalPreferences portalPreferences WHERE portalPreferencesId IN (";
1031 private static final String _SQL_SELECT_PORTALPREFERENCES_WHERE = "SELECT portalPreferences FROM PortalPreferences portalPreferences WHERE ";
1032 private static final String _SQL_COUNT_PORTALPREFERENCES = "SELECT COUNT(portalPreferences) FROM PortalPreferences portalPreferences";
1033 private static final String _SQL_COUNT_PORTALPREFERENCES_WHERE = "SELECT COUNT(portalPreferences) FROM PortalPreferences portalPreferences WHERE ";
1034 private static final String _ORDER_BY_ENTITY_ALIAS = "portalPreferences.";
1035 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PortalPreferences exists with the primary key ";
1036 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PortalPreferences exists with the key {";
1037 private static final Log _log = LogFactoryUtil.getLog(PortalPreferencesPersistenceImpl.class);
1038 private static final PortalPreferences _nullPortalPreferences = new PortalPreferencesImpl() {
1039 @Override
1040 public Object clone() {
1041 return this;
1042 }
1043
1044 @Override
1045 public CacheModel<PortalPreferences> toCacheModel() {
1046 return _nullPortalPreferencesCacheModel;
1047 }
1048 };
1049
1050 private static final CacheModel<PortalPreferences> _nullPortalPreferencesCacheModel =
1051 new NullCacheModel();
1052
1053 private static class NullCacheModel implements CacheModel<PortalPreferences>,
1054 MVCCModel {
1055 @Override
1056 public long getMvccVersion() {
1057 return -1;
1058 }
1059
1060 @Override
1061 public void setMvccVersion(long mvccVersion) {
1062 }
1063
1064 @Override
1065 public PortalPreferences toEntityModel() {
1066 return _nullPortalPreferences;
1067 }
1068 }
1069 }