001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchPreferencesException;
019 import com.liferay.portal.kernel.bean.BeanReference;
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.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.PortalPreferences;
040 import com.liferay.portal.model.impl.PortalPreferencesImpl;
041 import com.liferay.portal.model.impl.PortalPreferencesModelImpl;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import java.io.Serializable;
045
046 import java.util.ArrayList;
047 import java.util.Collections;
048 import java.util.List;
049
050
062 public class PortalPreferencesPersistenceImpl extends BasePersistenceImpl<PortalPreferences>
063 implements PortalPreferencesPersistence {
064
069 public static final String FINDER_CLASS_NAME_ENTITY = PortalPreferencesImpl.class.getName();
070 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071 ".List1";
072 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List2";
074 public static final FinderPath FINDER_PATH_FETCH_BY_O_O = new FinderPath(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
075 PortalPreferencesModelImpl.FINDER_CACHE_ENABLED,
076 PortalPreferencesImpl.class, FINDER_CLASS_NAME_ENTITY,
077 "fetchByO_O",
078 new String[] { Long.class.getName(), Integer.class.getName() },
079 PortalPreferencesModelImpl.OWNERID_COLUMN_BITMASK |
080 PortalPreferencesModelImpl.OWNERTYPE_COLUMN_BITMASK);
081 public static final FinderPath FINDER_PATH_COUNT_BY_O_O = new FinderPath(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
082 PortalPreferencesModelImpl.FINDER_CACHE_ENABLED, Long.class,
083 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByO_O",
084 new String[] { Long.class.getName(), Integer.class.getName() });
085 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
086 PortalPreferencesModelImpl.FINDER_CACHE_ENABLED,
087 PortalPreferencesImpl.class,
088 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
089 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
090 PortalPreferencesModelImpl.FINDER_CACHE_ENABLED,
091 PortalPreferencesImpl.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
093 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
094 PortalPreferencesModelImpl.FINDER_CACHE_ENABLED, Long.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
096
097
102 public void cacheResult(PortalPreferences portalPreferences) {
103 EntityCacheUtil.putResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
104 PortalPreferencesImpl.class, portalPreferences.getPrimaryKey(),
105 portalPreferences);
106
107 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O,
108 new Object[] {
109 Long.valueOf(portalPreferences.getOwnerId()),
110 Integer.valueOf(portalPreferences.getOwnerType())
111 }, portalPreferences);
112
113 portalPreferences.resetOriginalValues();
114 }
115
116
121 public void cacheResult(List<PortalPreferences> portalPreferenceses) {
122 for (PortalPreferences portalPreferences : portalPreferenceses) {
123 if (EntityCacheUtil.getResult(
124 PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
125 PortalPreferencesImpl.class,
126 portalPreferences.getPrimaryKey()) == null) {
127 cacheResult(portalPreferences);
128 }
129 else {
130 portalPreferences.resetOriginalValues();
131 }
132 }
133 }
134
135
142 @Override
143 public void clearCache() {
144 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
145 CacheRegistryUtil.clear(PortalPreferencesImpl.class.getName());
146 }
147
148 EntityCacheUtil.clearCache(PortalPreferencesImpl.class.getName());
149
150 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
151 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
152 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
153 }
154
155
162 @Override
163 public void clearCache(PortalPreferences portalPreferences) {
164 EntityCacheUtil.removeResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
165 PortalPreferencesImpl.class, portalPreferences.getPrimaryKey());
166
167 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
168 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
169
170 clearUniqueFindersCache(portalPreferences);
171 }
172
173 @Override
174 public void clearCache(List<PortalPreferences> portalPreferenceses) {
175 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
176 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
177
178 for (PortalPreferences portalPreferences : portalPreferenceses) {
179 EntityCacheUtil.removeResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
180 PortalPreferencesImpl.class, portalPreferences.getPrimaryKey());
181
182 clearUniqueFindersCache(portalPreferences);
183 }
184 }
185
186 protected void cacheUniqueFindersCache(PortalPreferences portalPreferences) {
187 if (portalPreferences.isNew()) {
188 Object[] args = new Object[] {
189 Long.valueOf(portalPreferences.getOwnerId()),
190 Integer.valueOf(portalPreferences.getOwnerType())
191 };
192
193 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_O_O, args,
194 Long.valueOf(1));
195 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O, args,
196 portalPreferences);
197 }
198 else {
199 PortalPreferencesModelImpl portalPreferencesModelImpl = (PortalPreferencesModelImpl)portalPreferences;
200
201 if ((portalPreferencesModelImpl.getColumnBitmask() &
202 FINDER_PATH_FETCH_BY_O_O.getColumnBitmask()) != 0) {
203 Object[] args = new Object[] {
204 Long.valueOf(portalPreferences.getOwnerId()),
205 Integer.valueOf(portalPreferences.getOwnerType())
206 };
207
208 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_O_O, args,
209 Long.valueOf(1));
210 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O, args,
211 portalPreferences);
212 }
213 }
214 }
215
216 protected void clearUniqueFindersCache(PortalPreferences portalPreferences) {
217 PortalPreferencesModelImpl portalPreferencesModelImpl = (PortalPreferencesModelImpl)portalPreferences;
218
219 Object[] args = new Object[] {
220 Long.valueOf(portalPreferences.getOwnerId()),
221 Integer.valueOf(portalPreferences.getOwnerType())
222 };
223
224 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_O_O, args);
225 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O, args);
226
227 if ((portalPreferencesModelImpl.getColumnBitmask() &
228 FINDER_PATH_FETCH_BY_O_O.getColumnBitmask()) != 0) {
229 args = new Object[] {
230 Long.valueOf(portalPreferencesModelImpl.getOriginalOwnerId()),
231 Integer.valueOf(portalPreferencesModelImpl.getOriginalOwnerType())
232 };
233
234 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_O_O, args);
235 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O, args);
236 }
237 }
238
239
245 public PortalPreferences create(long portalPreferencesId) {
246 PortalPreferences portalPreferences = new PortalPreferencesImpl();
247
248 portalPreferences.setNew(true);
249 portalPreferences.setPrimaryKey(portalPreferencesId);
250
251 return portalPreferences;
252 }
253
254
262 public PortalPreferences remove(long portalPreferencesId)
263 throws NoSuchPreferencesException, SystemException {
264 return remove(Long.valueOf(portalPreferencesId));
265 }
266
267
275 @Override
276 public PortalPreferences remove(Serializable primaryKey)
277 throws NoSuchPreferencesException, SystemException {
278 Session session = null;
279
280 try {
281 session = openSession();
282
283 PortalPreferences portalPreferences = (PortalPreferences)session.get(PortalPreferencesImpl.class,
284 primaryKey);
285
286 if (portalPreferences == null) {
287 if (_log.isWarnEnabled()) {
288 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
289 }
290
291 throw new NoSuchPreferencesException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
292 primaryKey);
293 }
294
295 return remove(portalPreferences);
296 }
297 catch (NoSuchPreferencesException nsee) {
298 throw nsee;
299 }
300 catch (Exception e) {
301 throw processException(e);
302 }
303 finally {
304 closeSession(session);
305 }
306 }
307
308 @Override
309 protected PortalPreferences removeImpl(PortalPreferences portalPreferences)
310 throws SystemException {
311 portalPreferences = toUnwrappedModel(portalPreferences);
312
313 Session session = null;
314
315 try {
316 session = openSession();
317
318 BatchSessionUtil.delete(session, portalPreferences);
319 }
320 catch (Exception e) {
321 throw processException(e);
322 }
323 finally {
324 closeSession(session);
325 }
326
327 clearCache(portalPreferences);
328
329 return portalPreferences;
330 }
331
332 @Override
333 public PortalPreferences updateImpl(
334 com.liferay.portal.model.PortalPreferences portalPreferences,
335 boolean merge) throws SystemException {
336 portalPreferences = toUnwrappedModel(portalPreferences);
337
338 boolean isNew = portalPreferences.isNew();
339
340 Session session = null;
341
342 try {
343 session = openSession();
344
345 BatchSessionUtil.update(session, portalPreferences, merge);
346
347 portalPreferences.setNew(false);
348 }
349 catch (Exception e) {
350 throw processException(e);
351 }
352 finally {
353 closeSession(session);
354 }
355
356 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
357
358 if (isNew || !PortalPreferencesModelImpl.COLUMN_BITMASK_ENABLED) {
359 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
360 }
361
362 EntityCacheUtil.putResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
363 PortalPreferencesImpl.class, portalPreferences.getPrimaryKey(),
364 portalPreferences);
365
366 clearUniqueFindersCache(portalPreferences);
367 cacheUniqueFindersCache(portalPreferences);
368
369 return portalPreferences;
370 }
371
372 protected PortalPreferences toUnwrappedModel(
373 PortalPreferences portalPreferences) {
374 if (portalPreferences instanceof PortalPreferencesImpl) {
375 return portalPreferences;
376 }
377
378 PortalPreferencesImpl portalPreferencesImpl = new PortalPreferencesImpl();
379
380 portalPreferencesImpl.setNew(portalPreferences.isNew());
381 portalPreferencesImpl.setPrimaryKey(portalPreferences.getPrimaryKey());
382
383 portalPreferencesImpl.setPortalPreferencesId(portalPreferences.getPortalPreferencesId());
384 portalPreferencesImpl.setOwnerId(portalPreferences.getOwnerId());
385 portalPreferencesImpl.setOwnerType(portalPreferences.getOwnerType());
386 portalPreferencesImpl.setPreferences(portalPreferences.getPreferences());
387
388 return portalPreferencesImpl;
389 }
390
391
399 @Override
400 public PortalPreferences findByPrimaryKey(Serializable primaryKey)
401 throws NoSuchModelException, SystemException {
402 return findByPrimaryKey(((Long)primaryKey).longValue());
403 }
404
405
413 public PortalPreferences findByPrimaryKey(long portalPreferencesId)
414 throws NoSuchPreferencesException, SystemException {
415 PortalPreferences portalPreferences = fetchByPrimaryKey(portalPreferencesId);
416
417 if (portalPreferences == null) {
418 if (_log.isWarnEnabled()) {
419 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
420 portalPreferencesId);
421 }
422
423 throw new NoSuchPreferencesException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
424 portalPreferencesId);
425 }
426
427 return portalPreferences;
428 }
429
430
437 @Override
438 public PortalPreferences fetchByPrimaryKey(Serializable primaryKey)
439 throws SystemException {
440 return fetchByPrimaryKey(((Long)primaryKey).longValue());
441 }
442
443
450 public PortalPreferences fetchByPrimaryKey(long portalPreferencesId)
451 throws SystemException {
452 PortalPreferences portalPreferences = (PortalPreferences)EntityCacheUtil.getResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
453 PortalPreferencesImpl.class, portalPreferencesId);
454
455 if (portalPreferences == _nullPortalPreferences) {
456 return null;
457 }
458
459 if (portalPreferences == null) {
460 Session session = null;
461
462 boolean hasException = false;
463
464 try {
465 session = openSession();
466
467 portalPreferences = (PortalPreferences)session.get(PortalPreferencesImpl.class,
468 Long.valueOf(portalPreferencesId));
469 }
470 catch (Exception e) {
471 hasException = true;
472
473 throw processException(e);
474 }
475 finally {
476 if (portalPreferences != null) {
477 cacheResult(portalPreferences);
478 }
479 else if (!hasException) {
480 EntityCacheUtil.putResult(PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED,
481 PortalPreferencesImpl.class, portalPreferencesId,
482 _nullPortalPreferences);
483 }
484
485 closeSession(session);
486 }
487 }
488
489 return portalPreferences;
490 }
491
492
501 public PortalPreferences findByO_O(long ownerId, int ownerType)
502 throws NoSuchPreferencesException, SystemException {
503 PortalPreferences portalPreferences = fetchByO_O(ownerId, ownerType);
504
505 if (portalPreferences == null) {
506 StringBundler msg = new StringBundler(6);
507
508 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
509
510 msg.append("ownerId=");
511 msg.append(ownerId);
512
513 msg.append(", ownerType=");
514 msg.append(ownerType);
515
516 msg.append(StringPool.CLOSE_CURLY_BRACE);
517
518 if (_log.isWarnEnabled()) {
519 _log.warn(msg.toString());
520 }
521
522 throw new NoSuchPreferencesException(msg.toString());
523 }
524
525 return portalPreferences;
526 }
527
528
536 public PortalPreferences fetchByO_O(long ownerId, int ownerType)
537 throws SystemException {
538 return fetchByO_O(ownerId, ownerType, true);
539 }
540
541
550 public PortalPreferences fetchByO_O(long ownerId, int ownerType,
551 boolean retrieveFromCache) throws SystemException {
552 Object[] finderArgs = new Object[] { ownerId, ownerType };
553
554 Object result = null;
555
556 if (retrieveFromCache) {
557 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_O_O,
558 finderArgs, this);
559 }
560
561 if (result instanceof PortalPreferences) {
562 PortalPreferences portalPreferences = (PortalPreferences)result;
563
564 if ((ownerId != portalPreferences.getOwnerId()) ||
565 (ownerType != portalPreferences.getOwnerType())) {
566 result = null;
567 }
568 }
569
570 if (result == null) {
571 StringBundler query = new StringBundler(3);
572
573 query.append(_SQL_SELECT_PORTALPREFERENCES_WHERE);
574
575 query.append(_FINDER_COLUMN_O_O_OWNERID_2);
576
577 query.append(_FINDER_COLUMN_O_O_OWNERTYPE_2);
578
579 String sql = query.toString();
580
581 Session session = null;
582
583 try {
584 session = openSession();
585
586 Query q = session.createQuery(sql);
587
588 QueryPos qPos = QueryPos.getInstance(q);
589
590 qPos.add(ownerId);
591
592 qPos.add(ownerType);
593
594 List<PortalPreferences> list = q.list();
595
596 result = list;
597
598 PortalPreferences portalPreferences = null;
599
600 if (list.isEmpty()) {
601 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O,
602 finderArgs, list);
603 }
604 else {
605 portalPreferences = list.get(0);
606
607 cacheResult(portalPreferences);
608
609 if ((portalPreferences.getOwnerId() != ownerId) ||
610 (portalPreferences.getOwnerType() != ownerType)) {
611 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O,
612 finderArgs, portalPreferences);
613 }
614 }
615
616 return portalPreferences;
617 }
618 catch (Exception e) {
619 throw processException(e);
620 }
621 finally {
622 if (result == null) {
623 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O,
624 finderArgs);
625 }
626
627 closeSession(session);
628 }
629 }
630 else {
631 if (result instanceof List<?>) {
632 return null;
633 }
634 else {
635 return (PortalPreferences)result;
636 }
637 }
638 }
639
640
646 public List<PortalPreferences> findAll() throws SystemException {
647 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
648 }
649
650
662 public List<PortalPreferences> findAll(int start, int end)
663 throws SystemException {
664 return findAll(start, end, null);
665 }
666
667
680 public List<PortalPreferences> findAll(int start, int end,
681 OrderByComparator orderByComparator) throws SystemException {
682 FinderPath finderPath = null;
683 Object[] finderArgs = new Object[] { start, end, orderByComparator };
684
685 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
686 (orderByComparator == null)) {
687 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
688 finderArgs = FINDER_ARGS_EMPTY;
689 }
690 else {
691 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
692 finderArgs = new Object[] { start, end, orderByComparator };
693 }
694
695 List<PortalPreferences> list = (List<PortalPreferences>)FinderCacheUtil.getResult(finderPath,
696 finderArgs, this);
697
698 if (list == null) {
699 StringBundler query = null;
700 String sql = null;
701
702 if (orderByComparator != null) {
703 query = new StringBundler(2 +
704 (orderByComparator.getOrderByFields().length * 3));
705
706 query.append(_SQL_SELECT_PORTALPREFERENCES);
707
708 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
709 orderByComparator);
710
711 sql = query.toString();
712 }
713 else {
714 sql = _SQL_SELECT_PORTALPREFERENCES;
715 }
716
717 Session session = null;
718
719 try {
720 session = openSession();
721
722 Query q = session.createQuery(sql);
723
724 if (orderByComparator == null) {
725 list = (List<PortalPreferences>)QueryUtil.list(q,
726 getDialect(), start, end, false);
727
728 Collections.sort(list);
729 }
730 else {
731 list = (List<PortalPreferences>)QueryUtil.list(q,
732 getDialect(), start, end);
733 }
734 }
735 catch (Exception e) {
736 throw processException(e);
737 }
738 finally {
739 if (list == null) {
740 FinderCacheUtil.removeResult(finderPath, finderArgs);
741 }
742 else {
743 cacheResult(list);
744
745 FinderCacheUtil.putResult(finderPath, finderArgs, list);
746 }
747
748 closeSession(session);
749 }
750 }
751
752 return list;
753 }
754
755
763 public PortalPreferences removeByO_O(long ownerId, int ownerType)
764 throws NoSuchPreferencesException, SystemException {
765 PortalPreferences portalPreferences = findByO_O(ownerId, ownerType);
766
767 return remove(portalPreferences);
768 }
769
770
775 public void removeAll() throws SystemException {
776 for (PortalPreferences portalPreferences : findAll()) {
777 remove(portalPreferences);
778 }
779 }
780
781
789 public int countByO_O(long ownerId, int ownerType)
790 throws SystemException {
791 Object[] finderArgs = new Object[] { ownerId, ownerType };
792
793 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_O_O,
794 finderArgs, this);
795
796 if (count == null) {
797 StringBundler query = new StringBundler(3);
798
799 query.append(_SQL_COUNT_PORTALPREFERENCES_WHERE);
800
801 query.append(_FINDER_COLUMN_O_O_OWNERID_2);
802
803 query.append(_FINDER_COLUMN_O_O_OWNERTYPE_2);
804
805 String sql = query.toString();
806
807 Session session = null;
808
809 try {
810 session = openSession();
811
812 Query q = session.createQuery(sql);
813
814 QueryPos qPos = QueryPos.getInstance(q);
815
816 qPos.add(ownerId);
817
818 qPos.add(ownerType);
819
820 count = (Long)q.uniqueResult();
821 }
822 catch (Exception e) {
823 throw processException(e);
824 }
825 finally {
826 if (count == null) {
827 count = Long.valueOf(0);
828 }
829
830 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_O_O, finderArgs,
831 count);
832
833 closeSession(session);
834 }
835 }
836
837 return count.intValue();
838 }
839
840
846 public int countAll() throws SystemException {
847 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
848 FINDER_ARGS_EMPTY, this);
849
850 if (count == null) {
851 Session session = null;
852
853 try {
854 session = openSession();
855
856 Query q = session.createQuery(_SQL_COUNT_PORTALPREFERENCES);
857
858 count = (Long)q.uniqueResult();
859 }
860 catch (Exception e) {
861 throw processException(e);
862 }
863 finally {
864 if (count == null) {
865 count = Long.valueOf(0);
866 }
867
868 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
869 FINDER_ARGS_EMPTY, count);
870
871 closeSession(session);
872 }
873 }
874
875 return count.intValue();
876 }
877
878
881 public void afterPropertiesSet() {
882 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
883 com.liferay.portal.util.PropsUtil.get(
884 "value.object.listener.com.liferay.portal.model.PortalPreferences")));
885
886 if (listenerClassNames.length > 0) {
887 try {
888 List<ModelListener<PortalPreferences>> listenersList = new ArrayList<ModelListener<PortalPreferences>>();
889
890 for (String listenerClassName : listenerClassNames) {
891 Class<?> clazz = getClass();
892
893 listenersList.add((ModelListener<PortalPreferences>)InstanceFactory.newInstance(
894 clazz.getClassLoader(), listenerClassName));
895 }
896
897 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
898 }
899 catch (Exception e) {
900 _log.error(e);
901 }
902 }
903 }
904
905 public void destroy() {
906 EntityCacheUtil.removeCache(PortalPreferencesImpl.class.getName());
907 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
908 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
909 }
910
911 @BeanReference(type = AccountPersistence.class)
912 protected AccountPersistence accountPersistence;
913 @BeanReference(type = AddressPersistence.class)
914 protected AddressPersistence addressPersistence;
915 @BeanReference(type = BrowserTrackerPersistence.class)
916 protected BrowserTrackerPersistence browserTrackerPersistence;
917 @BeanReference(type = ClassNamePersistence.class)
918 protected ClassNamePersistence classNamePersistence;
919 @BeanReference(type = ClusterGroupPersistence.class)
920 protected ClusterGroupPersistence clusterGroupPersistence;
921 @BeanReference(type = CompanyPersistence.class)
922 protected CompanyPersistence companyPersistence;
923 @BeanReference(type = ContactPersistence.class)
924 protected ContactPersistence contactPersistence;
925 @BeanReference(type = CountryPersistence.class)
926 protected CountryPersistence countryPersistence;
927 @BeanReference(type = EmailAddressPersistence.class)
928 protected EmailAddressPersistence emailAddressPersistence;
929 @BeanReference(type = GroupPersistence.class)
930 protected GroupPersistence groupPersistence;
931 @BeanReference(type = ImagePersistence.class)
932 protected ImagePersistence imagePersistence;
933 @BeanReference(type = LayoutPersistence.class)
934 protected LayoutPersistence layoutPersistence;
935 @BeanReference(type = LayoutBranchPersistence.class)
936 protected LayoutBranchPersistence layoutBranchPersistence;
937 @BeanReference(type = LayoutPrototypePersistence.class)
938 protected LayoutPrototypePersistence layoutPrototypePersistence;
939 @BeanReference(type = LayoutRevisionPersistence.class)
940 protected LayoutRevisionPersistence layoutRevisionPersistence;
941 @BeanReference(type = LayoutSetPersistence.class)
942 protected LayoutSetPersistence layoutSetPersistence;
943 @BeanReference(type = LayoutSetBranchPersistence.class)
944 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
945 @BeanReference(type = LayoutSetPrototypePersistence.class)
946 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
947 @BeanReference(type = ListTypePersistence.class)
948 protected ListTypePersistence listTypePersistence;
949 @BeanReference(type = LockPersistence.class)
950 protected LockPersistence lockPersistence;
951 @BeanReference(type = MembershipRequestPersistence.class)
952 protected MembershipRequestPersistence membershipRequestPersistence;
953 @BeanReference(type = OrganizationPersistence.class)
954 protected OrganizationPersistence organizationPersistence;
955 @BeanReference(type = OrgGroupPermissionPersistence.class)
956 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
957 @BeanReference(type = OrgGroupRolePersistence.class)
958 protected OrgGroupRolePersistence orgGroupRolePersistence;
959 @BeanReference(type = OrgLaborPersistence.class)
960 protected OrgLaborPersistence orgLaborPersistence;
961 @BeanReference(type = PasswordPolicyPersistence.class)
962 protected PasswordPolicyPersistence passwordPolicyPersistence;
963 @BeanReference(type = PasswordPolicyRelPersistence.class)
964 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
965 @BeanReference(type = PasswordTrackerPersistence.class)
966 protected PasswordTrackerPersistence passwordTrackerPersistence;
967 @BeanReference(type = PermissionPersistence.class)
968 protected PermissionPersistence permissionPersistence;
969 @BeanReference(type = PhonePersistence.class)
970 protected PhonePersistence phonePersistence;
971 @BeanReference(type = PluginSettingPersistence.class)
972 protected PluginSettingPersistence pluginSettingPersistence;
973 @BeanReference(type = PortalPreferencesPersistence.class)
974 protected PortalPreferencesPersistence portalPreferencesPersistence;
975 @BeanReference(type = PortletPersistence.class)
976 protected PortletPersistence portletPersistence;
977 @BeanReference(type = PortletItemPersistence.class)
978 protected PortletItemPersistence portletItemPersistence;
979 @BeanReference(type = PortletPreferencesPersistence.class)
980 protected PortletPreferencesPersistence portletPreferencesPersistence;
981 @BeanReference(type = RegionPersistence.class)
982 protected RegionPersistence regionPersistence;
983 @BeanReference(type = ReleasePersistence.class)
984 protected ReleasePersistence releasePersistence;
985 @BeanReference(type = RepositoryPersistence.class)
986 protected RepositoryPersistence repositoryPersistence;
987 @BeanReference(type = RepositoryEntryPersistence.class)
988 protected RepositoryEntryPersistence repositoryEntryPersistence;
989 @BeanReference(type = ResourcePersistence.class)
990 protected ResourcePersistence resourcePersistence;
991 @BeanReference(type = ResourceActionPersistence.class)
992 protected ResourceActionPersistence resourceActionPersistence;
993 @BeanReference(type = ResourceBlockPersistence.class)
994 protected ResourceBlockPersistence resourceBlockPersistence;
995 @BeanReference(type = ResourceBlockPermissionPersistence.class)
996 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
997 @BeanReference(type = ResourceCodePersistence.class)
998 protected ResourceCodePersistence resourceCodePersistence;
999 @BeanReference(type = ResourcePermissionPersistence.class)
1000 protected ResourcePermissionPersistence resourcePermissionPersistence;
1001 @BeanReference(type = ResourceTypePermissionPersistence.class)
1002 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1003 @BeanReference(type = RolePersistence.class)
1004 protected RolePersistence rolePersistence;
1005 @BeanReference(type = ServiceComponentPersistence.class)
1006 protected ServiceComponentPersistence serviceComponentPersistence;
1007 @BeanReference(type = ShardPersistence.class)
1008 protected ShardPersistence shardPersistence;
1009 @BeanReference(type = SubscriptionPersistence.class)
1010 protected SubscriptionPersistence subscriptionPersistence;
1011 @BeanReference(type = TeamPersistence.class)
1012 protected TeamPersistence teamPersistence;
1013 @BeanReference(type = TicketPersistence.class)
1014 protected TicketPersistence ticketPersistence;
1015 @BeanReference(type = UserPersistence.class)
1016 protected UserPersistence userPersistence;
1017 @BeanReference(type = UserGroupPersistence.class)
1018 protected UserGroupPersistence userGroupPersistence;
1019 @BeanReference(type = UserGroupGroupRolePersistence.class)
1020 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1021 @BeanReference(type = UserGroupRolePersistence.class)
1022 protected UserGroupRolePersistence userGroupRolePersistence;
1023 @BeanReference(type = UserIdMapperPersistence.class)
1024 protected UserIdMapperPersistence userIdMapperPersistence;
1025 @BeanReference(type = UserNotificationEventPersistence.class)
1026 protected UserNotificationEventPersistence userNotificationEventPersistence;
1027 @BeanReference(type = UserTrackerPersistence.class)
1028 protected UserTrackerPersistence userTrackerPersistence;
1029 @BeanReference(type = UserTrackerPathPersistence.class)
1030 protected UserTrackerPathPersistence userTrackerPathPersistence;
1031 @BeanReference(type = VirtualHostPersistence.class)
1032 protected VirtualHostPersistence virtualHostPersistence;
1033 @BeanReference(type = WebDAVPropsPersistence.class)
1034 protected WebDAVPropsPersistence webDAVPropsPersistence;
1035 @BeanReference(type = WebsitePersistence.class)
1036 protected WebsitePersistence websitePersistence;
1037 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1038 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1039 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1040 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1041 private static final String _SQL_SELECT_PORTALPREFERENCES = "SELECT portalPreferences FROM PortalPreferences portalPreferences";
1042 private static final String _SQL_SELECT_PORTALPREFERENCES_WHERE = "SELECT portalPreferences FROM PortalPreferences portalPreferences WHERE ";
1043 private static final String _SQL_COUNT_PORTALPREFERENCES = "SELECT COUNT(portalPreferences) FROM PortalPreferences portalPreferences";
1044 private static final String _SQL_COUNT_PORTALPREFERENCES_WHERE = "SELECT COUNT(portalPreferences) FROM PortalPreferences portalPreferences WHERE ";
1045 private static final String _FINDER_COLUMN_O_O_OWNERID_2 = "portalPreferences.ownerId = ? AND ";
1046 private static final String _FINDER_COLUMN_O_O_OWNERTYPE_2 = "portalPreferences.ownerType = ?";
1047 private static final String _ORDER_BY_ENTITY_ALIAS = "portalPreferences.";
1048 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PortalPreferences exists with the primary key ";
1049 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PortalPreferences exists with the key {";
1050 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1051 private static Log _log = LogFactoryUtil.getLog(PortalPreferencesPersistenceImpl.class);
1052 private static PortalPreferences _nullPortalPreferences = new PortalPreferencesImpl() {
1053 @Override
1054 public Object clone() {
1055 return this;
1056 }
1057
1058 @Override
1059 public CacheModel<PortalPreferences> toCacheModel() {
1060 return _nullPortalPreferencesCacheModel;
1061 }
1062 };
1063
1064 private static CacheModel<PortalPreferences> _nullPortalPreferencesCacheModel =
1065 new CacheModel<PortalPreferences>() {
1066 public PortalPreferences toEntityModel() {
1067 return _nullPortalPreferences;
1068 }
1069 };
1070 }