/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.portlet.ratings.service.persistence.impl; import aQute.bnd.annotation.ProviderType; import com.liferay.portal.kernel.bean.BeanReference; import com.liferay.portal.kernel.dao.orm.EntityCache; import com.liferay.portal.kernel.dao.orm.EntityCacheUtil; import com.liferay.portal.kernel.dao.orm.FinderCache; import com.liferay.portal.kernel.dao.orm.FinderCacheUtil; import com.liferay.portal.kernel.dao.orm.FinderPath; import com.liferay.portal.kernel.dao.orm.Query; import com.liferay.portal.kernel.dao.orm.QueryPos; import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.dao.orm.Session; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.service.ServiceContext; import com.liferay.portal.kernel.service.ServiceContextThreadLocal; import com.liferay.portal.kernel.service.persistence.CompanyProvider; import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper; import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl; import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.util.ReflectionUtil; import com.liferay.portal.kernel.util.SetUtil; import com.liferay.portal.kernel.util.StringBundler; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.uuid.PortalUUIDUtil; import com.liferay.portlet.ratings.model.impl.RatingsEntryImpl; import com.liferay.portlet.ratings.model.impl.RatingsEntryModelImpl; import com.liferay.ratings.kernel.exception.NoSuchEntryException; import com.liferay.ratings.kernel.model.RatingsEntry; import com.liferay.ratings.kernel.service.persistence.RatingsEntryPersistence; import java.io.Serializable; import java.lang.reflect.Field; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; /** * The persistence implementation for the ratings entry service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author Brian Wing Shun Chan * @see RatingsEntryPersistence * @see com.liferay.ratings.kernel.service.persistence.RatingsEntryUtil * @generated */ @ProviderType public class RatingsEntryPersistenceImpl extends BasePersistenceImpl<RatingsEntry> implements RatingsEntryPersistence { /* * NOTE FOR DEVELOPERS: * * 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. */ public static final String FINDER_CLASS_NAME_ENTITY = RatingsEntryImpl.class.getName(); public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List1"; public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List2"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, RatingsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, RatingsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, RatingsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, RatingsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid", new String[] { String.class.getName() }, RatingsEntryModelImpl.UUID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid", new String[] { String.class.getName() }); /** * Returns all the ratings entries where uuid = ?. * * @param uuid the uuid * @return the matching ratings entries */ @Override public List<RatingsEntry> findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ratings entries where uuid = ?. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @return the range of matching ratings entries */ @Override public List<RatingsEntry> findByUuid(String uuid, int start, int end) { return findByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the ratings entries where uuid = ?. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching ratings entries */ @Override public List<RatingsEntry> findByUuid(String uuid, int start, int end, OrderByComparator<RatingsEntry> orderByComparator) { return findByUuid(uuid, start, end, orderByComparator, true); } /** * Returns an ordered range of all the ratings entries where uuid = ?. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching ratings entries */ @Override public List<RatingsEntry> findByUuid(String uuid, int start, int end, OrderByComparator<RatingsEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID; finderArgs = new Object[] { uuid }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID; finderArgs = new Object[] { uuid, start, end, orderByComparator }; } List<RatingsEntry> list = null; if (retrieveFromCache) { list = (List<RatingsEntry>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (RatingsEntry ratingsEntry : list) { if (!Objects.equals(uuid, ratingsEntry.getUuid())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_RATINGSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(RatingsEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } if (!pagination) { list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first ratings entry in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching ratings entry * @throws NoSuchEntryException if a matching ratings entry could not be found */ @Override public RatingsEntry findByUuid_First(String uuid, OrderByComparator<RatingsEntry> orderByComparator) throws NoSuchEntryException { RatingsEntry ratingsEntry = fetchByUuid_First(uuid, orderByComparator); if (ratingsEntry != null) { return ratingsEntry; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } /** * Returns the first ratings entry in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching ratings entry, or <code>null</code> if a matching ratings entry could not be found */ @Override public RatingsEntry fetchByUuid_First(String uuid, OrderByComparator<RatingsEntry> orderByComparator) { List<RatingsEntry> list = findByUuid(uuid, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last ratings entry in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching ratings entry * @throws NoSuchEntryException if a matching ratings entry could not be found */ @Override public RatingsEntry findByUuid_Last(String uuid, OrderByComparator<RatingsEntry> orderByComparator) throws NoSuchEntryException { RatingsEntry ratingsEntry = fetchByUuid_Last(uuid, orderByComparator); if (ratingsEntry != null) { return ratingsEntry; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } /** * Returns the last ratings entry in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching ratings entry, or <code>null</code> if a matching ratings entry could not be found */ @Override public RatingsEntry fetchByUuid_Last(String uuid, OrderByComparator<RatingsEntry> orderByComparator) { int count = countByUuid(uuid); if (count == 0) { return null; } List<RatingsEntry> list = findByUuid(uuid, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the ratings entries before and after the current ratings entry in the ordered set where uuid = ?. * * @param entryId the primary key of the current ratings entry * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next ratings entry * @throws NoSuchEntryException if a ratings entry with the primary key could not be found */ @Override public RatingsEntry[] findByUuid_PrevAndNext(long entryId, String uuid, OrderByComparator<RatingsEntry> orderByComparator) throws NoSuchEntryException { RatingsEntry ratingsEntry = findByPrimaryKey(entryId); Session session = null; try { session = openSession(); RatingsEntry[] array = new RatingsEntryImpl[3]; array[0] = getByUuid_PrevAndNext(session, ratingsEntry, uuid, orderByComparator, true); array[1] = ratingsEntry; array[2] = getByUuid_PrevAndNext(session, ratingsEntry, uuid, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected RatingsEntry getByUuid_PrevAndNext(Session session, RatingsEntry ratingsEntry, String uuid, OrderByComparator<RatingsEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_RATINGSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(RatingsEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(ratingsEntry); for (Object value : values) { qPos.add(value); } } List<RatingsEntry> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the ratings entries where uuid = ? from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (RatingsEntry ratingsEntry : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ratingsEntry); } } /** * Returns the number of ratings entries where uuid = ?. * * @param uuid the uuid * @return the number of matching ratings entries */ @Override public int countByUuid(String uuid) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID; Object[] finderArgs = new Object[] { uuid }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_RATINGSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_UUID_1 = "ratingsEntry.uuid IS NULL"; private static final String _FINDER_COLUMN_UUID_UUID_2 = "ratingsEntry.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(ratingsEntry.uuid IS NULL OR ratingsEntry.uuid = '')"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, RatingsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, RatingsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName() }, RatingsEntryModelImpl.UUID_COLUMN_BITMASK | RatingsEntryModelImpl.COMPANYID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C", new String[] { String.class.getName(), Long.class.getName() }); /** * Returns all the ratings entries where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching ratings entries */ @Override public List<RatingsEntry> findByUuid_C(String uuid, long companyId) { return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ratings entries where uuid = ? and companyId = ?. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @return the range of matching ratings entries */ @Override public List<RatingsEntry> findByUuid_C(String uuid, long companyId, int start, int end) { return findByUuid_C(uuid, companyId, start, end, null); } /** * Returns an ordered range of all the ratings entries where uuid = ? and companyId = ?. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching ratings entries */ @Override public List<RatingsEntry> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<RatingsEntry> orderByComparator) { return findByUuid_C(uuid, companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the ratings entries where uuid = ? and companyId = ?. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching ratings entries */ @Override public List<RatingsEntry> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<RatingsEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C; finderArgs = new Object[] { uuid, companyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C; finderArgs = new Object[] { uuid, companyId, start, end, orderByComparator }; } List<RatingsEntry> list = null; if (retrieveFromCache) { list = (List<RatingsEntry>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (RatingsEntry ratingsEntry : list) { if (!Objects.equals(uuid, ratingsEntry.getUuid()) || (companyId != ratingsEntry.getCompanyId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_RATINGSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(RatingsEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); if (!pagination) { list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first ratings entry in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching ratings entry * @throws NoSuchEntryException if a matching ratings entry could not be found */ @Override public RatingsEntry findByUuid_C_First(String uuid, long companyId, OrderByComparator<RatingsEntry> orderByComparator) throws NoSuchEntryException { RatingsEntry ratingsEntry = fetchByUuid_C_First(uuid, companyId, orderByComparator); if (ratingsEntry != null) { return ratingsEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } /** * Returns the first ratings entry in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching ratings entry, or <code>null</code> if a matching ratings entry could not be found */ @Override public RatingsEntry fetchByUuid_C_First(String uuid, long companyId, OrderByComparator<RatingsEntry> orderByComparator) { List<RatingsEntry> list = findByUuid_C(uuid, companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last ratings entry in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching ratings entry * @throws NoSuchEntryException if a matching ratings entry could not be found */ @Override public RatingsEntry findByUuid_C_Last(String uuid, long companyId, OrderByComparator<RatingsEntry> orderByComparator) throws NoSuchEntryException { RatingsEntry ratingsEntry = fetchByUuid_C_Last(uuid, companyId, orderByComparator); if (ratingsEntry != null) { return ratingsEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } /** * Returns the last ratings entry in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching ratings entry, or <code>null</code> if a matching ratings entry could not be found */ @Override public RatingsEntry fetchByUuid_C_Last(String uuid, long companyId, OrderByComparator<RatingsEntry> orderByComparator) { int count = countByUuid_C(uuid, companyId); if (count == 0) { return null; } List<RatingsEntry> list = findByUuid_C(uuid, companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the ratings entries before and after the current ratings entry in the ordered set where uuid = ? and companyId = ?. * * @param entryId the primary key of the current ratings entry * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next ratings entry * @throws NoSuchEntryException if a ratings entry with the primary key could not be found */ @Override public RatingsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid, long companyId, OrderByComparator<RatingsEntry> orderByComparator) throws NoSuchEntryException { RatingsEntry ratingsEntry = findByPrimaryKey(entryId); Session session = null; try { session = openSession(); RatingsEntry[] array = new RatingsEntryImpl[3]; array[0] = getByUuid_C_PrevAndNext(session, ratingsEntry, uuid, companyId, orderByComparator, true); array[1] = ratingsEntry; array[2] = getByUuid_C_PrevAndNext(session, ratingsEntry, uuid, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected RatingsEntry getByUuid_C_PrevAndNext(Session session, RatingsEntry ratingsEntry, String uuid, long companyId, OrderByComparator<RatingsEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_RATINGSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(RatingsEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(ratingsEntry); for (Object value : values) { qPos.add(value); } } List<RatingsEntry> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the ratings entries where uuid = ? and companyId = ? from the database. * * @param uuid the uuid * @param companyId the company ID */ @Override public void removeByUuid_C(String uuid, long companyId) { for (RatingsEntry ratingsEntry : findByUuid_C(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ratingsEntry); } } /** * Returns the number of ratings entries where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching ratings entries */ @Override public int countByUuid_C(String uuid, long companyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C; Object[] finderArgs = new Object[] { uuid, companyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_RATINGSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "ratingsEntry.uuid IS NULL AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "ratingsEntry.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(ratingsEntry.uuid IS NULL OR ratingsEntry.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "ratingsEntry.companyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, RatingsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, RatingsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C", new String[] { Long.class.getName(), Long.class.getName() }, RatingsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK | RatingsEntryModelImpl.CLASSPK_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the ratings entries where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @return the matching ratings entries */ @Override public List<RatingsEntry> findByC_C(long classNameId, long classPK) { return findByC_C(classNameId, classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ratings entries where classNameId = ? and classPK = ?. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param classNameId the class name ID * @param classPK the class pk * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @return the range of matching ratings entries */ @Override public List<RatingsEntry> findByC_C(long classNameId, long classPK, int start, int end) { return findByC_C(classNameId, classPK, start, end, null); } /** * Returns an ordered range of all the ratings entries where classNameId = ? and classPK = ?. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param classNameId the class name ID * @param classPK the class pk * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching ratings entries */ @Override public List<RatingsEntry> findByC_C(long classNameId, long classPK, int start, int end, OrderByComparator<RatingsEntry> orderByComparator) { return findByC_C(classNameId, classPK, start, end, orderByComparator, true); } /** * Returns an ordered range of all the ratings entries where classNameId = ? and classPK = ?. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param classNameId the class name ID * @param classPK the class pk * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching ratings entries */ @Override public List<RatingsEntry> findByC_C(long classNameId, long classPK, int start, int end, OrderByComparator<RatingsEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C; finderArgs = new Object[] { classNameId, classPK }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C; finderArgs = new Object[] { classNameId, classPK, start, end, orderByComparator }; } List<RatingsEntry> list = null; if (retrieveFromCache) { list = (List<RatingsEntry>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (RatingsEntry ratingsEntry : list) { if ((classNameId != ratingsEntry.getClassNameId()) || (classPK != ratingsEntry.getClassPK())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_RATINGSENTRY_WHERE); query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_CLASSPK_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(RatingsEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(classNameId); qPos.add(classPK); if (!pagination) { list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first ratings entry in the ordered set where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching ratings entry * @throws NoSuchEntryException if a matching ratings entry could not be found */ @Override public RatingsEntry findByC_C_First(long classNameId, long classPK, OrderByComparator<RatingsEntry> orderByComparator) throws NoSuchEntryException { RatingsEntry ratingsEntry = fetchByC_C_First(classNameId, classPK, orderByComparator); if (ratingsEntry != null) { return ratingsEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } /** * Returns the first ratings entry in the ordered set where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching ratings entry, or <code>null</code> if a matching ratings entry could not be found */ @Override public RatingsEntry fetchByC_C_First(long classNameId, long classPK, OrderByComparator<RatingsEntry> orderByComparator) { List<RatingsEntry> list = findByC_C(classNameId, classPK, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last ratings entry in the ordered set where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching ratings entry * @throws NoSuchEntryException if a matching ratings entry could not be found */ @Override public RatingsEntry findByC_C_Last(long classNameId, long classPK, OrderByComparator<RatingsEntry> orderByComparator) throws NoSuchEntryException { RatingsEntry ratingsEntry = fetchByC_C_Last(classNameId, classPK, orderByComparator); if (ratingsEntry != null) { return ratingsEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } /** * Returns the last ratings entry in the ordered set where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching ratings entry, or <code>null</code> if a matching ratings entry could not be found */ @Override public RatingsEntry fetchByC_C_Last(long classNameId, long classPK, OrderByComparator<RatingsEntry> orderByComparator) { int count = countByC_C(classNameId, classPK); if (count == 0) { return null; } List<RatingsEntry> list = findByC_C(classNameId, classPK, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the ratings entries before and after the current ratings entry in the ordered set where classNameId = ? and classPK = ?. * * @param entryId the primary key of the current ratings entry * @param classNameId the class name ID * @param classPK the class pk * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next ratings entry * @throws NoSuchEntryException if a ratings entry with the primary key could not be found */ @Override public RatingsEntry[] findByC_C_PrevAndNext(long entryId, long classNameId, long classPK, OrderByComparator<RatingsEntry> orderByComparator) throws NoSuchEntryException { RatingsEntry ratingsEntry = findByPrimaryKey(entryId); Session session = null; try { session = openSession(); RatingsEntry[] array = new RatingsEntryImpl[3]; array[0] = getByC_C_PrevAndNext(session, ratingsEntry, classNameId, classPK, orderByComparator, true); array[1] = ratingsEntry; array[2] = getByC_C_PrevAndNext(session, ratingsEntry, classNameId, classPK, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected RatingsEntry getByC_C_PrevAndNext(Session session, RatingsEntry ratingsEntry, long classNameId, long classPK, OrderByComparator<RatingsEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_RATINGSENTRY_WHERE); query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_CLASSPK_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(RatingsEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(classNameId); qPos.add(classPK); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(ratingsEntry); for (Object value : values) { qPos.add(value); } } List<RatingsEntry> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the ratings entries where classNameId = ? and classPK = ? from the database. * * @param classNameId the class name ID * @param classPK the class pk */ @Override public void removeByC_C(long classNameId, long classPK) { for (RatingsEntry ratingsEntry : findByC_C(classNameId, classPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ratingsEntry); } } /** * Returns the number of ratings entries where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @return the number of matching ratings entries */ @Override public int countByC_C(long classNameId, long classPK) { FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C; Object[] finderArgs = new Object[] { classNameId, classPK }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_RATINGSENTRY_WHERE); query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_CLASSPK_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(classNameId); qPos.add(classPK); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "ratingsEntry.classNameId = ? AND "; private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "ratingsEntry.classPK = ?"; public static final FinderPath FINDER_PATH_FETCH_BY_U_C_C = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, RatingsEntryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByU_C_C", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }, RatingsEntryModelImpl.USERID_COLUMN_BITMASK | RatingsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK | RatingsEntryModelImpl.CLASSPK_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C_C", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }); /** * Returns the ratings entry where userId = ? and classNameId = ? and classPK = ? or throws a {@link NoSuchEntryException} if it could not be found. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @return the matching ratings entry * @throws NoSuchEntryException if a matching ratings entry could not be found */ @Override public RatingsEntry findByU_C_C(long userId, long classNameId, long classPK) throws NoSuchEntryException { RatingsEntry ratingsEntry = fetchByU_C_C(userId, classNameId, classPK); if (ratingsEntry == null) { StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(", classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(StringPool.CLOSE_CURLY_BRACE); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchEntryException(msg.toString()); } return ratingsEntry; } /** * Returns the ratings entry where userId = ? and classNameId = ? and classPK = ? or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @return the matching ratings entry, or <code>null</code> if a matching ratings entry could not be found */ @Override public RatingsEntry fetchByU_C_C(long userId, long classNameId, long classPK) { return fetchByU_C_C(userId, classNameId, classPK, true); } /** * Returns the ratings entry where userId = ? and classNameId = ? and classPK = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching ratings entry, or <code>null</code> if a matching ratings entry could not be found */ @Override public RatingsEntry fetchByU_C_C(long userId, long classNameId, long classPK, boolean retrieveFromCache) { Object[] finderArgs = new Object[] { userId, classNameId, classPK }; Object result = null; if (retrieveFromCache) { result = finderCache.getResult(FINDER_PATH_FETCH_BY_U_C_C, finderArgs, this); } if (result instanceof RatingsEntry) { RatingsEntry ratingsEntry = (RatingsEntry)result; if ((userId != ratingsEntry.getUserId()) || (classNameId != ratingsEntry.getClassNameId()) || (classPK != ratingsEntry.getClassPK())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(5); query.append(_SQL_SELECT_RATINGSENTRY_WHERE); query.append(_FINDER_COLUMN_U_C_C_USERID_2); query.append(_FINDER_COLUMN_U_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_U_C_C_CLASSPK_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(classNameId); qPos.add(classPK); List<RatingsEntry> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_U_C_C, finderArgs, list); } else { RatingsEntry ratingsEntry = list.get(0); result = ratingsEntry; cacheResult(ratingsEntry); if ((ratingsEntry.getUserId() != userId) || (ratingsEntry.getClassNameId() != classNameId) || (ratingsEntry.getClassPK() != classPK)) { finderCache.putResult(FINDER_PATH_FETCH_BY_U_C_C, finderArgs, ratingsEntry); } } } catch (Exception e) { finderCache.removeResult(FINDER_PATH_FETCH_BY_U_C_C, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (RatingsEntry)result; } } /** * Removes the ratings entry where userId = ? and classNameId = ? and classPK = ? from the database. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @return the ratings entry that was removed */ @Override public RatingsEntry removeByU_C_C(long userId, long classNameId, long classPK) throws NoSuchEntryException { RatingsEntry ratingsEntry = findByU_C_C(userId, classNameId, classPK); return remove(ratingsEntry); } /** * Returns the number of ratings entries where userId = ? and classNameId = ? and classPK = ?. * * @param userId the user ID * @param classNameId the class name ID * @param classPK the class pk * @return the number of matching ratings entries */ @Override public int countByU_C_C(long userId, long classNameId, long classPK) { FinderPath finderPath = FINDER_PATH_COUNT_BY_U_C_C; Object[] finderArgs = new Object[] { userId, classNameId, classPK }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_RATINGSENTRY_WHERE); query.append(_FINDER_COLUMN_U_C_C_USERID_2); query.append(_FINDER_COLUMN_U_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_U_C_C_CLASSPK_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(classNameId); qPos.add(classPK); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_U_C_C_USERID_2 = "ratingsEntry.userId = ? AND "; private static final String _FINDER_COLUMN_U_C_C_CLASSNAMEID_2 = "ratingsEntry.classNameId = ? AND "; private static final String _FINDER_COLUMN_U_C_C_CLASSPK_2 = "ratingsEntry.classPK = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_S = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, RatingsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_S", new String[] { Long.class.getName(), Long.class.getName(), Double.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, RatingsEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_S", new String[] { Long.class.getName(), Long.class.getName(), Double.class.getName() }, RatingsEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK | RatingsEntryModelImpl.CLASSPK_COLUMN_BITMASK | RatingsEntryModelImpl.SCORE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_C_C_S = new FinderPath(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_S", new String[] { Long.class.getName(), Long.class.getName(), Double.class.getName() }); /** * Returns all the ratings entries where classNameId = ? and classPK = ? and score = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param score the score * @return the matching ratings entries */ @Override public List<RatingsEntry> findByC_C_S(long classNameId, long classPK, double score) { return findByC_C_S(classNameId, classPK, score, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ratings entries where classNameId = ? and classPK = ? and score = ?. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param classNameId the class name ID * @param classPK the class pk * @param score the score * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @return the range of matching ratings entries */ @Override public List<RatingsEntry> findByC_C_S(long classNameId, long classPK, double score, int start, int end) { return findByC_C_S(classNameId, classPK, score, start, end, null); } /** * Returns an ordered range of all the ratings entries where classNameId = ? and classPK = ? and score = ?. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param classNameId the class name ID * @param classPK the class pk * @param score the score * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching ratings entries */ @Override public List<RatingsEntry> findByC_C_S(long classNameId, long classPK, double score, int start, int end, OrderByComparator<RatingsEntry> orderByComparator) { return findByC_C_S(classNameId, classPK, score, start, end, orderByComparator, true); } /** * Returns an ordered range of all the ratings entries where classNameId = ? and classPK = ? and score = ?. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param classNameId the class name ID * @param classPK the class pk * @param score the score * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching ratings entries */ @Override public List<RatingsEntry> findByC_C_S(long classNameId, long classPK, double score, int start, int end, OrderByComparator<RatingsEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S; finderArgs = new Object[] { classNameId, classPK, score }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_S; finderArgs = new Object[] { classNameId, classPK, score, start, end, orderByComparator }; } List<RatingsEntry> list = null; if (retrieveFromCache) { list = (List<RatingsEntry>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (RatingsEntry ratingsEntry : list) { if ((classNameId != ratingsEntry.getClassNameId()) || (classPK != ratingsEntry.getClassPK()) || (score != ratingsEntry.getScore())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_RATINGSENTRY_WHERE); query.append(_FINDER_COLUMN_C_C_S_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_S_CLASSPK_2); query.append(_FINDER_COLUMN_C_C_S_SCORE_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(RatingsEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(classNameId); qPos.add(classPK); qPos.add(score); if (!pagination) { list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first ratings entry in the ordered set where classNameId = ? and classPK = ? and score = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param score the score * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching ratings entry * @throws NoSuchEntryException if a matching ratings entry could not be found */ @Override public RatingsEntry findByC_C_S_First(long classNameId, long classPK, double score, OrderByComparator<RatingsEntry> orderByComparator) throws NoSuchEntryException { RatingsEntry ratingsEntry = fetchByC_C_S_First(classNameId, classPK, score, orderByComparator); if (ratingsEntry != null) { return ratingsEntry; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(", score="); msg.append(score); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } /** * Returns the first ratings entry in the ordered set where classNameId = ? and classPK = ? and score = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param score the score * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching ratings entry, or <code>null</code> if a matching ratings entry could not be found */ @Override public RatingsEntry fetchByC_C_S_First(long classNameId, long classPK, double score, OrderByComparator<RatingsEntry> orderByComparator) { List<RatingsEntry> list = findByC_C_S(classNameId, classPK, score, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last ratings entry in the ordered set where classNameId = ? and classPK = ? and score = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param score the score * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching ratings entry * @throws NoSuchEntryException if a matching ratings entry could not be found */ @Override public RatingsEntry findByC_C_S_Last(long classNameId, long classPK, double score, OrderByComparator<RatingsEntry> orderByComparator) throws NoSuchEntryException { RatingsEntry ratingsEntry = fetchByC_C_S_Last(classNameId, classPK, score, orderByComparator); if (ratingsEntry != null) { return ratingsEntry; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append(", score="); msg.append(score); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } /** * Returns the last ratings entry in the ordered set where classNameId = ? and classPK = ? and score = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param score the score * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching ratings entry, or <code>null</code> if a matching ratings entry could not be found */ @Override public RatingsEntry fetchByC_C_S_Last(long classNameId, long classPK, double score, OrderByComparator<RatingsEntry> orderByComparator) { int count = countByC_C_S(classNameId, classPK, score); if (count == 0) { return null; } List<RatingsEntry> list = findByC_C_S(classNameId, classPK, score, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the ratings entries before and after the current ratings entry in the ordered set where classNameId = ? and classPK = ? and score = ?. * * @param entryId the primary key of the current ratings entry * @param classNameId the class name ID * @param classPK the class pk * @param score the score * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next ratings entry * @throws NoSuchEntryException if a ratings entry with the primary key could not be found */ @Override public RatingsEntry[] findByC_C_S_PrevAndNext(long entryId, long classNameId, long classPK, double score, OrderByComparator<RatingsEntry> orderByComparator) throws NoSuchEntryException { RatingsEntry ratingsEntry = findByPrimaryKey(entryId); Session session = null; try { session = openSession(); RatingsEntry[] array = new RatingsEntryImpl[3]; array[0] = getByC_C_S_PrevAndNext(session, ratingsEntry, classNameId, classPK, score, orderByComparator, true); array[1] = ratingsEntry; array[2] = getByC_C_S_PrevAndNext(session, ratingsEntry, classNameId, classPK, score, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected RatingsEntry getByC_C_S_PrevAndNext(Session session, RatingsEntry ratingsEntry, long classNameId, long classPK, double score, OrderByComparator<RatingsEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_RATINGSENTRY_WHERE); query.append(_FINDER_COLUMN_C_C_S_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_S_CLASSPK_2); query.append(_FINDER_COLUMN_C_C_S_SCORE_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(RatingsEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(classNameId); qPos.add(classPK); qPos.add(score); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(ratingsEntry); for (Object value : values) { qPos.add(value); } } List<RatingsEntry> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the ratings entries where classNameId = ? and classPK = ? and score = ? from the database. * * @param classNameId the class name ID * @param classPK the class pk * @param score the score */ @Override public void removeByC_C_S(long classNameId, long classPK, double score) { for (RatingsEntry ratingsEntry : findByC_C_S(classNameId, classPK, score, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ratingsEntry); } } /** * Returns the number of ratings entries where classNameId = ? and classPK = ? and score = ?. * * @param classNameId the class name ID * @param classPK the class pk * @param score the score * @return the number of matching ratings entries */ @Override public int countByC_C_S(long classNameId, long classPK, double score) { FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_S; Object[] finderArgs = new Object[] { classNameId, classPK, score }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_RATINGSENTRY_WHERE); query.append(_FINDER_COLUMN_C_C_S_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_S_CLASSPK_2); query.append(_FINDER_COLUMN_C_C_S_SCORE_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(classNameId); qPos.add(classPK); qPos.add(score); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_C_C_S_CLASSNAMEID_2 = "ratingsEntry.classNameId = ? AND "; private static final String _FINDER_COLUMN_C_C_S_CLASSPK_2 = "ratingsEntry.classPK = ? AND "; private static final String _FINDER_COLUMN_C_C_S_SCORE_2 = "ratingsEntry.score = ?"; public RatingsEntryPersistenceImpl() { setModelClass(RatingsEntry.class); try { Field field = ReflectionUtil.getDeclaredField(BasePersistenceImpl.class, "_dbColumnNames"); Map<String, String> dbColumnNames = new HashMap<String, String>(); dbColumnNames.put("uuid", "uuid_"); field.set(this, dbColumnNames); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } } } /** * Caches the ratings entry in the entity cache if it is enabled. * * @param ratingsEntry the ratings entry */ @Override public void cacheResult(RatingsEntry ratingsEntry) { entityCache.putResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryImpl.class, ratingsEntry.getPrimaryKey(), ratingsEntry); finderCache.putResult(FINDER_PATH_FETCH_BY_U_C_C, new Object[] { ratingsEntry.getUserId(), ratingsEntry.getClassNameId(), ratingsEntry.getClassPK() }, ratingsEntry); ratingsEntry.resetOriginalValues(); } /** * Caches the ratings entries in the entity cache if it is enabled. * * @param ratingsEntries the ratings entries */ @Override public void cacheResult(List<RatingsEntry> ratingsEntries) { for (RatingsEntry ratingsEntry : ratingsEntries) { if (entityCache.getResult( RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryImpl.class, ratingsEntry.getPrimaryKey()) == null) { cacheResult(ratingsEntry); } else { ratingsEntry.resetOriginalValues(); } } } /** * Clears the cache for all ratings entries. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache() { entityCache.clearCache(RatingsEntryImpl.class); finderCache.clearCache(FINDER_CLASS_NAME_ENTITY); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the ratings entry. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache(RatingsEntry ratingsEntry) { entityCache.removeResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryImpl.class, ratingsEntry.getPrimaryKey()); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((RatingsEntryModelImpl)ratingsEntry, true); } @Override public void clearCache(List<RatingsEntry> ratingsEntries) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (RatingsEntry ratingsEntry : ratingsEntries) { entityCache.removeResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryImpl.class, ratingsEntry.getPrimaryKey()); clearUniqueFindersCache((RatingsEntryModelImpl)ratingsEntry, true); } } protected void cacheUniqueFindersCache( RatingsEntryModelImpl ratingsEntryModelImpl) { Object[] args = new Object[] { ratingsEntryModelImpl.getUserId(), ratingsEntryModelImpl.getClassNameId(), ratingsEntryModelImpl.getClassPK() }; finderCache.putResult(FINDER_PATH_COUNT_BY_U_C_C, args, Long.valueOf(1), false); finderCache.putResult(FINDER_PATH_FETCH_BY_U_C_C, args, ratingsEntryModelImpl, false); } protected void clearUniqueFindersCache( RatingsEntryModelImpl ratingsEntryModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { ratingsEntryModelImpl.getUserId(), ratingsEntryModelImpl.getClassNameId(), ratingsEntryModelImpl.getClassPK() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C_C, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_U_C_C, args); } if ((ratingsEntryModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_U_C_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { ratingsEntryModelImpl.getOriginalUserId(), ratingsEntryModelImpl.getOriginalClassNameId(), ratingsEntryModelImpl.getOriginalClassPK() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U_C_C, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_U_C_C, args); } } /** * Creates a new ratings entry with the primary key. Does not add the ratings entry to the database. * * @param entryId the primary key for the new ratings entry * @return the new ratings entry */ @Override public RatingsEntry create(long entryId) { RatingsEntry ratingsEntry = new RatingsEntryImpl(); ratingsEntry.setNew(true); ratingsEntry.setPrimaryKey(entryId); String uuid = PortalUUIDUtil.generate(); ratingsEntry.setUuid(uuid); ratingsEntry.setCompanyId(companyProvider.getCompanyId()); return ratingsEntry; } /** * Removes the ratings entry with the primary key from the database. Also notifies the appropriate model listeners. * * @param entryId the primary key of the ratings entry * @return the ratings entry that was removed * @throws NoSuchEntryException if a ratings entry with the primary key could not be found */ @Override public RatingsEntry remove(long entryId) throws NoSuchEntryException { return remove((Serializable)entryId); } /** * Removes the ratings entry with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the ratings entry * @return the ratings entry that was removed * @throws NoSuchEntryException if a ratings entry with the primary key could not be found */ @Override public RatingsEntry remove(Serializable primaryKey) throws NoSuchEntryException { Session session = null; try { session = openSession(); RatingsEntry ratingsEntry = (RatingsEntry)session.get(RatingsEntryImpl.class, primaryKey); if (ratingsEntry == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(ratingsEntry); } catch (NoSuchEntryException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected RatingsEntry removeImpl(RatingsEntry ratingsEntry) { ratingsEntry = toUnwrappedModel(ratingsEntry); Session session = null; try { session = openSession(); if (!session.contains(ratingsEntry)) { ratingsEntry = (RatingsEntry)session.get(RatingsEntryImpl.class, ratingsEntry.getPrimaryKeyObj()); } if (ratingsEntry != null) { session.delete(ratingsEntry); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (ratingsEntry != null) { clearCache(ratingsEntry); } return ratingsEntry; } @Override public RatingsEntry updateImpl(RatingsEntry ratingsEntry) { ratingsEntry = toUnwrappedModel(ratingsEntry); boolean isNew = ratingsEntry.isNew(); RatingsEntryModelImpl ratingsEntryModelImpl = (RatingsEntryModelImpl)ratingsEntry; if (Validator.isNull(ratingsEntry.getUuid())) { String uuid = PortalUUIDUtil.generate(); ratingsEntry.setUuid(uuid); } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (ratingsEntry.getCreateDate() == null)) { if (serviceContext == null) { ratingsEntry.setCreateDate(now); } else { ratingsEntry.setCreateDate(serviceContext.getCreateDate(now)); } } if (!ratingsEntryModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { ratingsEntry.setModifiedDate(now); } else { ratingsEntry.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (ratingsEntry.isNew()) { session.save(ratingsEntry); ratingsEntry.setNew(false); } else { ratingsEntry = (RatingsEntry)session.merge(ratingsEntry); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!RatingsEntryModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] { ratingsEntryModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { ratingsEntryModelImpl.getUuid(), ratingsEntryModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { ratingsEntryModelImpl.getClassNameId(), ratingsEntryModelImpl.getClassPK() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C, args); args = new Object[] { ratingsEntryModelImpl.getClassNameId(), ratingsEntryModelImpl.getClassPK(), ratingsEntryModelImpl.getScore() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S, args); finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL, FINDER_ARGS_EMPTY); } else { if ((ratingsEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) { Object[] args = new Object[] { ratingsEntryModelImpl.getOriginalUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { ratingsEntryModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); } if ((ratingsEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { ratingsEntryModelImpl.getOriginalUuid(), ratingsEntryModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { ratingsEntryModelImpl.getUuid(), ratingsEntryModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); } if ((ratingsEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { ratingsEntryModelImpl.getOriginalClassNameId(), ratingsEntryModelImpl.getOriginalClassPK() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C, args); args = new Object[] { ratingsEntryModelImpl.getClassNameId(), ratingsEntryModelImpl.getClassPK() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C, args); } if ((ratingsEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { ratingsEntryModelImpl.getOriginalClassNameId(), ratingsEntryModelImpl.getOriginalClassPK(), ratingsEntryModelImpl.getOriginalScore() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S, args); args = new Object[] { ratingsEntryModelImpl.getClassNameId(), ratingsEntryModelImpl.getClassPK(), ratingsEntryModelImpl.getScore() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_S, args); } } entityCache.putResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryImpl.class, ratingsEntry.getPrimaryKey(), ratingsEntry, false); clearUniqueFindersCache(ratingsEntryModelImpl, false); cacheUniqueFindersCache(ratingsEntryModelImpl); ratingsEntry.resetOriginalValues(); return ratingsEntry; } protected RatingsEntry toUnwrappedModel(RatingsEntry ratingsEntry) { if (ratingsEntry instanceof RatingsEntryImpl) { return ratingsEntry; } RatingsEntryImpl ratingsEntryImpl = new RatingsEntryImpl(); ratingsEntryImpl.setNew(ratingsEntry.isNew()); ratingsEntryImpl.setPrimaryKey(ratingsEntry.getPrimaryKey()); ratingsEntryImpl.setUuid(ratingsEntry.getUuid()); ratingsEntryImpl.setEntryId(ratingsEntry.getEntryId()); ratingsEntryImpl.setCompanyId(ratingsEntry.getCompanyId()); ratingsEntryImpl.setUserId(ratingsEntry.getUserId()); ratingsEntryImpl.setUserName(ratingsEntry.getUserName()); ratingsEntryImpl.setCreateDate(ratingsEntry.getCreateDate()); ratingsEntryImpl.setModifiedDate(ratingsEntry.getModifiedDate()); ratingsEntryImpl.setClassNameId(ratingsEntry.getClassNameId()); ratingsEntryImpl.setClassPK(ratingsEntry.getClassPK()); ratingsEntryImpl.setScore(ratingsEntry.getScore()); return ratingsEntryImpl; } /** * Returns the ratings entry with the primary key or throws a {@link com.liferay.portal.kernel.exception.NoSuchModelException} if it could not be found. * * @param primaryKey the primary key of the ratings entry * @return the ratings entry * @throws NoSuchEntryException if a ratings entry with the primary key could not be found */ @Override public RatingsEntry findByPrimaryKey(Serializable primaryKey) throws NoSuchEntryException { RatingsEntry ratingsEntry = fetchByPrimaryKey(primaryKey); if (ratingsEntry == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return ratingsEntry; } /** * Returns the ratings entry with the primary key or throws a {@link NoSuchEntryException} if it could not be found. * * @param entryId the primary key of the ratings entry * @return the ratings entry * @throws NoSuchEntryException if a ratings entry with the primary key could not be found */ @Override public RatingsEntry findByPrimaryKey(long entryId) throws NoSuchEntryException { return findByPrimaryKey((Serializable)entryId); } /** * Returns the ratings entry with the primary key or returns <code>null</code> if it could not be found. * * @param primaryKey the primary key of the ratings entry * @return the ratings entry, or <code>null</code> if a ratings entry with the primary key could not be found */ @Override public RatingsEntry fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = entityCache.getResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryImpl.class, primaryKey); if (serializable == nullModel) { return null; } RatingsEntry ratingsEntry = (RatingsEntry)serializable; if (ratingsEntry == null) { Session session = null; try { session = openSession(); ratingsEntry = (RatingsEntry)session.get(RatingsEntryImpl.class, primaryKey); if (ratingsEntry != null) { cacheResult(ratingsEntry); } else { entityCache.putResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryImpl.class, primaryKey, nullModel); } } catch (Exception e) { entityCache.removeResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return ratingsEntry; } /** * Returns the ratings entry with the primary key or returns <code>null</code> if it could not be found. * * @param entryId the primary key of the ratings entry * @return the ratings entry, or <code>null</code> if a ratings entry with the primary key could not be found */ @Override public RatingsEntry fetchByPrimaryKey(long entryId) { return fetchByPrimaryKey((Serializable)entryId); } @Override public Map<Serializable, RatingsEntry> fetchByPrimaryKeys( Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map<Serializable, RatingsEntry> map = new HashMap<Serializable, RatingsEntry>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); RatingsEntry ratingsEntry = fetchByPrimaryKey(primaryKey); if (ratingsEntry != null) { map.put(primaryKey, ratingsEntry); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (RatingsEntry)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_RATINGSENTRY_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long)primaryKey); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (RatingsEntry ratingsEntry : (List<RatingsEntry>)q.list()) { map.put(ratingsEntry.getPrimaryKeyObj(), ratingsEntry); cacheResult(ratingsEntry); uncachedPrimaryKeys.remove(ratingsEntry.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(RatingsEntryModelImpl.ENTITY_CACHE_ENABLED, RatingsEntryImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the ratings entries. * * @return the ratings entries */ @Override public List<RatingsEntry> findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ratings entries. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @return the range of ratings entries */ @Override public List<RatingsEntry> findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the ratings entries. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of ratings entries */ @Override public List<RatingsEntry> findAll(int start, int end, OrderByComparator<RatingsEntry> orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the ratings entries. * * <p> * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link RatingsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of ratings entries * @param end the upper bound of the range of ratings entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of ratings entries */ @Override public List<RatingsEntry> findAll(int start, int end, OrderByComparator<RatingsEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL; finderArgs = new Object[] { start, end, orderByComparator }; } List<RatingsEntry> list = null; if (retrieveFromCache) { list = (List<RatingsEntry>)finderCache.getResult(finderPath, finderArgs, this); } if (list == null) { StringBundler query = null; String sql = null; if (orderByComparator != null) { query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 2)); query.append(_SQL_SELECT_RATINGSENTRY); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_RATINGSENTRY; if (pagination) { sql = sql.concat(RatingsEntryModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<RatingsEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the ratings entries from the database. * */ @Override public void removeAll() { for (RatingsEntry ratingsEntry : findAll()) { remove(ratingsEntry); } } /** * Returns the number of ratings entries. * * @return the number of ratings entries */ @Override public int countAll() { Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query q = session.createQuery(_SQL_COUNT_RATINGSENTRY); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } @Override public Set<String> getBadColumnNames() { return _badColumnNames; } @Override protected Map<String, Integer> getTableColumnsMap() { return RatingsEntryModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the ratings entry persistence. */ public void afterPropertiesSet() { } public void destroy() { entityCache.removeCache(RatingsEntryImpl.class.getName()); finderCache.removeCache(FINDER_CLASS_NAME_ENTITY); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @BeanReference(type = CompanyProviderWrapper.class) protected CompanyProvider companyProvider; protected EntityCache entityCache = EntityCacheUtil.getEntityCache(); protected FinderCache finderCache = FinderCacheUtil.getFinderCache(); private static final String _SQL_SELECT_RATINGSENTRY = "SELECT ratingsEntry FROM RatingsEntry ratingsEntry"; private static final String _SQL_SELECT_RATINGSENTRY_WHERE_PKS_IN = "SELECT ratingsEntry FROM RatingsEntry ratingsEntry WHERE entryId IN ("; private static final String _SQL_SELECT_RATINGSENTRY_WHERE = "SELECT ratingsEntry FROM RatingsEntry ratingsEntry WHERE "; private static final String _SQL_COUNT_RATINGSENTRY = "SELECT COUNT(ratingsEntry) FROM RatingsEntry ratingsEntry"; private static final String _SQL_COUNT_RATINGSENTRY_WHERE = "SELECT COUNT(ratingsEntry) FROM RatingsEntry ratingsEntry WHERE "; private static final String _ORDER_BY_ENTITY_ALIAS = "ratingsEntry."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No RatingsEntry exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No RatingsEntry exists with the key {"; private static final Log _log = LogFactoryUtil.getLog(RatingsEntryPersistenceImpl.class); private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] { "uuid" }); }