Java tutorial
/** * 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.bemis.portal.report.service.persistence.impl; import aQute.bnd.annotation.ProviderType; import com.bemis.portal.report.exception.NoSuchReportRequestException; import com.bemis.portal.report.model.ReportRequest; import com.bemis.portal.report.model.impl.ReportRequestImpl; import com.bemis.portal.report.model.impl.ReportRequestModelImpl; import com.bemis.portal.report.service.persistence.ReportRequestPersistence; import com.liferay.portal.kernel.dao.orm.EntityCache; import com.liferay.portal.kernel.dao.orm.FinderCache; 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.SQLQuery; 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.security.permission.InlineSQLHelperUtil; 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.ArrayUtil; import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.util.StringBundler; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringUtil; import com.liferay.portal.spring.extender.service.ServiceReference; import java.io.Serializable; import java.util.Arrays; 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 report request service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author Michael C. Han * @see ReportRequestPersistence * @see com.bemis.portal.report.service.persistence.ReportRequestUtil * @generated */ @ProviderType public class ReportRequestPersistenceImpl extends BasePersistenceImpl<ReportRequest> implements ReportRequestPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use {@link ReportRequestUtil} to access the report request persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = ReportRequestImpl.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( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, ReportRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, ReportRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.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_REPORTDEFINITIONID = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, ReportRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByReportDefinitionId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPORTDEFINITIONID = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, ReportRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByReportDefinitionId", new String[] { Long.class.getName() }, ReportRequestModelImpl.REPORTDEFINITIONID_COLUMN_BITMASK | ReportRequestModelImpl.REPORTREQUESTFINISH_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_REPORTDEFINITIONID = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByReportDefinitionId", new String[] { Long.class.getName() }); /** * Returns all the report requests where reportDefinitionId = ?. * * @param reportDefinitionId the report definition ID * @return the matching report requests */ @Override public List<ReportRequest> findByReportDefinitionId(long reportDefinitionId) { return findByReportDefinitionId(reportDefinitionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the report requests where reportDefinitionId = ?. * * <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 ReportRequestModelImpl}. 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 reportDefinitionId the report definition ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @return the range of matching report requests */ @Override public List<ReportRequest> findByReportDefinitionId(long reportDefinitionId, int start, int end) { return findByReportDefinitionId(reportDefinitionId, start, end, null); } /** * Returns an ordered range of all the report requests where reportDefinitionId = ?. * * <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 ReportRequestModelImpl}. 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 reportDefinitionId the report definition ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching report requests */ @Override public List<ReportRequest> findByReportDefinitionId(long reportDefinitionId, int start, int end, OrderByComparator<ReportRequest> orderByComparator) { return findByReportDefinitionId(reportDefinitionId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the report requests where reportDefinitionId = ?. * * <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 ReportRequestModelImpl}. 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 reportDefinitionId the report definition ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (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 report requests */ @Override public List<ReportRequest> findByReportDefinitionId(long reportDefinitionId, int start, int end, OrderByComparator<ReportRequest> 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_REPORTDEFINITIONID; finderArgs = new Object[] { reportDefinitionId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_REPORTDEFINITIONID; finderArgs = new Object[] { reportDefinitionId, start, end, orderByComparator }; } List<ReportRequest> list = null; if (retrieveFromCache) { list = (List<ReportRequest>) finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (ReportRequest reportRequest : list) { if ((reportDefinitionId != reportRequest.getReportDefinitionId())) { 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_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_REPORTDEFINITIONID_REPORTDEFINITIONID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(ReportRequestModelImpl.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(reportDefinitionId); if (!pagination) { list = (List<ReportRequest>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<ReportRequest>) 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 report request in the ordered set where reportDefinitionId = ?. * * @param reportDefinitionId the report definition ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching report request * @throws NoSuchReportRequestException if a matching report request could not be found */ @Override public ReportRequest findByReportDefinitionId_First(long reportDefinitionId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = fetchByReportDefinitionId_First(reportDefinitionId, orderByComparator); if (reportRequest != null) { return reportRequest; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("reportDefinitionId="); msg.append(reportDefinitionId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchReportRequestException(msg.toString()); } /** * Returns the first report request in the ordered set where reportDefinitionId = ?. * * @param reportDefinitionId the report definition ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching report request, or <code>null</code> if a matching report request could not be found */ @Override public ReportRequest fetchByReportDefinitionId_First(long reportDefinitionId, OrderByComparator<ReportRequest> orderByComparator) { List<ReportRequest> list = findByReportDefinitionId(reportDefinitionId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last report request in the ordered set where reportDefinitionId = ?. * * @param reportDefinitionId the report definition ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching report request * @throws NoSuchReportRequestException if a matching report request could not be found */ @Override public ReportRequest findByReportDefinitionId_Last(long reportDefinitionId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = fetchByReportDefinitionId_Last(reportDefinitionId, orderByComparator); if (reportRequest != null) { return reportRequest; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("reportDefinitionId="); msg.append(reportDefinitionId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchReportRequestException(msg.toString()); } /** * Returns the last report request in the ordered set where reportDefinitionId = ?. * * @param reportDefinitionId the report definition ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching report request, or <code>null</code> if a matching report request could not be found */ @Override public ReportRequest fetchByReportDefinitionId_Last(long reportDefinitionId, OrderByComparator<ReportRequest> orderByComparator) { int count = countByReportDefinitionId(reportDefinitionId); if (count == 0) { return null; } List<ReportRequest> list = findByReportDefinitionId(reportDefinitionId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the report requests before and after the current report request in the ordered set where reportDefinitionId = ?. * * @param reportRequestId the primary key of the current report request * @param reportDefinitionId the report definition ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next report request * @throws NoSuchReportRequestException if a report request with the primary key could not be found */ @Override public ReportRequest[] findByReportDefinitionId_PrevAndNext(long reportRequestId, long reportDefinitionId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = findByPrimaryKey(reportRequestId); Session session = null; try { session = openSession(); ReportRequest[] array = new ReportRequestImpl[3]; array[0] = getByReportDefinitionId_PrevAndNext(session, reportRequest, reportDefinitionId, orderByComparator, true); array[1] = reportRequest; array[2] = getByReportDefinitionId_PrevAndNext(session, reportRequest, reportDefinitionId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected ReportRequest getByReportDefinitionId_PrevAndNext(Session session, ReportRequest reportRequest, long reportDefinitionId, OrderByComparator<ReportRequest> 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_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_REPORTDEFINITIONID_REPORTDEFINITIONID_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(ReportRequestModelImpl.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(reportDefinitionId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(reportRequest); for (Object value : values) { qPos.add(value); } } List<ReportRequest> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the report requests where reportDefinitionId = ? from the database. * * @param reportDefinitionId the report definition ID */ @Override public void removeByReportDefinitionId(long reportDefinitionId) { for (ReportRequest reportRequest : findByReportDefinitionId(reportDefinitionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(reportRequest); } } /** * Returns the number of report requests where reportDefinitionId = ?. * * @param reportDefinitionId the report definition ID * @return the number of matching report requests */ @Override public int countByReportDefinitionId(long reportDefinitionId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_REPORTDEFINITIONID; Object[] finderArgs = new Object[] { reportDefinitionId }; Long count = (Long) finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_REPORTDEFINITIONID_REPORTDEFINITIONID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(reportDefinitionId); 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_REPORTDEFINITIONID_REPORTDEFINITIONID_2 = "reportRequest.reportDefinitionId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, ReportRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, ReportRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId", new String[] { Long.class.getName() }, ReportRequestModelImpl.USERID_COLUMN_BITMASK | ReportRequestModelImpl.REPORTREQUESTFINISH_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId", new String[] { Long.class.getName() }); /** * Returns all the report requests where userId = ?. * * @param userId the user ID * @return the matching report requests */ @Override public List<ReportRequest> findByUserId(long userId) { return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the report requests where userId = ?. * * <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 ReportRequestModelImpl}. 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 userId the user ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @return the range of matching report requests */ @Override public List<ReportRequest> findByUserId(long userId, int start, int end) { return findByUserId(userId, start, end, null); } /** * Returns an ordered range of all the report requests where userId = ?. * * <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 ReportRequestModelImpl}. 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 userId the user ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching report requests */ @Override public List<ReportRequest> findByUserId(long userId, int start, int end, OrderByComparator<ReportRequest> orderByComparator) { return findByUserId(userId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the report requests where userId = ?. * * <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 ReportRequestModelImpl}. 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 userId the user ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (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 report requests */ @Override public List<ReportRequest> findByUserId(long userId, int start, int end, OrderByComparator<ReportRequest> 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_USERID; finderArgs = new Object[] { userId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID; finderArgs = new Object[] { userId, start, end, orderByComparator }; } List<ReportRequest> list = null; if (retrieveFromCache) { list = (List<ReportRequest>) finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (ReportRequest reportRequest : list) { if ((userId != reportRequest.getUserId())) { 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_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_USERID_USERID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(ReportRequestModelImpl.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(userId); if (!pagination) { list = (List<ReportRequest>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<ReportRequest>) 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 report request in the ordered set where userId = ?. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching report request * @throws NoSuchReportRequestException if a matching report request could not be found */ @Override public ReportRequest findByUserId_First(long userId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = fetchByUserId_First(userId, orderByComparator); if (reportRequest != null) { return reportRequest; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchReportRequestException(msg.toString()); } /** * Returns the first report request in the ordered set where userId = ?. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching report request, or <code>null</code> if a matching report request could not be found */ @Override public ReportRequest fetchByUserId_First(long userId, OrderByComparator<ReportRequest> orderByComparator) { List<ReportRequest> list = findByUserId(userId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last report request in the ordered set where userId = ?. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching report request * @throws NoSuchReportRequestException if a matching report request could not be found */ @Override public ReportRequest findByUserId_Last(long userId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = fetchByUserId_Last(userId, orderByComparator); if (reportRequest != null) { return reportRequest; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchReportRequestException(msg.toString()); } /** * Returns the last report request in the ordered set where userId = ?. * * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching report request, or <code>null</code> if a matching report request could not be found */ @Override public ReportRequest fetchByUserId_Last(long userId, OrderByComparator<ReportRequest> orderByComparator) { int count = countByUserId(userId); if (count == 0) { return null; } List<ReportRequest> list = findByUserId(userId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the report requests before and after the current report request in the ordered set where userId = ?. * * @param reportRequestId the primary key of the current report request * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next report request * @throws NoSuchReportRequestException if a report request with the primary key could not be found */ @Override public ReportRequest[] findByUserId_PrevAndNext(long reportRequestId, long userId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = findByPrimaryKey(reportRequestId); Session session = null; try { session = openSession(); ReportRequest[] array = new ReportRequestImpl[3]; array[0] = getByUserId_PrevAndNext(session, reportRequest, userId, orderByComparator, true); array[1] = reportRequest; array[2] = getByUserId_PrevAndNext(session, reportRequest, userId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected ReportRequest getByUserId_PrevAndNext(Session session, ReportRequest reportRequest, long userId, OrderByComparator<ReportRequest> 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_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_USERID_USERID_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(ReportRequestModelImpl.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(userId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(reportRequest); for (Object value : values) { qPos.add(value); } } List<ReportRequest> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the report requests where userId = ? from the database. * * @param userId the user ID */ @Override public void removeByUserId(long userId) { for (ReportRequest reportRequest : findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(reportRequest); } } /** * Returns the number of report requests where userId = ?. * * @param userId the user ID * @return the number of matching report requests */ @Override public int countByUserId(long userId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID; Object[] finderArgs = new Object[] { userId }; Long count = (Long) finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_USERID_USERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); 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_USERID_USERID_2 = "reportRequest.userId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RDC_U = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, ReportRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByRDC_U", 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_RDC_U = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, ReportRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRDC_U", new String[] { String.class.getName(), Long.class.getName() }, ReportRequestModelImpl.REPORTDEFINITIONCATEGORY_COLUMN_BITMASK | ReportRequestModelImpl.USERID_COLUMN_BITMASK | ReportRequestModelImpl.REPORTREQUESTFINISH_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_RDC_U = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRDC_U", new String[] { String.class.getName(), Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_RDC_U = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByRDC_U", new String[] { String.class.getName(), Long.class.getName() }); /** * Returns all the report requests where reportDefinitionCategory = ? and userId = ?. * * @param reportDefinitionCategory the report definition category * @param userId the user ID * @return the matching report requests */ @Override public List<ReportRequest> findByRDC_U(String reportDefinitionCategory, long userId) { return findByRDC_U(reportDefinitionCategory, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the report requests where reportDefinitionCategory = ? and userId = ?. * * <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 ReportRequestModelImpl}. 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 reportDefinitionCategory the report definition category * @param userId the user ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @return the range of matching report requests */ @Override public List<ReportRequest> findByRDC_U(String reportDefinitionCategory, long userId, int start, int end) { return findByRDC_U(reportDefinitionCategory, userId, start, end, null); } /** * Returns an ordered range of all the report requests where reportDefinitionCategory = ? and userId = ?. * * <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 ReportRequestModelImpl}. 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 reportDefinitionCategory the report definition category * @param userId the user ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching report requests */ @Override public List<ReportRequest> findByRDC_U(String reportDefinitionCategory, long userId, int start, int end, OrderByComparator<ReportRequest> orderByComparator) { return findByRDC_U(reportDefinitionCategory, userId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the report requests where reportDefinitionCategory = ? and userId = ?. * * <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 ReportRequestModelImpl}. 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 reportDefinitionCategory the report definition category * @param userId the user ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (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 report requests */ @Override public List<ReportRequest> findByRDC_U(String reportDefinitionCategory, long userId, int start, int end, OrderByComparator<ReportRequest> 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_RDC_U; finderArgs = new Object[] { reportDefinitionCategory, userId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RDC_U; finderArgs = new Object[] { reportDefinitionCategory, userId, start, end, orderByComparator }; } List<ReportRequest> list = null; if (retrieveFromCache) { list = (List<ReportRequest>) finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (ReportRequest reportRequest : list) { if (!Objects.equals(reportDefinitionCategory, reportRequest.getReportDefinitionCategory()) || (userId != reportRequest.getUserId())) { 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_REPORTREQUEST_WHERE); boolean bindReportDefinitionCategory = false; if (reportDefinitionCategory == null) { query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_1); } else if (reportDefinitionCategory.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_3); } else { bindReportDefinitionCategory = true; query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_2); } query.append(_FINDER_COLUMN_RDC_U_USERID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(ReportRequestModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindReportDefinitionCategory) { qPos.add(reportDefinitionCategory); } qPos.add(userId); if (!pagination) { list = (List<ReportRequest>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<ReportRequest>) 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 report request in the ordered set where reportDefinitionCategory = ? and userId = ?. * * @param reportDefinitionCategory the report definition category * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching report request * @throws NoSuchReportRequestException if a matching report request could not be found */ @Override public ReportRequest findByRDC_U_First(String reportDefinitionCategory, long userId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = fetchByRDC_U_First(reportDefinitionCategory, userId, orderByComparator); if (reportRequest != null) { return reportRequest; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("reportDefinitionCategory="); msg.append(reportDefinitionCategory); msg.append(", userId="); msg.append(userId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchReportRequestException(msg.toString()); } /** * Returns the first report request in the ordered set where reportDefinitionCategory = ? and userId = ?. * * @param reportDefinitionCategory the report definition category * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching report request, or <code>null</code> if a matching report request could not be found */ @Override public ReportRequest fetchByRDC_U_First(String reportDefinitionCategory, long userId, OrderByComparator<ReportRequest> orderByComparator) { List<ReportRequest> list = findByRDC_U(reportDefinitionCategory, userId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last report request in the ordered set where reportDefinitionCategory = ? and userId = ?. * * @param reportDefinitionCategory the report definition category * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching report request * @throws NoSuchReportRequestException if a matching report request could not be found */ @Override public ReportRequest findByRDC_U_Last(String reportDefinitionCategory, long userId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = fetchByRDC_U_Last(reportDefinitionCategory, userId, orderByComparator); if (reportRequest != null) { return reportRequest; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("reportDefinitionCategory="); msg.append(reportDefinitionCategory); msg.append(", userId="); msg.append(userId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchReportRequestException(msg.toString()); } /** * Returns the last report request in the ordered set where reportDefinitionCategory = ? and userId = ?. * * @param reportDefinitionCategory the report definition category * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching report request, or <code>null</code> if a matching report request could not be found */ @Override public ReportRequest fetchByRDC_U_Last(String reportDefinitionCategory, long userId, OrderByComparator<ReportRequest> orderByComparator) { int count = countByRDC_U(reportDefinitionCategory, userId); if (count == 0) { return null; } List<ReportRequest> list = findByRDC_U(reportDefinitionCategory, userId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the report requests before and after the current report request in the ordered set where reportDefinitionCategory = ? and userId = ?. * * @param reportRequestId the primary key of the current report request * @param reportDefinitionCategory the report definition category * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next report request * @throws NoSuchReportRequestException if a report request with the primary key could not be found */ @Override public ReportRequest[] findByRDC_U_PrevAndNext(long reportRequestId, String reportDefinitionCategory, long userId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = findByPrimaryKey(reportRequestId); Session session = null; try { session = openSession(); ReportRequest[] array = new ReportRequestImpl[3]; array[0] = getByRDC_U_PrevAndNext(session, reportRequest, reportDefinitionCategory, userId, orderByComparator, true); array[1] = reportRequest; array[2] = getByRDC_U_PrevAndNext(session, reportRequest, reportDefinitionCategory, userId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected ReportRequest getByRDC_U_PrevAndNext(Session session, ReportRequest reportRequest, String reportDefinitionCategory, long userId, OrderByComparator<ReportRequest> 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_REPORTREQUEST_WHERE); boolean bindReportDefinitionCategory = false; if (reportDefinitionCategory == null) { query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_1); } else if (reportDefinitionCategory.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_3); } else { bindReportDefinitionCategory = true; query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_2); } query.append(_FINDER_COLUMN_RDC_U_USERID_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(ReportRequestModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindReportDefinitionCategory) { qPos.add(reportDefinitionCategory); } qPos.add(userId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(reportRequest); for (Object value : values) { qPos.add(value); } } List<ReportRequest> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the report requests where reportDefinitionCategory = any ? and userId = ?. * * <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 ReportRequestModelImpl}. 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 reportDefinitionCategories the report definition categories * @param userId the user ID * @return the matching report requests */ @Override public List<ReportRequest> findByRDC_U(String[] reportDefinitionCategories, long userId) { return findByRDC_U(reportDefinitionCategories, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the report requests where reportDefinitionCategory = any ? and userId = ?. * * <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 ReportRequestModelImpl}. 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 reportDefinitionCategories the report definition categories * @param userId the user ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @return the range of matching report requests */ @Override public List<ReportRequest> findByRDC_U(String[] reportDefinitionCategories, long userId, int start, int end) { return findByRDC_U(reportDefinitionCategories, userId, start, end, null); } /** * Returns an ordered range of all the report requests where reportDefinitionCategory = any ? and userId = ?. * * <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 ReportRequestModelImpl}. 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 reportDefinitionCategories the report definition categories * @param userId the user ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching report requests */ @Override public List<ReportRequest> findByRDC_U(String[] reportDefinitionCategories, long userId, int start, int end, OrderByComparator<ReportRequest> orderByComparator) { return findByRDC_U(reportDefinitionCategories, userId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the report requests where reportDefinitionCategory = ? and userId = ?, optionally using the finder cache. * * <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 ReportRequestModelImpl}. 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 reportDefinitionCategory the report definition category * @param userId the user ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (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 report requests */ @Override public List<ReportRequest> findByRDC_U(String[] reportDefinitionCategories, long userId, int start, int end, OrderByComparator<ReportRequest> orderByComparator, boolean retrieveFromCache) { if (reportDefinitionCategories == null) { reportDefinitionCategories = new String[0]; } else if (reportDefinitionCategories.length > 1) { reportDefinitionCategories = ArrayUtil.distinct(reportDefinitionCategories, NULL_SAFE_STRING_COMPARATOR); Arrays.sort(reportDefinitionCategories, NULL_SAFE_STRING_COMPARATOR); } if (reportDefinitionCategories.length == 1) { return findByRDC_U(reportDefinitionCategories[0], userId, start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { StringUtil.merge(reportDefinitionCategories), userId }; } else { finderArgs = new Object[] { StringUtil.merge(reportDefinitionCategories), userId, start, end, orderByComparator }; } List<ReportRequest> list = null; if (retrieveFromCache) { list = (List<ReportRequest>) finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_RDC_U, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (ReportRequest reportRequest : list) { if (!ArrayUtil.contains(reportDefinitionCategories, reportRequest.getReportDefinitionCategory()) || (userId != reportRequest.getUserId())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_REPORTREQUEST_WHERE); if (reportDefinitionCategories.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < reportDefinitionCategories.length; i++) { String reportDefinitionCategory = reportDefinitionCategories[i]; if (reportDefinitionCategory == null) { query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_4); } else if (reportDefinitionCategory.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_6); } else { query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_5); } if ((i + 1) < reportDefinitionCategories.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_RDC_U_USERID_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(ReportRequestModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); for (String reportDefinitionCategory : reportDefinitionCategories) { if ((reportDefinitionCategory != null) && !reportDefinitionCategory.isEmpty()) { qPos.add(reportDefinitionCategory); } } qPos.add(userId); if (!pagination) { list = (List<ReportRequest>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<ReportRequest>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_RDC_U, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_RDC_U, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the report requests where reportDefinitionCategory = ? and userId = ? from the database. * * @param reportDefinitionCategory the report definition category * @param userId the user ID */ @Override public void removeByRDC_U(String reportDefinitionCategory, long userId) { for (ReportRequest reportRequest : findByRDC_U(reportDefinitionCategory, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(reportRequest); } } /** * Returns the number of report requests where reportDefinitionCategory = ? and userId = ?. * * @param reportDefinitionCategory the report definition category * @param userId the user ID * @return the number of matching report requests */ @Override public int countByRDC_U(String reportDefinitionCategory, long userId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_RDC_U; Object[] finderArgs = new Object[] { reportDefinitionCategory, userId }; Long count = (Long) finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_REPORTREQUEST_WHERE); boolean bindReportDefinitionCategory = false; if (reportDefinitionCategory == null) { query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_1); } else if (reportDefinitionCategory.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_3); } else { bindReportDefinitionCategory = true; query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_2); } query.append(_FINDER_COLUMN_RDC_U_USERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindReportDefinitionCategory) { qPos.add(reportDefinitionCategory); } qPos.add(userId); 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(); } /** * Returns the number of report requests where reportDefinitionCategory = any ? and userId = ?. * * @param reportDefinitionCategories the report definition categories * @param userId the user ID * @return the number of matching report requests */ @Override public int countByRDC_U(String[] reportDefinitionCategories, long userId) { if (reportDefinitionCategories == null) { reportDefinitionCategories = new String[0]; } else if (reportDefinitionCategories.length > 1) { reportDefinitionCategories = ArrayUtil.distinct(reportDefinitionCategories, NULL_SAFE_STRING_COMPARATOR); Arrays.sort(reportDefinitionCategories, NULL_SAFE_STRING_COMPARATOR); } Object[] finderArgs = new Object[] { StringUtil.merge(reportDefinitionCategories), userId }; Long count = (Long) finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_RDC_U, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_REPORTREQUEST_WHERE); if (reportDefinitionCategories.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < reportDefinitionCategories.length; i++) { String reportDefinitionCategory = reportDefinitionCategories[i]; if (reportDefinitionCategory == null) { query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_4); } else if (reportDefinitionCategory.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_6); } else { query.append(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_5); } if ((i + 1) < reportDefinitionCategories.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_RDC_U_USERID_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); for (String reportDefinitionCategory : reportDefinitionCategories) { if ((reportDefinitionCategory != null) && !reportDefinitionCategory.isEmpty()) { qPos.add(reportDefinitionCategory); } } qPos.add(userId); count = (Long) q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_RDC_U, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_RDC_U, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_1 = "reportRequest.reportDefinitionCategory IS NULL AND "; private static final String _FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_2 = "reportRequest.reportDefinitionCategory = ? AND "; private static final String _FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_3 = "(reportRequest.reportDefinitionCategory IS NULL OR reportRequest.reportDefinitionCategory = '') AND "; private static final String _FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_4 = "(" + removeConjunction(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_1) + ")"; private static final String _FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_5 = "(" + removeConjunction(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_2) + ")"; private static final String _FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_6 = "(" + removeConjunction(_FINDER_COLUMN_RDC_U_REPORTDEFINITIONCATEGORY_3) + ")"; private static final String _FINDER_COLUMN_RDC_U_USERID_2 = "reportRequest.userId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, ReportRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_G", 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_G = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, ReportRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_G", new String[] { Long.class.getName(), Long.class.getName() }, ReportRequestModelImpl.COMPANYID_COLUMN_BITMASK | ReportRequestModelImpl.GROUPID_COLUMN_BITMASK | ReportRequestModelImpl.REPORTREQUESTFINISH_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_C_G = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_G", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the report requests where companyId = ? and groupId = ?. * * @param companyId the company ID * @param groupId the group ID * @return the matching report requests */ @Override public List<ReportRequest> findByC_G(long companyId, long groupId) { return findByC_G(companyId, groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the report requests where companyId = ? and groupId = ?. * * <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 ReportRequestModelImpl}. 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 companyId the company ID * @param groupId the group ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @return the range of matching report requests */ @Override public List<ReportRequest> findByC_G(long companyId, long groupId, int start, int end) { return findByC_G(companyId, groupId, start, end, null); } /** * Returns an ordered range of all the report requests where companyId = ? and groupId = ?. * * <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 ReportRequestModelImpl}. 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 companyId the company ID * @param groupId the group ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching report requests */ @Override public List<ReportRequest> findByC_G(long companyId, long groupId, int start, int end, OrderByComparator<ReportRequest> orderByComparator) { return findByC_G(companyId, groupId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the report requests where companyId = ? and groupId = ?. * * <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 ReportRequestModelImpl}. 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 companyId the company ID * @param groupId the group ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (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 report requests */ @Override public List<ReportRequest> findByC_G(long companyId, long groupId, int start, int end, OrderByComparator<ReportRequest> 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_G; finderArgs = new Object[] { companyId, groupId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G; finderArgs = new Object[] { companyId, groupId, start, end, orderByComparator }; } List<ReportRequest> list = null; if (retrieveFromCache) { list = (List<ReportRequest>) finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (ReportRequest reportRequest : list) { if ((companyId != reportRequest.getCompanyId()) || (groupId != reportRequest.getGroupId())) { 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_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_C_G_COMPANYID_2); query.append(_FINDER_COLUMN_C_G_GROUPID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(ReportRequestModelImpl.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(companyId); qPos.add(groupId); if (!pagination) { list = (List<ReportRequest>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<ReportRequest>) 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 report request in the ordered set where companyId = ? and groupId = ?. * * @param companyId the company ID * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching report request * @throws NoSuchReportRequestException if a matching report request could not be found */ @Override public ReportRequest findByC_G_First(long companyId, long groupId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = fetchByC_G_First(companyId, groupId, orderByComparator); if (reportRequest != null) { return reportRequest; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", groupId="); msg.append(groupId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchReportRequestException(msg.toString()); } /** * Returns the first report request in the ordered set where companyId = ? and groupId = ?. * * @param companyId the company ID * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching report request, or <code>null</code> if a matching report request could not be found */ @Override public ReportRequest fetchByC_G_First(long companyId, long groupId, OrderByComparator<ReportRequest> orderByComparator) { List<ReportRequest> list = findByC_G(companyId, groupId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last report request in the ordered set where companyId = ? and groupId = ?. * * @param companyId the company ID * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching report request * @throws NoSuchReportRequestException if a matching report request could not be found */ @Override public ReportRequest findByC_G_Last(long companyId, long groupId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = fetchByC_G_Last(companyId, groupId, orderByComparator); if (reportRequest != null) { return reportRequest; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", groupId="); msg.append(groupId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchReportRequestException(msg.toString()); } /** * Returns the last report request in the ordered set where companyId = ? and groupId = ?. * * @param companyId the company ID * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching report request, or <code>null</code> if a matching report request could not be found */ @Override public ReportRequest fetchByC_G_Last(long companyId, long groupId, OrderByComparator<ReportRequest> orderByComparator) { int count = countByC_G(companyId, groupId); if (count == 0) { return null; } List<ReportRequest> list = findByC_G(companyId, groupId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the report requests before and after the current report request in the ordered set where companyId = ? and groupId = ?. * * @param reportRequestId the primary key of the current report request * @param companyId the company ID * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next report request * @throws NoSuchReportRequestException if a report request with the primary key could not be found */ @Override public ReportRequest[] findByC_G_PrevAndNext(long reportRequestId, long companyId, long groupId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = findByPrimaryKey(reportRequestId); Session session = null; try { session = openSession(); ReportRequest[] array = new ReportRequestImpl[3]; array[0] = getByC_G_PrevAndNext(session, reportRequest, companyId, groupId, orderByComparator, true); array[1] = reportRequest; array[2] = getByC_G_PrevAndNext(session, reportRequest, companyId, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected ReportRequest getByC_G_PrevAndNext(Session session, ReportRequest reportRequest, long companyId, long groupId, OrderByComparator<ReportRequest> 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_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_C_G_COMPANYID_2); query.append(_FINDER_COLUMN_C_G_GROUPID_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(ReportRequestModelImpl.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(companyId); qPos.add(groupId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(reportRequest); for (Object value : values) { qPos.add(value); } } List<ReportRequest> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the report requests that the user has permission to view where companyId = ? and groupId = ?. * * @param companyId the company ID * @param groupId the group ID * @return the matching report requests that the user has permission to view */ @Override public List<ReportRequest> filterFindByC_G(long companyId, long groupId) { return filterFindByC_G(companyId, groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the report requests that the user has permission to view where companyId = ? and groupId = ?. * * <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 ReportRequestModelImpl}. 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 companyId the company ID * @param groupId the group ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @return the range of matching report requests that the user has permission to view */ @Override public List<ReportRequest> filterFindByC_G(long companyId, long groupId, int start, int end) { return filterFindByC_G(companyId, groupId, start, end, null); } /** * Returns an ordered range of all the report requests that the user has permissions to view where companyId = ? and groupId = ?. * * <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 ReportRequestModelImpl}. 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 companyId the company ID * @param groupId the group ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching report requests that the user has permission to view */ @Override public List<ReportRequest> filterFindByC_G(long companyId, long groupId, int start, int end, OrderByComparator<ReportRequest> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByC_G(companyId, groupId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_REPORTREQUEST_WHERE); } else { query.append(_FILTER_SQL_SELECT_REPORTREQUEST_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_C_G_COMPANYID_2); query.append(_FINDER_COLUMN_C_G_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_REPORTREQUEST_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(ReportRequestModelImpl.ORDER_BY_JPQL); } else { query.append(ReportRequestModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), ReportRequest.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, ReportRequestImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, ReportRequestImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); return (List<ReportRequest>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the report requests before and after the current report request in the ordered set of report requests that the user has permission to view where companyId = ? and groupId = ?. * * @param reportRequestId the primary key of the current report request * @param companyId the company ID * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next report request * @throws NoSuchReportRequestException if a report request with the primary key could not be found */ @Override public ReportRequest[] filterFindByC_G_PrevAndNext(long reportRequestId, long companyId, long groupId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByC_G_PrevAndNext(reportRequestId, companyId, groupId, orderByComparator); } ReportRequest reportRequest = findByPrimaryKey(reportRequestId); Session session = null; try { session = openSession(); ReportRequest[] array = new ReportRequestImpl[3]; array[0] = filterGetByC_G_PrevAndNext(session, reportRequest, companyId, groupId, orderByComparator, true); array[1] = reportRequest; array[2] = filterGetByC_G_PrevAndNext(session, reportRequest, companyId, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected ReportRequest filterGetByC_G_PrevAndNext(Session session, ReportRequest reportRequest, long companyId, long groupId, OrderByComparator<ReportRequest> 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); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_REPORTREQUEST_WHERE); } else { query.append(_FILTER_SQL_SELECT_REPORTREQUEST_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_C_G_COMPANYID_2); query.append(_FINDER_COLUMN_C_G_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_REPORTREQUEST_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } 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++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } 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 { if (getDB().isSupportsInlineDistinct()) { query.append(ReportRequestModelImpl.ORDER_BY_JPQL); } else { query.append(ReportRequestModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), ReportRequest.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, ReportRequestImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, ReportRequestImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(reportRequest); for (Object value : values) { qPos.add(value); } } List<ReportRequest> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the report requests where companyId = ? and groupId = ? from the database. * * @param companyId the company ID * @param groupId the group ID */ @Override public void removeByC_G(long companyId, long groupId) { for (ReportRequest reportRequest : findByC_G(companyId, groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(reportRequest); } } /** * Returns the number of report requests where companyId = ? and groupId = ?. * * @param companyId the company ID * @param groupId the group ID * @return the number of matching report requests */ @Override public int countByC_G(long companyId, long groupId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_C_G; Object[] finderArgs = new Object[] { companyId, groupId }; Long count = (Long) finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_C_G_COMPANYID_2); query.append(_FINDER_COLUMN_C_G_GROUPID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); 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(); } /** * Returns the number of report requests that the user has permission to view where companyId = ? and groupId = ?. * * @param companyId the company ID * @param groupId the group ID * @return the number of matching report requests that the user has permission to view */ @Override public int filterCountByC_G(long companyId, long groupId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByC_G(companyId, groupId); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_C_G_COMPANYID_2); query.append(_FINDER_COLUMN_C_G_GROUPID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), ReportRequest.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_C_G_COMPANYID_2 = "reportRequest.companyId = ? AND "; private static final String _FINDER_COLUMN_C_G_GROUPID_2 = "reportRequest.groupId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RDI_U = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, ReportRequestImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByRDI_U", 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_RDI_U = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, ReportRequestImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRDI_U", new String[] { Long.class.getName(), Long.class.getName() }, ReportRequestModelImpl.REPORTDEFINITIONID_COLUMN_BITMASK | ReportRequestModelImpl.USERID_COLUMN_BITMASK | ReportRequestModelImpl.REPORTREQUESTFINISH_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_RDI_U = new FinderPath( ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRDI_U", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the report requests where reportDefinitionId = ? and userId = ?. * * @param reportDefinitionId the report definition ID * @param userId the user ID * @return the matching report requests */ @Override public List<ReportRequest> findByRDI_U(long reportDefinitionId, long userId) { return findByRDI_U(reportDefinitionId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the report requests where reportDefinitionId = ? and userId = ?. * * <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 ReportRequestModelImpl}. 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 reportDefinitionId the report definition ID * @param userId the user ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @return the range of matching report requests */ @Override public List<ReportRequest> findByRDI_U(long reportDefinitionId, long userId, int start, int end) { return findByRDI_U(reportDefinitionId, userId, start, end, null); } /** * Returns an ordered range of all the report requests where reportDefinitionId = ? and userId = ?. * * <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 ReportRequestModelImpl}. 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 reportDefinitionId the report definition ID * @param userId the user ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching report requests */ @Override public List<ReportRequest> findByRDI_U(long reportDefinitionId, long userId, int start, int end, OrderByComparator<ReportRequest> orderByComparator) { return findByRDI_U(reportDefinitionId, userId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the report requests where reportDefinitionId = ? and userId = ?. * * <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 ReportRequestModelImpl}. 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 reportDefinitionId the report definition ID * @param userId the user ID * @param start the lower bound of the range of report requests * @param end the upper bound of the range of report requests (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 report requests */ @Override public List<ReportRequest> findByRDI_U(long reportDefinitionId, long userId, int start, int end, OrderByComparator<ReportRequest> 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_RDI_U; finderArgs = new Object[] { reportDefinitionId, userId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RDI_U; finderArgs = new Object[] { reportDefinitionId, userId, start, end, orderByComparator }; } List<ReportRequest> list = null; if (retrieveFromCache) { list = (List<ReportRequest>) finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (ReportRequest reportRequest : list) { if ((reportDefinitionId != reportRequest.getReportDefinitionId()) || (userId != reportRequest.getUserId())) { 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_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_RDI_U_REPORTDEFINITIONID_2); query.append(_FINDER_COLUMN_RDI_U_USERID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(ReportRequestModelImpl.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(reportDefinitionId); qPos.add(userId); if (!pagination) { list = (List<ReportRequest>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<ReportRequest>) 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 report request in the ordered set where reportDefinitionId = ? and userId = ?. * * @param reportDefinitionId the report definition ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching report request * @throws NoSuchReportRequestException if a matching report request could not be found */ @Override public ReportRequest findByRDI_U_First(long reportDefinitionId, long userId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = fetchByRDI_U_First(reportDefinitionId, userId, orderByComparator); if (reportRequest != null) { return reportRequest; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("reportDefinitionId="); msg.append(reportDefinitionId); msg.append(", userId="); msg.append(userId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchReportRequestException(msg.toString()); } /** * Returns the first report request in the ordered set where reportDefinitionId = ? and userId = ?. * * @param reportDefinitionId the report definition ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching report request, or <code>null</code> if a matching report request could not be found */ @Override public ReportRequest fetchByRDI_U_First(long reportDefinitionId, long userId, OrderByComparator<ReportRequest> orderByComparator) { List<ReportRequest> list = findByRDI_U(reportDefinitionId, userId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last report request in the ordered set where reportDefinitionId = ? and userId = ?. * * @param reportDefinitionId the report definition ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching report request * @throws NoSuchReportRequestException if a matching report request could not be found */ @Override public ReportRequest findByRDI_U_Last(long reportDefinitionId, long userId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = fetchByRDI_U_Last(reportDefinitionId, userId, orderByComparator); if (reportRequest != null) { return reportRequest; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("reportDefinitionId="); msg.append(reportDefinitionId); msg.append(", userId="); msg.append(userId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchReportRequestException(msg.toString()); } /** * Returns the last report request in the ordered set where reportDefinitionId = ? and userId = ?. * * @param reportDefinitionId the report definition ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching report request, or <code>null</code> if a matching report request could not be found */ @Override public ReportRequest fetchByRDI_U_Last(long reportDefinitionId, long userId, OrderByComparator<ReportRequest> orderByComparator) { int count = countByRDI_U(reportDefinitionId, userId); if (count == 0) { return null; } List<ReportRequest> list = findByRDI_U(reportDefinitionId, userId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the report requests before and after the current report request in the ordered set where reportDefinitionId = ? and userId = ?. * * @param reportRequestId the primary key of the current report request * @param reportDefinitionId the report definition ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next report request * @throws NoSuchReportRequestException if a report request with the primary key could not be found */ @Override public ReportRequest[] findByRDI_U_PrevAndNext(long reportRequestId, long reportDefinitionId, long userId, OrderByComparator<ReportRequest> orderByComparator) throws NoSuchReportRequestException { ReportRequest reportRequest = findByPrimaryKey(reportRequestId); Session session = null; try { session = openSession(); ReportRequest[] array = new ReportRequestImpl[3]; array[0] = getByRDI_U_PrevAndNext(session, reportRequest, reportDefinitionId, userId, orderByComparator, true); array[1] = reportRequest; array[2] = getByRDI_U_PrevAndNext(session, reportRequest, reportDefinitionId, userId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected ReportRequest getByRDI_U_PrevAndNext(Session session, ReportRequest reportRequest, long reportDefinitionId, long userId, OrderByComparator<ReportRequest> 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_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_RDI_U_REPORTDEFINITIONID_2); query.append(_FINDER_COLUMN_RDI_U_USERID_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(ReportRequestModelImpl.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(reportDefinitionId); qPos.add(userId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(reportRequest); for (Object value : values) { qPos.add(value); } } List<ReportRequest> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the report requests where reportDefinitionId = ? and userId = ? from the database. * * @param reportDefinitionId the report definition ID * @param userId the user ID */ @Override public void removeByRDI_U(long reportDefinitionId, long userId) { for (ReportRequest reportRequest : findByRDI_U(reportDefinitionId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(reportRequest); } } /** * Returns the number of report requests where reportDefinitionId = ? and userId = ?. * * @param reportDefinitionId the report definition ID * @param userId the user ID * @return the number of matching report requests */ @Override public int countByRDI_U(long reportDefinitionId, long userId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_RDI_U; Object[] finderArgs = new Object[] { reportDefinitionId, userId }; Long count = (Long) finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_REPORTREQUEST_WHERE); query.append(_FINDER_COLUMN_RDI_U_REPORTDEFINITIONID_2); query.append(_FINDER_COLUMN_RDI_U_USERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(reportDefinitionId); qPos.add(userId); 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_RDI_U_REPORTDEFINITIONID_2 = "reportRequest.reportDefinitionId = ? AND "; private static final String _FINDER_COLUMN_RDI_U_USERID_2 = "reportRequest.userId = ?"; public ReportRequestPersistenceImpl() { setModelClass(ReportRequest.class); } /** * Caches the report request in the entity cache if it is enabled. * * @param reportRequest the report request */ @Override public void cacheResult(ReportRequest reportRequest) { entityCache.putResult(ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestImpl.class, reportRequest.getPrimaryKey(), reportRequest); reportRequest.resetOriginalValues(); } /** * Caches the report requests in the entity cache if it is enabled. * * @param reportRequests the report requests */ @Override public void cacheResult(List<ReportRequest> reportRequests) { for (ReportRequest reportRequest : reportRequests) { if (entityCache.getResult(ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestImpl.class, reportRequest.getPrimaryKey()) == null) { cacheResult(reportRequest); } else { reportRequest.resetOriginalValues(); } } } /** * Clears the cache for all report requests. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache() { entityCache.clearCache(ReportRequestImpl.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 report request. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache(ReportRequest reportRequest) { entityCache.removeResult(ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestImpl.class, reportRequest.getPrimaryKey()); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @Override public void clearCache(List<ReportRequest> reportRequests) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (ReportRequest reportRequest : reportRequests) { entityCache.removeResult(ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestImpl.class, reportRequest.getPrimaryKey()); } } /** * Creates a new report request with the primary key. Does not add the report request to the database. * * @param reportRequestId the primary key for the new report request * @return the new report request */ @Override public ReportRequest create(long reportRequestId) { ReportRequest reportRequest = new ReportRequestImpl(); reportRequest.setNew(true); reportRequest.setPrimaryKey(reportRequestId); reportRequest.setCompanyId(companyProvider.getCompanyId()); return reportRequest; } /** * Removes the report request with the primary key from the database. Also notifies the appropriate model listeners. * * @param reportRequestId the primary key of the report request * @return the report request that was removed * @throws NoSuchReportRequestException if a report request with the primary key could not be found */ @Override public ReportRequest remove(long reportRequestId) throws NoSuchReportRequestException { return remove((Serializable) reportRequestId); } /** * Removes the report request with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the report request * @return the report request that was removed * @throws NoSuchReportRequestException if a report request with the primary key could not be found */ @Override public ReportRequest remove(Serializable primaryKey) throws NoSuchReportRequestException { Session session = null; try { session = openSession(); ReportRequest reportRequest = (ReportRequest) session.get(ReportRequestImpl.class, primaryKey); if (reportRequest == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchReportRequestException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(reportRequest); } catch (NoSuchReportRequestException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected ReportRequest removeImpl(ReportRequest reportRequest) { reportRequest = toUnwrappedModel(reportRequest); Session session = null; try { session = openSession(); if (!session.contains(reportRequest)) { reportRequest = (ReportRequest) session.get(ReportRequestImpl.class, reportRequest.getPrimaryKeyObj()); } if (reportRequest != null) { session.delete(reportRequest); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (reportRequest != null) { clearCache(reportRequest); } return reportRequest; } @Override public ReportRequest updateImpl(ReportRequest reportRequest) { reportRequest = toUnwrappedModel(reportRequest); boolean isNew = reportRequest.isNew(); ReportRequestModelImpl reportRequestModelImpl = (ReportRequestModelImpl) reportRequest; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (reportRequest.getCreateDate() == null)) { if (serviceContext == null) { reportRequest.setCreateDate(now); } else { reportRequest.setCreateDate(serviceContext.getCreateDate(now)); } } if (!reportRequestModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { reportRequest.setModifiedDate(now); } else { reportRequest.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (reportRequest.isNew()) { session.save(reportRequest); reportRequest.setNew(false); } else { reportRequest = (ReportRequest) session.merge(reportRequest); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !ReportRequestModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((reportRequestModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPORTDEFINITIONID.getColumnBitmask()) != 0) { Object[] args = new Object[] { reportRequestModelImpl.getOriginalReportDefinitionId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_REPORTDEFINITIONID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPORTDEFINITIONID, args); args = new Object[] { reportRequestModelImpl.getReportDefinitionId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_REPORTDEFINITIONID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPORTDEFINITIONID, args); } if ((reportRequestModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) { Object[] args = new Object[] { reportRequestModelImpl.getOriginalUserId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID, args); args = new Object[] { reportRequestModelImpl.getUserId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID, args); } if ((reportRequestModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RDC_U.getColumnBitmask()) != 0) { Object[] args = new Object[] { reportRequestModelImpl.getOriginalReportDefinitionCategory(), reportRequestModelImpl.getOriginalUserId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_RDC_U, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RDC_U, args); args = new Object[] { reportRequestModelImpl.getReportDefinitionCategory(), reportRequestModelImpl.getUserId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_RDC_U, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RDC_U, args); } if ((reportRequestModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_G.getColumnBitmask()) != 0) { Object[] args = new Object[] { reportRequestModelImpl.getOriginalCompanyId(), reportRequestModelImpl.getOriginalGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_G, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_G, args); args = new Object[] { reportRequestModelImpl.getCompanyId(), reportRequestModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_G, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_G, args); } if ((reportRequestModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RDI_U.getColumnBitmask()) != 0) { Object[] args = new Object[] { reportRequestModelImpl.getOriginalReportDefinitionId(), reportRequestModelImpl.getOriginalUserId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_RDI_U, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RDI_U, args); args = new Object[] { reportRequestModelImpl.getReportDefinitionId(), reportRequestModelImpl.getUserId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_RDI_U, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RDI_U, args); } } entityCache.putResult(ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestImpl.class, reportRequest.getPrimaryKey(), reportRequest, false); reportRequest.resetOriginalValues(); return reportRequest; } protected ReportRequest toUnwrappedModel(ReportRequest reportRequest) { if (reportRequest instanceof ReportRequestImpl) { return reportRequest; } ReportRequestImpl reportRequestImpl = new ReportRequestImpl(); reportRequestImpl.setNew(reportRequest.isNew()); reportRequestImpl.setPrimaryKey(reportRequest.getPrimaryKey()); reportRequestImpl.setReportRequestId(reportRequest.getReportRequestId()); reportRequestImpl.setGroupId(reportRequest.getGroupId()); reportRequestImpl.setCompanyId(reportRequest.getCompanyId()); reportRequestImpl.setUserId(reportRequest.getUserId()); reportRequestImpl.setUserName(reportRequest.getUserName()); reportRequestImpl.setCreateDate(reportRequest.getCreateDate()); reportRequestImpl.setModifiedDate(reportRequest.getModifiedDate()); reportRequestImpl.setErrorMessage(reportRequest.getErrorMessage()); reportRequestImpl.setReportDefinitionId(reportRequest.getReportDefinitionId()); reportRequestImpl.setReportDefinitionName(reportRequest.getReportDefinitionName()); reportRequestImpl.setReportDefinitionCategory(reportRequest.getReportDefinitionCategory()); reportRequestImpl.setParameters(reportRequest.getParameters()); reportRequestImpl.setSelectedFields(reportRequest.getSelectedFields()); reportRequestImpl.setReportFormat(reportRequest.getReportFormat()); reportRequestImpl.setReportRequestStart(reportRequest.getReportRequestStart()); reportRequestImpl.setReportRequestFinish(reportRequest.getReportRequestFinish()); reportRequestImpl.setSortFields(reportRequest.getSortFields()); reportRequestImpl.setSuccess(reportRequest.isSuccess()); return reportRequestImpl; } /** * Returns the report request 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 report request * @return the report request * @throws NoSuchReportRequestException if a report request with the primary key could not be found */ @Override public ReportRequest findByPrimaryKey(Serializable primaryKey) throws NoSuchReportRequestException { ReportRequest reportRequest = fetchByPrimaryKey(primaryKey); if (reportRequest == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchReportRequestException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return reportRequest; } /** * Returns the report request with the primary key or throws a {@link NoSuchReportRequestException} if it could not be found. * * @param reportRequestId the primary key of the report request * @return the report request * @throws NoSuchReportRequestException if a report request with the primary key could not be found */ @Override public ReportRequest findByPrimaryKey(long reportRequestId) throws NoSuchReportRequestException { return findByPrimaryKey((Serializable) reportRequestId); } /** * Returns the report request with the primary key or returns <code>null</code> if it could not be found. * * @param primaryKey the primary key of the report request * @return the report request, or <code>null</code> if a report request with the primary key could not be found */ @Override public ReportRequest fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = entityCache.getResult(ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestImpl.class, primaryKey); if (serializable == nullModel) { return null; } ReportRequest reportRequest = (ReportRequest) serializable; if (reportRequest == null) { Session session = null; try { session = openSession(); reportRequest = (ReportRequest) session.get(ReportRequestImpl.class, primaryKey); if (reportRequest != null) { cacheResult(reportRequest); } else { entityCache.putResult(ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestImpl.class, primaryKey, nullModel); } } catch (Exception e) { entityCache.removeResult(ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return reportRequest; } /** * Returns the report request with the primary key or returns <code>null</code> if it could not be found. * * @param reportRequestId the primary key of the report request * @return the report request, or <code>null</code> if a report request with the primary key could not be found */ @Override public ReportRequest fetchByPrimaryKey(long reportRequestId) { return fetchByPrimaryKey((Serializable) reportRequestId); } @Override public Map<Serializable, ReportRequest> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map<Serializable, ReportRequest> map = new HashMap<Serializable, ReportRequest>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); ReportRequest reportRequest = fetchByPrimaryKey(primaryKey); if (reportRequest != null) { map.put(primaryKey, reportRequest); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (ReportRequest) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_REPORTREQUEST_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(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 (ReportRequest reportRequest : (List<ReportRequest>) q.list()) { map.put(reportRequest.getPrimaryKeyObj(), reportRequest); cacheResult(reportRequest); uncachedPrimaryKeys.remove(reportRequest.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(ReportRequestModelImpl.ENTITY_CACHE_ENABLED, ReportRequestImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the report requests. * * @return the report requests */ @Override public List<ReportRequest> findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the report requests. * * <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 ReportRequestModelImpl}. 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 report requests * @param end the upper bound of the range of report requests (not inclusive) * @return the range of report requests */ @Override public List<ReportRequest> findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the report requests. * * <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 ReportRequestModelImpl}. 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 report requests * @param end the upper bound of the range of report requests (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of report requests */ @Override public List<ReportRequest> findAll(int start, int end, OrderByComparator<ReportRequest> orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the report requests. * * <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 ReportRequestModelImpl}. 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 report requests * @param end the upper bound of the range of report requests (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 report requests */ @Override public List<ReportRequest> findAll(int start, int end, OrderByComparator<ReportRequest> 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<ReportRequest> list = null; if (retrieveFromCache) { list = (List<ReportRequest>) 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_REPORTREQUEST); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_REPORTREQUEST; if (pagination) { sql = sql.concat(ReportRequestModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<ReportRequest>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<ReportRequest>) 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 report requests from the database. * */ @Override public void removeAll() { for (ReportRequest reportRequest : findAll()) { remove(reportRequest); } } /** * Returns the number of report requests. * * @return the number of report requests */ @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_REPORTREQUEST); 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 protected Map<String, Integer> getTableColumnsMap() { return ReportRequestModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the report request persistence. */ public void afterPropertiesSet() { } public void destroy() { entityCache.removeCache(ReportRequestImpl.class.getName()); finderCache.removeCache(FINDER_CLASS_NAME_ENTITY); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @ServiceReference(type = CompanyProviderWrapper.class) protected CompanyProvider companyProvider; @ServiceReference(type = EntityCache.class) protected EntityCache entityCache; @ServiceReference(type = FinderCache.class) protected FinderCache finderCache; private static final String _SQL_SELECT_REPORTREQUEST = "SELECT reportRequest FROM ReportRequest reportRequest"; private static final String _SQL_SELECT_REPORTREQUEST_WHERE_PKS_IN = "SELECT reportRequest FROM ReportRequest reportRequest WHERE reportRequestId IN ("; private static final String _SQL_SELECT_REPORTREQUEST_WHERE = "SELECT reportRequest FROM ReportRequest reportRequest WHERE "; private static final String _SQL_COUNT_REPORTREQUEST = "SELECT COUNT(reportRequest) FROM ReportRequest reportRequest"; private static final String _SQL_COUNT_REPORTREQUEST_WHERE = "SELECT COUNT(reportRequest) FROM ReportRequest reportRequest WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "reportRequest.reportRequestId"; private static final String _FILTER_SQL_SELECT_REPORTREQUEST_WHERE = "SELECT DISTINCT {reportRequest.*} FROM Bemis_ReportRequest reportRequest WHERE "; private static final String _FILTER_SQL_SELECT_REPORTREQUEST_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {Bemis_ReportRequest.*} FROM (SELECT DISTINCT reportRequest.reportRequestId FROM Bemis_ReportRequest reportRequest WHERE "; private static final String _FILTER_SQL_SELECT_REPORTREQUEST_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN Bemis_ReportRequest ON TEMP_TABLE.reportRequestId = Bemis_ReportRequest.reportRequestId"; private static final String _FILTER_SQL_COUNT_REPORTREQUEST_WHERE = "SELECT COUNT(DISTINCT reportRequest.reportRequestId) AS COUNT_VALUE FROM Bemis_ReportRequest reportRequest WHERE "; private static final String _FILTER_ENTITY_ALIAS = "reportRequest"; private static final String _FILTER_ENTITY_TABLE = "Bemis_ReportRequest"; private static final String _ORDER_BY_ENTITY_ALIAS = "reportRequest."; private static final String _ORDER_BY_ENTITY_TABLE = "Bemis_ReportRequest."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ReportRequest exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ReportRequest exists with the key {"; private static final Log _log = LogFactoryUtil.getLog(ReportRequestPersistenceImpl.class); }