
com.liferay.commerce.service.persistence.impl.CommerceOrderPersistenceImpl Maven / Gradle / Ivy
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.commerce.service.persistence.impl;
import com.liferay.commerce.exception.DuplicateCommerceOrderExternalReferenceCodeException;
import com.liferay.commerce.exception.NoSuchOrderException;
import com.liferay.commerce.model.CommerceOrder;
import com.liferay.commerce.model.CommerceOrderTable;
import com.liferay.commerce.model.impl.CommerceOrderImpl;
import com.liferay.commerce.model.impl.CommerceOrderModelImpl;
import com.liferay.commerce.service.persistence.CommerceOrderPersistence;
import com.liferay.commerce.service.persistence.CommerceOrderUtil;
import com.liferay.commerce.service.persistence.impl.constants.CommercePersistenceConstants;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.configuration.Configuration;
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.dao.orm.SessionFactory;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.sanitizer.Sanitizer;
import com.liferay.portal.kernel.sanitizer.SanitizerException;
import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal;
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.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.sql.DataSource;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
/**
* The persistence implementation for the commerce order service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Alessio Antonio Rendina
* @generated
*/
@Component(service = CommerceOrderPersistence.class)
public class CommerceOrderPersistenceImpl
extends BasePersistenceImpl
implements CommerceOrderPersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use CommerceOrderUtil
to access the commerce order persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY =
CommerceOrderImpl.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";
private FinderPath _finderPathWithPaginationFindAll;
private FinderPath _finderPathWithoutPaginationFindAll;
private FinderPath _finderPathCountAll;
private FinderPath _finderPathWithPaginationFindByUuid;
private FinderPath _finderPathWithoutPaginationFindByUuid;
private FinderPath _finderPathCountByUuid;
/**
* Returns all the commerce orders where uuid = ?.
*
* @param uuid the uuid
* @return the matching commerce orders
*/
@Override
public List findByUuid(String uuid) {
return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders
*/
@Override
public List findByUuid(String uuid, int start, int end) {
return findByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid(uuid, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the commerce orders where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching commerce orders
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUuid;
finderArgs = new Object[] {uuid};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUuid;
finderArgs = new Object[] {uuid, start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (CommerceOrder commerceOrder : list) {
if (!uuid.equals(commerceOrder.getUuid())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first commerce order in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByUuid_First(
String uuid, OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByUuid_First(
uuid, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the first commerce order in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByUuid_First(
String uuid, OrderByComparator orderByComparator) {
List list = findByUuid(uuid, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last commerce order in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByUuid_Last(
String uuid, OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByUuid_Last(uuid, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the last commerce order in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByUuid_Last(
String uuid, OrderByComparator orderByComparator) {
int count = countByUuid(uuid);
if (count == 0) {
return null;
}
List list = findByUuid(
uuid, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set where uuid = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] findByUuid_PrevAndNext(
long commerceOrderId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
uuid = Objects.toString(uuid, "");
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = getByUuid_PrevAndNext(
session, commerceOrder, uuid, orderByComparator, true);
array[1] = commerceOrder;
array[2] = getByUuid_PrevAndNext(
session, commerceOrder, uuid, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder getByUuid_PrevAndNext(
Session session, CommerceOrder commerceOrder, String uuid,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the commerce orders where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
for (CommerceOrder commerceOrder :
findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commerceOrder);
}
}
/**
* Returns the number of commerce orders where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching commerce orders
*/
@Override
public int countByUuid(String uuid) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid;
Object[] finderArgs = new Object[] {uuid};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_COMMERCEORDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_UUID_2 =
"commerceOrder.uuid = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3 =
"(commerceOrder.uuid IS NULL OR commerceOrder.uuid = '')";
private FinderPath _finderPathFetchByUUID_G;
/**
* Returns the commerce order where uuid = ? and groupId = ? or throws a NoSuchOrderException
if it could not be found.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByUUID_G(String uuid, long groupId)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByUUID_G(uuid, groupId);
if (commerceOrder == null) {
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", groupId=");
sb.append(groupId);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchOrderException(sb.toString());
}
return commerceOrder;
}
/**
* Returns the commerce order where uuid = ? and groupId = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByUUID_G(String uuid, long groupId) {
return fetchByUUID_G(uuid, groupId, true);
}
/**
* Returns the commerce order where uuid = ? and groupId = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @param useFinderCache whether to use the finder cache
* @return the matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByUUID_G(
String uuid, long groupId, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {uuid, groupId};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByUUID_G, finderArgs, this);
}
if (result instanceof CommerceOrder) {
CommerceOrder commerceOrder = (CommerceOrder)result;
if (!Objects.equals(uuid, commerceOrder.getUuid()) ||
(groupId != commerceOrder.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(groupId);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByUUID_G, finderArgs, list);
}
}
else {
CommerceOrder commerceOrder = list.get(0);
result = commerceOrder;
cacheResult(commerceOrder);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (CommerceOrder)result;
}
}
/**
* Removes the commerce order where uuid = ? and groupId = ? from the database.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the commerce order that was removed
*/
@Override
public CommerceOrder removeByUUID_G(String uuid, long groupId)
throws NoSuchOrderException {
CommerceOrder commerceOrder = findByUUID_G(uuid, groupId);
return remove(commerceOrder);
}
/**
* Returns the number of commerce orders where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the number of matching commerce orders
*/
@Override
public int countByUUID_G(String uuid, long groupId) {
CommerceOrder commerceOrder = fetchByUUID_G(uuid, groupId);
if (commerceOrder == null) {
return 0;
}
return 1;
}
private static final String _FINDER_COLUMN_UUID_G_UUID_2 =
"commerceOrder.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_G_UUID_3 =
"(commerceOrder.uuid IS NULL OR commerceOrder.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 =
"commerceOrder.groupId = ?";
private FinderPath _finderPathWithPaginationFindByUuid_C;
private FinderPath _finderPathWithoutPaginationFindByUuid_C;
private FinderPath _finderPathCountByUuid_C;
/**
* Returns all the commerce orders where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching commerce orders
*/
@Override
public List findByUuid_C(String uuid, long companyId) {
return findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end) {
return findByUuid_C(uuid, companyId, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid_C(
uuid, companyId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the commerce orders where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching commerce orders
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUuid_C;
finderArgs = new Object[] {uuid, companyId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUuid_C;
finderArgs = new Object[] {
uuid, companyId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (CommerceOrder commerceOrder : list) {
if (!uuid.equals(commerceOrder.getUuid()) ||
(companyId != commerceOrder.getCompanyId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first commerce order in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByUuid_C_First(
uuid, companyId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the first commerce order in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator) {
List list = findByUuid_C(
uuid, companyId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last commerce order in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByUuid_C_Last(
uuid, companyId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the last commerce order in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator) {
int count = countByUuid_C(uuid, companyId);
if (count == 0) {
return null;
}
List list = findByUuid_C(
uuid, companyId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set where uuid = ? and companyId = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] findByUuid_C_PrevAndNext(
long commerceOrderId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
uuid = Objects.toString(uuid, "");
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = getByUuid_C_PrevAndNext(
session, commerceOrder, uuid, companyId, orderByComparator,
true);
array[1] = commerceOrder;
array[2] = getByUuid_C_PrevAndNext(
session, commerceOrder, uuid, companyId, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder getByUuid_C_PrevAndNext(
Session session, CommerceOrder commerceOrder, String uuid,
long companyId, OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the commerce orders where uuid = ? and companyId = ? from the database.
*
* @param uuid the uuid
* @param companyId the company ID
*/
@Override
public void removeByUuid_C(String uuid, long companyId) {
for (CommerceOrder commerceOrder :
findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(commerceOrder);
}
}
/**
* Returns the number of commerce orders where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching commerce orders
*/
@Override
public int countByUuid_C(String uuid, long companyId) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid_C;
Object[] finderArgs = new Object[] {uuid, companyId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_COMMERCEORDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_C_UUID_2 =
"commerceOrder.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3 =
"(commerceOrder.uuid IS NULL OR commerceOrder.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 =
"commerceOrder.companyId = ?";
private FinderPath _finderPathWithPaginationFindByGroupId;
private FinderPath _finderPathWithoutPaginationFindByGroupId;
private FinderPath _finderPathCountByGroupId;
/**
* Returns all the commerce orders where groupId = ?.
*
* @param groupId the group ID
* @return the matching commerce orders
*/
@Override
public List findByGroupId(long groupId) {
return findByGroupId(
groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders
*/
@Override
public List findByGroupId(long groupId, int start, int end) {
return findByGroupId(groupId, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders
*/
@Override
public List findByGroupId(
long groupId, int start, int end,
OrderByComparator orderByComparator) {
return findByGroupId(groupId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the commerce orders where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching commerce orders
*/
@Override
public List findByGroupId(
long groupId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByGroupId;
finderArgs = new Object[] {groupId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByGroupId;
finderArgs = new Object[] {groupId, start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (CommerceOrder commerceOrder : list) {
if (groupId != commerceOrder.getGroupId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first commerce order in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByGroupId_First(
long groupId, OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByGroupId_First(
groupId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the first commerce order in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByGroupId_First(
long groupId, OrderByComparator orderByComparator) {
List list = findByGroupId(
groupId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last commerce order in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByGroupId_Last(
long groupId, OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByGroupId_Last(
groupId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the last commerce order in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByGroupId_Last(
long groupId, OrderByComparator orderByComparator) {
int count = countByGroupId(groupId);
if (count == 0) {
return null;
}
List list = findByGroupId(
groupId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set where groupId = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] findByGroupId_PrevAndNext(
long commerceOrderId, long groupId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = getByGroupId_PrevAndNext(
session, commerceOrder, groupId, orderByComparator, true);
array[1] = commerceOrder;
array[2] = getByGroupId_PrevAndNext(
session, commerceOrder, groupId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder getByGroupId_PrevAndNext(
Session session, CommerceOrder commerceOrder, long groupId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the commerce orders that the user has permission to view where groupId = ?.
*
* @param groupId the group ID
* @return the matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByGroupId(long groupId) {
return filterFindByGroupId(
groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders that the user has permission to view where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByGroupId(
long groupId, int start, int end) {
return filterFindByGroupId(groupId, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders that the user has permissions to view where groupId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByGroupId(
long groupId, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByGroupId(groupId, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_COMMERCEORDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, CommerceOrderImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, CommerceOrderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set of commerce orders that the user has permission to view where groupId = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] filterFindByGroupId_PrevAndNext(
long commerceOrderId, long groupId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByGroupId_PrevAndNext(
commerceOrderId, groupId, orderByComparator);
}
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = filterGetByGroupId_PrevAndNext(
session, commerceOrder, groupId, orderByComparator, true);
array[1] = commerceOrder;
array[2] = filterGetByGroupId_PrevAndNext(
session, commerceOrder, groupId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder filterGetByGroupId_PrevAndNext(
Session session, CommerceOrder commerceOrder, long groupId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_COMMERCEORDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, CommerceOrderImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, CommerceOrderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the commerce orders where groupId = ? from the database.
*
* @param groupId the group ID
*/
@Override
public void removeByGroupId(long groupId) {
for (CommerceOrder commerceOrder :
findByGroupId(
groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commerceOrder);
}
}
/**
* Returns the number of commerce orders where groupId = ?.
*
* @param groupId the group ID
* @return the number of matching commerce orders
*/
@Override
public int countByGroupId(long groupId) {
FinderPath finderPath = _finderPathCountByGroupId;
Object[] finderArgs = new Object[] {groupId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of commerce orders that the user has permission to view where groupId = ?.
*
* @param groupId the group ID
* @return the number of matching commerce orders that the user has permission to view
*/
@Override
public int filterCountByGroupId(long groupId) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByGroupId(groupId);
}
StringBundler sb = new StringBundler(2);
sb.append(_FILTER_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 =
"commerceOrder.groupId = ?";
private FinderPath _finderPathWithPaginationFindByUserId;
private FinderPath _finderPathWithoutPaginationFindByUserId;
private FinderPath _finderPathCountByUserId;
/**
* Returns all the commerce orders where userId = ?.
*
* @param userId the user ID
* @return the matching commerce orders
*/
@Override
public List findByUserId(long userId) {
return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders where userId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param userId the user ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders
*/
@Override
public List findByUserId(long userId, int start, int end) {
return findByUserId(userId, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders where userId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param userId the user ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders
*/
@Override
public List findByUserId(
long userId, int start, int end,
OrderByComparator orderByComparator) {
return findByUserId(userId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the commerce orders where userId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param userId the user ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching commerce orders
*/
@Override
public List findByUserId(
long userId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUserId;
finderArgs = new Object[] {userId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUserId;
finderArgs = new Object[] {userId, start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (CommerceOrder commerceOrder : list) {
if (userId != commerceOrder.getUserId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_USERID_USERID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(userId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first commerce order in the ordered set where userId = ?.
*
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByUserId_First(
long userId, OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByUserId_First(
userId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("userId=");
sb.append(userId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the first commerce order in the ordered set where userId = ?.
*
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByUserId_First(
long userId, OrderByComparator orderByComparator) {
List list = findByUserId(
userId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last commerce order in the ordered set where userId = ?.
*
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByUserId_Last(
long userId, OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByUserId_Last(
userId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("userId=");
sb.append(userId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the last commerce order in the ordered set where userId = ?.
*
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByUserId_Last(
long userId, OrderByComparator orderByComparator) {
int count = countByUserId(userId);
if (count == 0) {
return null;
}
List list = findByUserId(
userId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set where userId = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param userId the user ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] findByUserId_PrevAndNext(
long commerceOrderId, long userId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = getByUserId_PrevAndNext(
session, commerceOrder, userId, orderByComparator, true);
array[1] = commerceOrder;
array[2] = getByUserId_PrevAndNext(
session, commerceOrder, userId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder getByUserId_PrevAndNext(
Session session, CommerceOrder commerceOrder, long userId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_USERID_USERID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(userId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the commerce orders where userId = ? from the database.
*
* @param userId the user ID
*/
@Override
public void removeByUserId(long userId) {
for (CommerceOrder commerceOrder :
findByUserId(
userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commerceOrder);
}
}
/**
* Returns the number of commerce orders where userId = ?.
*
* @param userId the user ID
* @return the number of matching commerce orders
*/
@Override
public int countByUserId(long userId) {
FinderPath finderPath = _finderPathCountByUserId;
Object[] finderArgs = new Object[] {userId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_USERID_USERID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(userId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_USERID_USERID_2 =
"commerceOrder.userId = ?";
private FinderPath _finderPathWithPaginationFindByBillingAddressId;
private FinderPath _finderPathWithoutPaginationFindByBillingAddressId;
private FinderPath _finderPathCountByBillingAddressId;
/**
* Returns all the commerce orders where billingAddressId = ?.
*
* @param billingAddressId the billing address ID
* @return the matching commerce orders
*/
@Override
public List findByBillingAddressId(long billingAddressId) {
return findByBillingAddressId(
billingAddressId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders where billingAddressId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param billingAddressId the billing address ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders
*/
@Override
public List findByBillingAddressId(
long billingAddressId, int start, int end) {
return findByBillingAddressId(billingAddressId, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders where billingAddressId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param billingAddressId the billing address ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders
*/
@Override
public List findByBillingAddressId(
long billingAddressId, int start, int end,
OrderByComparator orderByComparator) {
return findByBillingAddressId(
billingAddressId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the commerce orders where billingAddressId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param billingAddressId the billing address ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching commerce orders
*/
@Override
public List findByBillingAddressId(
long billingAddressId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByBillingAddressId;
finderArgs = new Object[] {billingAddressId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByBillingAddressId;
finderArgs = new Object[] {
billingAddressId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (CommerceOrder commerceOrder : list) {
if (billingAddressId !=
commerceOrder.getBillingAddressId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_BILLINGADDRESSID_BILLINGADDRESSID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(billingAddressId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first commerce order in the ordered set where billingAddressId = ?.
*
* @param billingAddressId the billing address ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByBillingAddressId_First(
long billingAddressId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByBillingAddressId_First(
billingAddressId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("billingAddressId=");
sb.append(billingAddressId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the first commerce order in the ordered set where billingAddressId = ?.
*
* @param billingAddressId the billing address ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByBillingAddressId_First(
long billingAddressId,
OrderByComparator orderByComparator) {
List list = findByBillingAddressId(
billingAddressId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last commerce order in the ordered set where billingAddressId = ?.
*
* @param billingAddressId the billing address ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByBillingAddressId_Last(
long billingAddressId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByBillingAddressId_Last(
billingAddressId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("billingAddressId=");
sb.append(billingAddressId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the last commerce order in the ordered set where billingAddressId = ?.
*
* @param billingAddressId the billing address ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByBillingAddressId_Last(
long billingAddressId,
OrderByComparator orderByComparator) {
int count = countByBillingAddressId(billingAddressId);
if (count == 0) {
return null;
}
List list = findByBillingAddressId(
billingAddressId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set where billingAddressId = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param billingAddressId the billing address ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] findByBillingAddressId_PrevAndNext(
long commerceOrderId, long billingAddressId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = getByBillingAddressId_PrevAndNext(
session, commerceOrder, billingAddressId, orderByComparator,
true);
array[1] = commerceOrder;
array[2] = getByBillingAddressId_PrevAndNext(
session, commerceOrder, billingAddressId, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder getByBillingAddressId_PrevAndNext(
Session session, CommerceOrder commerceOrder, long billingAddressId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_BILLINGADDRESSID_BILLINGADDRESSID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(billingAddressId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the commerce orders where billingAddressId = ? from the database.
*
* @param billingAddressId the billing address ID
*/
@Override
public void removeByBillingAddressId(long billingAddressId) {
for (CommerceOrder commerceOrder :
findByBillingAddressId(
billingAddressId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(commerceOrder);
}
}
/**
* Returns the number of commerce orders where billingAddressId = ?.
*
* @param billingAddressId the billing address ID
* @return the number of matching commerce orders
*/
@Override
public int countByBillingAddressId(long billingAddressId) {
FinderPath finderPath = _finderPathCountByBillingAddressId;
Object[] finderArgs = new Object[] {billingAddressId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_BILLINGADDRESSID_BILLINGADDRESSID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(billingAddressId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String
_FINDER_COLUMN_BILLINGADDRESSID_BILLINGADDRESSID_2 =
"commerceOrder.billingAddressId = ?";
private FinderPath _finderPathWithPaginationFindByCommerceAccountId;
private FinderPath _finderPathWithoutPaginationFindByCommerceAccountId;
private FinderPath _finderPathCountByCommerceAccountId;
/**
* Returns all the commerce orders where commerceAccountId = ?.
*
* @param commerceAccountId the commerce account ID
* @return the matching commerce orders
*/
@Override
public List findByCommerceAccountId(long commerceAccountId) {
return findByCommerceAccountId(
commerceAccountId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders where commerceAccountId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param commerceAccountId the commerce account ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders
*/
@Override
public List findByCommerceAccountId(
long commerceAccountId, int start, int end) {
return findByCommerceAccountId(commerceAccountId, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders where commerceAccountId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param commerceAccountId the commerce account ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders
*/
@Override
public List findByCommerceAccountId(
long commerceAccountId, int start, int end,
OrderByComparator orderByComparator) {
return findByCommerceAccountId(
commerceAccountId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the commerce orders where commerceAccountId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param commerceAccountId the commerce account ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching commerce orders
*/
@Override
public List findByCommerceAccountId(
long commerceAccountId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath =
_finderPathWithoutPaginationFindByCommerceAccountId;
finderArgs = new Object[] {commerceAccountId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByCommerceAccountId;
finderArgs = new Object[] {
commerceAccountId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (CommerceOrder commerceOrder : list) {
if (commerceAccountId !=
commerceOrder.getCommerceAccountId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_COMMERCEACCOUNTID_COMMERCEACCOUNTID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(commerceAccountId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first commerce order in the ordered set where commerceAccountId = ?.
*
* @param commerceAccountId the commerce account ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByCommerceAccountId_First(
long commerceAccountId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByCommerceAccountId_First(
commerceAccountId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("commerceAccountId=");
sb.append(commerceAccountId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the first commerce order in the ordered set where commerceAccountId = ?.
*
* @param commerceAccountId the commerce account ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByCommerceAccountId_First(
long commerceAccountId,
OrderByComparator orderByComparator) {
List list = findByCommerceAccountId(
commerceAccountId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last commerce order in the ordered set where commerceAccountId = ?.
*
* @param commerceAccountId the commerce account ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByCommerceAccountId_Last(
long commerceAccountId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByCommerceAccountId_Last(
commerceAccountId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("commerceAccountId=");
sb.append(commerceAccountId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the last commerce order in the ordered set where commerceAccountId = ?.
*
* @param commerceAccountId the commerce account ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByCommerceAccountId_Last(
long commerceAccountId,
OrderByComparator orderByComparator) {
int count = countByCommerceAccountId(commerceAccountId);
if (count == 0) {
return null;
}
List list = findByCommerceAccountId(
commerceAccountId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set where commerceAccountId = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param commerceAccountId the commerce account ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] findByCommerceAccountId_PrevAndNext(
long commerceOrderId, long commerceAccountId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = getByCommerceAccountId_PrevAndNext(
session, commerceOrder, commerceAccountId, orderByComparator,
true);
array[1] = commerceOrder;
array[2] = getByCommerceAccountId_PrevAndNext(
session, commerceOrder, commerceAccountId, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder getByCommerceAccountId_PrevAndNext(
Session session, CommerceOrder commerceOrder, long commerceAccountId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_COMMERCEACCOUNTID_COMMERCEACCOUNTID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(commerceAccountId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the commerce orders where commerceAccountId = ? from the database.
*
* @param commerceAccountId the commerce account ID
*/
@Override
public void removeByCommerceAccountId(long commerceAccountId) {
for (CommerceOrder commerceOrder :
findByCommerceAccountId(
commerceAccountId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(commerceOrder);
}
}
/**
* Returns the number of commerce orders where commerceAccountId = ?.
*
* @param commerceAccountId the commerce account ID
* @return the number of matching commerce orders
*/
@Override
public int countByCommerceAccountId(long commerceAccountId) {
FinderPath finderPath = _finderPathCountByCommerceAccountId;
Object[] finderArgs = new Object[] {commerceAccountId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_COMMERCEACCOUNTID_COMMERCEACCOUNTID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(commerceAccountId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String
_FINDER_COLUMN_COMMERCEACCOUNTID_COMMERCEACCOUNTID_2 =
"commerceOrder.commerceAccountId = ?";
private FinderPath _finderPathWithPaginationFindByShippingAddressId;
private FinderPath _finderPathWithoutPaginationFindByShippingAddressId;
private FinderPath _finderPathCountByShippingAddressId;
/**
* Returns all the commerce orders where shippingAddressId = ?.
*
* @param shippingAddressId the shipping address ID
* @return the matching commerce orders
*/
@Override
public List findByShippingAddressId(long shippingAddressId) {
return findByShippingAddressId(
shippingAddressId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders where shippingAddressId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param shippingAddressId the shipping address ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders
*/
@Override
public List findByShippingAddressId(
long shippingAddressId, int start, int end) {
return findByShippingAddressId(shippingAddressId, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders where shippingAddressId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param shippingAddressId the shipping address ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders
*/
@Override
public List findByShippingAddressId(
long shippingAddressId, int start, int end,
OrderByComparator orderByComparator) {
return findByShippingAddressId(
shippingAddressId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the commerce orders where shippingAddressId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param shippingAddressId the shipping address ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching commerce orders
*/
@Override
public List findByShippingAddressId(
long shippingAddressId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath =
_finderPathWithoutPaginationFindByShippingAddressId;
finderArgs = new Object[] {shippingAddressId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByShippingAddressId;
finderArgs = new Object[] {
shippingAddressId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (CommerceOrder commerceOrder : list) {
if (shippingAddressId !=
commerceOrder.getShippingAddressId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_SHIPPINGADDRESSID_SHIPPINGADDRESSID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(shippingAddressId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first commerce order in the ordered set where shippingAddressId = ?.
*
* @param shippingAddressId the shipping address ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByShippingAddressId_First(
long shippingAddressId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByShippingAddressId_First(
shippingAddressId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("shippingAddressId=");
sb.append(shippingAddressId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the first commerce order in the ordered set where shippingAddressId = ?.
*
* @param shippingAddressId the shipping address ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByShippingAddressId_First(
long shippingAddressId,
OrderByComparator orderByComparator) {
List list = findByShippingAddressId(
shippingAddressId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last commerce order in the ordered set where shippingAddressId = ?.
*
* @param shippingAddressId the shipping address ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByShippingAddressId_Last(
long shippingAddressId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByShippingAddressId_Last(
shippingAddressId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("shippingAddressId=");
sb.append(shippingAddressId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the last commerce order in the ordered set where shippingAddressId = ?.
*
* @param shippingAddressId the shipping address ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByShippingAddressId_Last(
long shippingAddressId,
OrderByComparator orderByComparator) {
int count = countByShippingAddressId(shippingAddressId);
if (count == 0) {
return null;
}
List list = findByShippingAddressId(
shippingAddressId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set where shippingAddressId = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param shippingAddressId the shipping address ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] findByShippingAddressId_PrevAndNext(
long commerceOrderId, long shippingAddressId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = getByShippingAddressId_PrevAndNext(
session, commerceOrder, shippingAddressId, orderByComparator,
true);
array[1] = commerceOrder;
array[2] = getByShippingAddressId_PrevAndNext(
session, commerceOrder, shippingAddressId, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder getByShippingAddressId_PrevAndNext(
Session session, CommerceOrder commerceOrder, long shippingAddressId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_SHIPPINGADDRESSID_SHIPPINGADDRESSID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(shippingAddressId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the commerce orders where shippingAddressId = ? from the database.
*
* @param shippingAddressId the shipping address ID
*/
@Override
public void removeByShippingAddressId(long shippingAddressId) {
for (CommerceOrder commerceOrder :
findByShippingAddressId(
shippingAddressId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(commerceOrder);
}
}
/**
* Returns the number of commerce orders where shippingAddressId = ?.
*
* @param shippingAddressId the shipping address ID
* @return the number of matching commerce orders
*/
@Override
public int countByShippingAddressId(long shippingAddressId) {
FinderPath finderPath = _finderPathCountByShippingAddressId;
Object[] finderArgs = new Object[] {shippingAddressId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_SHIPPINGADDRESSID_SHIPPINGADDRESSID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(shippingAddressId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String
_FINDER_COLUMN_SHIPPINGADDRESSID_SHIPPINGADDRESSID_2 =
"commerceOrder.shippingAddressId = ?";
private FinderPath _finderPathWithPaginationFindByG_C;
private FinderPath _finderPathWithoutPaginationFindByG_C;
private FinderPath _finderPathCountByG_C;
/**
* Returns all the commerce orders where groupId = ? and commerceAccountId = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @return the matching commerce orders
*/
@Override
public List findByG_C(long groupId, long commerceAccountId) {
return findByG_C(
groupId, commerceAccountId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the commerce orders where groupId = ? and commerceAccountId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders
*/
@Override
public List findByG_C(
long groupId, long commerceAccountId, int start, int end) {
return findByG_C(groupId, commerceAccountId, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders where groupId = ? and commerceAccountId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders
*/
@Override
public List findByG_C(
long groupId, long commerceAccountId, int start, int end,
OrderByComparator orderByComparator) {
return findByG_C(
groupId, commerceAccountId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the commerce orders where groupId = ? and commerceAccountId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching commerce orders
*/
@Override
public List findByG_C(
long groupId, long commerceAccountId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByG_C;
finderArgs = new Object[] {groupId, commerceAccountId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByG_C;
finderArgs = new Object[] {
groupId, commerceAccountId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (CommerceOrder commerceOrder : list) {
if ((groupId != commerceOrder.getGroupId()) ||
(commerceAccountId !=
commerceOrder.getCommerceAccountId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_C_GROUPID_2);
sb.append(_FINDER_COLUMN_G_C_COMMERCEACCOUNTID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(commerceAccountId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first commerce order in the ordered set where groupId = ? and commerceAccountId = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByG_C_First(
long groupId, long commerceAccountId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByG_C_First(
groupId, commerceAccountId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", commerceAccountId=");
sb.append(commerceAccountId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the first commerce order in the ordered set where groupId = ? and commerceAccountId = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByG_C_First(
long groupId, long commerceAccountId,
OrderByComparator orderByComparator) {
List list = findByG_C(
groupId, commerceAccountId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last commerce order in the ordered set where groupId = ? and commerceAccountId = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByG_C_Last(
long groupId, long commerceAccountId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByG_C_Last(
groupId, commerceAccountId, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", commerceAccountId=");
sb.append(commerceAccountId);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the last commerce order in the ordered set where groupId = ? and commerceAccountId = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByG_C_Last(
long groupId, long commerceAccountId,
OrderByComparator orderByComparator) {
int count = countByG_C(groupId, commerceAccountId);
if (count == 0) {
return null;
}
List list = findByG_C(
groupId, commerceAccountId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set where groupId = ? and commerceAccountId = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] findByG_C_PrevAndNext(
long commerceOrderId, long groupId, long commerceAccountId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = getByG_C_PrevAndNext(
session, commerceOrder, groupId, commerceAccountId,
orderByComparator, true);
array[1] = commerceOrder;
array[2] = getByG_C_PrevAndNext(
session, commerceOrder, groupId, commerceAccountId,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder getByG_C_PrevAndNext(
Session session, CommerceOrder commerceOrder, long groupId,
long commerceAccountId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_C_GROUPID_2);
sb.append(_FINDER_COLUMN_G_C_COMMERCEACCOUNTID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(commerceAccountId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the commerce orders that the user has permission to view where groupId = ? and commerceAccountId = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @return the matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByG_C(
long groupId, long commerceAccountId) {
return filterFindByG_C(
groupId, commerceAccountId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the commerce orders that the user has permission to view where groupId = ? and commerceAccountId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByG_C(
long groupId, long commerceAccountId, int start, int end) {
return filterFindByG_C(groupId, commerceAccountId, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders that the user has permissions to view where groupId = ? and commerceAccountId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByG_C(
long groupId, long commerceAccountId, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_C(
groupId, commerceAccountId, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_COMMERCEORDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_C_GROUPID_2);
sb.append(_FINDER_COLUMN_G_C_COMMERCEACCOUNTID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, CommerceOrderImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, CommerceOrderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(commerceAccountId);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set of commerce orders that the user has permission to view where groupId = ? and commerceAccountId = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] filterFindByG_C_PrevAndNext(
long commerceOrderId, long groupId, long commerceAccountId,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_C_PrevAndNext(
commerceOrderId, groupId, commerceAccountId, orderByComparator);
}
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = filterGetByG_C_PrevAndNext(
session, commerceOrder, groupId, commerceAccountId,
orderByComparator, true);
array[1] = commerceOrder;
array[2] = filterGetByG_C_PrevAndNext(
session, commerceOrder, groupId, commerceAccountId,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder filterGetByG_C_PrevAndNext(
Session session, CommerceOrder commerceOrder, long groupId,
long commerceAccountId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_COMMERCEORDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_C_GROUPID_2);
sb.append(_FINDER_COLUMN_G_C_COMMERCEACCOUNTID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, CommerceOrderImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, CommerceOrderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(commerceAccountId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the commerce orders where groupId = ? and commerceAccountId = ? from the database.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
*/
@Override
public void removeByG_C(long groupId, long commerceAccountId) {
for (CommerceOrder commerceOrder :
findByG_C(
groupId, commerceAccountId, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(commerceOrder);
}
}
/**
* Returns the number of commerce orders where groupId = ? and commerceAccountId = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @return the number of matching commerce orders
*/
@Override
public int countByG_C(long groupId, long commerceAccountId) {
FinderPath finderPath = _finderPathCountByG_C;
Object[] finderArgs = new Object[] {groupId, commerceAccountId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_C_GROUPID_2);
sb.append(_FINDER_COLUMN_G_C_COMMERCEACCOUNTID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(commerceAccountId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of commerce orders that the user has permission to view where groupId = ? and commerceAccountId = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @return the number of matching commerce orders that the user has permission to view
*/
@Override
public int filterCountByG_C(long groupId, long commerceAccountId) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_C(groupId, commerceAccountId);
}
StringBundler sb = new StringBundler(3);
sb.append(_FILTER_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_C_GROUPID_2);
sb.append(_FINDER_COLUMN_G_C_COMMERCEACCOUNTID_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(commerceAccountId);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_C_GROUPID_2 =
"commerceOrder.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_C_COMMERCEACCOUNTID_2 =
"commerceOrder.commerceAccountId = ?";
private FinderPath _finderPathWithPaginationFindByG_CP;
private FinderPath _finderPathWithoutPaginationFindByG_CP;
private FinderPath _finderPathCountByG_CP;
/**
* Returns all the commerce orders where groupId = ? and commercePaymentMethodKey = ?.
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @return the matching commerce orders
*/
@Override
public List findByG_CP(
long groupId, String commercePaymentMethodKey) {
return findByG_CP(
groupId, commercePaymentMethodKey, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders where groupId = ? and commercePaymentMethodKey = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders
*/
@Override
public List findByG_CP(
long groupId, String commercePaymentMethodKey, int start, int end) {
return findByG_CP(groupId, commercePaymentMethodKey, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders where groupId = ? and commercePaymentMethodKey = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders
*/
@Override
public List findByG_CP(
long groupId, String commercePaymentMethodKey, int start, int end,
OrderByComparator orderByComparator) {
return findByG_CP(
groupId, commercePaymentMethodKey, start, end, orderByComparator,
true);
}
/**
* Returns an ordered range of all the commerce orders where groupId = ? and commercePaymentMethodKey = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching commerce orders
*/
@Override
public List findByG_CP(
long groupId, String commercePaymentMethodKey, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
commercePaymentMethodKey = Objects.toString(
commercePaymentMethodKey, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByG_CP;
finderArgs = new Object[] {groupId, commercePaymentMethodKey};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByG_CP;
finderArgs = new Object[] {
groupId, commercePaymentMethodKey, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (CommerceOrder commerceOrder : list) {
if ((groupId != commerceOrder.getGroupId()) ||
!commercePaymentMethodKey.equals(
commerceOrder.getCommercePaymentMethodKey())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_CP_GROUPID_2);
boolean bindCommercePaymentMethodKey = false;
if (commercePaymentMethodKey.isEmpty()) {
sb.append(_FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_3);
}
else {
bindCommercePaymentMethodKey = true;
sb.append(_FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
if (bindCommercePaymentMethodKey) {
queryPos.add(commercePaymentMethodKey);
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first commerce order in the ordered set where groupId = ? and commercePaymentMethodKey = ?.
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByG_CP_First(
long groupId, String commercePaymentMethodKey,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByG_CP_First(
groupId, commercePaymentMethodKey, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", commercePaymentMethodKey=");
sb.append(commercePaymentMethodKey);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the first commerce order in the ordered set where groupId = ? and commercePaymentMethodKey = ?.
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByG_CP_First(
long groupId, String commercePaymentMethodKey,
OrderByComparator orderByComparator) {
List list = findByG_CP(
groupId, commercePaymentMethodKey, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last commerce order in the ordered set where groupId = ? and commercePaymentMethodKey = ?.
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByG_CP_Last(
long groupId, String commercePaymentMethodKey,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByG_CP_Last(
groupId, commercePaymentMethodKey, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", commercePaymentMethodKey=");
sb.append(commercePaymentMethodKey);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the last commerce order in the ordered set where groupId = ? and commercePaymentMethodKey = ?.
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByG_CP_Last(
long groupId, String commercePaymentMethodKey,
OrderByComparator orderByComparator) {
int count = countByG_CP(groupId, commercePaymentMethodKey);
if (count == 0) {
return null;
}
List list = findByG_CP(
groupId, commercePaymentMethodKey, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set where groupId = ? and commercePaymentMethodKey = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] findByG_CP_PrevAndNext(
long commerceOrderId, long groupId, String commercePaymentMethodKey,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
commercePaymentMethodKey = Objects.toString(
commercePaymentMethodKey, "");
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = getByG_CP_PrevAndNext(
session, commerceOrder, groupId, commercePaymentMethodKey,
orderByComparator, true);
array[1] = commerceOrder;
array[2] = getByG_CP_PrevAndNext(
session, commerceOrder, groupId, commercePaymentMethodKey,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder getByG_CP_PrevAndNext(
Session session, CommerceOrder commerceOrder, long groupId,
String commercePaymentMethodKey,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_CP_GROUPID_2);
boolean bindCommercePaymentMethodKey = false;
if (commercePaymentMethodKey.isEmpty()) {
sb.append(_FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_3);
}
else {
bindCommercePaymentMethodKey = true;
sb.append(_FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
if (bindCommercePaymentMethodKey) {
queryPos.add(commercePaymentMethodKey);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the commerce orders that the user has permission to view where groupId = ? and commercePaymentMethodKey = ?.
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @return the matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByG_CP(
long groupId, String commercePaymentMethodKey) {
return filterFindByG_CP(
groupId, commercePaymentMethodKey, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders that the user has permission to view where groupId = ? and commercePaymentMethodKey = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByG_CP(
long groupId, String commercePaymentMethodKey, int start, int end) {
return filterFindByG_CP(
groupId, commercePaymentMethodKey, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders that the user has permissions to view where groupId = ? and commercePaymentMethodKey = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByG_CP(
long groupId, String commercePaymentMethodKey, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_CP(
groupId, commercePaymentMethodKey, start, end,
orderByComparator);
}
commercePaymentMethodKey = Objects.toString(
commercePaymentMethodKey, "");
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_COMMERCEORDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_CP_GROUPID_2);
boolean bindCommercePaymentMethodKey = false;
if (commercePaymentMethodKey.isEmpty()) {
sb.append(_FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_3);
}
else {
bindCommercePaymentMethodKey = true;
sb.append(_FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_2);
}
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, CommerceOrderImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, CommerceOrderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
if (bindCommercePaymentMethodKey) {
queryPos.add(commercePaymentMethodKey);
}
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set of commerce orders that the user has permission to view where groupId = ? and commercePaymentMethodKey = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] filterFindByG_CP_PrevAndNext(
long commerceOrderId, long groupId, String commercePaymentMethodKey,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_CP_PrevAndNext(
commerceOrderId, groupId, commercePaymentMethodKey,
orderByComparator);
}
commercePaymentMethodKey = Objects.toString(
commercePaymentMethodKey, "");
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = filterGetByG_CP_PrevAndNext(
session, commerceOrder, groupId, commercePaymentMethodKey,
orderByComparator, true);
array[1] = commerceOrder;
array[2] = filterGetByG_CP_PrevAndNext(
session, commerceOrder, groupId, commercePaymentMethodKey,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder filterGetByG_CP_PrevAndNext(
Session session, CommerceOrder commerceOrder, long groupId,
String commercePaymentMethodKey,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_COMMERCEORDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_CP_GROUPID_2);
boolean bindCommercePaymentMethodKey = false;
if (commercePaymentMethodKey.isEmpty()) {
sb.append(_FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_3);
}
else {
bindCommercePaymentMethodKey = true;
sb.append(_FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_2);
}
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, CommerceOrderImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, CommerceOrderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
if (bindCommercePaymentMethodKey) {
queryPos.add(commercePaymentMethodKey);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the commerce orders where groupId = ? and commercePaymentMethodKey = ? from the database.
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
*/
@Override
public void removeByG_CP(long groupId, String commercePaymentMethodKey) {
for (CommerceOrder commerceOrder :
findByG_CP(
groupId, commercePaymentMethodKey, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(commerceOrder);
}
}
/**
* Returns the number of commerce orders where groupId = ? and commercePaymentMethodKey = ?.
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @return the number of matching commerce orders
*/
@Override
public int countByG_CP(long groupId, String commercePaymentMethodKey) {
commercePaymentMethodKey = Objects.toString(
commercePaymentMethodKey, "");
FinderPath finderPath = _finderPathCountByG_CP;
Object[] finderArgs = new Object[] {groupId, commercePaymentMethodKey};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_CP_GROUPID_2);
boolean bindCommercePaymentMethodKey = false;
if (commercePaymentMethodKey.isEmpty()) {
sb.append(_FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_3);
}
else {
bindCommercePaymentMethodKey = true;
sb.append(_FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
if (bindCommercePaymentMethodKey) {
queryPos.add(commercePaymentMethodKey);
}
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of commerce orders that the user has permission to view where groupId = ? and commercePaymentMethodKey = ?.
*
* @param groupId the group ID
* @param commercePaymentMethodKey the commerce payment method key
* @return the number of matching commerce orders that the user has permission to view
*/
@Override
public int filterCountByG_CP(
long groupId, String commercePaymentMethodKey) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_CP(groupId, commercePaymentMethodKey);
}
commercePaymentMethodKey = Objects.toString(
commercePaymentMethodKey, "");
StringBundler sb = new StringBundler(3);
sb.append(_FILTER_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_CP_GROUPID_2);
boolean bindCommercePaymentMethodKey = false;
if (commercePaymentMethodKey.isEmpty()) {
sb.append(_FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_3);
}
else {
bindCommercePaymentMethodKey = true;
sb.append(_FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_2);
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
if (bindCommercePaymentMethodKey) {
queryPos.add(commercePaymentMethodKey);
}
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_CP_GROUPID_2 =
"commerceOrder.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_2 =
"commerceOrder.commercePaymentMethodKey = ?";
private static final String _FINDER_COLUMN_G_CP_COMMERCEPAYMENTMETHODKEY_3 =
"(commerceOrder.commercePaymentMethodKey IS NULL OR commerceOrder.commercePaymentMethodKey = '')";
private FinderPath _finderPathWithPaginationFindByG_U_O;
private FinderPath _finderPathWithoutPaginationFindByG_U_O;
private FinderPath _finderPathCountByG_U_O;
/**
* Returns all the commerce orders where groupId = ? and userId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @return the matching commerce orders
*/
@Override
public List findByG_U_O(
long groupId, long userId, int orderStatus) {
return findByG_U_O(
groupId, userId, orderStatus, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the commerce orders where groupId = ? and userId = ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders
*/
@Override
public List findByG_U_O(
long groupId, long userId, int orderStatus, int start, int end) {
return findByG_U_O(groupId, userId, orderStatus, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders where groupId = ? and userId = ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders
*/
@Override
public List findByG_U_O(
long groupId, long userId, int orderStatus, int start, int end,
OrderByComparator orderByComparator) {
return findByG_U_O(
groupId, userId, orderStatus, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the commerce orders where groupId = ? and userId = ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching commerce orders
*/
@Override
public List findByG_U_O(
long groupId, long userId, int orderStatus, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByG_U_O;
finderArgs = new Object[] {groupId, userId, orderStatus};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByG_U_O;
finderArgs = new Object[] {
groupId, userId, orderStatus, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (CommerceOrder commerceOrder : list) {
if ((groupId != commerceOrder.getGroupId()) ||
(userId != commerceOrder.getUserId()) ||
(orderStatus != commerceOrder.getOrderStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_U_O_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_O_USERID_2);
sb.append(_FINDER_COLUMN_G_U_O_ORDERSTATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(orderStatus);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first commerce order in the ordered set where groupId = ? and userId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByG_U_O_First(
long groupId, long userId, int orderStatus,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByG_U_O_First(
groupId, userId, orderStatus, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", userId=");
sb.append(userId);
sb.append(", orderStatus=");
sb.append(orderStatus);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the first commerce order in the ordered set where groupId = ? and userId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByG_U_O_First(
long groupId, long userId, int orderStatus,
OrderByComparator orderByComparator) {
List list = findByG_U_O(
groupId, userId, orderStatus, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last commerce order in the ordered set where groupId = ? and userId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByG_U_O_Last(
long groupId, long userId, int orderStatus,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByG_U_O_Last(
groupId, userId, orderStatus, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", userId=");
sb.append(userId);
sb.append(", orderStatus=");
sb.append(orderStatus);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the last commerce order in the ordered set where groupId = ? and userId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByG_U_O_Last(
long groupId, long userId, int orderStatus,
OrderByComparator orderByComparator) {
int count = countByG_U_O(groupId, userId, orderStatus);
if (count == 0) {
return null;
}
List list = findByG_U_O(
groupId, userId, orderStatus, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set where groupId = ? and userId = ? and orderStatus = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] findByG_U_O_PrevAndNext(
long commerceOrderId, long groupId, long userId, int orderStatus,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = getByG_U_O_PrevAndNext(
session, commerceOrder, groupId, userId, orderStatus,
orderByComparator, true);
array[1] = commerceOrder;
array[2] = getByG_U_O_PrevAndNext(
session, commerceOrder, groupId, userId, orderStatus,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder getByG_U_O_PrevAndNext(
Session session, CommerceOrder commerceOrder, long groupId, long userId,
int orderStatus, OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_U_O_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_O_USERID_2);
sb.append(_FINDER_COLUMN_G_U_O_ORDERSTATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(orderStatus);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the commerce orders that the user has permission to view where groupId = ? and userId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @return the matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByG_U_O(
long groupId, long userId, int orderStatus) {
return filterFindByG_U_O(
groupId, userId, orderStatus, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the commerce orders that the user has permission to view where groupId = ? and userId = ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByG_U_O(
long groupId, long userId, int orderStatus, int start, int end) {
return filterFindByG_U_O(
groupId, userId, orderStatus, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders that the user has permissions to view where groupId = ? and userId = ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByG_U_O(
long groupId, long userId, int orderStatus, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_U_O(
groupId, userId, orderStatus, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(6);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_COMMERCEORDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_U_O_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_O_USERID_2);
sb.append(_FINDER_COLUMN_G_U_O_ORDERSTATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, CommerceOrderImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, CommerceOrderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(orderStatus);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set of commerce orders that the user has permission to view where groupId = ? and userId = ? and orderStatus = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] filterFindByG_U_O_PrevAndNext(
long commerceOrderId, long groupId, long userId, int orderStatus,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_U_O_PrevAndNext(
commerceOrderId, groupId, userId, orderStatus,
orderByComparator);
}
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = filterGetByG_U_O_PrevAndNext(
session, commerceOrder, groupId, userId, orderStatus,
orderByComparator, true);
array[1] = commerceOrder;
array[2] = filterGetByG_U_O_PrevAndNext(
session, commerceOrder, groupId, userId, orderStatus,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder filterGetByG_U_O_PrevAndNext(
Session session, CommerceOrder commerceOrder, long groupId, long userId,
int orderStatus, OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
7 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(6);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_COMMERCEORDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_U_O_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_O_USERID_2);
sb.append(_FINDER_COLUMN_G_U_O_ORDERSTATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, CommerceOrderImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, CommerceOrderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(orderStatus);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the commerce orders where groupId = ? and userId = ? and orderStatus = ? from the database.
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
*/
@Override
public void removeByG_U_O(long groupId, long userId, int orderStatus) {
for (CommerceOrder commerceOrder :
findByG_U_O(
groupId, userId, orderStatus, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(commerceOrder);
}
}
/**
* Returns the number of commerce orders where groupId = ? and userId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @return the number of matching commerce orders
*/
@Override
public int countByG_U_O(long groupId, long userId, int orderStatus) {
FinderPath finderPath = _finderPathCountByG_U_O;
Object[] finderArgs = new Object[] {groupId, userId, orderStatus};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_U_O_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_O_USERID_2);
sb.append(_FINDER_COLUMN_G_U_O_ORDERSTATUS_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(orderStatus);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of commerce orders that the user has permission to view where groupId = ? and userId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param orderStatus the order status
* @return the number of matching commerce orders that the user has permission to view
*/
@Override
public int filterCountByG_U_O(long groupId, long userId, int orderStatus) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_U_O(groupId, userId, orderStatus);
}
StringBundler sb = new StringBundler(4);
sb.append(_FILTER_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_U_O_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_O_USERID_2);
sb.append(_FINDER_COLUMN_G_U_O_ORDERSTATUS_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(orderStatus);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_U_O_GROUPID_2 =
"commerceOrder.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_U_O_USERID_2 =
"commerceOrder.userId = ? AND ";
private static final String _FINDER_COLUMN_G_U_O_ORDERSTATUS_2 =
"commerceOrder.orderStatus = ?";
private FinderPath _finderPathWithPaginationFindByG_C_O;
private FinderPath _finderPathWithoutPaginationFindByG_C_O;
private FinderPath _finderPathCountByG_C_O;
/**
* Returns all the commerce orders where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @return the matching commerce orders
*/
@Override
public List findByG_C_O(
long groupId, long commerceAccountId, int orderStatus) {
return findByG_C_O(
groupId, commerceAccountId, orderStatus, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders
*/
@Override
public List findByG_C_O(
long groupId, long commerceAccountId, int orderStatus, int start,
int end) {
return findByG_C_O(
groupId, commerceAccountId, orderStatus, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders
*/
@Override
public List findByG_C_O(
long groupId, long commerceAccountId, int orderStatus, int start,
int end, OrderByComparator orderByComparator) {
return findByG_C_O(
groupId, commerceAccountId, orderStatus, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the commerce orders where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching commerce orders
*/
@Override
public List findByG_C_O(
long groupId, long commerceAccountId, int orderStatus, int start,
int end, OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByG_C_O;
finderArgs = new Object[] {
groupId, commerceAccountId, orderStatus
};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByG_C_O;
finderArgs = new Object[] {
groupId, commerceAccountId, orderStatus, start, end,
orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (CommerceOrder commerceOrder : list) {
if ((groupId != commerceOrder.getGroupId()) ||
(commerceAccountId !=
commerceOrder.getCommerceAccountId()) ||
(orderStatus != commerceOrder.getOrderStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_C_O_GROUPID_2);
sb.append(_FINDER_COLUMN_G_C_O_COMMERCEACCOUNTID_2);
sb.append(_FINDER_COLUMN_G_C_O_ORDERSTATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(commerceAccountId);
queryPos.add(orderStatus);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first commerce order in the ordered set where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByG_C_O_First(
long groupId, long commerceAccountId, int orderStatus,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByG_C_O_First(
groupId, commerceAccountId, orderStatus, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", commerceAccountId=");
sb.append(commerceAccountId);
sb.append(", orderStatus=");
sb.append(orderStatus);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the first commerce order in the ordered set where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByG_C_O_First(
long groupId, long commerceAccountId, int orderStatus,
OrderByComparator orderByComparator) {
List list = findByG_C_O(
groupId, commerceAccountId, orderStatus, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last commerce order in the ordered set where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByG_C_O_Last(
long groupId, long commerceAccountId, int orderStatus,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByG_C_O_Last(
groupId, commerceAccountId, orderStatus, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", commerceAccountId=");
sb.append(commerceAccountId);
sb.append(", orderStatus=");
sb.append(orderStatus);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the last commerce order in the ordered set where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching commerce order, or null
if a matching commerce order could not be found
*/
@Override
public CommerceOrder fetchByG_C_O_Last(
long groupId, long commerceAccountId, int orderStatus,
OrderByComparator orderByComparator) {
int count = countByG_C_O(groupId, commerceAccountId, orderStatus);
if (count == 0) {
return null;
}
List list = findByG_C_O(
groupId, commerceAccountId, orderStatus, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] findByG_C_O_PrevAndNext(
long commerceOrderId, long groupId, long commerceAccountId,
int orderStatus, OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = getByG_C_O_PrevAndNext(
session, commerceOrder, groupId, commerceAccountId, orderStatus,
orderByComparator, true);
array[1] = commerceOrder;
array[2] = getByG_C_O_PrevAndNext(
session, commerceOrder, groupId, commerceAccountId, orderStatus,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder getByG_C_O_PrevAndNext(
Session session, CommerceOrder commerceOrder, long groupId,
long commerceAccountId, int orderStatus,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_C_O_GROUPID_2);
sb.append(_FINDER_COLUMN_G_C_O_COMMERCEACCOUNTID_2);
sb.append(_FINDER_COLUMN_G_C_O_ORDERSTATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(commerceAccountId);
queryPos.add(orderStatus);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the commerce orders that the user has permission to view where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @return the matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByG_C_O(
long groupId, long commerceAccountId, int orderStatus) {
return filterFindByG_C_O(
groupId, commerceAccountId, orderStatus, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders that the user has permission to view where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByG_C_O(
long groupId, long commerceAccountId, int orderStatus, int start,
int end) {
return filterFindByG_C_O(
groupId, commerceAccountId, orderStatus, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders that the user has permissions to view where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders that the user has permission to view
*/
@Override
public List filterFindByG_C_O(
long groupId, long commerceAccountId, int orderStatus, int start,
int end, OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_C_O(
groupId, commerceAccountId, orderStatus, start, end,
orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(6);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_COMMERCEORDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_C_O_GROUPID_2);
sb.append(_FINDER_COLUMN_G_C_O_COMMERCEACCOUNTID_2);
sb.append(_FINDER_COLUMN_G_C_O_ORDERSTATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, CommerceOrderImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, CommerceOrderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(commerceAccountId);
queryPos.add(orderStatus);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the commerce orders before and after the current commerce order in the ordered set of commerce orders that the user has permission to view where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
* @param commerceOrderId the primary key of the current commerce order
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next commerce order
* @throws NoSuchOrderException if a commerce order with the primary key could not be found
*/
@Override
public CommerceOrder[] filterFindByG_C_O_PrevAndNext(
long commerceOrderId, long groupId, long commerceAccountId,
int orderStatus, OrderByComparator orderByComparator)
throws NoSuchOrderException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_C_O_PrevAndNext(
commerceOrderId, groupId, commerceAccountId, orderStatus,
orderByComparator);
}
CommerceOrder commerceOrder = findByPrimaryKey(commerceOrderId);
Session session = null;
try {
session = openSession();
CommerceOrder[] array = new CommerceOrderImpl[3];
array[0] = filterGetByG_C_O_PrevAndNext(
session, commerceOrder, groupId, commerceAccountId, orderStatus,
orderByComparator, true);
array[1] = commerceOrder;
array[2] = filterGetByG_C_O_PrevAndNext(
session, commerceOrder, groupId, commerceAccountId, orderStatus,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CommerceOrder filterGetByG_C_O_PrevAndNext(
Session session, CommerceOrder commerceOrder, long groupId,
long commerceAccountId, int orderStatus,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
7 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(6);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_COMMERCEORDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_C_O_GROUPID_2);
sb.append(_FINDER_COLUMN_G_C_O_COMMERCEACCOUNTID_2);
sb.append(_FINDER_COLUMN_G_C_O_ORDERSTATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_COMMERCEORDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, CommerceOrderImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, CommerceOrderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(commerceAccountId);
queryPos.add(orderStatus);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
commerceOrder)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the commerce orders where groupId = ? and commerceAccountId = ? and orderStatus = ? from the database.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
*/
@Override
public void removeByG_C_O(
long groupId, long commerceAccountId, int orderStatus) {
for (CommerceOrder commerceOrder :
findByG_C_O(
groupId, commerceAccountId, orderStatus, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(commerceOrder);
}
}
/**
* Returns the number of commerce orders where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @return the number of matching commerce orders
*/
@Override
public int countByG_C_O(
long groupId, long commerceAccountId, int orderStatus) {
FinderPath finderPath = _finderPathCountByG_C_O;
Object[] finderArgs = new Object[] {
groupId, commerceAccountId, orderStatus
};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_C_O_GROUPID_2);
sb.append(_FINDER_COLUMN_G_C_O_COMMERCEACCOUNTID_2);
sb.append(_FINDER_COLUMN_G_C_O_ORDERSTATUS_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(commerceAccountId);
queryPos.add(orderStatus);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of commerce orders that the user has permission to view where groupId = ? and commerceAccountId = ? and orderStatus = ?.
*
* @param groupId the group ID
* @param commerceAccountId the commerce account ID
* @param orderStatus the order status
* @return the number of matching commerce orders that the user has permission to view
*/
@Override
public int filterCountByG_C_O(
long groupId, long commerceAccountId, int orderStatus) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_C_O(groupId, commerceAccountId, orderStatus);
}
StringBundler sb = new StringBundler(4);
sb.append(_FILTER_SQL_COUNT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_G_C_O_GROUPID_2);
sb.append(_FINDER_COLUMN_G_C_O_COMMERCEACCOUNTID_2);
sb.append(_FINDER_COLUMN_G_C_O_ORDERSTATUS_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), CommerceOrder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(commerceAccountId);
queryPos.add(orderStatus);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_C_O_GROUPID_2 =
"commerceOrder.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_C_O_COMMERCEACCOUNTID_2 =
"commerceOrder.commerceAccountId = ? AND ";
private static final String _FINDER_COLUMN_G_C_O_ORDERSTATUS_2 =
"commerceOrder.orderStatus = ?";
private FinderPath _finderPathWithPaginationFindByU_LtC_O;
private FinderPath _finderPathWithPaginationCountByU_LtC_O;
/**
* Returns all the commerce orders where userId = ? and createDate < ? and orderStatus = ?.
*
* @param userId the user ID
* @param createDate the create date
* @param orderStatus the order status
* @return the matching commerce orders
*/
@Override
public List findByU_LtC_O(
long userId, Date createDate, int orderStatus) {
return findByU_LtC_O(
userId, createDate, orderStatus, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the commerce orders where userId = ? and createDate < ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param userId the user ID
* @param createDate the create date
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @return the range of matching commerce orders
*/
@Override
public List findByU_LtC_O(
long userId, Date createDate, int orderStatus, int start, int end) {
return findByU_LtC_O(userId, createDate, orderStatus, start, end, null);
}
/**
* Returns an ordered range of all the commerce orders where userId = ? and createDate < ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param userId the user ID
* @param createDate the create date
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching commerce orders
*/
@Override
public List findByU_LtC_O(
long userId, Date createDate, int orderStatus, int start, int end,
OrderByComparator orderByComparator) {
return findByU_LtC_O(
userId, createDate, orderStatus, start, end, orderByComparator,
true);
}
/**
* Returns an ordered range of all the commerce orders where userId = ? and createDate < ? and orderStatus = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CommerceOrderModelImpl
.
*
*
* @param userId the user ID
* @param createDate the create date
* @param orderStatus the order status
* @param start the lower bound of the range of commerce orders
* @param end the upper bound of the range of commerce orders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching commerce orders
*/
@Override
public List findByU_LtC_O(
long userId, Date createDate, int orderStatus, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
finderPath = _finderPathWithPaginationFindByU_LtC_O;
finderArgs = new Object[] {
userId, _getTime(createDate), orderStatus, start, end,
orderByComparator
};
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (CommerceOrder commerceOrder : list) {
if ((userId != commerceOrder.getUserId()) ||
(createDate.getTime() <= commerceOrder.getCreateDate(
).getTime()) ||
(orderStatus != commerceOrder.getOrderStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_COMMERCEORDER_WHERE);
sb.append(_FINDER_COLUMN_U_LTC_O_USERID_2);
boolean bindCreateDate = false;
if (createDate == null) {
sb.append(_FINDER_COLUMN_U_LTC_O_CREATEDATE_1);
}
else {
bindCreateDate = true;
sb.append(_FINDER_COLUMN_U_LTC_O_CREATEDATE_2);
}
sb.append(_FINDER_COLUMN_U_LTC_O_ORDERSTATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CommerceOrderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(userId);
if (bindCreateDate) {
queryPos.add(new Timestamp(createDate.getTime()));
}
queryPos.add(orderStatus);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first commerce order in the ordered set where userId = ? and createDate < ? and orderStatus = ?.
*
* @param userId the user ID
* @param createDate the create date
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching commerce order
* @throws NoSuchOrderException if a matching commerce order could not be found
*/
@Override
public CommerceOrder findByU_LtC_O_First(
long userId, Date createDate, int orderStatus,
OrderByComparator orderByComparator)
throws NoSuchOrderException {
CommerceOrder commerceOrder = fetchByU_LtC_O_First(
userId, createDate, orderStatus, orderByComparator);
if (commerceOrder != null) {
return commerceOrder;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("userId=");
sb.append(userId);
sb.append(", createDate<");
sb.append(createDate);
sb.append(", orderStatus=");
sb.append(orderStatus);
sb.append("}");
throw new NoSuchOrderException(sb.toString());
}
/**
* Returns the first commerce order in the ordered set where userId = ? and createDate < ? and orderStatus = ?.
*
* @param userId the user ID
* @param createDate the create date
* @param orderStatus the order status
* @param orderByComparator the comparator to order the set by (optionally