001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.ratings.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.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.ModelListener;
037    import com.liferay.portal.service.persistence.BatchSessionUtil;
038    import com.liferay.portal.service.persistence.ResourcePersistence;
039    import com.liferay.portal.service.persistence.UserPersistence;
040    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041    
042    import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
043    import com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence;
044    import com.liferay.portlet.ratings.NoSuchEntryException;
045    import com.liferay.portlet.ratings.model.RatingsEntry;
046    import com.liferay.portlet.ratings.model.impl.RatingsEntryImpl;
047    import com.liferay.portlet.ratings.model.impl.RatingsEntryModelImpl;
048    import com.liferay.portlet.social.service.persistence.SocialEquityLogPersistence;
049    
050    import java.io.Serializable;
051    
052    import java.util.ArrayList;
053    import java.util.Collections;
054    import java.util.List;
055    
056    /**
057     * The persistence implementation for the ratings entry service.
058     *
059     * <p>
060     * Never modify or reference this class directly. Always use {@link RatingsEntryUtil} to access the ratings entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
061     * </p>
062     *
063     * <p>
064     * Caching information and settings can be found in <code>portal.properties</code>
065     * </p>
066     *
067     * @author Brian Wing Shun Chan
068     * @see RatingsEntryPersistence
069     * @see RatingsEntryUtil
070     * @generated
071     */
072    public class RatingsEntryPersistenceImpl extends BasePersistenceImpl<RatingsEntry>
073            implements RatingsEntryPersistence {
074            public static final String FINDER_CLASS_NAME_ENTITY = RatingsEntryImpl.class.getName();
075            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
076                    ".List";
077            public static final FinderPath FINDER_PATH_FIND_BY_C_C = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED,
078                            RatingsEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
079                            "findByC_C",
080                            new String[] {
081                                    Long.class.getName(), Long.class.getName(),
082                                    
083                            "java.lang.Integer", "java.lang.Integer",
084                                    "com.liferay.portal.kernel.util.OrderByComparator"
085                            });
086            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED,
087                            RatingsEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
088                            "countByC_C",
089                            new String[] { Long.class.getName(), Long.class.getName() });
090            public static final FinderPath FINDER_PATH_FETCH_BY_U_C_C = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED,
091                            RatingsEntryModelImpl.FINDER_CACHE_ENABLED,
092                            FINDER_CLASS_NAME_ENTITY, "fetchByU_C_C",
093                            new String[] {
094                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
095                            });
096            public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED,
097                            RatingsEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
098                            "countByU_C_C",
099                            new String[] {
100                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
101                            });
102            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED,
103                            RatingsEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104                            "findAll", new String[0]);
105            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED,
106                            RatingsEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
107                            "countAll", new String[0]);
108    
109            /**
110             * Caches the ratings entry in the entity cache if it is enabled.
111             *
112             * @param ratingsEntry the ratings entry to cache
113             */
114            public void cacheResult(RatingsEntry ratingsEntry) {
115                    EntityCacheUtil.putResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED,
116                            RatingsEntryImpl.class, ratingsEntry.getPrimaryKey(), ratingsEntry);
117    
118                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C,
119                            new Object[] {
120                                    new Long(ratingsEntry.getUserId()),
121                                    new Long(ratingsEntry.getClassNameId()),
122                                    new Long(ratingsEntry.getClassPK())
123                            }, ratingsEntry);
124            }
125    
126            /**
127             * Caches the ratings entries in the entity cache if it is enabled.
128             *
129             * @param ratingsEntries the ratings entries to cache
130             */
131            public void cacheResult(List<RatingsEntry> ratingsEntries) {
132                    for (RatingsEntry ratingsEntry : ratingsEntries) {
133                            if (EntityCacheUtil.getResult(
134                                                    RatingsEntryModelImpl.ENTITY_CACHE_ENABLED,
135                                                    RatingsEntryImpl.class, ratingsEntry.getPrimaryKey(),
136                                                    this) == null) {
137                                    cacheResult(ratingsEntry);
138                            }
139                    }
140            }
141    
142            /**
143             * Clears the cache for all ratings entries.
144             *
145             * <p>
146             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
147             * </p>
148             */
149            public void clearCache() {
150                    CacheRegistryUtil.clear(RatingsEntryImpl.class.getName());
151                    EntityCacheUtil.clearCache(RatingsEntryImpl.class.getName());
152                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
153                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
154            }
155    
156            /**
157             * Clears the cache for the ratings entry.
158             *
159             * <p>
160             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
161             * </p>
162             */
163            public void clearCache(RatingsEntry ratingsEntry) {
164                    EntityCacheUtil.removeResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED,
165                            RatingsEntryImpl.class, ratingsEntry.getPrimaryKey());
166    
167                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C,
168                            new Object[] {
169                                    new Long(ratingsEntry.getUserId()),
170                                    new Long(ratingsEntry.getClassNameId()),
171                                    new Long(ratingsEntry.getClassPK())
172                            });
173            }
174    
175            /**
176             * Creates a new ratings entry with the primary key. Does not add the ratings entry to the database.
177             *
178             * @param entryId the primary key for the new ratings entry
179             * @return the new ratings entry
180             */
181            public RatingsEntry create(long entryId) {
182                    RatingsEntry ratingsEntry = new RatingsEntryImpl();
183    
184                    ratingsEntry.setNew(true);
185                    ratingsEntry.setPrimaryKey(entryId);
186    
187                    return ratingsEntry;
188            }
189    
190            /**
191             * Removes the ratings entry with the primary key from the database. Also notifies the appropriate model listeners.
192             *
193             * @param primaryKey the primary key of the ratings entry to remove
194             * @return the ratings entry that was removed
195             * @throws com.liferay.portal.NoSuchModelException if a ratings entry with the primary key could not be found
196             * @throws SystemException if a system exception occurred
197             */
198            public RatingsEntry remove(Serializable primaryKey)
199                    throws NoSuchModelException, SystemException {
200                    return remove(((Long)primaryKey).longValue());
201            }
202    
203            /**
204             * Removes the ratings entry with the primary key from the database. Also notifies the appropriate model listeners.
205             *
206             * @param entryId the primary key of the ratings entry to remove
207             * @return the ratings entry that was removed
208             * @throws com.liferay.portlet.ratings.NoSuchEntryException if a ratings entry with the primary key could not be found
209             * @throws SystemException if a system exception occurred
210             */
211            public RatingsEntry remove(long entryId)
212                    throws NoSuchEntryException, SystemException {
213                    Session session = null;
214    
215                    try {
216                            session = openSession();
217    
218                            RatingsEntry ratingsEntry = (RatingsEntry)session.get(RatingsEntryImpl.class,
219                                            new Long(entryId));
220    
221                            if (ratingsEntry == null) {
222                                    if (_log.isWarnEnabled()) {
223                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
224                                    }
225    
226                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
227                                            entryId);
228                            }
229    
230                            return remove(ratingsEntry);
231                    }
232                    catch (NoSuchEntryException nsee) {
233                            throw nsee;
234                    }
235                    catch (Exception e) {
236                            throw processException(e);
237                    }
238                    finally {
239                            closeSession(session);
240                    }
241            }
242    
243            protected RatingsEntry removeImpl(RatingsEntry ratingsEntry)
244                    throws SystemException {
245                    ratingsEntry = toUnwrappedModel(ratingsEntry);
246    
247                    Session session = null;
248    
249                    try {
250                            session = openSession();
251    
252                            BatchSessionUtil.delete(session, ratingsEntry);
253                    }
254                    catch (Exception e) {
255                            throw processException(e);
256                    }
257                    finally {
258                            closeSession(session);
259                    }
260    
261                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
262    
263                    RatingsEntryModelImpl ratingsEntryModelImpl = (RatingsEntryModelImpl)ratingsEntry;
264    
265                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C,
266                            new Object[] {
267                                    new Long(ratingsEntryModelImpl.getUserId()),
268                                    new Long(ratingsEntryModelImpl.getClassNameId()),
269                                    new Long(ratingsEntryModelImpl.getClassPK())
270                            });
271    
272                    EntityCacheUtil.removeResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED,
273                            RatingsEntryImpl.class, ratingsEntry.getPrimaryKey());
274    
275                    return ratingsEntry;
276            }
277    
278            public RatingsEntry updateImpl(
279                    com.liferay.portlet.ratings.model.RatingsEntry ratingsEntry,
280                    boolean merge) throws SystemException {
281                    ratingsEntry = toUnwrappedModel(ratingsEntry);
282    
283                    boolean isNew = ratingsEntry.isNew();
284    
285                    RatingsEntryModelImpl ratingsEntryModelImpl = (RatingsEntryModelImpl)ratingsEntry;
286    
287                    Session session = null;
288    
289                    try {
290                            session = openSession();
291    
292                            BatchSessionUtil.update(session, ratingsEntry, merge);
293    
294                            ratingsEntry.setNew(false);
295                    }
296                    catch (Exception e) {
297                            throw processException(e);
298                    }
299                    finally {
300                            closeSession(session);
301                    }
302    
303                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
304    
305                    EntityCacheUtil.putResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED,
306                            RatingsEntryImpl.class, ratingsEntry.getPrimaryKey(), ratingsEntry);
307    
308                    if (!isNew &&
309                                    ((ratingsEntry.getUserId() != ratingsEntryModelImpl.getOriginalUserId()) ||
310                                    (ratingsEntry.getClassNameId() != ratingsEntryModelImpl.getOriginalClassNameId()) ||
311                                    (ratingsEntry.getClassPK() != ratingsEntryModelImpl.getOriginalClassPK()))) {
312                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C,
313                                    new Object[] {
314                                            new Long(ratingsEntryModelImpl.getOriginalUserId()),
315                                            new Long(ratingsEntryModelImpl.getOriginalClassNameId()),
316                                            new Long(ratingsEntryModelImpl.getOriginalClassPK())
317                                    });
318                    }
319    
320                    if (isNew ||
321                                    ((ratingsEntry.getUserId() != ratingsEntryModelImpl.getOriginalUserId()) ||
322                                    (ratingsEntry.getClassNameId() != ratingsEntryModelImpl.getOriginalClassNameId()) ||
323                                    (ratingsEntry.getClassPK() != ratingsEntryModelImpl.getOriginalClassPK()))) {
324                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C,
325                                    new Object[] {
326                                            new Long(ratingsEntry.getUserId()),
327                                            new Long(ratingsEntry.getClassNameId()),
328                                            new Long(ratingsEntry.getClassPK())
329                                    }, ratingsEntry);
330                    }
331    
332                    return ratingsEntry;
333            }
334    
335            protected RatingsEntry toUnwrappedModel(RatingsEntry ratingsEntry) {
336                    if (ratingsEntry instanceof RatingsEntryImpl) {
337                            return ratingsEntry;
338                    }
339    
340                    RatingsEntryImpl ratingsEntryImpl = new RatingsEntryImpl();
341    
342                    ratingsEntryImpl.setNew(ratingsEntry.isNew());
343                    ratingsEntryImpl.setPrimaryKey(ratingsEntry.getPrimaryKey());
344    
345                    ratingsEntryImpl.setEntryId(ratingsEntry.getEntryId());
346                    ratingsEntryImpl.setCompanyId(ratingsEntry.getCompanyId());
347                    ratingsEntryImpl.setUserId(ratingsEntry.getUserId());
348                    ratingsEntryImpl.setUserName(ratingsEntry.getUserName());
349                    ratingsEntryImpl.setCreateDate(ratingsEntry.getCreateDate());
350                    ratingsEntryImpl.setModifiedDate(ratingsEntry.getModifiedDate());
351                    ratingsEntryImpl.setClassNameId(ratingsEntry.getClassNameId());
352                    ratingsEntryImpl.setClassPK(ratingsEntry.getClassPK());
353                    ratingsEntryImpl.setScore(ratingsEntry.getScore());
354    
355                    return ratingsEntryImpl;
356            }
357    
358            /**
359             * Finds the ratings entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
360             *
361             * @param primaryKey the primary key of the ratings entry to find
362             * @return the ratings entry
363             * @throws com.liferay.portal.NoSuchModelException if a ratings entry with the primary key could not be found
364             * @throws SystemException if a system exception occurred
365             */
366            public RatingsEntry findByPrimaryKey(Serializable primaryKey)
367                    throws NoSuchModelException, SystemException {
368                    return findByPrimaryKey(((Long)primaryKey).longValue());
369            }
370    
371            /**
372             * Finds the ratings entry with the primary key or throws a {@link com.liferay.portlet.ratings.NoSuchEntryException} if it could not be found.
373             *
374             * @param entryId the primary key of the ratings entry to find
375             * @return the ratings entry
376             * @throws com.liferay.portlet.ratings.NoSuchEntryException if a ratings entry with the primary key could not be found
377             * @throws SystemException if a system exception occurred
378             */
379            public RatingsEntry findByPrimaryKey(long entryId)
380                    throws NoSuchEntryException, SystemException {
381                    RatingsEntry ratingsEntry = fetchByPrimaryKey(entryId);
382    
383                    if (ratingsEntry == null) {
384                            if (_log.isWarnEnabled()) {
385                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
386                            }
387    
388                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
389                                    entryId);
390                    }
391    
392                    return ratingsEntry;
393            }
394    
395            /**
396             * Finds the ratings entry with the primary key or returns <code>null</code> if it could not be found.
397             *
398             * @param primaryKey the primary key of the ratings entry to find
399             * @return the ratings entry, or <code>null</code> if a ratings entry with the primary key could not be found
400             * @throws SystemException if a system exception occurred
401             */
402            public RatingsEntry fetchByPrimaryKey(Serializable primaryKey)
403                    throws SystemException {
404                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
405            }
406    
407            /**
408             * Finds the ratings entry with the primary key or returns <code>null</code> if it could not be found.
409             *
410             * @param entryId the primary key of the ratings entry to find
411             * @return the ratings entry, or <code>null</code> if a ratings entry with the primary key could not be found
412             * @throws SystemException if a system exception occurred
413             */
414            public RatingsEntry fetchByPrimaryKey(long entryId)
415                    throws SystemException {
416                    RatingsEntry ratingsEntry = (RatingsEntry)EntityCacheUtil.getResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED,
417                                    RatingsEntryImpl.class, entryId, this);
418    
419                    if (ratingsEntry == null) {
420                            Session session = null;
421    
422                            try {
423                                    session = openSession();
424    
425                                    ratingsEntry = (RatingsEntry)session.get(RatingsEntryImpl.class,
426                                                    new Long(entryId));
427                            }
428                            catch (Exception e) {
429                                    throw processException(e);
430                            }
431                            finally {
432                                    if (ratingsEntry != null) {
433                                            cacheResult(ratingsEntry);
434                                    }
435    
436                                    closeSession(session);
437                            }
438                    }
439    
440                    return ratingsEntry;
441            }
442    
443            /**
444             * Finds all the ratings entries where classNameId = &#63; and classPK = &#63;.
445             *
446             * @param classNameId the class name id to search with
447             * @param classPK the class p k to search with
448             * @return the matching ratings entries
449             * @throws SystemException if a system exception occurred
450             */
451            public List<RatingsEntry> findByC_C(long classNameId, long classPK)
452                    throws SystemException {
453                    return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
454                            QueryUtil.ALL_POS, null);
455            }
456    
457            /**
458             * Finds a range of all the ratings entries where classNameId = &#63; and classPK = &#63;.
459             *
460             * <p>
461             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
462             * </p>
463             *
464             * @param classNameId the class name id to search with
465             * @param classPK the class p k to search with
466             * @param start the lower bound of the range of ratings entries to return
467             * @param end the upper bound of the range of ratings entries to return (not inclusive)
468             * @return the range of matching ratings entries
469             * @throws SystemException if a system exception occurred
470             */
471            public List<RatingsEntry> findByC_C(long classNameId, long classPK,
472                    int start, int end) throws SystemException {
473                    return findByC_C(classNameId, classPK, start, end, null);
474            }
475    
476            /**
477             * Finds an ordered range of all the ratings entries where classNameId = &#63; and classPK = &#63;.
478             *
479             * <p>
480             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
481             * </p>
482             *
483             * @param classNameId the class name id to search with
484             * @param classPK the class p k to search with
485             * @param start the lower bound of the range of ratings entries to return
486             * @param end the upper bound of the range of ratings entries to return (not inclusive)
487             * @param orderByComparator the comparator to order the results by
488             * @return the ordered range of matching ratings entries
489             * @throws SystemException if a system exception occurred
490             */
491            public List<RatingsEntry> findByC_C(long classNameId, long classPK,
492                    int start, int end, OrderByComparator orderByComparator)
493                    throws SystemException {
494                    Object[] finderArgs = new Object[] {
495                                    classNameId, classPK,
496                                    
497                                    String.valueOf(start), String.valueOf(end),
498                                    String.valueOf(orderByComparator)
499                            };
500    
501                    List<RatingsEntry> list = (List<RatingsEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_C,
502                                    finderArgs, this);
503    
504                    if (list == null) {
505                            StringBundler query = null;
506    
507                            if (orderByComparator != null) {
508                                    query = new StringBundler(4 +
509                                                    (orderByComparator.getOrderByFields().length * 3));
510                            }
511                            else {
512                                    query = new StringBundler(3);
513                            }
514    
515                            query.append(_SQL_SELECT_RATINGSENTRY_WHERE);
516    
517                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
518    
519                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
520    
521                            if (orderByComparator != null) {
522                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
523                                            orderByComparator);
524                            }
525    
526                            String sql = query.toString();
527    
528                            Session session = null;
529    
530                            try {
531                                    session = openSession();
532    
533                                    Query q = session.createQuery(sql);
534    
535                                    QueryPos qPos = QueryPos.getInstance(q);
536    
537                                    qPos.add(classNameId);
538    
539                                    qPos.add(classPK);
540    
541                                    list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(),
542                                                    start, end);
543                            }
544                            catch (Exception e) {
545                                    throw processException(e);
546                            }
547                            finally {
548                                    if (list == null) {
549                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_C_C,
550                                                    finderArgs);
551                                    }
552                                    else {
553                                            cacheResult(list);
554    
555                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C,
556                                                    finderArgs, list);
557                                    }
558    
559                                    closeSession(session);
560                            }
561                    }
562    
563                    return list;
564            }
565    
566            /**
567             * Finds the first ratings entry in the ordered set where classNameId = &#63; and classPK = &#63;.
568             *
569             * <p>
570             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
571             * </p>
572             *
573             * @param classNameId the class name id to search with
574             * @param classPK the class p k to search with
575             * @param orderByComparator the comparator to order the set by
576             * @return the first matching ratings entry
577             * @throws com.liferay.portlet.ratings.NoSuchEntryException if a matching ratings entry could not be found
578             * @throws SystemException if a system exception occurred
579             */
580            public RatingsEntry findByC_C_First(long classNameId, long classPK,
581                    OrderByComparator orderByComparator)
582                    throws NoSuchEntryException, SystemException {
583                    List<RatingsEntry> list = findByC_C(classNameId, classPK, 0, 1,
584                                    orderByComparator);
585    
586                    if (list.isEmpty()) {
587                            StringBundler msg = new StringBundler(6);
588    
589                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
590    
591                            msg.append("classNameId=");
592                            msg.append(classNameId);
593    
594                            msg.append(", classPK=");
595                            msg.append(classPK);
596    
597                            msg.append(StringPool.CLOSE_CURLY_BRACE);
598    
599                            throw new NoSuchEntryException(msg.toString());
600                    }
601                    else {
602                            return list.get(0);
603                    }
604            }
605    
606            /**
607             * Finds the last ratings entry in the ordered set where classNameId = &#63; and classPK = &#63;.
608             *
609             * <p>
610             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
611             * </p>
612             *
613             * @param classNameId the class name id to search with
614             * @param classPK the class p k to search with
615             * @param orderByComparator the comparator to order the set by
616             * @return the last matching ratings entry
617             * @throws com.liferay.portlet.ratings.NoSuchEntryException if a matching ratings entry could not be found
618             * @throws SystemException if a system exception occurred
619             */
620            public RatingsEntry findByC_C_Last(long classNameId, long classPK,
621                    OrderByComparator orderByComparator)
622                    throws NoSuchEntryException, SystemException {
623                    int count = countByC_C(classNameId, classPK);
624    
625                    List<RatingsEntry> list = findByC_C(classNameId, classPK, count - 1,
626                                    count, orderByComparator);
627    
628                    if (list.isEmpty()) {
629                            StringBundler msg = new StringBundler(6);
630    
631                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
632    
633                            msg.append("classNameId=");
634                            msg.append(classNameId);
635    
636                            msg.append(", classPK=");
637                            msg.append(classPK);
638    
639                            msg.append(StringPool.CLOSE_CURLY_BRACE);
640    
641                            throw new NoSuchEntryException(msg.toString());
642                    }
643                    else {
644                            return list.get(0);
645                    }
646            }
647    
648            /**
649             * Finds the ratings entries before and after the current ratings entry in the ordered set where classNameId = &#63; and classPK = &#63;.
650             *
651             * <p>
652             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
653             * </p>
654             *
655             * @param entryId the primary key of the current ratings entry
656             * @param classNameId the class name id to search with
657             * @param classPK the class p k to search with
658             * @param orderByComparator the comparator to order the set by
659             * @return the previous, current, and next ratings entry
660             * @throws com.liferay.portlet.ratings.NoSuchEntryException if a ratings entry with the primary key could not be found
661             * @throws SystemException if a system exception occurred
662             */
663            public RatingsEntry[] findByC_C_PrevAndNext(long entryId, long classNameId,
664                    long classPK, OrderByComparator orderByComparator)
665                    throws NoSuchEntryException, SystemException {
666                    RatingsEntry ratingsEntry = findByPrimaryKey(entryId);
667    
668                    Session session = null;
669    
670                    try {
671                            session = openSession();
672    
673                            RatingsEntry[] array = new RatingsEntryImpl[3];
674    
675                            array[0] = getByC_C_PrevAndNext(session, ratingsEntry, classNameId,
676                                            classPK, orderByComparator, true);
677    
678                            array[1] = ratingsEntry;
679    
680                            array[2] = getByC_C_PrevAndNext(session, ratingsEntry, classNameId,
681                                            classPK, orderByComparator, false);
682    
683                            return array;
684                    }
685                    catch (Exception e) {
686                            throw processException(e);
687                    }
688                    finally {
689                            closeSession(session);
690                    }
691            }
692    
693            protected RatingsEntry getByC_C_PrevAndNext(Session session,
694                    RatingsEntry ratingsEntry, long classNameId, long classPK,
695                    OrderByComparator orderByComparator, boolean previous) {
696                    StringBundler query = null;
697    
698                    if (orderByComparator != null) {
699                            query = new StringBundler(6 +
700                                            (orderByComparator.getOrderByFields().length * 6));
701                    }
702                    else {
703                            query = new StringBundler(3);
704                    }
705    
706                    query.append(_SQL_SELECT_RATINGSENTRY_WHERE);
707    
708                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
709    
710                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
711    
712                    if (orderByComparator != null) {
713                            String[] orderByFields = orderByComparator.getOrderByFields();
714    
715                            if (orderByFields.length > 0) {
716                                    query.append(WHERE_AND);
717                            }
718    
719                            for (int i = 0; i < orderByFields.length; i++) {
720                                    query.append(_ORDER_BY_ENTITY_ALIAS);
721                                    query.append(orderByFields[i]);
722    
723                                    if ((i + 1) < orderByFields.length) {
724                                            if (orderByComparator.isAscending() ^ previous) {
725                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
726                                            }
727                                            else {
728                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
729                                            }
730                                    }
731                                    else {
732                                            if (orderByComparator.isAscending() ^ previous) {
733                                                    query.append(WHERE_GREATER_THAN);
734                                            }
735                                            else {
736                                                    query.append(WHERE_LESSER_THAN);
737                                            }
738                                    }
739                            }
740    
741                            query.append(ORDER_BY_CLAUSE);
742    
743                            for (int i = 0; i < orderByFields.length; i++) {
744                                    query.append(_ORDER_BY_ENTITY_ALIAS);
745                                    query.append(orderByFields[i]);
746    
747                                    if ((i + 1) < orderByFields.length) {
748                                            if (orderByComparator.isAscending() ^ previous) {
749                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
750                                            }
751                                            else {
752                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
753                                            }
754                                    }
755                                    else {
756                                            if (orderByComparator.isAscending() ^ previous) {
757                                                    query.append(ORDER_BY_ASC);
758                                            }
759                                            else {
760                                                    query.append(ORDER_BY_DESC);
761                                            }
762                                    }
763                            }
764                    }
765    
766                    String sql = query.toString();
767    
768                    Query q = session.createQuery(sql);
769    
770                    q.setFirstResult(0);
771                    q.setMaxResults(2);
772    
773                    QueryPos qPos = QueryPos.getInstance(q);
774    
775                    qPos.add(classNameId);
776    
777                    qPos.add(classPK);
778    
779                    if (orderByComparator != null) {
780                            Object[] values = orderByComparator.getOrderByValues(ratingsEntry);
781    
782                            for (Object value : values) {
783                                    qPos.add(value);
784                            }
785                    }
786    
787                    List<RatingsEntry> list = q.list();
788    
789                    if (list.size() == 2) {
790                            return list.get(1);
791                    }
792                    else {
793                            return null;
794                    }
795            }
796    
797            /**
798             * Finds the ratings entry where userId = &#63; and classNameId = &#63; and classPK = &#63; or throws a {@link com.liferay.portlet.ratings.NoSuchEntryException} if it could not be found.
799             *
800             * @param userId the user id to search with
801             * @param classNameId the class name id to search with
802             * @param classPK the class p k to search with
803             * @return the matching ratings entry
804             * @throws com.liferay.portlet.ratings.NoSuchEntryException if a matching ratings entry could not be found
805             * @throws SystemException if a system exception occurred
806             */
807            public RatingsEntry findByU_C_C(long userId, long classNameId, long classPK)
808                    throws NoSuchEntryException, SystemException {
809                    RatingsEntry ratingsEntry = fetchByU_C_C(userId, classNameId, classPK);
810    
811                    if (ratingsEntry == null) {
812                            StringBundler msg = new StringBundler(8);
813    
814                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
815    
816                            msg.append("userId=");
817                            msg.append(userId);
818    
819                            msg.append(", classNameId=");
820                            msg.append(classNameId);
821    
822                            msg.append(", classPK=");
823                            msg.append(classPK);
824    
825                            msg.append(StringPool.CLOSE_CURLY_BRACE);
826    
827                            if (_log.isWarnEnabled()) {
828                                    _log.warn(msg.toString());
829                            }
830    
831                            throw new NoSuchEntryException(msg.toString());
832                    }
833    
834                    return ratingsEntry;
835            }
836    
837            /**
838             * Finds the ratings entry where userId = &#63; and classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
839             *
840             * @param userId the user id to search with
841             * @param classNameId the class name id to search with
842             * @param classPK the class p k to search with
843             * @return the matching ratings entry, or <code>null</code> if a matching ratings entry could not be found
844             * @throws SystemException if a system exception occurred
845             */
846            public RatingsEntry fetchByU_C_C(long userId, long classNameId, long classPK)
847                    throws SystemException {
848                    return fetchByU_C_C(userId, classNameId, classPK, true);
849            }
850    
851            /**
852             * Finds the ratings entry where userId = &#63; and classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
853             *
854             * @param userId the user id to search with
855             * @param classNameId the class name id to search with
856             * @param classPK the class p k to search with
857             * @return the matching ratings entry, or <code>null</code> if a matching ratings entry could not be found
858             * @throws SystemException if a system exception occurred
859             */
860            public RatingsEntry fetchByU_C_C(long userId, long classNameId,
861                    long classPK, boolean retrieveFromCache) throws SystemException {
862                    Object[] finderArgs = new Object[] { userId, classNameId, classPK };
863    
864                    Object result = null;
865    
866                    if (retrieveFromCache) {
867                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_C_C,
868                                            finderArgs, this);
869                    }
870    
871                    if (result == null) {
872                            StringBundler query = new StringBundler(4);
873    
874                            query.append(_SQL_SELECT_RATINGSENTRY_WHERE);
875    
876                            query.append(_FINDER_COLUMN_U_C_C_USERID_2);
877    
878                            query.append(_FINDER_COLUMN_U_C_C_CLASSNAMEID_2);
879    
880                            query.append(_FINDER_COLUMN_U_C_C_CLASSPK_2);
881    
882                            String sql = query.toString();
883    
884                            Session session = null;
885    
886                            try {
887                                    session = openSession();
888    
889                                    Query q = session.createQuery(sql);
890    
891                                    QueryPos qPos = QueryPos.getInstance(q);
892    
893                                    qPos.add(userId);
894    
895                                    qPos.add(classNameId);
896    
897                                    qPos.add(classPK);
898    
899                                    List<RatingsEntry> list = q.list();
900    
901                                    result = list;
902    
903                                    RatingsEntry ratingsEntry = null;
904    
905                                    if (list.isEmpty()) {
906                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C,
907                                                    finderArgs, list);
908                                    }
909                                    else {
910                                            ratingsEntry = list.get(0);
911    
912                                            cacheResult(ratingsEntry);
913    
914                                            if ((ratingsEntry.getUserId() != userId) ||
915                                                            (ratingsEntry.getClassNameId() != classNameId) ||
916                                                            (ratingsEntry.getClassPK() != classPK)) {
917                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C,
918                                                            finderArgs, ratingsEntry);
919                                            }
920                                    }
921    
922                                    return ratingsEntry;
923                            }
924                            catch (Exception e) {
925                                    throw processException(e);
926                            }
927                            finally {
928                                    if (result == null) {
929                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_U_C_C,
930                                                    finderArgs);
931                                    }
932    
933                                    closeSession(session);
934                            }
935                    }
936                    else {
937                            if (result instanceof List<?>) {
938                                    return null;
939                            }
940                            else {
941                                    return (RatingsEntry)result;
942                            }
943                    }
944            }
945    
946            /**
947             * Finds all the ratings entries.
948             *
949             * @return the ratings entries
950             * @throws SystemException if a system exception occurred
951             */
952            public List<RatingsEntry> findAll() throws SystemException {
953                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
954            }
955    
956            /**
957             * Finds a range of all the ratings entries.
958             *
959             * <p>
960             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
961             * </p>
962             *
963             * @param start the lower bound of the range of ratings entries to return
964             * @param end the upper bound of the range of ratings entries to return (not inclusive)
965             * @return the range of ratings entries
966             * @throws SystemException if a system exception occurred
967             */
968            public List<RatingsEntry> findAll(int start, int end)
969                    throws SystemException {
970                    return findAll(start, end, null);
971            }
972    
973            /**
974             * Finds an ordered range of all the ratings entries.
975             *
976             * <p>
977             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
978             * </p>
979             *
980             * @param start the lower bound of the range of ratings entries to return
981             * @param end the upper bound of the range of ratings entries to return (not inclusive)
982             * @param orderByComparator the comparator to order the results by
983             * @return the ordered range of ratings entries
984             * @throws SystemException if a system exception occurred
985             */
986            public List<RatingsEntry> findAll(int start, int end,
987                    OrderByComparator orderByComparator) throws SystemException {
988                    Object[] finderArgs = new Object[] {
989                                    String.valueOf(start), String.valueOf(end),
990                                    String.valueOf(orderByComparator)
991                            };
992    
993                    List<RatingsEntry> list = (List<RatingsEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
994                                    finderArgs, this);
995    
996                    if (list == null) {
997                            StringBundler query = null;
998                            String sql = null;
999    
1000                            if (orderByComparator != null) {
1001                                    query = new StringBundler(2 +
1002                                                    (orderByComparator.getOrderByFields().length * 3));
1003    
1004                                    query.append(_SQL_SELECT_RATINGSENTRY);
1005    
1006                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1007                                            orderByComparator);
1008    
1009                                    sql = query.toString();
1010                            }
1011                            else {
1012                                    sql = _SQL_SELECT_RATINGSENTRY;
1013                            }
1014    
1015                            Session session = null;
1016    
1017                            try {
1018                                    session = openSession();
1019    
1020                                    Query q = session.createQuery(sql);
1021    
1022                                    if (orderByComparator == null) {
1023                                            list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(),
1024                                                            start, end, false);
1025    
1026                                            Collections.sort(list);
1027                                    }
1028                                    else {
1029                                            list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(),
1030                                                            start, end);
1031                                    }
1032                            }
1033                            catch (Exception e) {
1034                                    throw processException(e);
1035                            }
1036                            finally {
1037                                    if (list == null) {
1038                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
1039                                                    finderArgs);
1040                                    }
1041                                    else {
1042                                            cacheResult(list);
1043    
1044                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
1045                                                    list);
1046                                    }
1047    
1048                                    closeSession(session);
1049                            }
1050                    }
1051    
1052                    return list;
1053            }
1054    
1055            /**
1056             * Removes all the ratings entries where classNameId = &#63; and classPK = &#63; from the database.
1057             *
1058             * @param classNameId the class name id to search with
1059             * @param classPK the class p k to search with
1060             * @throws SystemException if a system exception occurred
1061             */
1062            public void removeByC_C(long classNameId, long classPK)
1063                    throws SystemException {
1064                    for (RatingsEntry ratingsEntry : findByC_C(classNameId, classPK)) {
1065                            remove(ratingsEntry);
1066                    }
1067            }
1068    
1069            /**
1070             * Removes the ratings entry where userId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
1071             *
1072             * @param userId the user id to search with
1073             * @param classNameId the class name id to search with
1074             * @param classPK the class p k to search with
1075             * @throws SystemException if a system exception occurred
1076             */
1077            public void removeByU_C_C(long userId, long classNameId, long classPK)
1078                    throws NoSuchEntryException, SystemException {
1079                    RatingsEntry ratingsEntry = findByU_C_C(userId, classNameId, classPK);
1080    
1081                    remove(ratingsEntry);
1082            }
1083    
1084            /**
1085             * Removes all the ratings entries from the database.
1086             *
1087             * @throws SystemException if a system exception occurred
1088             */
1089            public void removeAll() throws SystemException {
1090                    for (RatingsEntry ratingsEntry : findAll()) {
1091                            remove(ratingsEntry);
1092                    }
1093            }
1094    
1095            /**
1096             * Counts all the ratings entries where classNameId = &#63; and classPK = &#63;.
1097             *
1098             * @param classNameId the class name id to search with
1099             * @param classPK the class p k to search with
1100             * @return the number of matching ratings entries
1101             * @throws SystemException if a system exception occurred
1102             */
1103            public int countByC_C(long classNameId, long classPK)
1104                    throws SystemException {
1105                    Object[] finderArgs = new Object[] { classNameId, classPK };
1106    
1107                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
1108                                    finderArgs, this);
1109    
1110                    if (count == null) {
1111                            StringBundler query = new StringBundler(3);
1112    
1113                            query.append(_SQL_COUNT_RATINGSENTRY_WHERE);
1114    
1115                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1116    
1117                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1118    
1119                            String sql = query.toString();
1120    
1121                            Session session = null;
1122    
1123                            try {
1124                                    session = openSession();
1125    
1126                                    Query q = session.createQuery(sql);
1127    
1128                                    QueryPos qPos = QueryPos.getInstance(q);
1129    
1130                                    qPos.add(classNameId);
1131    
1132                                    qPos.add(classPK);
1133    
1134                                    count = (Long)q.uniqueResult();
1135                            }
1136                            catch (Exception e) {
1137                                    throw processException(e);
1138                            }
1139                            finally {
1140                                    if (count == null) {
1141                                            count = Long.valueOf(0);
1142                                    }
1143    
1144                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
1145                                            count);
1146    
1147                                    closeSession(session);
1148                            }
1149                    }
1150    
1151                    return count.intValue();
1152            }
1153    
1154            /**
1155             * Counts all the ratings entries where userId = &#63; and classNameId = &#63; and classPK = &#63;.
1156             *
1157             * @param userId the user id to search with
1158             * @param classNameId the class name id to search with
1159             * @param classPK the class p k to search with
1160             * @return the number of matching ratings entries
1161             * @throws SystemException if a system exception occurred
1162             */
1163            public int countByU_C_C(long userId, long classNameId, long classPK)
1164                    throws SystemException {
1165                    Object[] finderArgs = new Object[] { userId, classNameId, classPK };
1166    
1167                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_C,
1168                                    finderArgs, this);
1169    
1170                    if (count == null) {
1171                            StringBundler query = new StringBundler(4);
1172    
1173                            query.append(_SQL_COUNT_RATINGSENTRY_WHERE);
1174    
1175                            query.append(_FINDER_COLUMN_U_C_C_USERID_2);
1176    
1177                            query.append(_FINDER_COLUMN_U_C_C_CLASSNAMEID_2);
1178    
1179                            query.append(_FINDER_COLUMN_U_C_C_CLASSPK_2);
1180    
1181                            String sql = query.toString();
1182    
1183                            Session session = null;
1184    
1185                            try {
1186                                    session = openSession();
1187    
1188                                    Query q = session.createQuery(sql);
1189    
1190                                    QueryPos qPos = QueryPos.getInstance(q);
1191    
1192                                    qPos.add(userId);
1193    
1194                                    qPos.add(classNameId);
1195    
1196                                    qPos.add(classPK);
1197    
1198                                    count = (Long)q.uniqueResult();
1199                            }
1200                            catch (Exception e) {
1201                                    throw processException(e);
1202                            }
1203                            finally {
1204                                    if (count == null) {
1205                                            count = Long.valueOf(0);
1206                                    }
1207    
1208                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_C,
1209                                            finderArgs, count);
1210    
1211                                    closeSession(session);
1212                            }
1213                    }
1214    
1215                    return count.intValue();
1216            }
1217    
1218            /**
1219             * Counts all the ratings entries.
1220             *
1221             * @return the number of ratings entries
1222             * @throws SystemException if a system exception occurred
1223             */
1224            public int countAll() throws SystemException {
1225                    Object[] finderArgs = new Object[0];
1226    
1227                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1228                                    finderArgs, this);
1229    
1230                    if (count == null) {
1231                            Session session = null;
1232    
1233                            try {
1234                                    session = openSession();
1235    
1236                                    Query q = session.createQuery(_SQL_COUNT_RATINGSENTRY);
1237    
1238                                    count = (Long)q.uniqueResult();
1239                            }
1240                            catch (Exception e) {
1241                                    throw processException(e);
1242                            }
1243                            finally {
1244                                    if (count == null) {
1245                                            count = Long.valueOf(0);
1246                                    }
1247    
1248                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1249                                            count);
1250    
1251                                    closeSession(session);
1252                            }
1253                    }
1254    
1255                    return count.intValue();
1256            }
1257    
1258            /**
1259             * Initializes the ratings entry persistence.
1260             */
1261            public void afterPropertiesSet() {
1262                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1263                                            com.liferay.portal.util.PropsUtil.get(
1264                                                    "value.object.listener.com.liferay.portlet.ratings.model.RatingsEntry")));
1265    
1266                    if (listenerClassNames.length > 0) {
1267                            try {
1268                                    List<ModelListener<RatingsEntry>> listenersList = new ArrayList<ModelListener<RatingsEntry>>();
1269    
1270                                    for (String listenerClassName : listenerClassNames) {
1271                                            listenersList.add((ModelListener<RatingsEntry>)InstanceFactory.newInstance(
1272                                                            listenerClassName));
1273                                    }
1274    
1275                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1276                            }
1277                            catch (Exception e) {
1278                                    _log.error(e);
1279                            }
1280                    }
1281            }
1282    
1283            public void destroy() {
1284                    EntityCacheUtil.removeCache(RatingsEntryImpl.class.getName());
1285                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1286                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1287            }
1288    
1289            @BeanReference(type = RatingsEntryPersistence.class)
1290            protected RatingsEntryPersistence ratingsEntryPersistence;
1291            @BeanReference(type = RatingsStatsPersistence.class)
1292            protected RatingsStatsPersistence ratingsStatsPersistence;
1293            @BeanReference(type = ResourcePersistence.class)
1294            protected ResourcePersistence resourcePersistence;
1295            @BeanReference(type = UserPersistence.class)
1296            protected UserPersistence userPersistence;
1297            @BeanReference(type = BlogsEntryPersistence.class)
1298            protected BlogsEntryPersistence blogsEntryPersistence;
1299            @BeanReference(type = BlogsStatsUserPersistence.class)
1300            protected BlogsStatsUserPersistence blogsStatsUserPersistence;
1301            @BeanReference(type = SocialEquityLogPersistence.class)
1302            protected SocialEquityLogPersistence socialEquityLogPersistence;
1303            private static final String _SQL_SELECT_RATINGSENTRY = "SELECT ratingsEntry FROM RatingsEntry ratingsEntry";
1304            private static final String _SQL_SELECT_RATINGSENTRY_WHERE = "SELECT ratingsEntry FROM RatingsEntry ratingsEntry WHERE ";
1305            private static final String _SQL_COUNT_RATINGSENTRY = "SELECT COUNT(ratingsEntry) FROM RatingsEntry ratingsEntry";
1306            private static final String _SQL_COUNT_RATINGSENTRY_WHERE = "SELECT COUNT(ratingsEntry) FROM RatingsEntry ratingsEntry WHERE ";
1307            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "ratingsEntry.classNameId = ? AND ";
1308            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "ratingsEntry.classPK = ?";
1309            private static final String _FINDER_COLUMN_U_C_C_USERID_2 = "ratingsEntry.userId = ? AND ";
1310            private static final String _FINDER_COLUMN_U_C_C_CLASSNAMEID_2 = "ratingsEntry.classNameId = ? AND ";
1311            private static final String _FINDER_COLUMN_U_C_C_CLASSPK_2 = "ratingsEntry.classPK = ?";
1312            private static final String _ORDER_BY_ENTITY_ALIAS = "ratingsEntry.";
1313            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No RatingsEntry exists with the primary key ";
1314            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No RatingsEntry exists with the key {";
1315            private static Log _log = LogFactoryUtil.getLog(RatingsEntryPersistenceImpl.class);
1316    }