1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.ratings.service.persistence;
24  
25  import com.liferay.portal.NoSuchModelException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.kernel.annotation.BeanReference;
28  import com.liferay.portal.kernel.cache.CacheRegistry;
29  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
30  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
31  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32  import com.liferay.portal.kernel.dao.orm.FinderPath;
33  import com.liferay.portal.kernel.dao.orm.Query;
34  import com.liferay.portal.kernel.dao.orm.QueryPos;
35  import com.liferay.portal.kernel.dao.orm.QueryUtil;
36  import com.liferay.portal.kernel.dao.orm.Session;
37  import com.liferay.portal.kernel.log.Log;
38  import com.liferay.portal.kernel.log.LogFactoryUtil;
39  import com.liferay.portal.kernel.util.GetterUtil;
40  import com.liferay.portal.kernel.util.OrderByComparator;
41  import com.liferay.portal.kernel.util.StringBundler;
42  import com.liferay.portal.kernel.util.StringPool;
43  import com.liferay.portal.kernel.util.StringUtil;
44  import com.liferay.portal.model.ModelListener;
45  import com.liferay.portal.service.persistence.BatchSessionUtil;
46  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47  
48  import com.liferay.portlet.ratings.NoSuchStatsException;
49  import com.liferay.portlet.ratings.model.RatingsStats;
50  import com.liferay.portlet.ratings.model.impl.RatingsStatsImpl;
51  import com.liferay.portlet.ratings.model.impl.RatingsStatsModelImpl;
52  
53  import java.io.Serializable;
54  
55  import java.util.ArrayList;
56  import java.util.Collections;
57  import java.util.List;
58  
59  /**
60   * <a href="RatingsStatsPersistenceImpl.java.html"><b><i>View Source</i></b></a>
61   *
62   * <p>
63   * ServiceBuilder generated this class. Modifications in this class will be
64   * overwritten the next time is generated.
65   * </p>
66   *
67   * @author    Brian Wing Shun Chan
68   * @see       RatingsStatsPersistence
69   * @see       RatingsStatsUtil
70   * @generated
71   */
72  public class RatingsStatsPersistenceImpl extends BasePersistenceImpl<RatingsStats>
73      implements RatingsStatsPersistence {
74      public static final String FINDER_CLASS_NAME_ENTITY = RatingsStatsImpl.class.getName();
75      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
76          ".List";
77      public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
78              RatingsStatsModelImpl.FINDER_CACHE_ENABLED,
79              FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
80              new String[] { Long.class.getName(), Long.class.getName() });
81      public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
82              RatingsStatsModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
83              "countByC_C",
84              new String[] { Long.class.getName(), Long.class.getName() });
85      public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
86              RatingsStatsModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
87              "findAll", new String[0]);
88      public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
89              RatingsStatsModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
90              "countAll", new String[0]);
91  
92      public void cacheResult(RatingsStats ratingsStats) {
93          EntityCacheUtil.putResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
94              RatingsStatsImpl.class, ratingsStats.getPrimaryKey(), ratingsStats);
95  
96          FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
97              new Object[] {
98                  new Long(ratingsStats.getClassNameId()),
99                  new Long(ratingsStats.getClassPK())
100             }, ratingsStats);
101     }
102 
103     public void cacheResult(List<RatingsStats> ratingsStatses) {
104         for (RatingsStats ratingsStats : ratingsStatses) {
105             if (EntityCacheUtil.getResult(
106                         RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
107                         RatingsStatsImpl.class, ratingsStats.getPrimaryKey(),
108                         this) == null) {
109                 cacheResult(ratingsStats);
110             }
111         }
112     }
113 
114     public void clearCache() {
115         CacheRegistry.clear(RatingsStatsImpl.class.getName());
116         EntityCacheUtil.clearCache(RatingsStatsImpl.class.getName());
117         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
118         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
119     }
120 
121     public RatingsStats create(long statsId) {
122         RatingsStats ratingsStats = new RatingsStatsImpl();
123 
124         ratingsStats.setNew(true);
125         ratingsStats.setPrimaryKey(statsId);
126 
127         return ratingsStats;
128     }
129 
130     public RatingsStats remove(Serializable primaryKey)
131         throws NoSuchModelException, SystemException {
132         return remove(((Long)primaryKey).longValue());
133     }
134 
135     public RatingsStats remove(long statsId)
136         throws NoSuchStatsException, SystemException {
137         Session session = null;
138 
139         try {
140             session = openSession();
141 
142             RatingsStats ratingsStats = (RatingsStats)session.get(RatingsStatsImpl.class,
143                     new Long(statsId));
144 
145             if (ratingsStats == null) {
146                 if (_log.isWarnEnabled()) {
147                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsId);
148                 }
149 
150                 throw new NoSuchStatsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
151                     statsId);
152             }
153 
154             return remove(ratingsStats);
155         }
156         catch (NoSuchStatsException nsee) {
157             throw nsee;
158         }
159         catch (Exception e) {
160             throw processException(e);
161         }
162         finally {
163             closeSession(session);
164         }
165     }
166 
167     public RatingsStats remove(RatingsStats ratingsStats)
168         throws SystemException {
169         for (ModelListener<RatingsStats> listener : listeners) {
170             listener.onBeforeRemove(ratingsStats);
171         }
172 
173         ratingsStats = removeImpl(ratingsStats);
174 
175         for (ModelListener<RatingsStats> listener : listeners) {
176             listener.onAfterRemove(ratingsStats);
177         }
178 
179         return ratingsStats;
180     }
181 
182     protected RatingsStats removeImpl(RatingsStats ratingsStats)
183         throws SystemException {
184         ratingsStats = toUnwrappedModel(ratingsStats);
185 
186         Session session = null;
187 
188         try {
189             session = openSession();
190 
191             if (ratingsStats.isCachedModel() || BatchSessionUtil.isEnabled()) {
192                 Object staleObject = session.get(RatingsStatsImpl.class,
193                         ratingsStats.getPrimaryKeyObj());
194 
195                 if (staleObject != null) {
196                     session.evict(staleObject);
197                 }
198             }
199 
200             session.delete(ratingsStats);
201 
202             session.flush();
203         }
204         catch (Exception e) {
205             throw processException(e);
206         }
207         finally {
208             closeSession(session);
209         }
210 
211         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
212 
213         RatingsStatsModelImpl ratingsStatsModelImpl = (RatingsStatsModelImpl)ratingsStats;
214 
215         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
216             new Object[] {
217                 new Long(ratingsStatsModelImpl.getOriginalClassNameId()),
218                 new Long(ratingsStatsModelImpl.getOriginalClassPK())
219             });
220 
221         EntityCacheUtil.removeResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
222             RatingsStatsImpl.class, ratingsStats.getPrimaryKey());
223 
224         return ratingsStats;
225     }
226 
227     /**
228      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
229      */
230     public RatingsStats update(RatingsStats ratingsStats)
231         throws SystemException {
232         if (_log.isWarnEnabled()) {
233             _log.warn(
234                 "Using the deprecated update(RatingsStats ratingsStats) method. Use update(RatingsStats ratingsStats, boolean merge) instead.");
235         }
236 
237         return update(ratingsStats, false);
238     }
239 
240     public RatingsStats updateImpl(
241         com.liferay.portlet.ratings.model.RatingsStats ratingsStats,
242         boolean merge) throws SystemException {
243         ratingsStats = toUnwrappedModel(ratingsStats);
244 
245         boolean isNew = ratingsStats.isNew();
246 
247         RatingsStatsModelImpl ratingsStatsModelImpl = (RatingsStatsModelImpl)ratingsStats;
248 
249         Session session = null;
250 
251         try {
252             session = openSession();
253 
254             BatchSessionUtil.update(session, ratingsStats, merge);
255 
256             ratingsStats.setNew(false);
257         }
258         catch (Exception e) {
259             throw processException(e);
260         }
261         finally {
262             closeSession(session);
263         }
264 
265         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
266 
267         EntityCacheUtil.putResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
268             RatingsStatsImpl.class, ratingsStats.getPrimaryKey(), ratingsStats);
269 
270         if (!isNew &&
271                 ((ratingsStats.getClassNameId() != ratingsStatsModelImpl.getOriginalClassNameId()) ||
272                 (ratingsStats.getClassPK() != ratingsStatsModelImpl.getOriginalClassPK()))) {
273             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
274                 new Object[] {
275                     new Long(ratingsStatsModelImpl.getOriginalClassNameId()),
276                     new Long(ratingsStatsModelImpl.getOriginalClassPK())
277                 });
278         }
279 
280         if (isNew ||
281                 ((ratingsStats.getClassNameId() != ratingsStatsModelImpl.getOriginalClassNameId()) ||
282                 (ratingsStats.getClassPK() != ratingsStatsModelImpl.getOriginalClassPK()))) {
283             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
284                 new Object[] {
285                     new Long(ratingsStats.getClassNameId()),
286                     new Long(ratingsStats.getClassPK())
287                 }, ratingsStats);
288         }
289 
290         return ratingsStats;
291     }
292 
293     protected RatingsStats toUnwrappedModel(RatingsStats ratingsStats) {
294         if (ratingsStats instanceof RatingsStatsImpl) {
295             return ratingsStats;
296         }
297 
298         RatingsStatsImpl ratingsStatsImpl = new RatingsStatsImpl();
299 
300         ratingsStatsImpl.setNew(ratingsStats.isNew());
301         ratingsStatsImpl.setPrimaryKey(ratingsStats.getPrimaryKey());
302 
303         ratingsStatsImpl.setStatsId(ratingsStats.getStatsId());
304         ratingsStatsImpl.setClassNameId(ratingsStats.getClassNameId());
305         ratingsStatsImpl.setClassPK(ratingsStats.getClassPK());
306         ratingsStatsImpl.setTotalEntries(ratingsStats.getTotalEntries());
307         ratingsStatsImpl.setTotalScore(ratingsStats.getTotalScore());
308         ratingsStatsImpl.setAverageScore(ratingsStats.getAverageScore());
309 
310         return ratingsStatsImpl;
311     }
312 
313     public RatingsStats findByPrimaryKey(Serializable primaryKey)
314         throws NoSuchModelException, SystemException {
315         return findByPrimaryKey(((Long)primaryKey).longValue());
316     }
317 
318     public RatingsStats findByPrimaryKey(long statsId)
319         throws NoSuchStatsException, SystemException {
320         RatingsStats ratingsStats = fetchByPrimaryKey(statsId);
321 
322         if (ratingsStats == null) {
323             if (_log.isWarnEnabled()) {
324                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + statsId);
325             }
326 
327             throw new NoSuchStatsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
328                 statsId);
329         }
330 
331         return ratingsStats;
332     }
333 
334     public RatingsStats fetchByPrimaryKey(Serializable primaryKey)
335         throws SystemException {
336         return fetchByPrimaryKey(((Long)primaryKey).longValue());
337     }
338 
339     public RatingsStats fetchByPrimaryKey(long statsId)
340         throws SystemException {
341         RatingsStats ratingsStats = (RatingsStats)EntityCacheUtil.getResult(RatingsStatsModelImpl.ENTITY_CACHE_ENABLED,
342                 RatingsStatsImpl.class, statsId, this);
343 
344         if (ratingsStats == null) {
345             Session session = null;
346 
347             try {
348                 session = openSession();
349 
350                 ratingsStats = (RatingsStats)session.get(RatingsStatsImpl.class,
351                         new Long(statsId));
352             }
353             catch (Exception e) {
354                 throw processException(e);
355             }
356             finally {
357                 if (ratingsStats != null) {
358                     cacheResult(ratingsStats);
359                 }
360 
361                 closeSession(session);
362             }
363         }
364 
365         return ratingsStats;
366     }
367 
368     public RatingsStats findByC_C(long classNameId, long classPK)
369         throws NoSuchStatsException, SystemException {
370         RatingsStats ratingsStats = fetchByC_C(classNameId, classPK);
371 
372         if (ratingsStats == null) {
373             StringBundler msg = new StringBundler(6);
374 
375             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
376 
377             msg.append("classNameId=");
378             msg.append(classNameId);
379 
380             msg.append(", classPK=");
381             msg.append(classPK);
382 
383             msg.append(StringPool.CLOSE_CURLY_BRACE);
384 
385             if (_log.isWarnEnabled()) {
386                 _log.warn(msg.toString());
387             }
388 
389             throw new NoSuchStatsException(msg.toString());
390         }
391 
392         return ratingsStats;
393     }
394 
395     public RatingsStats fetchByC_C(long classNameId, long classPK)
396         throws SystemException {
397         return fetchByC_C(classNameId, classPK, true);
398     }
399 
400     public RatingsStats fetchByC_C(long classNameId, long classPK,
401         boolean retrieveFromCache) throws SystemException {
402         Object[] finderArgs = new Object[] {
403                 new Long(classNameId), new Long(classPK)
404             };
405 
406         Object result = null;
407 
408         if (retrieveFromCache) {
409             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
410                     finderArgs, this);
411         }
412 
413         if (result == null) {
414             Session session = null;
415 
416             try {
417                 session = openSession();
418 
419                 StringBundler query = new StringBundler(3);
420 
421                 query.append(_SQL_SELECT_RATINGSSTATS_WHERE);
422 
423                 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
424 
425                 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
426 
427                 String sql = query.toString();
428 
429                 Query q = session.createQuery(sql);
430 
431                 QueryPos qPos = QueryPos.getInstance(q);
432 
433                 qPos.add(classNameId);
434 
435                 qPos.add(classPK);
436 
437                 List<RatingsStats> list = q.list();
438 
439                 result = list;
440 
441                 RatingsStats ratingsStats = null;
442 
443                 if (list.isEmpty()) {
444                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
445                         finderArgs, list);
446                 }
447                 else {
448                     ratingsStats = list.get(0);
449 
450                     cacheResult(ratingsStats);
451 
452                     if ((ratingsStats.getClassNameId() != classNameId) ||
453                             (ratingsStats.getClassPK() != classPK)) {
454                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
455                             finderArgs, ratingsStats);
456                     }
457                 }
458 
459                 return ratingsStats;
460             }
461             catch (Exception e) {
462                 throw processException(e);
463             }
464             finally {
465                 if (result == null) {
466                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
467                         finderArgs, new ArrayList<RatingsStats>());
468                 }
469 
470                 closeSession(session);
471             }
472         }
473         else {
474             if (result instanceof List<?>) {
475                 return null;
476             }
477             else {
478                 return (RatingsStats)result;
479             }
480         }
481     }
482 
483     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
484         throws SystemException {
485         Session session = null;
486 
487         try {
488             session = openSession();
489 
490             dynamicQuery.compile(session);
491 
492             return dynamicQuery.list();
493         }
494         catch (Exception e) {
495             throw processException(e);
496         }
497         finally {
498             closeSession(session);
499         }
500     }
501 
502     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
503         int start, int end) throws SystemException {
504         Session session = null;
505 
506         try {
507             session = openSession();
508 
509             dynamicQuery.setLimit(start, end);
510 
511             dynamicQuery.compile(session);
512 
513             return dynamicQuery.list();
514         }
515         catch (Exception e) {
516             throw processException(e);
517         }
518         finally {
519             closeSession(session);
520         }
521     }
522 
523     public List<RatingsStats> findAll() throws SystemException {
524         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
525     }
526 
527     public List<RatingsStats> findAll(int start, int end)
528         throws SystemException {
529         return findAll(start, end, null);
530     }
531 
532     public List<RatingsStats> findAll(int start, int end, OrderByComparator obc)
533         throws SystemException {
534         Object[] finderArgs = new Object[] {
535                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
536             };
537 
538         List<RatingsStats> list = (List<RatingsStats>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
539                 finderArgs, this);
540 
541         if (list == null) {
542             Session session = null;
543 
544             try {
545                 session = openSession();
546 
547                 StringBundler query = null;
548                 String sql = null;
549 
550                 if (obc != null) {
551                     query = new StringBundler(2 +
552                             (obc.getOrderByFields().length * 3));
553 
554                     query.append(_SQL_SELECT_RATINGSSTATS);
555 
556                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
557 
558                     sql = query.toString();
559                 }
560 
561                 sql = _SQL_SELECT_RATINGSSTATS;
562 
563                 Query q = session.createQuery(sql);
564 
565                 if (obc == null) {
566                     list = (List<RatingsStats>)QueryUtil.list(q, getDialect(),
567                             start, end, false);
568 
569                     Collections.sort(list);
570                 }
571                 else {
572                     list = (List<RatingsStats>)QueryUtil.list(q, getDialect(),
573                             start, end);
574                 }
575             }
576             catch (Exception e) {
577                 throw processException(e);
578             }
579             finally {
580                 if (list == null) {
581                     list = new ArrayList<RatingsStats>();
582                 }
583 
584                 cacheResult(list);
585 
586                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
587 
588                 closeSession(session);
589             }
590         }
591 
592         return list;
593     }
594 
595     public void removeByC_C(long classNameId, long classPK)
596         throws NoSuchStatsException, SystemException {
597         RatingsStats ratingsStats = findByC_C(classNameId, classPK);
598 
599         remove(ratingsStats);
600     }
601 
602     public void removeAll() throws SystemException {
603         for (RatingsStats ratingsStats : findAll()) {
604             remove(ratingsStats);
605         }
606     }
607 
608     public int countByC_C(long classNameId, long classPK)
609         throws SystemException {
610         Object[] finderArgs = new Object[] {
611                 new Long(classNameId), new Long(classPK)
612             };
613 
614         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
615                 finderArgs, this);
616 
617         if (count == null) {
618             Session session = null;
619 
620             try {
621                 session = openSession();
622 
623                 StringBundler query = new StringBundler(3);
624 
625                 query.append(_SQL_COUNT_RATINGSSTATS_WHERE);
626 
627                 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
628 
629                 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
630 
631                 String sql = query.toString();
632 
633                 Query q = session.createQuery(sql);
634 
635                 QueryPos qPos = QueryPos.getInstance(q);
636 
637                 qPos.add(classNameId);
638 
639                 qPos.add(classPK);
640 
641                 count = (Long)q.uniqueResult();
642             }
643             catch (Exception e) {
644                 throw processException(e);
645             }
646             finally {
647                 if (count == null) {
648                     count = Long.valueOf(0);
649                 }
650 
651                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
652                     count);
653 
654                 closeSession(session);
655             }
656         }
657 
658         return count.intValue();
659     }
660 
661     public int countAll() throws SystemException {
662         Object[] finderArgs = new Object[0];
663 
664         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
665                 finderArgs, this);
666 
667         if (count == null) {
668             Session session = null;
669 
670             try {
671                 session = openSession();
672 
673                 Query q = session.createQuery(_SQL_COUNT_RATINGSSTATS);
674 
675                 count = (Long)q.uniqueResult();
676             }
677             catch (Exception e) {
678                 throw processException(e);
679             }
680             finally {
681                 if (count == null) {
682                     count = Long.valueOf(0);
683                 }
684 
685                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
686                     count);
687 
688                 closeSession(session);
689             }
690         }
691 
692         return count.intValue();
693     }
694 
695     public void afterPropertiesSet() {
696         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
697                     com.liferay.portal.util.PropsUtil.get(
698                         "value.object.listener.com.liferay.portlet.ratings.model.RatingsStats")));
699 
700         if (listenerClassNames.length > 0) {
701             try {
702                 List<ModelListener<RatingsStats>> listenersList = new ArrayList<ModelListener<RatingsStats>>();
703 
704                 for (String listenerClassName : listenerClassNames) {
705                     listenersList.add((ModelListener<RatingsStats>)Class.forName(
706                             listenerClassName).newInstance());
707                 }
708 
709                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
710             }
711             catch (Exception e) {
712                 _log.error(e);
713             }
714         }
715     }
716 
717     @BeanReference(name = "com.liferay.portlet.ratings.service.persistence.RatingsEntryPersistence")
718     protected com.liferay.portlet.ratings.service.persistence.RatingsEntryPersistence ratingsEntryPersistence;
719     @BeanReference(name = "com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence")
720     protected com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence ratingsStatsPersistence;
721     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
722     protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
723     @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
724     protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
725     private static final String _SQL_SELECT_RATINGSSTATS = "SELECT ratingsStats FROM RatingsStats ratingsStats";
726     private static final String _SQL_SELECT_RATINGSSTATS_WHERE = "SELECT ratingsStats FROM RatingsStats ratingsStats WHERE ";
727     private static final String _SQL_COUNT_RATINGSSTATS = "SELECT COUNT(ratingsStats) FROM RatingsStats ratingsStats";
728     private static final String _SQL_COUNT_RATINGSSTATS_WHERE = "SELECT COUNT(ratingsStats) FROM RatingsStats ratingsStats WHERE ";
729     private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "ratingsStats.classNameId = ? AND ";
730     private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "ratingsStats.classPK = ?";
731     private static final String _ORDER_BY_ENTITY_ALIAS = "ratingsStats.";
732     private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No RatingsStats exists with the primary key ";
733     private static final String _NO_SUCH_ENTITY_WITH_KEY = "No RatingsStats exists with the key {";
734     private static Log _log = LogFactoryUtil.getLog(RatingsStatsPersistenceImpl.class);
735 }