001
014
015 package com.liferay.portlet.ratings.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
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.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
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.kernel.util.StringUtil;
036 import com.liferay.portal.model.CacheModel;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.service.persistence.BatchSessionUtil;
039 import com.liferay.portal.service.persistence.ResourcePersistence;
040 import com.liferay.portal.service.persistence.UserPersistence;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import com.liferay.portlet.ratings.NoSuchStatsException;
044 import com.liferay.portlet.ratings.model.RatingsStats;
045 import com.liferay.portlet.ratings.model.impl.RatingsStatsImpl;
046 import com.liferay.portlet.ratings.model.impl.RatingsStatsModelImpl;
047
048 import java.io.Serializable;
049
050 import java.util.ArrayList;
051 import java.util.Collections;
052 import java.util.List;
053
054
066 public class RatingsStatsPersistenceImpl extends BasePersistenceImpl<RatingsStats>
067 implements RatingsStatsPersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = RatingsStatsImpl.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_FETCH_BY_C_C = new FinderPath(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
079 RatingsStatsModelImpl.FINDER_CACHE_ENABLED, RatingsStatsImpl.class,
080 FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
081 new String[] { Long.class.getName(), Long.class.getName() },
082 RatingsStatsModelImpl.CLASSNAMEID_COLUMN_BITMASK |
083 RatingsStatsModelImpl.CLASSPK_COLUMN_BITMASK);
084 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
085 RatingsStatsModelImpl.FINDER_CACHE_ENABLED, Long.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
087 new String[] { Long.class.getName(), Long.class.getName() });
088 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
089 RatingsStatsModelImpl.FINDER_CACHE_ENABLED, RatingsStatsImpl.class,
090 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
091 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
092 RatingsStatsModelImpl.FINDER_CACHE_ENABLED, RatingsStatsImpl.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
094 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
095 RatingsStatsModelImpl.FINDER_CACHE_ENABLED, Long.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
097
098
103 public void cacheResult(RatingsStats ratingsStats) {
104 EntityCacheUtil.putResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
105 RatingsStatsImpl.class, ratingsStats.getPrimaryKey(), ratingsStats);
106
107 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
108 new Object[] {
109 Long.valueOf(ratingsStats.getClassNameId()),
110 Long.valueOf(ratingsStats.getClassPK())
111 }, ratingsStats);
112
113 ratingsStats.resetOriginalValues();
114 }
115
116
121 public void cacheResult(List<RatingsStats> ratingsStatses) {
122 for (RatingsStats ratingsStats : ratingsStatses) {
123 if (EntityCacheUtil.getResult(
124 RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
125 RatingsStatsImpl.class, ratingsStats.getPrimaryKey()) == null) {
126 cacheResult(ratingsStats);
127 }
128 else {
129 ratingsStats.resetOriginalValues();
130 }
131 }
132 }
133
134
141 @Override
142 public void clearCache() {
143 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
144 CacheRegistryUtil.clear(RatingsStatsImpl.class.getName());
145 }
146
147 EntityCacheUtil.clearCache(RatingsStatsImpl.class.getName());
148
149 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
150 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
151 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
152 }
153
154
161 @Override
162 public void clearCache(RatingsStats ratingsStats) {
163 EntityCacheUtil.removeResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
164 RatingsStatsImpl.class, ratingsStats.getPrimaryKey());
165
166 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
167 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
168
169 clearUniqueFindersCache(ratingsStats);
170 }
171
172 @Override
173 public void clearCache(List<RatingsStats> ratingsStatses) {
174 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
175 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
176
177 for (RatingsStats ratingsStats : ratingsStatses) {
178 EntityCacheUtil.removeResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
179 RatingsStatsImpl.class, ratingsStats.getPrimaryKey());
180
181 clearUniqueFindersCache(ratingsStats);
182 }
183 }
184
185 protected void clearUniqueFindersCache(RatingsStats ratingsStats) {
186 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
187 new Object[] {
188 Long.valueOf(ratingsStats.getClassNameId()),
189 Long.valueOf(ratingsStats.getClassPK())
190 });
191 }
192
193
199 public RatingsStats create(long statsId) {
200 RatingsStats ratingsStats = new RatingsStatsImpl();
201
202 ratingsStats.setNew(true);
203 ratingsStats.setPrimaryKey(statsId);
204
205 return ratingsStats;
206 }
207
208
216 public RatingsStats remove(long statsId)
217 throws NoSuchStatsException, SystemException {
218 return remove(Long.valueOf(statsId));
219 }
220
221
229 @Override
230 public RatingsStats remove(Serializable primaryKey)
231 throws NoSuchStatsException, SystemException {
232 Session session = null;
233
234 try {
235 session = openSession();
236
237 RatingsStats ratingsStats = (RatingsStats)session.get(RatingsStatsImpl.class,
238 primaryKey);
239
240 if (ratingsStats == null) {
241 if (_log.isWarnEnabled()) {
242 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
243 }
244
245 throw new NoSuchStatsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
246 primaryKey);
247 }
248
249 return remove(ratingsStats);
250 }
251 catch (NoSuchStatsException nsee) {
252 throw nsee;
253 }
254 catch (Exception e) {
255 throw processException(e);
256 }
257 finally {
258 closeSession(session);
259 }
260 }
261
262 @Override
263 protected RatingsStats removeImpl(RatingsStats ratingsStats)
264 throws SystemException {
265 ratingsStats = toUnwrappedModel(ratingsStats);
266
267 Session session = null;
268
269 try {
270 session = openSession();
271
272 BatchSessionUtil.delete(session, ratingsStats);
273 }
274 catch (Exception e) {
275 throw processException(e);
276 }
277 finally {
278 closeSession(session);
279 }
280
281 clearCache(ratingsStats);
282
283 return ratingsStats;
284 }
285
286 @Override
287 public RatingsStats updateImpl(
288 com.liferay.portlet.ratings.model.RatingsStats ratingsStats,
289 boolean merge) throws SystemException {
290 ratingsStats = toUnwrappedModel(ratingsStats);
291
292 boolean isNew = ratingsStats.isNew();
293
294 RatingsStatsModelImpl ratingsStatsModelImpl = (RatingsStatsModelImpl)ratingsStats;
295
296 Session session = null;
297
298 try {
299 session = openSession();
300
301 BatchSessionUtil.update(session, ratingsStats, merge);
302
303 ratingsStats.setNew(false);
304 }
305 catch (Exception e) {
306 throw processException(e);
307 }
308 finally {
309 closeSession(session);
310 }
311
312 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
313
314 if (isNew || !RatingsStatsModelImpl.COLUMN_BITMASK_ENABLED) {
315 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
316 }
317
318 EntityCacheUtil.putResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
319 RatingsStatsImpl.class, ratingsStats.getPrimaryKey(), ratingsStats);
320
321 if (isNew) {
322 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
323 new Object[] {
324 Long.valueOf(ratingsStats.getClassNameId()),
325 Long.valueOf(ratingsStats.getClassPK())
326 }, ratingsStats);
327 }
328 else {
329 if ((ratingsStatsModelImpl.getColumnBitmask() &
330 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
331 Object[] args = new Object[] {
332 Long.valueOf(ratingsStatsModelImpl.getOriginalClassNameId()),
333 Long.valueOf(ratingsStatsModelImpl.getOriginalClassPK())
334 };
335
336 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
337
338 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
339
340 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
341 new Object[] {
342 Long.valueOf(ratingsStats.getClassNameId()),
343 Long.valueOf(ratingsStats.getClassPK())
344 }, ratingsStats);
345 }
346 }
347
348 return ratingsStats;
349 }
350
351 protected RatingsStats toUnwrappedModel(RatingsStats ratingsStats) {
352 if (ratingsStats instanceof RatingsStatsImpl) {
353 return ratingsStats;
354 }
355
356 RatingsStatsImpl ratingsStatsImpl = new RatingsStatsImpl();
357
358 ratingsStatsImpl.setNew(ratingsStats.isNew());
359 ratingsStatsImpl.setPrimaryKey(ratingsStats.getPrimaryKey());
360
361 ratingsStatsImpl.setStatsId(ratingsStats.getStatsId());
362 ratingsStatsImpl.setClassNameId(ratingsStats.getClassNameId());
363 ratingsStatsImpl.setClassPK(ratingsStats.getClassPK());
364 ratingsStatsImpl.setTotalEntries(ratingsStats.getTotalEntries());
365 ratingsStatsImpl.setTotalScore(ratingsStats.getTotalScore());
366 ratingsStatsImpl.setAverageScore(ratingsStats.getAverageScore());
367
368 return ratingsStatsImpl;
369 }
370
371
379 @Override
380 public RatingsStats findByPrimaryKey(Serializable primaryKey)
381 throws NoSuchModelException, SystemException {
382 return findByPrimaryKey(((Long)primaryKey).longValue());
383 }
384
385
393 public RatingsStats findByPrimaryKey(long statsId)
394 throws NoSuchStatsException, SystemException {
395 RatingsStats ratingsStats = fetchByPrimaryKey(statsId);
396
397 if (ratingsStats == null) {
398 if (_log.isWarnEnabled()) {
399 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsId);
400 }
401
402 throw new NoSuchStatsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
403 statsId);
404 }
405
406 return ratingsStats;
407 }
408
409
416 @Override
417 public RatingsStats fetchByPrimaryKey(Serializable primaryKey)
418 throws SystemException {
419 return fetchByPrimaryKey(((Long)primaryKey).longValue());
420 }
421
422
429 public RatingsStats fetchByPrimaryKey(long statsId)
430 throws SystemException {
431 RatingsStats ratingsStats = (RatingsStats)EntityCacheUtil.getResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
432 RatingsStatsImpl.class, statsId);
433
434 if (ratingsStats == _nullRatingsStats) {
435 return null;
436 }
437
438 if (ratingsStats == null) {
439 Session session = null;
440
441 boolean hasException = false;
442
443 try {
444 session = openSession();
445
446 ratingsStats = (RatingsStats)session.get(RatingsStatsImpl.class,
447 Long.valueOf(statsId));
448 }
449 catch (Exception e) {
450 hasException = true;
451
452 throw processException(e);
453 }
454 finally {
455 if (ratingsStats != null) {
456 cacheResult(ratingsStats);
457 }
458 else if (!hasException) {
459 EntityCacheUtil.putResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
460 RatingsStatsImpl.class, statsId, _nullRatingsStats);
461 }
462
463 closeSession(session);
464 }
465 }
466
467 return ratingsStats;
468 }
469
470
479 public RatingsStats findByC_C(long classNameId, long classPK)
480 throws NoSuchStatsException, SystemException {
481 RatingsStats ratingsStats = fetchByC_C(classNameId, classPK);
482
483 if (ratingsStats == null) {
484 StringBundler msg = new StringBundler(6);
485
486 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
487
488 msg.append("classNameId=");
489 msg.append(classNameId);
490
491 msg.append(", classPK=");
492 msg.append(classPK);
493
494 msg.append(StringPool.CLOSE_CURLY_BRACE);
495
496 if (_log.isWarnEnabled()) {
497 _log.warn(msg.toString());
498 }
499
500 throw new NoSuchStatsException(msg.toString());
501 }
502
503 return ratingsStats;
504 }
505
506
514 public RatingsStats fetchByC_C(long classNameId, long classPK)
515 throws SystemException {
516 return fetchByC_C(classNameId, classPK, true);
517 }
518
519
528 public RatingsStats fetchByC_C(long classNameId, long classPK,
529 boolean retrieveFromCache) throws SystemException {
530 Object[] finderArgs = new Object[] { classNameId, classPK };
531
532 Object result = null;
533
534 if (retrieveFromCache) {
535 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
536 finderArgs, this);
537 }
538
539 if (result instanceof RatingsStats) {
540 RatingsStats ratingsStats = (RatingsStats)result;
541
542 if ((classNameId != ratingsStats.getClassNameId()) ||
543 (classPK != ratingsStats.getClassPK())) {
544 result = null;
545 }
546 }
547
548 if (result == null) {
549 StringBundler query = new StringBundler(3);
550
551 query.append(_SQL_SELECT_RATINGSSTATS_WHERE);
552
553 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
554
555 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
556
557 String sql = query.toString();
558
559 Session session = null;
560
561 try {
562 session = openSession();
563
564 Query q = session.createQuery(sql);
565
566 QueryPos qPos = QueryPos.getInstance(q);
567
568 qPos.add(classNameId);
569
570 qPos.add(classPK);
571
572 List<RatingsStats> list = q.list();
573
574 result = list;
575
576 RatingsStats ratingsStats = null;
577
578 if (list.isEmpty()) {
579 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
580 finderArgs, list);
581 }
582 else {
583 ratingsStats = list.get(0);
584
585 cacheResult(ratingsStats);
586
587 if ((ratingsStats.getClassNameId() != classNameId) ||
588 (ratingsStats.getClassPK() != classPK)) {
589 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
590 finderArgs, ratingsStats);
591 }
592 }
593
594 return ratingsStats;
595 }
596 catch (Exception e) {
597 throw processException(e);
598 }
599 finally {
600 if (result == null) {
601 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
602 finderArgs);
603 }
604
605 closeSession(session);
606 }
607 }
608 else {
609 if (result instanceof List<?>) {
610 return null;
611 }
612 else {
613 return (RatingsStats)result;
614 }
615 }
616 }
617
618
624 public List<RatingsStats> findAll() throws SystemException {
625 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
626 }
627
628
640 public List<RatingsStats> findAll(int start, int end)
641 throws SystemException {
642 return findAll(start, end, null);
643 }
644
645
658 public List<RatingsStats> findAll(int start, int end,
659 OrderByComparator orderByComparator) throws SystemException {
660 FinderPath finderPath = null;
661 Object[] finderArgs = new Object[] { start, end, orderByComparator };
662
663 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
664 (orderByComparator == null)) {
665 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
666 finderArgs = FINDER_ARGS_EMPTY;
667 }
668 else {
669 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
670 finderArgs = new Object[] { start, end, orderByComparator };
671 }
672
673 List<RatingsStats> list = (List<RatingsStats>)FinderCacheUtil.getResult(finderPath,
674 finderArgs, this);
675
676 if (list == null) {
677 StringBundler query = null;
678 String sql = null;
679
680 if (orderByComparator != null) {
681 query = new StringBundler(2 +
682 (orderByComparator.getOrderByFields().length * 3));
683
684 query.append(_SQL_SELECT_RATINGSSTATS);
685
686 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
687 orderByComparator);
688
689 sql = query.toString();
690 }
691 else {
692 sql = _SQL_SELECT_RATINGSSTATS;
693 }
694
695 Session session = null;
696
697 try {
698 session = openSession();
699
700 Query q = session.createQuery(sql);
701
702 if (orderByComparator == null) {
703 list = (List<RatingsStats>)QueryUtil.list(q, getDialect(),
704 start, end, false);
705
706 Collections.sort(list);
707 }
708 else {
709 list = (List<RatingsStats>)QueryUtil.list(q, getDialect(),
710 start, end);
711 }
712 }
713 catch (Exception e) {
714 throw processException(e);
715 }
716 finally {
717 if (list == null) {
718 FinderCacheUtil.removeResult(finderPath, finderArgs);
719 }
720 else {
721 cacheResult(list);
722
723 FinderCacheUtil.putResult(finderPath, finderArgs, list);
724 }
725
726 closeSession(session);
727 }
728 }
729
730 return list;
731 }
732
733
741 public RatingsStats removeByC_C(long classNameId, long classPK)
742 throws NoSuchStatsException, SystemException {
743 RatingsStats ratingsStats = findByC_C(classNameId, classPK);
744
745 return remove(ratingsStats);
746 }
747
748
753 public void removeAll() throws SystemException {
754 for (RatingsStats ratingsStats : findAll()) {
755 remove(ratingsStats);
756 }
757 }
758
759
767 public int countByC_C(long classNameId, long classPK)
768 throws SystemException {
769 Object[] finderArgs = new Object[] { classNameId, classPK };
770
771 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
772 finderArgs, this);
773
774 if (count == null) {
775 StringBundler query = new StringBundler(3);
776
777 query.append(_SQL_COUNT_RATINGSSTATS_WHERE);
778
779 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
780
781 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
782
783 String sql = query.toString();
784
785 Session session = null;
786
787 try {
788 session = openSession();
789
790 Query q = session.createQuery(sql);
791
792 QueryPos qPos = QueryPos.getInstance(q);
793
794 qPos.add(classNameId);
795
796 qPos.add(classPK);
797
798 count = (Long)q.uniqueResult();
799 }
800 catch (Exception e) {
801 throw processException(e);
802 }
803 finally {
804 if (count == null) {
805 count = Long.valueOf(0);
806 }
807
808 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
809 count);
810
811 closeSession(session);
812 }
813 }
814
815 return count.intValue();
816 }
817
818
824 public int countAll() throws SystemException {
825 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
826 FINDER_ARGS_EMPTY, this);
827
828 if (count == null) {
829 Session session = null;
830
831 try {
832 session = openSession();
833
834 Query q = session.createQuery(_SQL_COUNT_RATINGSSTATS);
835
836 count = (Long)q.uniqueResult();
837 }
838 catch (Exception e) {
839 throw processException(e);
840 }
841 finally {
842 if (count == null) {
843 count = Long.valueOf(0);
844 }
845
846 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
847 FINDER_ARGS_EMPTY, count);
848
849 closeSession(session);
850 }
851 }
852
853 return count.intValue();
854 }
855
856
859 public void afterPropertiesSet() {
860 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
861 com.liferay.portal.util.PropsUtil.get(
862 "value.object.listener.com.liferay.portlet.ratings.model.RatingsStats")));
863
864 if (listenerClassNames.length > 0) {
865 try {
866 List<ModelListener<RatingsStats>> listenersList = new ArrayList<ModelListener<RatingsStats>>();
867
868 for (String listenerClassName : listenerClassNames) {
869 listenersList.add((ModelListener<RatingsStats>)InstanceFactory.newInstance(
870 listenerClassName));
871 }
872
873 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
874 }
875 catch (Exception e) {
876 _log.error(e);
877 }
878 }
879 }
880
881 public void destroy() {
882 EntityCacheUtil.removeCache(RatingsStatsImpl.class.getName());
883 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
884 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
885 }
886
887 @BeanReference(type = RatingsEntryPersistence.class)
888 protected RatingsEntryPersistence ratingsEntryPersistence;
889 @BeanReference(type = RatingsStatsPersistence.class)
890 protected RatingsStatsPersistence ratingsStatsPersistence;
891 @BeanReference(type = ResourcePersistence.class)
892 protected ResourcePersistence resourcePersistence;
893 @BeanReference(type = UserPersistence.class)
894 protected UserPersistence userPersistence;
895 private static final String _SQL_SELECT_RATINGSSTATS = "SELECT ratingsStats FROM RatingsStats ratingsStats";
896 private static final String _SQL_SELECT_RATINGSSTATS_WHERE = "SELECT ratingsStats FROM RatingsStats ratingsStats WHERE ";
897 private static final String _SQL_COUNT_RATINGSSTATS = "SELECT COUNT(ratingsStats) FROM RatingsStats ratingsStats";
898 private static final String _SQL_COUNT_RATINGSSTATS_WHERE = "SELECT COUNT(ratingsStats) FROM RatingsStats ratingsStats WHERE ";
899 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "ratingsStats.classNameId = ? AND ";
900 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "ratingsStats.classPK = ?";
901 private static final String _ORDER_BY_ENTITY_ALIAS = "ratingsStats.";
902 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No RatingsStats exists with the primary key ";
903 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No RatingsStats exists with the key {";
904 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
905 private static Log _log = LogFactoryUtil.getLog(RatingsStatsPersistenceImpl.class);
906 private static RatingsStats _nullRatingsStats = new RatingsStatsImpl() {
907 @Override
908 public Object clone() {
909 return this;
910 }
911
912 @Override
913 public CacheModel<RatingsStats> toCacheModel() {
914 return _nullRatingsStatsCacheModel;
915 }
916 };
917
918 private static CacheModel<RatingsStats> _nullRatingsStatsCacheModel = new CacheModel<RatingsStats>() {
919 public RatingsStats toEntityModel() {
920 return _nullRatingsStats;
921 }
922 };
923 }