All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liferay.commerce.pricing.service.persistence.impl.CommercePricingClassCPDefinitionRelPersistenceImpl Maven / Gradle / Ivy

The newest version!
/**
 * 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.pricing.service.persistence.impl;

import com.liferay.commerce.pricing.exception.NoSuchPricingClassCPDefinitionRelException;
import com.liferay.commerce.pricing.model.CommercePricingClassCPDefinitionRel;
import com.liferay.commerce.pricing.model.CommercePricingClassCPDefinitionRelTable;
import com.liferay.commerce.pricing.model.impl.CommercePricingClassCPDefinitionRelImpl;
import com.liferay.commerce.pricing.model.impl.CommercePricingClassCPDefinitionRelModelImpl;
import com.liferay.commerce.pricing.service.persistence.CommercePricingClassCPDefinitionRelPersistence;
import com.liferay.commerce.pricing.service.persistence.CommercePricingClassCPDefinitionRelUtil;
import com.liferay.commerce.pricing.service.persistence.impl.constants.CommercePersistenceConstants;
import com.liferay.petra.lang.SafeCloseable;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.change.tracking.CTCollectionThreadLocal;
import com.liferay.portal.kernel.change.tracking.CTColumnResolutionType;
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.Session;
import com.liferay.portal.kernel.dao.orm.SessionFactory;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.change.tracking.helper.CTPersistenceHelper;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
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 java.io.Serializable;

import java.lang.reflect.InvocationHandler;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
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 pricing class cp definition rel service.
 *
 * 

* Caching information and settings can be found in portal.properties *

* * @author Riccardo Alberti * @generated */ @Component(service = CommercePricingClassCPDefinitionRelPersistence.class) public class CommercePricingClassCPDefinitionRelPersistenceImpl extends BasePersistenceImpl implements CommercePricingClassCPDefinitionRelPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use CommercePricingClassCPDefinitionRelUtil to access the commerce pricing class cp definition rel persistence. Modify service.xml and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = CommercePricingClassCPDefinitionRelImpl.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 _finderPathWithPaginationFindByCommercePricingClassId; private FinderPath _finderPathWithoutPaginationFindByCommercePricingClassId; private FinderPath _finderPathCountByCommercePricingClassId; /** * Returns all the commerce pricing class cp definition rels where commercePricingClassId = ?. * * @param commercePricingClassId the commerce pricing class ID * @return the matching commerce pricing class cp definition rels */ @Override public List findByCommercePricingClassId(long commercePricingClassId) { return findByCommercePricingClassId( commercePricingClassId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the commerce pricing class cp definition rels where commercePricingClassId = ?. * *

* 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 CommercePricingClassCPDefinitionRelModelImpl. *

* * @param commercePricingClassId the commerce pricing class ID * @param start the lower bound of the range of commerce pricing class cp definition rels * @param end the upper bound of the range of commerce pricing class cp definition rels (not inclusive) * @return the range of matching commerce pricing class cp definition rels */ @Override public List findByCommercePricingClassId( long commercePricingClassId, int start, int end) { return findByCommercePricingClassId( commercePricingClassId, start, end, null); } /** * Returns an ordered range of all the commerce pricing class cp definition rels where commercePricingClassId = ?. * *

* 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 CommercePricingClassCPDefinitionRelModelImpl. *

* * @param commercePricingClassId the commerce pricing class ID * @param start the lower bound of the range of commerce pricing class cp definition rels * @param end the upper bound of the range of commerce pricing class cp definition rels (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching commerce pricing class cp definition rels */ @Override public List findByCommercePricingClassId( long commercePricingClassId, int start, int end, OrderByComparator orderByComparator) { return findByCommercePricingClassId( commercePricingClassId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the commerce pricing class cp definition rels where commercePricingClassId = ?. * *

* 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 CommercePricingClassCPDefinitionRelModelImpl. *

* * @param commercePricingClassId the commerce pricing class ID * @param start the lower bound of the range of commerce pricing class cp definition rels * @param end the upper bound of the range of commerce pricing class cp definition rels (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 pricing class cp definition rels */ @Override public List findByCommercePricingClassId( long commercePricingClassId, int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { try (SafeCloseable safeCloseable = ctPersistenceHelper.setCTCollectionIdWithSafeCloseable( CommercePricingClassCPDefinitionRel.class)) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByCommercePricingClassId; finderArgs = new Object[] {commercePricingClassId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByCommercePricingClassId; finderArgs = new Object[] { commercePricingClassId, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List) finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel : list) { if (commercePricingClassId != commercePricingClassCPDefinitionRel. getCommercePricingClassId()) { 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_COMMERCEPRICINGCLASSCPDEFINITIONREL_WHERE); sb.append( _FINDER_COLUMN_COMMERCEPRICINGCLASSID_COMMERCEPRICINGCLASSID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append( CommercePricingClassCPDefinitionRelModelImpl. 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(commercePricingClassId); 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 pricing class cp definition rel in the ordered set where commercePricingClassId = ?. * * @param commercePricingClassId the commerce pricing class ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching commerce pricing class cp definition rel * @throws NoSuchPricingClassCPDefinitionRelException if a matching commerce pricing class cp definition rel could not be found */ @Override public CommercePricingClassCPDefinitionRel findByCommercePricingClassId_First( long commercePricingClassId, OrderByComparator orderByComparator) throws NoSuchPricingClassCPDefinitionRelException { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = fetchByCommercePricingClassId_First( commercePricingClassId, orderByComparator); if (commercePricingClassCPDefinitionRel != null) { return commercePricingClassCPDefinitionRel; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("commercePricingClassId="); sb.append(commercePricingClassId); sb.append("}"); throw new NoSuchPricingClassCPDefinitionRelException(sb.toString()); } /** * Returns the first commerce pricing class cp definition rel in the ordered set where commercePricingClassId = ?. * * @param commercePricingClassId the commerce pricing class ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching commerce pricing class cp definition rel, or null if a matching commerce pricing class cp definition rel could not be found */ @Override public CommercePricingClassCPDefinitionRel fetchByCommercePricingClassId_First( long commercePricingClassId, OrderByComparator orderByComparator) { List list = findByCommercePricingClassId( commercePricingClassId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last commerce pricing class cp definition rel in the ordered set where commercePricingClassId = ?. * * @param commercePricingClassId the commerce pricing class ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching commerce pricing class cp definition rel * @throws NoSuchPricingClassCPDefinitionRelException if a matching commerce pricing class cp definition rel could not be found */ @Override public CommercePricingClassCPDefinitionRel findByCommercePricingClassId_Last( long commercePricingClassId, OrderByComparator orderByComparator) throws NoSuchPricingClassCPDefinitionRelException { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = fetchByCommercePricingClassId_Last( commercePricingClassId, orderByComparator); if (commercePricingClassCPDefinitionRel != null) { return commercePricingClassCPDefinitionRel; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("commercePricingClassId="); sb.append(commercePricingClassId); sb.append("}"); throw new NoSuchPricingClassCPDefinitionRelException(sb.toString()); } /** * Returns the last commerce pricing class cp definition rel in the ordered set where commercePricingClassId = ?. * * @param commercePricingClassId the commerce pricing class ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching commerce pricing class cp definition rel, or null if a matching commerce pricing class cp definition rel could not be found */ @Override public CommercePricingClassCPDefinitionRel fetchByCommercePricingClassId_Last( long commercePricingClassId, OrderByComparator orderByComparator) { int count = countByCommercePricingClassId(commercePricingClassId); if (count == 0) { return null; } List list = findByCommercePricingClassId( commercePricingClassId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the commerce pricing class cp definition rels before and after the current commerce pricing class cp definition rel in the ordered set where commercePricingClassId = ?. * * @param CommercePricingClassCPDefinitionRelId the primary key of the current commerce pricing class cp definition rel * @param commercePricingClassId the commerce pricing class ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next commerce pricing class cp definition rel * @throws NoSuchPricingClassCPDefinitionRelException if a commerce pricing class cp definition rel with the primary key could not be found */ @Override public CommercePricingClassCPDefinitionRel[] findByCommercePricingClassId_PrevAndNext( long CommercePricingClassCPDefinitionRelId, long commercePricingClassId, OrderByComparator orderByComparator) throws NoSuchPricingClassCPDefinitionRelException { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = findByPrimaryKey( CommercePricingClassCPDefinitionRelId); Session session = null; try { session = openSession(); CommercePricingClassCPDefinitionRel[] array = new CommercePricingClassCPDefinitionRelImpl[3]; array[0] = getByCommercePricingClassId_PrevAndNext( session, commercePricingClassCPDefinitionRel, commercePricingClassId, orderByComparator, true); array[1] = commercePricingClassCPDefinitionRel; array[2] = getByCommercePricingClassId_PrevAndNext( session, commercePricingClassCPDefinitionRel, commercePricingClassId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CommercePricingClassCPDefinitionRel getByCommercePricingClassId_PrevAndNext( Session session, CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel, long commercePricingClassId, 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_COMMERCEPRICINGCLASSCPDEFINITIONREL_WHERE); sb.append( _FINDER_COLUMN_COMMERCEPRICINGCLASSID_COMMERCEPRICINGCLASSID_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( CommercePricingClassCPDefinitionRelModelImpl.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(commercePricingClassId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( commercePricingClassCPDefinitionRel)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the commerce pricing class cp definition rels where commercePricingClassId = ? from the database. * * @param commercePricingClassId the commerce pricing class ID */ @Override public void removeByCommercePricingClassId(long commercePricingClassId) { for (CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel : findByCommercePricingClassId( commercePricingClassId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(commercePricingClassCPDefinitionRel); } } /** * Returns the number of commerce pricing class cp definition rels where commercePricingClassId = ?. * * @param commercePricingClassId the commerce pricing class ID * @return the number of matching commerce pricing class cp definition rels */ @Override public int countByCommercePricingClassId(long commercePricingClassId) { try (SafeCloseable safeCloseable = ctPersistenceHelper.setCTCollectionIdWithSafeCloseable( CommercePricingClassCPDefinitionRel.class)) { FinderPath finderPath = _finderPathCountByCommercePricingClassId; Object[] finderArgs = new Object[] {commercePricingClassId}; Long count = (Long)finderCache.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_COMMERCEPRICINGCLASSCPDEFINITIONREL_WHERE); sb.append( _FINDER_COLUMN_COMMERCEPRICINGCLASSID_COMMERCEPRICINGCLASSID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(commercePricingClassId); 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_COMMERCEPRICINGCLASSID_COMMERCEPRICINGCLASSID_2 = "commercePricingClassCPDefinitionRel.commercePricingClassId = ?"; private FinderPath _finderPathWithPaginationFindByCPDefinitionId; private FinderPath _finderPathWithoutPaginationFindByCPDefinitionId; private FinderPath _finderPathCountByCPDefinitionId; /** * Returns all the commerce pricing class cp definition rels where CPDefinitionId = ?. * * @param CPDefinitionId the cp definition ID * @return the matching commerce pricing class cp definition rels */ @Override public List findByCPDefinitionId( long CPDefinitionId) { return findByCPDefinitionId( CPDefinitionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the commerce pricing class cp definition rels where CPDefinitionId = ?. * *

* 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 CommercePricingClassCPDefinitionRelModelImpl. *

* * @param CPDefinitionId the cp definition ID * @param start the lower bound of the range of commerce pricing class cp definition rels * @param end the upper bound of the range of commerce pricing class cp definition rels (not inclusive) * @return the range of matching commerce pricing class cp definition rels */ @Override public List findByCPDefinitionId( long CPDefinitionId, int start, int end) { return findByCPDefinitionId(CPDefinitionId, start, end, null); } /** * Returns an ordered range of all the commerce pricing class cp definition rels where CPDefinitionId = ?. * *

* 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 CommercePricingClassCPDefinitionRelModelImpl. *

* * @param CPDefinitionId the cp definition ID * @param start the lower bound of the range of commerce pricing class cp definition rels * @param end the upper bound of the range of commerce pricing class cp definition rels (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching commerce pricing class cp definition rels */ @Override public List findByCPDefinitionId( long CPDefinitionId, int start, int end, OrderByComparator orderByComparator) { return findByCPDefinitionId( CPDefinitionId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the commerce pricing class cp definition rels where CPDefinitionId = ?. * *

* 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 CommercePricingClassCPDefinitionRelModelImpl. *

* * @param CPDefinitionId the cp definition ID * @param start the lower bound of the range of commerce pricing class cp definition rels * @param end the upper bound of the range of commerce pricing class cp definition rels (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 pricing class cp definition rels */ @Override public List findByCPDefinitionId( long CPDefinitionId, int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { try (SafeCloseable safeCloseable = ctPersistenceHelper.setCTCollectionIdWithSafeCloseable( CommercePricingClassCPDefinitionRel.class)) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByCPDefinitionId; finderArgs = new Object[] {CPDefinitionId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByCPDefinitionId; finderArgs = new Object[] { CPDefinitionId, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List) finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel : list) { if (CPDefinitionId != commercePricingClassCPDefinitionRel. getCPDefinitionId()) { 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_COMMERCEPRICINGCLASSCPDEFINITIONREL_WHERE); sb.append(_FINDER_COLUMN_CPDEFINITIONID_CPDEFINITIONID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append( CommercePricingClassCPDefinitionRelModelImpl. 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(CPDefinitionId); 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 pricing class cp definition rel in the ordered set where CPDefinitionId = ?. * * @param CPDefinitionId the cp definition ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching commerce pricing class cp definition rel * @throws NoSuchPricingClassCPDefinitionRelException if a matching commerce pricing class cp definition rel could not be found */ @Override public CommercePricingClassCPDefinitionRel findByCPDefinitionId_First( long CPDefinitionId, OrderByComparator orderByComparator) throws NoSuchPricingClassCPDefinitionRelException { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = fetchByCPDefinitionId_First( CPDefinitionId, orderByComparator); if (commercePricingClassCPDefinitionRel != null) { return commercePricingClassCPDefinitionRel; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("CPDefinitionId="); sb.append(CPDefinitionId); sb.append("}"); throw new NoSuchPricingClassCPDefinitionRelException(sb.toString()); } /** * Returns the first commerce pricing class cp definition rel in the ordered set where CPDefinitionId = ?. * * @param CPDefinitionId the cp definition ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching commerce pricing class cp definition rel, or null if a matching commerce pricing class cp definition rel could not be found */ @Override public CommercePricingClassCPDefinitionRel fetchByCPDefinitionId_First( long CPDefinitionId, OrderByComparator orderByComparator) { List list = findByCPDefinitionId( CPDefinitionId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last commerce pricing class cp definition rel in the ordered set where CPDefinitionId = ?. * * @param CPDefinitionId the cp definition ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching commerce pricing class cp definition rel * @throws NoSuchPricingClassCPDefinitionRelException if a matching commerce pricing class cp definition rel could not be found */ @Override public CommercePricingClassCPDefinitionRel findByCPDefinitionId_Last( long CPDefinitionId, OrderByComparator orderByComparator) throws NoSuchPricingClassCPDefinitionRelException { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = fetchByCPDefinitionId_Last( CPDefinitionId, orderByComparator); if (commercePricingClassCPDefinitionRel != null) { return commercePricingClassCPDefinitionRel; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("CPDefinitionId="); sb.append(CPDefinitionId); sb.append("}"); throw new NoSuchPricingClassCPDefinitionRelException(sb.toString()); } /** * Returns the last commerce pricing class cp definition rel in the ordered set where CPDefinitionId = ?. * * @param CPDefinitionId the cp definition ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching commerce pricing class cp definition rel, or null if a matching commerce pricing class cp definition rel could not be found */ @Override public CommercePricingClassCPDefinitionRel fetchByCPDefinitionId_Last( long CPDefinitionId, OrderByComparator orderByComparator) { int count = countByCPDefinitionId(CPDefinitionId); if (count == 0) { return null; } List list = findByCPDefinitionId( CPDefinitionId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the commerce pricing class cp definition rels before and after the current commerce pricing class cp definition rel in the ordered set where CPDefinitionId = ?. * * @param CommercePricingClassCPDefinitionRelId the primary key of the current commerce pricing class cp definition rel * @param CPDefinitionId the cp definition ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next commerce pricing class cp definition rel * @throws NoSuchPricingClassCPDefinitionRelException if a commerce pricing class cp definition rel with the primary key could not be found */ @Override public CommercePricingClassCPDefinitionRel[] findByCPDefinitionId_PrevAndNext( long CommercePricingClassCPDefinitionRelId, long CPDefinitionId, OrderByComparator orderByComparator) throws NoSuchPricingClassCPDefinitionRelException { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = findByPrimaryKey( CommercePricingClassCPDefinitionRelId); Session session = null; try { session = openSession(); CommercePricingClassCPDefinitionRel[] array = new CommercePricingClassCPDefinitionRelImpl[3]; array[0] = getByCPDefinitionId_PrevAndNext( session, commercePricingClassCPDefinitionRel, CPDefinitionId, orderByComparator, true); array[1] = commercePricingClassCPDefinitionRel; array[2] = getByCPDefinitionId_PrevAndNext( session, commercePricingClassCPDefinitionRel, CPDefinitionId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CommercePricingClassCPDefinitionRel getByCPDefinitionId_PrevAndNext( Session session, CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel, long CPDefinitionId, 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_COMMERCEPRICINGCLASSCPDEFINITIONREL_WHERE); sb.append(_FINDER_COLUMN_CPDEFINITIONID_CPDEFINITIONID_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( CommercePricingClassCPDefinitionRelModelImpl.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(CPDefinitionId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( commercePricingClassCPDefinitionRel)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the commerce pricing class cp definition rels where CPDefinitionId = ? from the database. * * @param CPDefinitionId the cp definition ID */ @Override public void removeByCPDefinitionId(long CPDefinitionId) { for (CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel : findByCPDefinitionId( CPDefinitionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(commercePricingClassCPDefinitionRel); } } /** * Returns the number of commerce pricing class cp definition rels where CPDefinitionId = ?. * * @param CPDefinitionId the cp definition ID * @return the number of matching commerce pricing class cp definition rels */ @Override public int countByCPDefinitionId(long CPDefinitionId) { try (SafeCloseable safeCloseable = ctPersistenceHelper.setCTCollectionIdWithSafeCloseable( CommercePricingClassCPDefinitionRel.class)) { FinderPath finderPath = _finderPathCountByCPDefinitionId; Object[] finderArgs = new Object[] {CPDefinitionId}; Long count = (Long)finderCache.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_COMMERCEPRICINGCLASSCPDEFINITIONREL_WHERE); sb.append(_FINDER_COLUMN_CPDEFINITIONID_CPDEFINITIONID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(CPDefinitionId); 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_CPDEFINITIONID_CPDEFINITIONID_2 = "commercePricingClassCPDefinitionRel.CPDefinitionId = ?"; private FinderPath _finderPathFetchByC_C; private FinderPath _finderPathCountByC_C; /** * Returns the commerce pricing class cp definition rel where commercePricingClassId = ? and CPDefinitionId = ? or throws a NoSuchPricingClassCPDefinitionRelException if it could not be found. * * @param commercePricingClassId the commerce pricing class ID * @param CPDefinitionId the cp definition ID * @return the matching commerce pricing class cp definition rel * @throws NoSuchPricingClassCPDefinitionRelException if a matching commerce pricing class cp definition rel could not be found */ @Override public CommercePricingClassCPDefinitionRel findByC_C( long commercePricingClassId, long CPDefinitionId) throws NoSuchPricingClassCPDefinitionRelException { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = fetchByC_C( commercePricingClassId, CPDefinitionId); if (commercePricingClassCPDefinitionRel == null) { StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("commercePricingClassId="); sb.append(commercePricingClassId); sb.append(", CPDefinitionId="); sb.append(CPDefinitionId); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchPricingClassCPDefinitionRelException(sb.toString()); } return commercePricingClassCPDefinitionRel; } /** * Returns the commerce pricing class cp definition rel where commercePricingClassId = ? and CPDefinitionId = ? or returns null if it could not be found. Uses the finder cache. * * @param commercePricingClassId the commerce pricing class ID * @param CPDefinitionId the cp definition ID * @return the matching commerce pricing class cp definition rel, or null if a matching commerce pricing class cp definition rel could not be found */ @Override public CommercePricingClassCPDefinitionRel fetchByC_C( long commercePricingClassId, long CPDefinitionId) { return fetchByC_C(commercePricingClassId, CPDefinitionId, true); } /** * Returns the commerce pricing class cp definition rel where commercePricingClassId = ? and CPDefinitionId = ? or returns null if it could not be found, optionally using the finder cache. * * @param commercePricingClassId the commerce pricing class ID * @param CPDefinitionId the cp definition ID * @param useFinderCache whether to use the finder cache * @return the matching commerce pricing class cp definition rel, or null if a matching commerce pricing class cp definition rel could not be found */ @Override public CommercePricingClassCPDefinitionRel fetchByC_C( long commercePricingClassId, long CPDefinitionId, boolean useFinderCache) { try (SafeCloseable safeCloseable = ctPersistenceHelper.setCTCollectionIdWithSafeCloseable( CommercePricingClassCPDefinitionRel.class)) { Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] { commercePricingClassId, CPDefinitionId }; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByC_C, finderArgs, this); } if (result instanceof CommercePricingClassCPDefinitionRel) { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = (CommercePricingClassCPDefinitionRel)result; if ((commercePricingClassId != commercePricingClassCPDefinitionRel. getCommercePricingClassId()) || (CPDefinitionId != commercePricingClassCPDefinitionRel. getCPDefinitionId())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(4); sb.append( _SQL_SELECT_COMMERCEPRICINGCLASSCPDEFINITIONREL_WHERE); sb.append(_FINDER_COLUMN_C_C_COMMERCEPRICINGCLASSID_2); sb.append(_FINDER_COLUMN_C_C_CPDEFINITIONID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(commercePricingClassId); queryPos.add(CPDefinitionId); List list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByC_C, finderArgs, list); } } else { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = list.get(0); result = commercePricingClassCPDefinitionRel; cacheResult(commercePricingClassCPDefinitionRel); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (CommercePricingClassCPDefinitionRel)result; } } } /** * Removes the commerce pricing class cp definition rel where commercePricingClassId = ? and CPDefinitionId = ? from the database. * * @param commercePricingClassId the commerce pricing class ID * @param CPDefinitionId the cp definition ID * @return the commerce pricing class cp definition rel that was removed */ @Override public CommercePricingClassCPDefinitionRel removeByC_C( long commercePricingClassId, long CPDefinitionId) throws NoSuchPricingClassCPDefinitionRelException { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = findByC_C( commercePricingClassId, CPDefinitionId); return remove(commercePricingClassCPDefinitionRel); } /** * Returns the number of commerce pricing class cp definition rels where commercePricingClassId = ? and CPDefinitionId = ?. * * @param commercePricingClassId the commerce pricing class ID * @param CPDefinitionId the cp definition ID * @return the number of matching commerce pricing class cp definition rels */ @Override public int countByC_C(long commercePricingClassId, long CPDefinitionId) { try (SafeCloseable safeCloseable = ctPersistenceHelper.setCTCollectionIdWithSafeCloseable( CommercePricingClassCPDefinitionRel.class)) { FinderPath finderPath = _finderPathCountByC_C; Object[] finderArgs = new Object[] { commercePricingClassId, CPDefinitionId }; Long count = (Long)finderCache.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_COMMERCEPRICINGCLASSCPDEFINITIONREL_WHERE); sb.append(_FINDER_COLUMN_C_C_COMMERCEPRICINGCLASSID_2); sb.append(_FINDER_COLUMN_C_C_CPDEFINITIONID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(commercePricingClassId); queryPos.add(CPDefinitionId); 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_C_C_COMMERCEPRICINGCLASSID_2 = "commercePricingClassCPDefinitionRel.commercePricingClassId = ? AND "; private static final String _FINDER_COLUMN_C_C_CPDEFINITIONID_2 = "commercePricingClassCPDefinitionRel.CPDefinitionId = ?"; public CommercePricingClassCPDefinitionRelPersistenceImpl() { Map dbColumnNames = new HashMap(); dbColumnNames.put( "CommercePricingClassCPDefinitionRelId", "CPricingClassCPDefinitionRelId"); setDBColumnNames(dbColumnNames); setModelClass(CommercePricingClassCPDefinitionRel.class); setModelImplClass(CommercePricingClassCPDefinitionRelImpl.class); setModelPKClass(long.class); setTable(CommercePricingClassCPDefinitionRelTable.INSTANCE); } /** * Caches the commerce pricing class cp definition rel in the entity cache if it is enabled. * * @param commercePricingClassCPDefinitionRel the commerce pricing class cp definition rel */ @Override public void cacheResult( CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel) { try (SafeCloseable safeCloseable = CTCollectionThreadLocal.setCTCollectionIdWithSafeCloseable( commercePricingClassCPDefinitionRel.getCtCollectionId())) { entityCache.putResult( CommercePricingClassCPDefinitionRelImpl.class, commercePricingClassCPDefinitionRel.getPrimaryKey(), commercePricingClassCPDefinitionRel); finderCache.putResult( _finderPathFetchByC_C, new Object[] { commercePricingClassCPDefinitionRel. getCommercePricingClassId(), commercePricingClassCPDefinitionRel.getCPDefinitionId() }, commercePricingClassCPDefinitionRel); } } private int _valueObjectFinderCacheListThreshold; /** * Caches the commerce pricing class cp definition rels in the entity cache if it is enabled. * * @param commercePricingClassCPDefinitionRels the commerce pricing class cp definition rels */ @Override public void cacheResult( List commercePricingClassCPDefinitionRels) { if ((_valueObjectFinderCacheListThreshold == 0) || ((_valueObjectFinderCacheListThreshold > 0) && (commercePricingClassCPDefinitionRels.size() > _valueObjectFinderCacheListThreshold))) { return; } for (CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel : commercePricingClassCPDefinitionRels) { try (SafeCloseable safeCloseable = CTCollectionThreadLocal.setCTCollectionIdWithSafeCloseable( commercePricingClassCPDefinitionRel. getCtCollectionId())) { if (entityCache.getResult( CommercePricingClassCPDefinitionRelImpl.class, commercePricingClassCPDefinitionRel.getPrimaryKey()) == null) { cacheResult(commercePricingClassCPDefinitionRel); } } } } /** * Clears the cache for all commerce pricing class cp definition rels. * *

* The EntityCache and FinderCache are both cleared by this method. *

*/ @Override public void clearCache() { entityCache.clearCache(CommercePricingClassCPDefinitionRelImpl.class); finderCache.clearCache(CommercePricingClassCPDefinitionRelImpl.class); } /** * Clears the cache for the commerce pricing class cp definition rel. * *

* The EntityCache and FinderCache are both cleared by this method. *

*/ @Override public void clearCache( CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel) { entityCache.removeResult( CommercePricingClassCPDefinitionRelImpl.class, commercePricingClassCPDefinitionRel); } @Override public void clearCache( List commercePricingClassCPDefinitionRels) { for (CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel : commercePricingClassCPDefinitionRels) { entityCache.removeResult( CommercePricingClassCPDefinitionRelImpl.class, commercePricingClassCPDefinitionRel); } } @Override public void clearCache(Set primaryKeys) { finderCache.clearCache(CommercePricingClassCPDefinitionRelImpl.class); for (Serializable primaryKey : primaryKeys) { entityCache.removeResult( CommercePricingClassCPDefinitionRelImpl.class, primaryKey); } } protected void cacheUniqueFindersCache( CommercePricingClassCPDefinitionRelModelImpl commercePricingClassCPDefinitionRelModelImpl) { try (SafeCloseable safeCloseable = CTCollectionThreadLocal.setCTCollectionIdWithSafeCloseable( commercePricingClassCPDefinitionRelModelImpl. getCtCollectionId())) { Object[] args = new Object[] { commercePricingClassCPDefinitionRelModelImpl. getCommercePricingClassId(), commercePricingClassCPDefinitionRelModelImpl.getCPDefinitionId() }; finderCache.putResult(_finderPathCountByC_C, args, Long.valueOf(1)); finderCache.putResult( _finderPathFetchByC_C, args, commercePricingClassCPDefinitionRelModelImpl); } } /** * Creates a new commerce pricing class cp definition rel with the primary key. Does not add the commerce pricing class cp definition rel to the database. * * @param CommercePricingClassCPDefinitionRelId the primary key for the new commerce pricing class cp definition rel * @return the new commerce pricing class cp definition rel */ @Override public CommercePricingClassCPDefinitionRel create( long CommercePricingClassCPDefinitionRelId) { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = new CommercePricingClassCPDefinitionRelImpl(); commercePricingClassCPDefinitionRel.setNew(true); commercePricingClassCPDefinitionRel.setPrimaryKey( CommercePricingClassCPDefinitionRelId); commercePricingClassCPDefinitionRel.setCompanyId( CompanyThreadLocal.getCompanyId()); return commercePricingClassCPDefinitionRel; } /** * Removes the commerce pricing class cp definition rel with the primary key from the database. Also notifies the appropriate model listeners. * * @param CommercePricingClassCPDefinitionRelId the primary key of the commerce pricing class cp definition rel * @return the commerce pricing class cp definition rel that was removed * @throws NoSuchPricingClassCPDefinitionRelException if a commerce pricing class cp definition rel with the primary key could not be found */ @Override public CommercePricingClassCPDefinitionRel remove( long CommercePricingClassCPDefinitionRelId) throws NoSuchPricingClassCPDefinitionRelException { return remove((Serializable)CommercePricingClassCPDefinitionRelId); } /** * Removes the commerce pricing class cp definition rel with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the commerce pricing class cp definition rel * @return the commerce pricing class cp definition rel that was removed * @throws NoSuchPricingClassCPDefinitionRelException if a commerce pricing class cp definition rel with the primary key could not be found */ @Override public CommercePricingClassCPDefinitionRel remove(Serializable primaryKey) throws NoSuchPricingClassCPDefinitionRelException { Session session = null; try { session = openSession(); CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = (CommercePricingClassCPDefinitionRel)session.get( CommercePricingClassCPDefinitionRelImpl.class, primaryKey); if (commercePricingClassCPDefinitionRel == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchPricingClassCPDefinitionRelException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(commercePricingClassCPDefinitionRel); } catch (NoSuchPricingClassCPDefinitionRelException noSuchEntityException) { throw noSuchEntityException; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } @Override protected CommercePricingClassCPDefinitionRel removeImpl( CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel) { Session session = null; try { session = openSession(); if (!session.contains(commercePricingClassCPDefinitionRel)) { commercePricingClassCPDefinitionRel = (CommercePricingClassCPDefinitionRel)session.get( CommercePricingClassCPDefinitionRelImpl.class, commercePricingClassCPDefinitionRel.getPrimaryKeyObj()); } if ((commercePricingClassCPDefinitionRel != null) && ctPersistenceHelper.isRemove( commercePricingClassCPDefinitionRel)) { session.delete(commercePricingClassCPDefinitionRel); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } if (commercePricingClassCPDefinitionRel != null) { clearCache(commercePricingClassCPDefinitionRel); } return commercePricingClassCPDefinitionRel; } @Override public CommercePricingClassCPDefinitionRel updateImpl( CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel) { boolean isNew = commercePricingClassCPDefinitionRel.isNew(); if (!(commercePricingClassCPDefinitionRel instanceof CommercePricingClassCPDefinitionRelModelImpl)) { InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass( commercePricingClassCPDefinitionRel.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler( commercePricingClassCPDefinitionRel); throw new IllegalArgumentException( "Implement ModelWrapper in commercePricingClassCPDefinitionRel proxy " + invocationHandler.getClass()); } throw new IllegalArgumentException( "Implement ModelWrapper in custom CommercePricingClassCPDefinitionRel implementation " + commercePricingClassCPDefinitionRel.getClass()); } CommercePricingClassCPDefinitionRelModelImpl commercePricingClassCPDefinitionRelModelImpl = (CommercePricingClassCPDefinitionRelModelImpl) commercePricingClassCPDefinitionRel; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date date = new Date(); if (isNew && (commercePricingClassCPDefinitionRel.getCreateDate() == null)) { if (serviceContext == null) { commercePricingClassCPDefinitionRel.setCreateDate(date); } else { commercePricingClassCPDefinitionRel.setCreateDate( serviceContext.getCreateDate(date)); } } if (!commercePricingClassCPDefinitionRelModelImpl. hasSetModifiedDate()) { if (serviceContext == null) { commercePricingClassCPDefinitionRel.setModifiedDate(date); } else { commercePricingClassCPDefinitionRel.setModifiedDate( serviceContext.getModifiedDate(date)); } } Session session = null; try { session = openSession(); if (ctPersistenceHelper.isInsert( commercePricingClassCPDefinitionRel)) { if (!isNew) { session.evict( CommercePricingClassCPDefinitionRelImpl.class, commercePricingClassCPDefinitionRel.getPrimaryKeyObj()); } session.save(commercePricingClassCPDefinitionRel); } else { commercePricingClassCPDefinitionRel = (CommercePricingClassCPDefinitionRel)session.merge( commercePricingClassCPDefinitionRel); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } entityCache.putResult( CommercePricingClassCPDefinitionRelImpl.class, commercePricingClassCPDefinitionRelModelImpl, false, true); cacheUniqueFindersCache(commercePricingClassCPDefinitionRelModelImpl); if (isNew) { commercePricingClassCPDefinitionRel.setNew(false); } commercePricingClassCPDefinitionRel.resetOriginalValues(); return commercePricingClassCPDefinitionRel; } /** * Returns the commerce pricing class cp definition rel with the primary key or throws a com.liferay.portal.kernel.exception.NoSuchModelException if it could not be found. * * @param primaryKey the primary key of the commerce pricing class cp definition rel * @return the commerce pricing class cp definition rel * @throws NoSuchPricingClassCPDefinitionRelException if a commerce pricing class cp definition rel with the primary key could not be found */ @Override public CommercePricingClassCPDefinitionRel findByPrimaryKey( Serializable primaryKey) throws NoSuchPricingClassCPDefinitionRelException { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = fetchByPrimaryKey(primaryKey); if (commercePricingClassCPDefinitionRel == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchPricingClassCPDefinitionRelException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return commercePricingClassCPDefinitionRel; } /** * Returns the commerce pricing class cp definition rel with the primary key or throws a NoSuchPricingClassCPDefinitionRelException if it could not be found. * * @param CommercePricingClassCPDefinitionRelId the primary key of the commerce pricing class cp definition rel * @return the commerce pricing class cp definition rel * @throws NoSuchPricingClassCPDefinitionRelException if a commerce pricing class cp definition rel with the primary key could not be found */ @Override public CommercePricingClassCPDefinitionRel findByPrimaryKey( long CommercePricingClassCPDefinitionRelId) throws NoSuchPricingClassCPDefinitionRelException { return findByPrimaryKey( (Serializable)CommercePricingClassCPDefinitionRelId); } /** * Returns the commerce pricing class cp definition rel with the primary key or returns null if it could not be found. * * @param primaryKey the primary key of the commerce pricing class cp definition rel * @return the commerce pricing class cp definition rel, or null if a commerce pricing class cp definition rel with the primary key could not be found */ @Override public CommercePricingClassCPDefinitionRel fetchByPrimaryKey( Serializable primaryKey) { if (ctPersistenceHelper.isProductionMode( CommercePricingClassCPDefinitionRel.class, primaryKey)) { try (SafeCloseable safeCloseable = CTCollectionThreadLocal. setProductionModeWithSafeCloseable()) { return super.fetchByPrimaryKey(primaryKey); } } CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = (CommercePricingClassCPDefinitionRel)entityCache.getResult( CommercePricingClassCPDefinitionRelImpl.class, primaryKey); if (commercePricingClassCPDefinitionRel != null) { return commercePricingClassCPDefinitionRel; } Session session = null; try { session = openSession(); commercePricingClassCPDefinitionRel = (CommercePricingClassCPDefinitionRel)session.get( CommercePricingClassCPDefinitionRelImpl.class, primaryKey); if (commercePricingClassCPDefinitionRel != null) { cacheResult(commercePricingClassCPDefinitionRel); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } return commercePricingClassCPDefinitionRel; } /** * Returns the commerce pricing class cp definition rel with the primary key or returns null if it could not be found. * * @param CommercePricingClassCPDefinitionRelId the primary key of the commerce pricing class cp definition rel * @return the commerce pricing class cp definition rel, or null if a commerce pricing class cp definition rel with the primary key could not be found */ @Override public CommercePricingClassCPDefinitionRel fetchByPrimaryKey( long CommercePricingClassCPDefinitionRelId) { return fetchByPrimaryKey( (Serializable)CommercePricingClassCPDefinitionRelId); } @Override public Map fetchByPrimaryKeys(Set primaryKeys) { if (ctPersistenceHelper.isProductionMode( CommercePricingClassCPDefinitionRel.class)) { try (SafeCloseable safeCloseable = CTCollectionThreadLocal. setProductionModeWithSafeCloseable()) { return super.fetchByPrimaryKeys(primaryKeys); } } if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map map = new HashMap(); if (primaryKeys.size() == 1) { Iterator iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = fetchByPrimaryKey( primaryKey); if (commercePricingClassCPDefinitionRel != null) { map.put(primaryKey, commercePricingClassCPDefinitionRel); } return map; } Set uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { try (SafeCloseable safeCloseable = ctPersistenceHelper.setCTCollectionIdWithSafeCloseable( CommercePricingClassCPDefinitionRel.class, primaryKey)) { CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel = (CommercePricingClassCPDefinitionRel) entityCache.getResult( CommercePricingClassCPDefinitionRelImpl.class, primaryKey); if (commercePricingClassCPDefinitionRel == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, commercePricingClassCPDefinitionRel); } } } if (uncachedPrimaryKeys == null) { return map; } if ((databaseInMaxParameters > 0) && (primaryKeys.size() > databaseInMaxParameters)) { Iterator iterator = primaryKeys.iterator(); while (iterator.hasNext()) { Set page = new HashSet<>(); for (int i = 0; (i < databaseInMaxParameters) && iterator.hasNext(); i++) { page.add(iterator.next()); } map.putAll(fetchByPrimaryKeys(page)); } return map; } StringBundler sb = new StringBundler((primaryKeys.size() * 2) + 1); sb.append(getSelectSQL()); sb.append(" WHERE "); sb.append(getPKDBName()); sb.append(" IN ("); for (Serializable primaryKey : primaryKeys) { sb.append((long)primaryKey); sb.append(","); } sb.setIndex(sb.index() - 1); sb.append(")"); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); for (CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel : (List) query.list()) { map.put( commercePricingClassCPDefinitionRel.getPrimaryKeyObj(), commercePricingClassCPDefinitionRel); cacheResult(commercePricingClassCPDefinitionRel); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } return map; } /** * Returns all the commerce pricing class cp definition rels. * * @return the commerce pricing class cp definition rels */ @Override public List findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the commerce pricing class cp definition rels. * *

* 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 CommercePricingClassCPDefinitionRelModelImpl. *

* * @param start the lower bound of the range of commerce pricing class cp definition rels * @param end the upper bound of the range of commerce pricing class cp definition rels (not inclusive) * @return the range of commerce pricing class cp definition rels */ @Override public List findAll( int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the commerce pricing class cp definition rels. * *

* 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 CommercePricingClassCPDefinitionRelModelImpl. *

* * @param start the lower bound of the range of commerce pricing class cp definition rels * @param end the upper bound of the range of commerce pricing class cp definition rels (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of commerce pricing class cp definition rels */ @Override public List findAll( int start, int end, OrderByComparator orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the commerce pricing class cp definition rels. * *

* 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 CommercePricingClassCPDefinitionRelModelImpl. *

* * @param start the lower bound of the range of commerce pricing class cp definition rels * @param end the upper bound of the range of commerce pricing class cp definition rels (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 commerce pricing class cp definition rels */ @Override public List findAll( int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { try (SafeCloseable safeCloseable = ctPersistenceHelper.setCTCollectionIdWithSafeCloseable( CommercePricingClassCPDefinitionRel.class)) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindAll; finderArgs = FINDER_ARGS_EMPTY; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindAll; finderArgs = new Object[] {start, end, orderByComparator}; } List list = null; if (useFinderCache) { list = (List) finderCache.getResult(finderPath, finderArgs, this); } if (list == null) { StringBundler sb = null; String sql = null; if (orderByComparator != null) { sb = new StringBundler( 2 + (orderByComparator.getOrderByFields().length * 2)); sb.append(_SQL_SELECT_COMMERCEPRICINGCLASSCPDEFINITIONREL); appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = sb.toString(); } else { sql = _SQL_SELECT_COMMERCEPRICINGCLASSCPDEFINITIONREL; sql = sql.concat( CommercePricingClassCPDefinitionRelModelImpl. ORDER_BY_JPQL); } Session session = null; try { session = openSession(); Query query = session.createQuery(sql); 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; } } /** * Removes all the commerce pricing class cp definition rels from the database. * */ @Override public void removeAll() { for (CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel : findAll()) { remove(commercePricingClassCPDefinitionRel); } } /** * Returns the number of commerce pricing class cp definition rels. * * @return the number of commerce pricing class cp definition rels */ @Override public int countAll() { try (SafeCloseable safeCloseable = ctPersistenceHelper.setCTCollectionIdWithSafeCloseable( CommercePricingClassCPDefinitionRel.class)) { Long count = (Long)finderCache.getResult( _finderPathCountAll, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query query = session.createQuery( _SQL_COUNT_COMMERCEPRICINGCLASSCPDEFINITIONREL); count = (Long)query.uniqueResult(); finderCache.putResult( _finderPathCountAll, FINDER_ARGS_EMPTY, count); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } } @Override public Set getBadColumnNames() { return _badColumnNames; } @Override protected EntityCache getEntityCache() { return entityCache; } @Override protected String getPKDBName() { return "CPricingClassCPDefinitionRelId"; } @Override protected String getSelectSQL() { return _SQL_SELECT_COMMERCEPRICINGCLASSCPDEFINITIONREL; } @Override public Set getCTColumnNames( CTColumnResolutionType ctColumnResolutionType) { return _ctColumnNamesMap.getOrDefault( ctColumnResolutionType, Collections.emptySet()); } @Override public List getMappingTableNames() { return _mappingTableNames; } @Override public Map getTableColumnsMap() { return CommercePricingClassCPDefinitionRelModelImpl.TABLE_COLUMNS_MAP; } @Override public String getTableName() { return "CPricingClassCPDefinitionRel"; } @Override public List getUniqueIndexColumnNames() { return _uniqueIndexColumnNames; } private static final Map> _ctColumnNamesMap = new EnumMap>( CTColumnResolutionType.class); private static final List _mappingTableNames = new ArrayList(); private static final List _uniqueIndexColumnNames = new ArrayList(); static { Set ctControlColumnNames = new HashSet(); Set ctIgnoreColumnNames = new HashSet(); Set ctStrictColumnNames = new HashSet(); ctControlColumnNames.add("mvccVersion"); ctControlColumnNames.add("ctCollectionId"); ctStrictColumnNames.add("companyId"); ctStrictColumnNames.add("userId"); ctStrictColumnNames.add("userName"); ctStrictColumnNames.add("createDate"); ctIgnoreColumnNames.add("modifiedDate"); ctStrictColumnNames.add("commercePricingClassId"); ctStrictColumnNames.add("CPDefinitionId"); _ctColumnNamesMap.put( CTColumnResolutionType.CONTROL, ctControlColumnNames); _ctColumnNamesMap.put( CTColumnResolutionType.IGNORE, ctIgnoreColumnNames); _ctColumnNamesMap.put( CTColumnResolutionType.PK, Collections.singleton("CPricingClassCPDefinitionRelId")); _ctColumnNamesMap.put( CTColumnResolutionType.STRICT, ctStrictColumnNames); _uniqueIndexColumnNames.add( new String[] {"commercePricingClassId", "CPDefinitionId"}); } /** * Initializes the commerce pricing class cp definition rel persistence. */ @Activate public void activate() { _valueObjectFinderCacheListThreshold = GetterUtil.getInteger( PropsUtil.get(PropsKeys.VALUE_OBJECT_FINDER_CACHE_LIST_THRESHOLD)); _finderPathWithPaginationFindAll = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0], new String[0], true); _finderPathWithoutPaginationFindAll = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0], new String[0], true); _finderPathCountAll = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0], new String[0], false); _finderPathWithPaginationFindByCommercePricingClassId = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCommercePricingClassId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"commercePricingClassId"}, true); _finderPathWithoutPaginationFindByCommercePricingClassId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCommercePricingClassId", new String[] {Long.class.getName()}, new String[] {"commercePricingClassId"}, true); _finderPathCountByCommercePricingClassId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCommercePricingClassId", new String[] {Long.class.getName()}, new String[] {"commercePricingClassId"}, false); _finderPathWithPaginationFindByCPDefinitionId = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCPDefinitionId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"CPDefinitionId"}, true); _finderPathWithoutPaginationFindByCPDefinitionId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCPDefinitionId", new String[] {Long.class.getName()}, new String[] {"CPDefinitionId"}, true); _finderPathCountByCPDefinitionId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCPDefinitionId", new String[] {Long.class.getName()}, new String[] {"CPDefinitionId"}, false); _finderPathFetchByC_C = new FinderPath( FINDER_CLASS_NAME_ENTITY, "fetchByC_C", new String[] {Long.class.getName(), Long.class.getName()}, new String[] {"commercePricingClassId", "CPDefinitionId"}, true); _finderPathCountByC_C = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C", new String[] {Long.class.getName(), Long.class.getName()}, new String[] {"commercePricingClassId", "CPDefinitionId"}, false); CommercePricingClassCPDefinitionRelUtil.setPersistence(this); } @Deactivate public void deactivate() { CommercePricingClassCPDefinitionRelUtil.setPersistence(null); entityCache.removeCache( CommercePricingClassCPDefinitionRelImpl.class.getName()); } @Override @Reference( target = CommercePersistenceConstants.SERVICE_CONFIGURATION_FILTER, unbind = "-" ) public void setConfiguration(Configuration configuration) { } @Override @Reference( target = CommercePersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setDataSource(DataSource dataSource) { super.setDataSource(dataSource); } @Override @Reference( target = CommercePersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setSessionFactory(SessionFactory sessionFactory) { super.setSessionFactory(sessionFactory); } @Reference protected CTPersistenceHelper ctPersistenceHelper; @Reference protected EntityCache entityCache; @Reference protected FinderCache finderCache; private static final String _SQL_SELECT_COMMERCEPRICINGCLASSCPDEFINITIONREL = "SELECT commercePricingClassCPDefinitionRel FROM CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel"; private static final String _SQL_SELECT_COMMERCEPRICINGCLASSCPDEFINITIONREL_WHERE = "SELECT commercePricingClassCPDefinitionRel FROM CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel WHERE "; private static final String _SQL_COUNT_COMMERCEPRICINGCLASSCPDEFINITIONREL = "SELECT COUNT(commercePricingClassCPDefinitionRel) FROM CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel"; private static final String _SQL_COUNT_COMMERCEPRICINGCLASSCPDEFINITIONREL_WHERE = "SELECT COUNT(commercePricingClassCPDefinitionRel) FROM CommercePricingClassCPDefinitionRel commercePricingClassCPDefinitionRel WHERE "; private static final String _ORDER_BY_ENTITY_ALIAS = "commercePricingClassCPDefinitionRel."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No CommercePricingClassCPDefinitionRel exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No CommercePricingClassCPDefinitionRel exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( CommercePricingClassCPDefinitionRelPersistenceImpl.class); private static final Set _badColumnNames = SetUtil.fromArray( new String[] {"CommercePricingClassCPDefinitionRelId"}); @Override protected FinderCache getFinderCache() { return finderCache; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy