001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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.getOriginalUserId()),
268                                    new Long(ratingsEntryModelImpl.getOriginalClassNameId()),
269                                    new Long(ratingsEntryModelImpl.getOriginalClassPK())
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                            Session session = null;
506    
507                            try {
508                                    session = openSession();
509    
510                                    StringBundler query = null;
511    
512                                    if (orderByComparator != null) {
513                                            query = new StringBundler(4 +
514                                                            (orderByComparator.getOrderByFields().length * 3));
515                                    }
516                                    else {
517                                            query = new StringBundler(3);
518                                    }
519    
520                                    query.append(_SQL_SELECT_RATINGSENTRY_WHERE);
521    
522                                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
523    
524                                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
525    
526                                    if (orderByComparator != null) {
527                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
528                                                    orderByComparator);
529                                    }
530    
531                                    String sql = query.toString();
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                                            list = new ArrayList<RatingsEntry>();
550                                    }
551    
552                                    cacheResult(list);
553    
554                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_C, finderArgs,
555                                            list);
556    
557                                    closeSession(session);
558                            }
559                    }
560    
561                    return list;
562            }
563    
564            /**
565             * Finds the first ratings entry in the ordered set where classNameId = &#63; and classPK = &#63;.
566             *
567             * <p>
568             * 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.
569             * </p>
570             *
571             * @param classNameId the class name id to search with
572             * @param classPK the class p k to search with
573             * @param orderByComparator the comparator to order the set by
574             * @return the first matching ratings entry
575             * @throws com.liferay.portlet.ratings.NoSuchEntryException if a matching ratings entry could not be found
576             * @throws SystemException if a system exception occurred
577             */
578            public RatingsEntry findByC_C_First(long classNameId, long classPK,
579                    OrderByComparator orderByComparator)
580                    throws NoSuchEntryException, SystemException {
581                    List<RatingsEntry> list = findByC_C(classNameId, classPK, 0, 1,
582                                    orderByComparator);
583    
584                    if (list.isEmpty()) {
585                            StringBundler msg = new StringBundler(6);
586    
587                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
588    
589                            msg.append("classNameId=");
590                            msg.append(classNameId);
591    
592                            msg.append(", classPK=");
593                            msg.append(classPK);
594    
595                            msg.append(StringPool.CLOSE_CURLY_BRACE);
596    
597                            throw new NoSuchEntryException(msg.toString());
598                    }
599                    else {
600                            return list.get(0);
601                    }
602            }
603    
604            /**
605             * Finds the last ratings entry in the ordered set where classNameId = &#63; and classPK = &#63;.
606             *
607             * <p>
608             * 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.
609             * </p>
610             *
611             * @param classNameId the class name id to search with
612             * @param classPK the class p k to search with
613             * @param orderByComparator the comparator to order the set by
614             * @return the last matching ratings entry
615             * @throws com.liferay.portlet.ratings.NoSuchEntryException if a matching ratings entry could not be found
616             * @throws SystemException if a system exception occurred
617             */
618            public RatingsEntry findByC_C_Last(long classNameId, long classPK,
619                    OrderByComparator orderByComparator)
620                    throws NoSuchEntryException, SystemException {
621                    int count = countByC_C(classNameId, classPK);
622    
623                    List<RatingsEntry> list = findByC_C(classNameId, classPK, count - 1,
624                                    count, orderByComparator);
625    
626                    if (list.isEmpty()) {
627                            StringBundler msg = new StringBundler(6);
628    
629                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
630    
631                            msg.append("classNameId=");
632                            msg.append(classNameId);
633    
634                            msg.append(", classPK=");
635                            msg.append(classPK);
636    
637                            msg.append(StringPool.CLOSE_CURLY_BRACE);
638    
639                            throw new NoSuchEntryException(msg.toString());
640                    }
641                    else {
642                            return list.get(0);
643                    }
644            }
645    
646            /**
647             * Finds the ratings entries before and after the current ratings entry in the ordered set where classNameId = &#63; and classPK = &#63;.
648             *
649             * <p>
650             * 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.
651             * </p>
652             *
653             * @param entryId the primary key of the current ratings entry
654             * @param classNameId the class name id to search with
655             * @param classPK the class p k to search with
656             * @param orderByComparator the comparator to order the set by
657             * @return the previous, current, and next ratings entry
658             * @throws com.liferay.portlet.ratings.NoSuchEntryException if a ratings entry with the primary key could not be found
659             * @throws SystemException if a system exception occurred
660             */
661            public RatingsEntry[] findByC_C_PrevAndNext(long entryId, long classNameId,
662                    long classPK, OrderByComparator orderByComparator)
663                    throws NoSuchEntryException, SystemException {
664                    RatingsEntry ratingsEntry = findByPrimaryKey(entryId);
665    
666                    Session session = null;
667    
668                    try {
669                            session = openSession();
670    
671                            RatingsEntry[] array = new RatingsEntryImpl[3];
672    
673                            array[0] = getByC_C_PrevAndNext(session, ratingsEntry, classNameId,
674                                            classPK, orderByComparator, true);
675    
676                            array[1] = ratingsEntry;
677    
678                            array[2] = getByC_C_PrevAndNext(session, ratingsEntry, classNameId,
679                                            classPK, orderByComparator, false);
680    
681                            return array;
682                    }
683                    catch (Exception e) {
684                            throw processException(e);
685                    }
686                    finally {
687                            closeSession(session);
688                    }
689            }
690    
691            protected RatingsEntry getByC_C_PrevAndNext(Session session,
692                    RatingsEntry ratingsEntry, long classNameId, long classPK,
693                    OrderByComparator orderByComparator, boolean previous) {
694                    StringBundler query = null;
695    
696                    if (orderByComparator != null) {
697                            query = new StringBundler(6 +
698                                            (orderByComparator.getOrderByFields().length * 6));
699                    }
700                    else {
701                            query = new StringBundler(3);
702                    }
703    
704                    query.append(_SQL_SELECT_RATINGSENTRY_WHERE);
705    
706                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
707    
708                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
709    
710                    if (orderByComparator != null) {
711                            String[] orderByFields = orderByComparator.getOrderByFields();
712    
713                            if (orderByFields.length > 0) {
714                                    query.append(WHERE_AND);
715                            }
716    
717                            for (int i = 0; i < orderByFields.length; i++) {
718                                    query.append(_ORDER_BY_ENTITY_ALIAS);
719                                    query.append(orderByFields[i]);
720    
721                                    if ((i + 1) < orderByFields.length) {
722                                            if (orderByComparator.isAscending() ^ previous) {
723                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
724                                            }
725                                            else {
726                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
727                                            }
728                                    }
729                                    else {
730                                            if (orderByComparator.isAscending() ^ previous) {
731                                                    query.append(WHERE_GREATER_THAN);
732                                            }
733                                            else {
734                                                    query.append(WHERE_LESSER_THAN);
735                                            }
736                                    }
737                            }
738    
739                            query.append(ORDER_BY_CLAUSE);
740    
741                            for (int i = 0; i < orderByFields.length; i++) {
742                                    query.append(_ORDER_BY_ENTITY_ALIAS);
743                                    query.append(orderByFields[i]);
744    
745                                    if ((i + 1) < orderByFields.length) {
746                                            if (orderByComparator.isAscending() ^ previous) {
747                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
748                                            }
749                                            else {
750                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
751                                            }
752                                    }
753                                    else {
754                                            if (orderByComparator.isAscending() ^ previous) {
755                                                    query.append(ORDER_BY_ASC);
756                                            }
757                                            else {
758                                                    query.append(ORDER_BY_DESC);
759                                            }
760                                    }
761                            }
762                    }
763    
764                    String sql = query.toString();
765    
766                    Query q = session.createQuery(sql);
767    
768                    q.setFirstResult(0);
769                    q.setMaxResults(2);
770    
771                    QueryPos qPos = QueryPos.getInstance(q);
772    
773                    qPos.add(classNameId);
774    
775                    qPos.add(classPK);
776    
777                    if (orderByComparator != null) {
778                            Object[] values = orderByComparator.getOrderByValues(ratingsEntry);
779    
780                            for (Object value : values) {
781                                    qPos.add(value);
782                            }
783                    }
784    
785                    List<RatingsEntry> list = q.list();
786    
787                    if (list.size() == 2) {
788                            return list.get(1);
789                    }
790                    else {
791                            return null;
792                    }
793            }
794    
795            /**
796             * 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.
797             *
798             * @param userId the user id to search with
799             * @param classNameId the class name id to search with
800             * @param classPK the class p k to search with
801             * @return the matching ratings entry
802             * @throws com.liferay.portlet.ratings.NoSuchEntryException if a matching ratings entry could not be found
803             * @throws SystemException if a system exception occurred
804             */
805            public RatingsEntry findByU_C_C(long userId, long classNameId, long classPK)
806                    throws NoSuchEntryException, SystemException {
807                    RatingsEntry ratingsEntry = fetchByU_C_C(userId, classNameId, classPK);
808    
809                    if (ratingsEntry == null) {
810                            StringBundler msg = new StringBundler(8);
811    
812                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
813    
814                            msg.append("userId=");
815                            msg.append(userId);
816    
817                            msg.append(", classNameId=");
818                            msg.append(classNameId);
819    
820                            msg.append(", classPK=");
821                            msg.append(classPK);
822    
823                            msg.append(StringPool.CLOSE_CURLY_BRACE);
824    
825                            if (_log.isWarnEnabled()) {
826                                    _log.warn(msg.toString());
827                            }
828    
829                            throw new NoSuchEntryException(msg.toString());
830                    }
831    
832                    return ratingsEntry;
833            }
834    
835            /**
836             * 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.
837             *
838             * @param userId the user id to search with
839             * @param classNameId the class name id to search with
840             * @param classPK the class p k to search with
841             * @return the matching ratings entry, or <code>null</code> if a matching ratings entry could not be found
842             * @throws SystemException if a system exception occurred
843             */
844            public RatingsEntry fetchByU_C_C(long userId, long classNameId, long classPK)
845                    throws SystemException {
846                    return fetchByU_C_C(userId, classNameId, classPK, true);
847            }
848    
849            /**
850             * 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.
851             *
852             * @param userId the user id to search with
853             * @param classNameId the class name id to search with
854             * @param classPK the class p k to search with
855             * @return the matching ratings entry, or <code>null</code> if a matching ratings entry could not be found
856             * @throws SystemException if a system exception occurred
857             */
858            public RatingsEntry fetchByU_C_C(long userId, long classNameId,
859                    long classPK, boolean retrieveFromCache) throws SystemException {
860                    Object[] finderArgs = new Object[] { userId, classNameId, classPK };
861    
862                    Object result = null;
863    
864                    if (retrieveFromCache) {
865                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_U_C_C,
866                                            finderArgs, this);
867                    }
868    
869                    if (result == null) {
870                            Session session = null;
871    
872                            try {
873                                    session = openSession();
874    
875                                    StringBundler query = new StringBundler(4);
876    
877                                    query.append(_SQL_SELECT_RATINGSENTRY_WHERE);
878    
879                                    query.append(_FINDER_COLUMN_U_C_C_USERID_2);
880    
881                                    query.append(_FINDER_COLUMN_U_C_C_CLASSNAMEID_2);
882    
883                                    query.append(_FINDER_COLUMN_U_C_C_CLASSPK_2);
884    
885                                    String sql = query.toString();
886    
887                                    Query q = session.createQuery(sql);
888    
889                                    QueryPos qPos = QueryPos.getInstance(q);
890    
891                                    qPos.add(userId);
892    
893                                    qPos.add(classNameId);
894    
895                                    qPos.add(classPK);
896    
897                                    List<RatingsEntry> list = q.list();
898    
899                                    result = list;
900    
901                                    RatingsEntry ratingsEntry = null;
902    
903                                    if (list.isEmpty()) {
904                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C,
905                                                    finderArgs, list);
906                                    }
907                                    else {
908                                            ratingsEntry = list.get(0);
909    
910                                            cacheResult(ratingsEntry);
911    
912                                            if ((ratingsEntry.getUserId() != userId) ||
913                                                            (ratingsEntry.getClassNameId() != classNameId) ||
914                                                            (ratingsEntry.getClassPK() != classPK)) {
915                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C,
916                                                            finderArgs, ratingsEntry);
917                                            }
918                                    }
919    
920                                    return ratingsEntry;
921                            }
922                            catch (Exception e) {
923                                    throw processException(e);
924                            }
925                            finally {
926                                    if (result == null) {
927                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_U_C_C,
928                                                    finderArgs, new ArrayList<RatingsEntry>());
929                                    }
930    
931                                    closeSession(session);
932                            }
933                    }
934                    else {
935                            if (result instanceof List<?>) {
936                                    return null;
937                            }
938                            else {
939                                    return (RatingsEntry)result;
940                            }
941                    }
942            }
943    
944            /**
945             * Finds all the ratings entries.
946             *
947             * @return the ratings entries
948             * @throws SystemException if a system exception occurred
949             */
950            public List<RatingsEntry> findAll() throws SystemException {
951                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
952            }
953    
954            /**
955             * Finds a range of all the ratings entries.
956             *
957             * <p>
958             * 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.
959             * </p>
960             *
961             * @param start the lower bound of the range of ratings entries to return
962             * @param end the upper bound of the range of ratings entries to return (not inclusive)
963             * @return the range of ratings entries
964             * @throws SystemException if a system exception occurred
965             */
966            public List<RatingsEntry> findAll(int start, int end)
967                    throws SystemException {
968                    return findAll(start, end, null);
969            }
970    
971            /**
972             * Finds an ordered range of all the ratings entries.
973             *
974             * <p>
975             * 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.
976             * </p>
977             *
978             * @param start the lower bound of the range of ratings entries to return
979             * @param end the upper bound of the range of ratings entries to return (not inclusive)
980             * @param orderByComparator the comparator to order the results by
981             * @return the ordered range of ratings entries
982             * @throws SystemException if a system exception occurred
983             */
984            public List<RatingsEntry> findAll(int start, int end,
985                    OrderByComparator orderByComparator) throws SystemException {
986                    Object[] finderArgs = new Object[] {
987                                    String.valueOf(start), String.valueOf(end),
988                                    String.valueOf(orderByComparator)
989                            };
990    
991                    List<RatingsEntry> list = (List<RatingsEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
992                                    finderArgs, this);
993    
994                    if (list == null) {
995                            Session session = null;
996    
997                            try {
998                                    session = openSession();
999    
1000                                    StringBundler query = null;
1001                                    String sql = null;
1002    
1003                                    if (orderByComparator != null) {
1004                                            query = new StringBundler(2 +
1005                                                            (orderByComparator.getOrderByFields().length * 3));
1006    
1007                                            query.append(_SQL_SELECT_RATINGSENTRY);
1008    
1009                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1010                                                    orderByComparator);
1011    
1012                                            sql = query.toString();
1013                                    }
1014                                    else {
1015                                            sql = _SQL_SELECT_RATINGSENTRY;
1016                                    }
1017    
1018                                    Query q = session.createQuery(sql);
1019    
1020                                    if (orderByComparator == null) {
1021                                            list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(),
1022                                                            start, end, false);
1023    
1024                                            Collections.sort(list);
1025                                    }
1026                                    else {
1027                                            list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(),
1028                                                            start, end);
1029                                    }
1030                            }
1031                            catch (Exception e) {
1032                                    throw processException(e);
1033                            }
1034                            finally {
1035                                    if (list == null) {
1036                                            list = new ArrayList<RatingsEntry>();
1037                                    }
1038    
1039                                    cacheResult(list);
1040    
1041                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1042    
1043                                    closeSession(session);
1044                            }
1045                    }
1046    
1047                    return list;
1048            }
1049    
1050            /**
1051             * Removes all the ratings entries where classNameId = &#63; and classPK = &#63; from the database.
1052             *
1053             * @param classNameId the class name id to search with
1054             * @param classPK the class p k to search with
1055             * @throws SystemException if a system exception occurred
1056             */
1057            public void removeByC_C(long classNameId, long classPK)
1058                    throws SystemException {
1059                    for (RatingsEntry ratingsEntry : findByC_C(classNameId, classPK)) {
1060                            remove(ratingsEntry);
1061                    }
1062            }
1063    
1064            /**
1065             * Removes the ratings entry where userId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
1066             *
1067             * @param userId the user id to search with
1068             * @param classNameId the class name id to search with
1069             * @param classPK the class p k to search with
1070             * @throws SystemException if a system exception occurred
1071             */
1072            public void removeByU_C_C(long userId, long classNameId, long classPK)
1073                    throws NoSuchEntryException, SystemException {
1074                    RatingsEntry ratingsEntry = findByU_C_C(userId, classNameId, classPK);
1075    
1076                    remove(ratingsEntry);
1077            }
1078    
1079            /**
1080             * Removes all the ratings entries from the database.
1081             *
1082             * @throws SystemException if a system exception occurred
1083             */
1084            public void removeAll() throws SystemException {
1085                    for (RatingsEntry ratingsEntry : findAll()) {
1086                            remove(ratingsEntry);
1087                    }
1088            }
1089    
1090            /**
1091             * Counts all the ratings entries where classNameId = &#63; and classPK = &#63;.
1092             *
1093             * @param classNameId the class name id to search with
1094             * @param classPK the class p k to search with
1095             * @return the number of matching ratings entries
1096             * @throws SystemException if a system exception occurred
1097             */
1098            public int countByC_C(long classNameId, long classPK)
1099                    throws SystemException {
1100                    Object[] finderArgs = new Object[] { classNameId, classPK };
1101    
1102                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
1103                                    finderArgs, this);
1104    
1105                    if (count == null) {
1106                            Session session = null;
1107    
1108                            try {
1109                                    session = openSession();
1110    
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                                    Query q = session.createQuery(sql);
1122    
1123                                    QueryPos qPos = QueryPos.getInstance(q);
1124    
1125                                    qPos.add(classNameId);
1126    
1127                                    qPos.add(classPK);
1128    
1129                                    count = (Long)q.uniqueResult();
1130                            }
1131                            catch (Exception e) {
1132                                    throw processException(e);
1133                            }
1134                            finally {
1135                                    if (count == null) {
1136                                            count = Long.valueOf(0);
1137                                    }
1138    
1139                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
1140                                            count);
1141    
1142                                    closeSession(session);
1143                            }
1144                    }
1145    
1146                    return count.intValue();
1147            }
1148    
1149            /**
1150             * Counts all the ratings entries where userId = &#63; and classNameId = &#63; and classPK = &#63;.
1151             *
1152             * @param userId the user id to search with
1153             * @param classNameId the class name id to search with
1154             * @param classPK the class p k to search with
1155             * @return the number of matching ratings entries
1156             * @throws SystemException if a system exception occurred
1157             */
1158            public int countByU_C_C(long userId, long classNameId, long classPK)
1159                    throws SystemException {
1160                    Object[] finderArgs = new Object[] { userId, classNameId, classPK };
1161    
1162                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_U_C_C,
1163                                    finderArgs, this);
1164    
1165                    if (count == null) {
1166                            Session session = null;
1167    
1168                            try {
1169                                    session = openSession();
1170    
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                                    Query q = session.createQuery(sql);
1184    
1185                                    QueryPos qPos = QueryPos.getInstance(q);
1186    
1187                                    qPos.add(userId);
1188    
1189                                    qPos.add(classNameId);
1190    
1191                                    qPos.add(classPK);
1192    
1193                                    count = (Long)q.uniqueResult();
1194                            }
1195                            catch (Exception e) {
1196                                    throw processException(e);
1197                            }
1198                            finally {
1199                                    if (count == null) {
1200                                            count = Long.valueOf(0);
1201                                    }
1202    
1203                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_U_C_C,
1204                                            finderArgs, count);
1205    
1206                                    closeSession(session);
1207                            }
1208                    }
1209    
1210                    return count.intValue();
1211            }
1212    
1213            /**
1214             * Counts all the ratings entries.
1215             *
1216             * @return the number of ratings entries
1217             * @throws SystemException if a system exception occurred
1218             */
1219            public int countAll() throws SystemException {
1220                    Object[] finderArgs = new Object[0];
1221    
1222                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1223                                    finderArgs, this);
1224    
1225                    if (count == null) {
1226                            Session session = null;
1227    
1228                            try {
1229                                    session = openSession();
1230    
1231                                    Query q = session.createQuery(_SQL_COUNT_RATINGSENTRY);
1232    
1233                                    count = (Long)q.uniqueResult();
1234                            }
1235                            catch (Exception e) {
1236                                    throw processException(e);
1237                            }
1238                            finally {
1239                                    if (count == null) {
1240                                            count = Long.valueOf(0);
1241                                    }
1242    
1243                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1244                                            count);
1245    
1246                                    closeSession(session);
1247                            }
1248                    }
1249    
1250                    return count.intValue();
1251            }
1252    
1253            /**
1254             * Initializes the ratings entry persistence.
1255             */
1256            public void afterPropertiesSet() {
1257                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1258                                            com.liferay.portal.util.PropsUtil.get(
1259                                                    "value.object.listener.com.liferay.portlet.ratings.model.RatingsEntry")));
1260    
1261                    if (listenerClassNames.length > 0) {
1262                            try {
1263                                    List<ModelListener<RatingsEntry>> listenersList = new ArrayList<ModelListener<RatingsEntry>>();
1264    
1265                                    for (String listenerClassName : listenerClassNames) {
1266                                            listenersList.add((ModelListener<RatingsEntry>)InstanceFactory.newInstance(
1267                                                            listenerClassName));
1268                                    }
1269    
1270                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1271                            }
1272                            catch (Exception e) {
1273                                    _log.error(e);
1274                            }
1275                    }
1276            }
1277    
1278            public void destroy() {
1279                    EntityCacheUtil.removeCache(RatingsEntryImpl.class.getName());
1280                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1281                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1282            }
1283    
1284            @BeanReference(type = RatingsEntryPersistence.class)
1285            protected RatingsEntryPersistence ratingsEntryPersistence;
1286            @BeanReference(type = RatingsStatsPersistence.class)
1287            protected RatingsStatsPersistence ratingsStatsPersistence;
1288            @BeanReference(type = ResourcePersistence.class)
1289            protected ResourcePersistence resourcePersistence;
1290            @BeanReference(type = UserPersistence.class)
1291            protected UserPersistence userPersistence;
1292            @BeanReference(type = BlogsEntryPersistence.class)
1293            protected BlogsEntryPersistence blogsEntryPersistence;
1294            @BeanReference(type = BlogsStatsUserPersistence.class)
1295            protected BlogsStatsUserPersistence blogsStatsUserPersistence;
1296            @BeanReference(type = SocialEquityLogPersistence.class)
1297            protected SocialEquityLogPersistence socialEquityLogPersistence;
1298            private static final String _SQL_SELECT_RATINGSENTRY = "SELECT ratingsEntry FROM RatingsEntry ratingsEntry";
1299            private static final String _SQL_SELECT_RATINGSENTRY_WHERE = "SELECT ratingsEntry FROM RatingsEntry ratingsEntry WHERE ";
1300            private static final String _SQL_COUNT_RATINGSENTRY = "SELECT COUNT(ratingsEntry) FROM RatingsEntry ratingsEntry";
1301            private static final String _SQL_COUNT_RATINGSENTRY_WHERE = "SELECT COUNT(ratingsEntry) FROM RatingsEntry ratingsEntry WHERE ";
1302            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "ratingsEntry.classNameId = ? AND ";
1303            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "ratingsEntry.classPK = ?";
1304            private static final String _FINDER_COLUMN_U_C_C_USERID_2 = "ratingsEntry.userId = ? AND ";
1305            private static final String _FINDER_COLUMN_U_C_C_CLASSNAMEID_2 = "ratingsEntry.classNameId = ? AND ";
1306            private static final String _FINDER_COLUMN_U_C_C_CLASSPK_2 = "ratingsEntry.classPK = ?";
1307            private static final String _ORDER_BY_ENTITY_ALIAS = "ratingsEntry.";
1308            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No RatingsEntry exists with the primary key ";
1309            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No RatingsEntry exists with the key {";
1310            private static Log _log = LogFactoryUtil.getLog(RatingsEntryPersistenceImpl.class);
1311    }