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_WITHOUT_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_WITH_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 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
170 new Object[] {
171 Long.valueOf(ratingsStats.getClassNameId()),
172 Long.valueOf(ratingsStats.getClassPK())
173 });
174 }
175
176
182 public RatingsStats create(long statsId) {
183 RatingsStats ratingsStats = new RatingsStatsImpl();
184
185 ratingsStats.setNew(true);
186 ratingsStats.setPrimaryKey(statsId);
187
188 return ratingsStats;
189 }
190
191
199 @Override
200 public RatingsStats remove(Serializable primaryKey)
201 throws NoSuchModelException, SystemException {
202 return remove(((Long)primaryKey).longValue());
203 }
204
205
213 public RatingsStats remove(long statsId)
214 throws NoSuchStatsException, SystemException {
215 Session session = null;
216
217 try {
218 session = openSession();
219
220 RatingsStats ratingsStats = (RatingsStats)session.get(RatingsStatsImpl.class,
221 Long.valueOf(statsId));
222
223 if (ratingsStats == null) {
224 if (_log.isWarnEnabled()) {
225 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsId);
226 }
227
228 throw new NoSuchStatsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
229 statsId);
230 }
231
232 return ratingsStatsPersistence.remove(ratingsStats);
233 }
234 catch (NoSuchStatsException nsee) {
235 throw nsee;
236 }
237 catch (Exception e) {
238 throw processException(e);
239 }
240 finally {
241 closeSession(session);
242 }
243 }
244
245
252 @Override
253 public RatingsStats remove(RatingsStats ratingsStats)
254 throws SystemException {
255 return super.remove(ratingsStats);
256 }
257
258 @Override
259 protected RatingsStats removeImpl(RatingsStats ratingsStats)
260 throws SystemException {
261 ratingsStats = toUnwrappedModel(ratingsStats);
262
263 Session session = null;
264
265 try {
266 session = openSession();
267
268 BatchSessionUtil.delete(session, ratingsStats);
269 }
270 catch (Exception e) {
271 throw processException(e);
272 }
273 finally {
274 closeSession(session);
275 }
276
277 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
278 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
279
280 RatingsStatsModelImpl ratingsStatsModelImpl = (RatingsStatsModelImpl)ratingsStats;
281
282 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
283 new Object[] {
284 Long.valueOf(ratingsStatsModelImpl.getClassNameId()),
285 Long.valueOf(ratingsStatsModelImpl.getClassPK())
286 });
287
288 EntityCacheUtil.removeResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
289 RatingsStatsImpl.class, ratingsStats.getPrimaryKey());
290
291 return ratingsStats;
292 }
293
294 @Override
295 public RatingsStats updateImpl(
296 com.liferay.portlet.ratings.model.RatingsStats ratingsStats,
297 boolean merge) throws SystemException {
298 ratingsStats = toUnwrappedModel(ratingsStats);
299
300 boolean isNew = ratingsStats.isNew();
301
302 RatingsStatsModelImpl ratingsStatsModelImpl = (RatingsStatsModelImpl)ratingsStats;
303
304 Session session = null;
305
306 try {
307 session = openSession();
308
309 BatchSessionUtil.update(session, ratingsStats, merge);
310
311 ratingsStats.setNew(false);
312 }
313 catch (Exception e) {
314 throw processException(e);
315 }
316 finally {
317 closeSession(session);
318 }
319
320 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
321
322 if (isNew || !RatingsStatsModelImpl.COLUMN_BITMASK_ENABLED) {
323 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
324 }
325
326 EntityCacheUtil.putResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
327 RatingsStatsImpl.class, ratingsStats.getPrimaryKey(), ratingsStats);
328
329 if (isNew) {
330 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
331 new Object[] {
332 Long.valueOf(ratingsStats.getClassNameId()),
333 Long.valueOf(ratingsStats.getClassPK())
334 }, ratingsStats);
335 }
336 else {
337 if ((ratingsStatsModelImpl.getColumnBitmask() &
338 FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
339 Object[] args = new Object[] {
340 Long.valueOf(ratingsStatsModelImpl.getOriginalClassNameId()),
341 Long.valueOf(ratingsStatsModelImpl.getOriginalClassPK())
342 };
343
344 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
345 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
346
347 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
348 new Object[] {
349 Long.valueOf(ratingsStats.getClassNameId()),
350 Long.valueOf(ratingsStats.getClassPK())
351 }, ratingsStats);
352 }
353 }
354
355 return ratingsStats;
356 }
357
358 protected RatingsStats toUnwrappedModel(RatingsStats ratingsStats) {
359 if (ratingsStats instanceof RatingsStatsImpl) {
360 return ratingsStats;
361 }
362
363 RatingsStatsImpl ratingsStatsImpl = new RatingsStatsImpl();
364
365 ratingsStatsImpl.setNew(ratingsStats.isNew());
366 ratingsStatsImpl.setPrimaryKey(ratingsStats.getPrimaryKey());
367
368 ratingsStatsImpl.setStatsId(ratingsStats.getStatsId());
369 ratingsStatsImpl.setClassNameId(ratingsStats.getClassNameId());
370 ratingsStatsImpl.setClassPK(ratingsStats.getClassPK());
371 ratingsStatsImpl.setTotalEntries(ratingsStats.getTotalEntries());
372 ratingsStatsImpl.setTotalScore(ratingsStats.getTotalScore());
373 ratingsStatsImpl.setAverageScore(ratingsStats.getAverageScore());
374
375 return ratingsStatsImpl;
376 }
377
378
386 @Override
387 public RatingsStats findByPrimaryKey(Serializable primaryKey)
388 throws NoSuchModelException, SystemException {
389 return findByPrimaryKey(((Long)primaryKey).longValue());
390 }
391
392
400 public RatingsStats findByPrimaryKey(long statsId)
401 throws NoSuchStatsException, SystemException {
402 RatingsStats ratingsStats = fetchByPrimaryKey(statsId);
403
404 if (ratingsStats == null) {
405 if (_log.isWarnEnabled()) {
406 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsId);
407 }
408
409 throw new NoSuchStatsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
410 statsId);
411 }
412
413 return ratingsStats;
414 }
415
416
423 @Override
424 public RatingsStats fetchByPrimaryKey(Serializable primaryKey)
425 throws SystemException {
426 return fetchByPrimaryKey(((Long)primaryKey).longValue());
427 }
428
429
436 public RatingsStats fetchByPrimaryKey(long statsId)
437 throws SystemException {
438 RatingsStats ratingsStats = (RatingsStats)EntityCacheUtil.getResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
439 RatingsStatsImpl.class, statsId);
440
441 if (ratingsStats == _nullRatingsStats) {
442 return null;
443 }
444
445 if (ratingsStats == null) {
446 Session session = null;
447
448 boolean hasException = false;
449
450 try {
451 session = openSession();
452
453 ratingsStats = (RatingsStats)session.get(RatingsStatsImpl.class,
454 Long.valueOf(statsId));
455 }
456 catch (Exception e) {
457 hasException = true;
458
459 throw processException(e);
460 }
461 finally {
462 if (ratingsStats != null) {
463 cacheResult(ratingsStats);
464 }
465 else if (!hasException) {
466 EntityCacheUtil.putResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
467 RatingsStatsImpl.class, statsId, _nullRatingsStats);
468 }
469
470 closeSession(session);
471 }
472 }
473
474 return ratingsStats;
475 }
476
477
486 public RatingsStats findByC_C(long classNameId, long classPK)
487 throws NoSuchStatsException, SystemException {
488 RatingsStats ratingsStats = fetchByC_C(classNameId, classPK);
489
490 if (ratingsStats == null) {
491 StringBundler msg = new StringBundler(6);
492
493 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
494
495 msg.append("classNameId=");
496 msg.append(classNameId);
497
498 msg.append(", classPK=");
499 msg.append(classPK);
500
501 msg.append(StringPool.CLOSE_CURLY_BRACE);
502
503 if (_log.isWarnEnabled()) {
504 _log.warn(msg.toString());
505 }
506
507 throw new NoSuchStatsException(msg.toString());
508 }
509
510 return ratingsStats;
511 }
512
513
521 public RatingsStats fetchByC_C(long classNameId, long classPK)
522 throws SystemException {
523 return fetchByC_C(classNameId, classPK, true);
524 }
525
526
535 public RatingsStats fetchByC_C(long classNameId, long classPK,
536 boolean retrieveFromCache) throws SystemException {
537 Object[] finderArgs = new Object[] { classNameId, classPK };
538
539 Object result = null;
540
541 if (retrieveFromCache) {
542 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
543 finderArgs, this);
544 }
545
546 if (result == null) {
547 StringBundler query = new StringBundler(3);
548
549 query.append(_SQL_SELECT_RATINGSSTATS_WHERE);
550
551 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
552
553 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
554
555 String sql = query.toString();
556
557 Session session = null;
558
559 try {
560 session = openSession();
561
562 Query q = session.createQuery(sql);
563
564 QueryPos qPos = QueryPos.getInstance(q);
565
566 qPos.add(classNameId);
567
568 qPos.add(classPK);
569
570 List<RatingsStats> list = q.list();
571
572 result = list;
573
574 RatingsStats ratingsStats = null;
575
576 if (list.isEmpty()) {
577 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
578 finderArgs, list);
579 }
580 else {
581 ratingsStats = list.get(0);
582
583 cacheResult(ratingsStats);
584
585 if ((ratingsStats.getClassNameId() != classNameId) ||
586 (ratingsStats.getClassPK() != classPK)) {
587 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
588 finderArgs, ratingsStats);
589 }
590 }
591
592 return ratingsStats;
593 }
594 catch (Exception e) {
595 throw processException(e);
596 }
597 finally {
598 if (result == null) {
599 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
600 finderArgs);
601 }
602
603 closeSession(session);
604 }
605 }
606 else {
607 if (result instanceof List<?>) {
608 return null;
609 }
610 else {
611 return (RatingsStats)result;
612 }
613 }
614 }
615
616
622 public List<RatingsStats> findAll() throws SystemException {
623 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
624 }
625
626
638 public List<RatingsStats> findAll(int start, int end)
639 throws SystemException {
640 return findAll(start, end, null);
641 }
642
643
656 public List<RatingsStats> findAll(int start, int end,
657 OrderByComparator orderByComparator) throws SystemException {
658 FinderPath finderPath = null;
659 Object[] finderArgs = new Object[] { start, end, orderByComparator };
660
661 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
662 (orderByComparator == null)) {
663 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
664 finderArgs = FINDER_ARGS_EMPTY;
665 }
666 else {
667 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
668 finderArgs = new Object[] { start, end, orderByComparator };
669 }
670
671 List<RatingsStats> list = (List<RatingsStats>)FinderCacheUtil.getResult(finderPath,
672 finderArgs, this);
673
674 if (list == null) {
675 StringBundler query = null;
676 String sql = null;
677
678 if (orderByComparator != null) {
679 query = new StringBundler(2 +
680 (orderByComparator.getOrderByFields().length * 3));
681
682 query.append(_SQL_SELECT_RATINGSSTATS);
683
684 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
685 orderByComparator);
686
687 sql = query.toString();
688 }
689 else {
690 sql = _SQL_SELECT_RATINGSSTATS;
691 }
692
693 Session session = null;
694
695 try {
696 session = openSession();
697
698 Query q = session.createQuery(sql);
699
700 if (orderByComparator == null) {
701 list = (List<RatingsStats>)QueryUtil.list(q, getDialect(),
702 start, end, false);
703
704 Collections.sort(list);
705 }
706 else {
707 list = (List<RatingsStats>)QueryUtil.list(q, getDialect(),
708 start, end);
709 }
710 }
711 catch (Exception e) {
712 throw processException(e);
713 }
714 finally {
715 if (list == null) {
716 FinderCacheUtil.removeResult(finderPath, finderArgs);
717 }
718 else {
719 cacheResult(list);
720
721 FinderCacheUtil.putResult(finderPath, finderArgs, list);
722 }
723
724 closeSession(session);
725 }
726 }
727
728 return list;
729 }
730
731
738 public void removeByC_C(long classNameId, long classPK)
739 throws NoSuchStatsException, SystemException {
740 RatingsStats ratingsStats = findByC_C(classNameId, classPK);
741
742 ratingsStatsPersistence.remove(ratingsStats);
743 }
744
745
750 public void removeAll() throws SystemException {
751 for (RatingsStats ratingsStats : findAll()) {
752 ratingsStatsPersistence.remove(ratingsStats);
753 }
754 }
755
756
764 public int countByC_C(long classNameId, long classPK)
765 throws SystemException {
766 Object[] finderArgs = new Object[] { classNameId, classPK };
767
768 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
769 finderArgs, this);
770
771 if (count == null) {
772 StringBundler query = new StringBundler(3);
773
774 query.append(_SQL_COUNT_RATINGSSTATS_WHERE);
775
776 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
777
778 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
779
780 String sql = query.toString();
781
782 Session session = null;
783
784 try {
785 session = openSession();
786
787 Query q = session.createQuery(sql);
788
789 QueryPos qPos = QueryPos.getInstance(q);
790
791 qPos.add(classNameId);
792
793 qPos.add(classPK);
794
795 count = (Long)q.uniqueResult();
796 }
797 catch (Exception e) {
798 throw processException(e);
799 }
800 finally {
801 if (count == null) {
802 count = Long.valueOf(0);
803 }
804
805 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
806 count);
807
808 closeSession(session);
809 }
810 }
811
812 return count.intValue();
813 }
814
815
821 public int countAll() throws SystemException {
822 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
823 FINDER_ARGS_EMPTY, this);
824
825 if (count == null) {
826 Session session = null;
827
828 try {
829 session = openSession();
830
831 Query q = session.createQuery(_SQL_COUNT_RATINGSSTATS);
832
833 count = (Long)q.uniqueResult();
834 }
835 catch (Exception e) {
836 throw processException(e);
837 }
838 finally {
839 if (count == null) {
840 count = Long.valueOf(0);
841 }
842
843 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
844 FINDER_ARGS_EMPTY, count);
845
846 closeSession(session);
847 }
848 }
849
850 return count.intValue();
851 }
852
853
856 public void afterPropertiesSet() {
857 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
858 com.liferay.portal.util.PropsUtil.get(
859 "value.object.listener.com.liferay.portlet.ratings.model.RatingsStats")));
860
861 if (listenerClassNames.length > 0) {
862 try {
863 List<ModelListener<RatingsStats>> listenersList = new ArrayList<ModelListener<RatingsStats>>();
864
865 for (String listenerClassName : listenerClassNames) {
866 listenersList.add((ModelListener<RatingsStats>)InstanceFactory.newInstance(
867 listenerClassName));
868 }
869
870 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
871 }
872 catch (Exception e) {
873 _log.error(e);
874 }
875 }
876 }
877
878 public void destroy() {
879 EntityCacheUtil.removeCache(RatingsStatsImpl.class.getName());
880 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
881 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
882 }
883
884 @BeanReference(type = RatingsEntryPersistence.class)
885 protected RatingsEntryPersistence ratingsEntryPersistence;
886 @BeanReference(type = RatingsStatsPersistence.class)
887 protected RatingsStatsPersistence ratingsStatsPersistence;
888 @BeanReference(type = ResourcePersistence.class)
889 protected ResourcePersistence resourcePersistence;
890 @BeanReference(type = UserPersistence.class)
891 protected UserPersistence userPersistence;
892 private static final String _SQL_SELECT_RATINGSSTATS = "SELECT ratingsStats FROM RatingsStats ratingsStats";
893 private static final String _SQL_SELECT_RATINGSSTATS_WHERE = "SELECT ratingsStats FROM RatingsStats ratingsStats WHERE ";
894 private static final String _SQL_COUNT_RATINGSSTATS = "SELECT COUNT(ratingsStats) FROM RatingsStats ratingsStats";
895 private static final String _SQL_COUNT_RATINGSSTATS_WHERE = "SELECT COUNT(ratingsStats) FROM RatingsStats ratingsStats WHERE ";
896 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "ratingsStats.classNameId = ? AND ";
897 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "ratingsStats.classPK = ?";
898 private static final String _ORDER_BY_ENTITY_ALIAS = "ratingsStats.";
899 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No RatingsStats exists with the primary key ";
900 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No RatingsStats exists with the key {";
901 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
902 private static Log _log = LogFactoryUtil.getLog(RatingsStatsPersistenceImpl.class);
903 private static RatingsStats _nullRatingsStats = new RatingsStatsImpl() {
904 @Override
905 public Object clone() {
906 return this;
907 }
908
909 @Override
910 public CacheModel<RatingsStats> toCacheModel() {
911 return _nullRatingsStatsCacheModel;
912 }
913 };
914
915 private static CacheModel<RatingsStats> _nullRatingsStatsCacheModel = new CacheModel<RatingsStats>() {
916 public RatingsStats toEntityModel() {
917 return _nullRatingsStats;
918 }
919 };
920 }