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

com.liferay.change.tracking.service.persistence.impl.CTEntryPersistenceImpl Maven / Gradle / Ivy

There is a newer version: 3.0.108
Show 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.change.tracking.service.persistence.impl;

import com.liferay.change.tracking.exception.DuplicateCTEntryExternalReferenceCodeException;
import com.liferay.change.tracking.exception.NoSuchEntryException;
import com.liferay.change.tracking.model.CTEntry;
import com.liferay.change.tracking.model.CTEntryTable;
import com.liferay.change.tracking.model.impl.CTEntryImpl;
import com.liferay.change.tracking.model.impl.CTEntryModelImpl;
import com.liferay.change.tracking.service.persistence.CTEntryPersistence;
import com.liferay.change.tracking.service.persistence.CTEntryUtil;
import com.liferay.change.tracking.service.persistence.impl.constants.CTPersistenceConstants;
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.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.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.ArrayUtil;
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.StringUtil;
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.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 ct entry service.
 *
 * 

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

* * @author Brian Wing Shun Chan * @generated */ @Component(service = CTEntryPersistence.class) public class CTEntryPersistenceImpl extends BasePersistenceImpl implements CTEntryPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use CTEntryUtil to access the ct entry persistence. Modify service.xml and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = CTEntryImpl.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 ct entries where uuid = ?. * * @param uuid the uuid * @return the matching ct entries */ @Override public List findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct entries 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 CTEntryModelImpl. *

* * @param uuid the uuid * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (not inclusive) * @return the range of matching ct entries */ @Override public List findByUuid(String uuid, int start, int end) { return findByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the ct entries 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 CTEntryModelImpl. *

* * @param uuid the uuid * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct entries */ @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 ct entries 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 CTEntryModelImpl. *

* * @param uuid the uuid * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (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 ct entries */ @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 (CTEntry ctEntry : list) { if (!uuid.equals(ctEntry.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_CTENTRY_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(CTEntryModelImpl.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 ct entry 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 ct entry * @throws NoSuchEntryException if a matching ct entry could not be found */ @Override public CTEntry findByUuid_First( String uuid, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = fetchByUuid_First(uuid, orderByComparator); if (ctEntry != null) { return ctEntry; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append("}"); throw new NoSuchEntryException(sb.toString()); } /** * Returns the first ct entry 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 ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry 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 ct entry 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 ct entry * @throws NoSuchEntryException if a matching ct entry could not be found */ @Override public CTEntry findByUuid_Last( String uuid, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = fetchByUuid_Last(uuid, orderByComparator); if (ctEntry != null) { return ctEntry; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append("}"); throw new NoSuchEntryException(sb.toString()); } /** * Returns the last ct entry 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 ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry 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 ct entries before and after the current ct entry in the ordered set where uuid = ?. * * @param ctEntryId the primary key of the current ct entry * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next ct entry * @throws NoSuchEntryException if a ct entry with the primary key could not be found */ @Override public CTEntry[] findByUuid_PrevAndNext( long ctEntryId, String uuid, OrderByComparator orderByComparator) throws NoSuchEntryException { uuid = Objects.toString(uuid, ""); CTEntry ctEntry = findByPrimaryKey(ctEntryId); Session session = null; try { session = openSession(); CTEntry[] array = new CTEntryImpl[3]; array[0] = getByUuid_PrevAndNext( session, ctEntry, uuid, orderByComparator, true); array[1] = ctEntry; array[2] = getByUuid_PrevAndNext( session, ctEntry, uuid, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTEntry getByUuid_PrevAndNext( Session session, CTEntry ctEntry, 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_CTENTRY_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(CTEntryModelImpl.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(ctEntry)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the ct entries where uuid = ? from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (CTEntry ctEntry : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ctEntry); } } /** * Returns the number of ct entries where uuid = ?. * * @param uuid the uuid * @return the number of matching ct entries */ @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_CTENTRY_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 = "ctEntry.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(ctEntry.uuid IS NULL OR ctEntry.uuid = '')"; private FinderPath _finderPathWithPaginationFindByUuid_C; private FinderPath _finderPathWithoutPaginationFindByUuid_C; private FinderPath _finderPathCountByUuid_C; /** * Returns all the ct entries where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching ct entries */ @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 ct entries 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 CTEntryModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (not inclusive) * @return the range of matching ct entries */ @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 ct entries 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 CTEntryModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct entries */ @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 ct entries 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 CTEntryModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (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 ct entries */ @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 (CTEntry ctEntry : list) { if (!uuid.equals(ctEntry.getUuid()) || (companyId != ctEntry.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_CTENTRY_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(CTEntryModelImpl.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 ct entry in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct entry * @throws NoSuchEntryException if a matching ct entry could not be found */ @Override public CTEntry findByUuid_C_First( String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = fetchByUuid_C_First( uuid, companyId, orderByComparator); if (ctEntry != null) { return ctEntry; } 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 NoSuchEntryException(sb.toString()); } /** * Returns the first ct entry in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry 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 ct entry in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct entry * @throws NoSuchEntryException if a matching ct entry could not be found */ @Override public CTEntry findByUuid_C_Last( String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = fetchByUuid_C_Last( uuid, companyId, orderByComparator); if (ctEntry != null) { return ctEntry; } 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 NoSuchEntryException(sb.toString()); } /** * Returns the last ct entry in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry 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 ct entries before and after the current ct entry in the ordered set where uuid = ? and companyId = ?. * * @param ctEntryId the primary key of the current ct entry * @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 ct entry * @throws NoSuchEntryException if a ct entry with the primary key could not be found */ @Override public CTEntry[] findByUuid_C_PrevAndNext( long ctEntryId, String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchEntryException { uuid = Objects.toString(uuid, ""); CTEntry ctEntry = findByPrimaryKey(ctEntryId); Session session = null; try { session = openSession(); CTEntry[] array = new CTEntryImpl[3]; array[0] = getByUuid_C_PrevAndNext( session, ctEntry, uuid, companyId, orderByComparator, true); array[1] = ctEntry; array[2] = getByUuid_C_PrevAndNext( session, ctEntry, uuid, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTEntry getByUuid_C_PrevAndNext( Session session, CTEntry ctEntry, 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_CTENTRY_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(CTEntryModelImpl.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(ctEntry)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the ct entries where uuid = ? and companyId = ? from the database. * * @param uuid the uuid * @param companyId the company ID */ @Override public void removeByUuid_C(String uuid, long companyId) { for (CTEntry ctEntry : findByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ctEntry); } } /** * Returns the number of ct entries where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching ct entries */ @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_CTENTRY_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 = "ctEntry.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(ctEntry.uuid IS NULL OR ctEntry.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "ctEntry.companyId = ?"; private FinderPath _finderPathWithPaginationFindByCtCollectionId; private FinderPath _finderPathWithoutPaginationFindByCtCollectionId; private FinderPath _finderPathCountByCtCollectionId; /** * Returns all the ct entries where ctCollectionId = ?. * * @param ctCollectionId the ct collection ID * @return the matching ct entries */ @Override public List findByCtCollectionId(long ctCollectionId) { return findByCtCollectionId( ctCollectionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct entries where ctCollectionId = ?. * *

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

* * @param ctCollectionId the ct collection ID * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (not inclusive) * @return the range of matching ct entries */ @Override public List findByCtCollectionId( long ctCollectionId, int start, int end) { return findByCtCollectionId(ctCollectionId, start, end, null); } /** * Returns an ordered range of all the ct entries where ctCollectionId = ?. * *

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

* * @param ctCollectionId the ct collection ID * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct entries */ @Override public List findByCtCollectionId( long ctCollectionId, int start, int end, OrderByComparator orderByComparator) { return findByCtCollectionId( ctCollectionId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the ct entries where ctCollectionId = ?. * *

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

* * @param ctCollectionId the ct collection ID * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (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 ct entries */ @Override public List findByCtCollectionId( long ctCollectionId, 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 = _finderPathWithoutPaginationFindByCtCollectionId; finderArgs = new Object[] {ctCollectionId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByCtCollectionId; finderArgs = new Object[] { ctCollectionId, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (CTEntry ctEntry : list) { if (ctCollectionId != ctEntry.getCtCollectionId()) { 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_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_CTCOLLECTIONID_CTCOLLECTIONID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(CTEntryModelImpl.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(ctCollectionId); 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 ct entry in the ordered set where ctCollectionId = ?. * * @param ctCollectionId the ct collection ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct entry * @throws NoSuchEntryException if a matching ct entry could not be found */ @Override public CTEntry findByCtCollectionId_First( long ctCollectionId, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = fetchByCtCollectionId_First( ctCollectionId, orderByComparator); if (ctEntry != null) { return ctEntry; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("ctCollectionId="); sb.append(ctCollectionId); sb.append("}"); throw new NoSuchEntryException(sb.toString()); } /** * Returns the first ct entry in the ordered set where ctCollectionId = ?. * * @param ctCollectionId the ct collection ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry fetchByCtCollectionId_First( long ctCollectionId, OrderByComparator orderByComparator) { List list = findByCtCollectionId( ctCollectionId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last ct entry in the ordered set where ctCollectionId = ?. * * @param ctCollectionId the ct collection ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct entry * @throws NoSuchEntryException if a matching ct entry could not be found */ @Override public CTEntry findByCtCollectionId_Last( long ctCollectionId, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = fetchByCtCollectionId_Last( ctCollectionId, orderByComparator); if (ctEntry != null) { return ctEntry; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("ctCollectionId="); sb.append(ctCollectionId); sb.append("}"); throw new NoSuchEntryException(sb.toString()); } /** * Returns the last ct entry in the ordered set where ctCollectionId = ?. * * @param ctCollectionId the ct collection ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry fetchByCtCollectionId_Last( long ctCollectionId, OrderByComparator orderByComparator) { int count = countByCtCollectionId(ctCollectionId); if (count == 0) { return null; } List list = findByCtCollectionId( ctCollectionId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the ct entries before and after the current ct entry in the ordered set where ctCollectionId = ?. * * @param ctEntryId the primary key of the current ct entry * @param ctCollectionId the ct collection ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next ct entry * @throws NoSuchEntryException if a ct entry with the primary key could not be found */ @Override public CTEntry[] findByCtCollectionId_PrevAndNext( long ctEntryId, long ctCollectionId, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = findByPrimaryKey(ctEntryId); Session session = null; try { session = openSession(); CTEntry[] array = new CTEntryImpl[3]; array[0] = getByCtCollectionId_PrevAndNext( session, ctEntry, ctCollectionId, orderByComparator, true); array[1] = ctEntry; array[2] = getByCtCollectionId_PrevAndNext( session, ctEntry, ctCollectionId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTEntry getByCtCollectionId_PrevAndNext( Session session, CTEntry ctEntry, long ctCollectionId, 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_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_CTCOLLECTIONID_CTCOLLECTIONID_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(CTEntryModelImpl.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(ctCollectionId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(ctEntry)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the ct entries where ctCollectionId = ? from the database. * * @param ctCollectionId the ct collection ID */ @Override public void removeByCtCollectionId(long ctCollectionId) { for (CTEntry ctEntry : findByCtCollectionId( ctCollectionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ctEntry); } } /** * Returns the number of ct entries where ctCollectionId = ?. * * @param ctCollectionId the ct collection ID * @return the number of matching ct entries */ @Override public int countByCtCollectionId(long ctCollectionId) { FinderPath finderPath = _finderPathCountByCtCollectionId; Object[] finderArgs = new Object[] {ctCollectionId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_CTCOLLECTIONID_CTCOLLECTIONID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(ctCollectionId); 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_CTCOLLECTIONID_CTCOLLECTIONID_2 = "ctEntry.ctCollectionId = ?"; private FinderPath _finderPathWithPaginationFindByC_MCNI; private FinderPath _finderPathWithoutPaginationFindByC_MCNI; private FinderPath _finderPathCountByC_MCNI; /** * Returns all the ct entries where ctCollectionId = ? and modelClassNameId = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @return the matching ct entries */ @Override public List findByC_MCNI( long ctCollectionId, long modelClassNameId) { return findByC_MCNI( ctCollectionId, modelClassNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct entries where ctCollectionId = ? and modelClassNameId = ?. * *

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

* * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (not inclusive) * @return the range of matching ct entries */ @Override public List findByC_MCNI( long ctCollectionId, long modelClassNameId, int start, int end) { return findByC_MCNI(ctCollectionId, modelClassNameId, start, end, null); } /** * Returns an ordered range of all the ct entries where ctCollectionId = ? and modelClassNameId = ?. * *

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

* * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct entries */ @Override public List findByC_MCNI( long ctCollectionId, long modelClassNameId, int start, int end, OrderByComparator orderByComparator) { return findByC_MCNI( ctCollectionId, modelClassNameId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the ct entries where ctCollectionId = ? and modelClassNameId = ?. * *

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

* * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (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 ct entries */ @Override public List findByC_MCNI( long ctCollectionId, long modelClassNameId, 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 = _finderPathWithoutPaginationFindByC_MCNI; finderArgs = new Object[] {ctCollectionId, modelClassNameId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByC_MCNI; finderArgs = new Object[] { ctCollectionId, modelClassNameId, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (CTEntry ctEntry : list) { if ((ctCollectionId != ctEntry.getCtCollectionId()) || (modelClassNameId != ctEntry.getModelClassNameId())) { 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_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_C_MCNI_CTCOLLECTIONID_2); sb.append(_FINDER_COLUMN_C_MCNI_MODELCLASSNAMEID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(CTEntryModelImpl.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(ctCollectionId); queryPos.add(modelClassNameId); 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 ct entry in the ordered set where ctCollectionId = ? and modelClassNameId = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct entry * @throws NoSuchEntryException if a matching ct entry could not be found */ @Override public CTEntry findByC_MCNI_First( long ctCollectionId, long modelClassNameId, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = fetchByC_MCNI_First( ctCollectionId, modelClassNameId, orderByComparator); if (ctEntry != null) { return ctEntry; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("ctCollectionId="); sb.append(ctCollectionId); sb.append(", modelClassNameId="); sb.append(modelClassNameId); sb.append("}"); throw new NoSuchEntryException(sb.toString()); } /** * Returns the first ct entry in the ordered set where ctCollectionId = ? and modelClassNameId = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry fetchByC_MCNI_First( long ctCollectionId, long modelClassNameId, OrderByComparator orderByComparator) { List list = findByC_MCNI( ctCollectionId, modelClassNameId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last ct entry in the ordered set where ctCollectionId = ? and modelClassNameId = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct entry * @throws NoSuchEntryException if a matching ct entry could not be found */ @Override public CTEntry findByC_MCNI_Last( long ctCollectionId, long modelClassNameId, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = fetchByC_MCNI_Last( ctCollectionId, modelClassNameId, orderByComparator); if (ctEntry != null) { return ctEntry; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("ctCollectionId="); sb.append(ctCollectionId); sb.append(", modelClassNameId="); sb.append(modelClassNameId); sb.append("}"); throw new NoSuchEntryException(sb.toString()); } /** * Returns the last ct entry in the ordered set where ctCollectionId = ? and modelClassNameId = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry fetchByC_MCNI_Last( long ctCollectionId, long modelClassNameId, OrderByComparator orderByComparator) { int count = countByC_MCNI(ctCollectionId, modelClassNameId); if (count == 0) { return null; } List list = findByC_MCNI( ctCollectionId, modelClassNameId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the ct entries before and after the current ct entry in the ordered set where ctCollectionId = ? and modelClassNameId = ?. * * @param ctEntryId the primary key of the current ct entry * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next ct entry * @throws NoSuchEntryException if a ct entry with the primary key could not be found */ @Override public CTEntry[] findByC_MCNI_PrevAndNext( long ctEntryId, long ctCollectionId, long modelClassNameId, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = findByPrimaryKey(ctEntryId); Session session = null; try { session = openSession(); CTEntry[] array = new CTEntryImpl[3]; array[0] = getByC_MCNI_PrevAndNext( session, ctEntry, ctCollectionId, modelClassNameId, orderByComparator, true); array[1] = ctEntry; array[2] = getByC_MCNI_PrevAndNext( session, ctEntry, ctCollectionId, modelClassNameId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTEntry getByC_MCNI_PrevAndNext( Session session, CTEntry ctEntry, long ctCollectionId, long modelClassNameId, 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_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_C_MCNI_CTCOLLECTIONID_2); sb.append(_FINDER_COLUMN_C_MCNI_MODELCLASSNAMEID_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(CTEntryModelImpl.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(ctCollectionId); queryPos.add(modelClassNameId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(ctEntry)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the ct entries where ctCollectionId = ? and modelClassNameId = ? from the database. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID */ @Override public void removeByC_MCNI(long ctCollectionId, long modelClassNameId) { for (CTEntry ctEntry : findByC_MCNI( ctCollectionId, modelClassNameId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ctEntry); } } /** * Returns the number of ct entries where ctCollectionId = ? and modelClassNameId = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @return the number of matching ct entries */ @Override public int countByC_MCNI(long ctCollectionId, long modelClassNameId) { FinderPath finderPath = _finderPathCountByC_MCNI; Object[] finderArgs = new Object[] {ctCollectionId, modelClassNameId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_C_MCNI_CTCOLLECTIONID_2); sb.append(_FINDER_COLUMN_C_MCNI_MODELCLASSNAMEID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(ctCollectionId); queryPos.add(modelClassNameId); 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_MCNI_CTCOLLECTIONID_2 = "ctEntry.ctCollectionId = ? AND "; private static final String _FINDER_COLUMN_C_MCNI_MODELCLASSNAMEID_2 = "ctEntry.modelClassNameId = ?"; private FinderPath _finderPathFetchByC_MCNI_MCPK; private FinderPath _finderPathCountByC_MCNI_MCPK; /** * Returns the ct entry where ctCollectionId = ? and modelClassNameId = ? and modelClassPK = ? or throws a NoSuchEntryException if it could not be found. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @return the matching ct entry * @throws NoSuchEntryException if a matching ct entry could not be found */ @Override public CTEntry findByC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long modelClassPK) throws NoSuchEntryException { CTEntry ctEntry = fetchByC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPK); if (ctEntry == null) { StringBundler sb = new StringBundler(8); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("ctCollectionId="); sb.append(ctCollectionId); sb.append(", modelClassNameId="); sb.append(modelClassNameId); sb.append(", modelClassPK="); sb.append(modelClassPK); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchEntryException(sb.toString()); } return ctEntry; } /** * Returns the ct entry where ctCollectionId = ? and modelClassNameId = ? and modelClassPK = ? or returns null if it could not be found. Uses the finder cache. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @return the matching ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry fetchByC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long modelClassPK) { return fetchByC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPK, true); } /** * Returns the ct entry where ctCollectionId = ? and modelClassNameId = ? and modelClassPK = ? or returns null if it could not be found, optionally using the finder cache. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @param useFinderCache whether to use the finder cache * @return the matching ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry fetchByC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long modelClassPK, boolean useFinderCache) { Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] { ctCollectionId, modelClassNameId, modelClassPK }; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByC_MCNI_MCPK, finderArgs, this); } if (result instanceof CTEntry) { CTEntry ctEntry = (CTEntry)result; if ((ctCollectionId != ctEntry.getCtCollectionId()) || (modelClassNameId != ctEntry.getModelClassNameId()) || (modelClassPK != ctEntry.getModelClassPK())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(5); sb.append(_SQL_SELECT_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_C_MCNI_MCPK_CTCOLLECTIONID_2); sb.append(_FINDER_COLUMN_C_MCNI_MCPK_MODELCLASSNAMEID_2); sb.append(_FINDER_COLUMN_C_MCNI_MCPK_MODELCLASSPK_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(ctCollectionId); queryPos.add(modelClassNameId); queryPos.add(modelClassPK); List list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByC_MCNI_MCPK, finderArgs, list); } } else { CTEntry ctEntry = list.get(0); result = ctEntry; cacheResult(ctEntry); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (CTEntry)result; } } /** * Removes the ct entry where ctCollectionId = ? and modelClassNameId = ? and modelClassPK = ? from the database. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @return the ct entry that was removed */ @Override public CTEntry removeByC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long modelClassPK) throws NoSuchEntryException { CTEntry ctEntry = findByC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPK); return remove(ctEntry); } /** * Returns the number of ct entries where ctCollectionId = ? and modelClassNameId = ? and modelClassPK = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @return the number of matching ct entries */ @Override public int countByC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long modelClassPK) { FinderPath finderPath = _finderPathCountByC_MCNI_MCPK; Object[] finderArgs = new Object[] { ctCollectionId, modelClassNameId, modelClassPK }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_COUNT_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_C_MCNI_MCPK_CTCOLLECTIONID_2); sb.append(_FINDER_COLUMN_C_MCNI_MCPK_MODELCLASSNAMEID_2); sb.append(_FINDER_COLUMN_C_MCNI_MCPK_MODELCLASSPK_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(ctCollectionId); queryPos.add(modelClassNameId); queryPos.add(modelClassPK); 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_MCNI_MCPK_CTCOLLECTIONID_2 = "ctEntry.ctCollectionId = ? AND "; private static final String _FINDER_COLUMN_C_MCNI_MCPK_MODELCLASSNAMEID_2 = "ctEntry.modelClassNameId = ? AND "; private static final String _FINDER_COLUMN_C_MCNI_MCPK_MODELCLASSPK_2 = "ctEntry.modelClassPK = ?"; private FinderPath _finderPathWithPaginationFindByNotC_MCNI_MCPK; private FinderPath _finderPathWithPaginationCountByNotC_MCNI_MCPK; /** * Returns all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @return the matching ct entries */ @Override public List findByNotC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long modelClassPK) { return findByNotC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?. * *

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

* * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (not inclusive) * @return the range of matching ct entries */ @Override public List findByNotC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long modelClassPK, int start, int end) { return findByNotC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPK, start, end, null); } /** * Returns an ordered range of all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?. * *

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

* * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct entries */ @Override public List findByNotC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long modelClassPK, int start, int end, OrderByComparator orderByComparator) { return findByNotC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPK, start, end, orderByComparator, true); } /** * Returns an ordered range of all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?. * *

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

* * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (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 ct entries */ @Override public List findByNotC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long modelClassPK, int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; finderPath = _finderPathWithPaginationFindByNotC_MCNI_MCPK; finderArgs = new Object[] { ctCollectionId, modelClassNameId, modelClassPK, start, end, orderByComparator }; List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (CTEntry ctEntry : list) { if ((ctCollectionId == ctEntry.getCtCollectionId()) || (modelClassNameId != ctEntry.getModelClassNameId()) || (modelClassPK != ctEntry.getModelClassPK())) { 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_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_CTCOLLECTIONID_2); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSNAMEID_2); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(CTEntryModelImpl.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(ctCollectionId); queryPos.add(modelClassNameId); queryPos.add(modelClassPK); 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 ct entry in the ordered set where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct entry * @throws NoSuchEntryException if a matching ct entry could not be found */ @Override public CTEntry findByNotC_MCNI_MCPK_First( long ctCollectionId, long modelClassNameId, long modelClassPK, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = fetchByNotC_MCNI_MCPK_First( ctCollectionId, modelClassNameId, modelClassPK, orderByComparator); if (ctEntry != null) { return ctEntry; } StringBundler sb = new StringBundler(8); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("ctCollectionId!="); sb.append(ctCollectionId); sb.append(", modelClassNameId="); sb.append(modelClassNameId); sb.append(", modelClassPK="); sb.append(modelClassPK); sb.append("}"); throw new NoSuchEntryException(sb.toString()); } /** * Returns the first ct entry in the ordered set where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry fetchByNotC_MCNI_MCPK_First( long ctCollectionId, long modelClassNameId, long modelClassPK, OrderByComparator orderByComparator) { List list = findByNotC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPK, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last ct entry in the ordered set where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct entry * @throws NoSuchEntryException if a matching ct entry could not be found */ @Override public CTEntry findByNotC_MCNI_MCPK_Last( long ctCollectionId, long modelClassNameId, long modelClassPK, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = fetchByNotC_MCNI_MCPK_Last( ctCollectionId, modelClassNameId, modelClassPK, orderByComparator); if (ctEntry != null) { return ctEntry; } StringBundler sb = new StringBundler(8); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("ctCollectionId!="); sb.append(ctCollectionId); sb.append(", modelClassNameId="); sb.append(modelClassNameId); sb.append(", modelClassPK="); sb.append(modelClassPK); sb.append("}"); throw new NoSuchEntryException(sb.toString()); } /** * Returns the last ct entry in the ordered set where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry fetchByNotC_MCNI_MCPK_Last( long ctCollectionId, long modelClassNameId, long modelClassPK, OrderByComparator orderByComparator) { int count = countByNotC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPK); if (count == 0) { return null; } List list = findByNotC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPK, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the ct entries before and after the current ct entry in the ordered set where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?. * * @param ctEntryId the primary key of the current ct entry * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next ct entry * @throws NoSuchEntryException if a ct entry with the primary key could not be found */ @Override public CTEntry[] findByNotC_MCNI_MCPK_PrevAndNext( long ctEntryId, long ctCollectionId, long modelClassNameId, long modelClassPK, OrderByComparator orderByComparator) throws NoSuchEntryException { CTEntry ctEntry = findByPrimaryKey(ctEntryId); Session session = null; try { session = openSession(); CTEntry[] array = new CTEntryImpl[3]; array[0] = getByNotC_MCNI_MCPK_PrevAndNext( session, ctEntry, ctCollectionId, modelClassNameId, modelClassPK, orderByComparator, true); array[1] = ctEntry; array[2] = getByNotC_MCNI_MCPK_PrevAndNext( session, ctEntry, ctCollectionId, modelClassNameId, modelClassPK, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTEntry getByNotC_MCNI_MCPK_PrevAndNext( Session session, CTEntry ctEntry, long ctCollectionId, long modelClassNameId, long modelClassPK, 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_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_CTCOLLECTIONID_2); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSNAMEID_2); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_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(CTEntryModelImpl.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(ctCollectionId); queryPos.add(modelClassNameId); queryPos.add(modelClassPK); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(ctEntry)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = any ?. * *

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

* * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPKs the model class pks * @return the matching ct entries */ @Override public List findByNotC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long[] modelClassPKs) { return findByNotC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPKs, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = any ?. * *

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

* * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPKs the model class pks * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (not inclusive) * @return the range of matching ct entries */ @Override public List findByNotC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long[] modelClassPKs, int start, int end) { return findByNotC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPKs, start, end, null); } /** * Returns an ordered range of all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = any ?. * *

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

* * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPKs the model class pks * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct entries */ @Override public List findByNotC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long[] modelClassPKs, int start, int end, OrderByComparator orderByComparator) { return findByNotC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPKs, start, end, orderByComparator, true); } /** * Returns an ordered range of all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?, optionally using the finder cache. * *

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

* * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPKs the model class pks * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (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 ct entries */ @Override public List findByNotC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long[] modelClassPKs, int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { if (modelClassPKs == null) { modelClassPKs = new long[0]; } else if (modelClassPKs.length > 1) { modelClassPKs = ArrayUtil.sortedUnique(modelClassPKs); } if (modelClassPKs.length == 1) { return findByNotC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPKs[0], start, end, orderByComparator); } Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderArgs = new Object[] { ctCollectionId, modelClassNameId, StringUtil.merge(modelClassPKs) }; } } else if (useFinderCache) { finderArgs = new Object[] { ctCollectionId, modelClassNameId, StringUtil.merge(modelClassPKs), start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( _finderPathWithPaginationFindByNotC_MCNI_MCPK, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (CTEntry ctEntry : list) { if ((ctCollectionId == ctEntry.getCtCollectionId()) || (modelClassNameId != ctEntry.getModelClassNameId()) || !ArrayUtil.contains( modelClassPKs, ctEntry.getModelClassPK())) { list = null; break; } } } } if (list == null) { StringBundler sb = new StringBundler(); sb.append(_SQL_SELECT_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_CTCOLLECTIONID_2); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSNAMEID_2); if (modelClassPKs.length > 0) { sb.append("("); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_7); sb.append(StringUtil.merge(modelClassPKs)); sb.append(")"); sb.append(")"); } sb.setStringAt( removeConjunction(sb.stringAt(sb.index() - 1)), sb.index() - 1); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(CTEntryModelImpl.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(ctCollectionId); queryPos.add(modelClassNameId); list = (List)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult( _finderPathWithPaginationFindByNotC_MCNI_MCPK, finderArgs, list); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return list; } /** * Removes all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ? from the database. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk */ @Override public void removeByNotC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long modelClassPK) { for (CTEntry ctEntry : findByNotC_MCNI_MCPK( ctCollectionId, modelClassNameId, modelClassPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ctEntry); } } /** * Returns the number of ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPK the model class pk * @return the number of matching ct entries */ @Override public int countByNotC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long modelClassPK) { FinderPath finderPath = _finderPathWithPaginationCountByNotC_MCNI_MCPK; Object[] finderArgs = new Object[] { ctCollectionId, modelClassNameId, modelClassPK }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_COUNT_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_CTCOLLECTIONID_2); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSNAMEID_2); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(ctCollectionId); queryPos.add(modelClassNameId); queryPos.add(modelClassPK); 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 ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = any ?. * * @param ctCollectionId the ct collection ID * @param modelClassNameId the model class name ID * @param modelClassPKs the model class pks * @return the number of matching ct entries */ @Override public int countByNotC_MCNI_MCPK( long ctCollectionId, long modelClassNameId, long[] modelClassPKs) { if (modelClassPKs == null) { modelClassPKs = new long[0]; } else if (modelClassPKs.length > 1) { modelClassPKs = ArrayUtil.sortedUnique(modelClassPKs); } Object[] finderArgs = new Object[] { ctCollectionId, modelClassNameId, StringUtil.merge(modelClassPKs) }; Long count = (Long)finderCache.getResult( _finderPathWithPaginationCountByNotC_MCNI_MCPK, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(); sb.append(_SQL_COUNT_CTENTRY_WHERE); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_CTCOLLECTIONID_2); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSNAMEID_2); if (modelClassPKs.length > 0) { sb.append("("); sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_7); sb.append(StringUtil.merge(modelClassPKs)); sb.append(")"); sb.append(")"); } sb.setStringAt( removeConjunction(sb.stringAt(sb.index() - 1)), sb.index() - 1); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(ctCollectionId); queryPos.add(modelClassNameId); count = (Long)query.uniqueResult(); finderCache.putResult( _finderPathWithPaginationCountByNotC_MCNI_MCPK, finderArgs, count); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_NOTC_MCNI_MCPK_CTCOLLECTIONID_2 = "ctEntry.ctCollectionId != ? AND "; private static final String _FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSNAMEID_2 = "ctEntry.modelClassNameId = ? AND "; private static final String _FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_2 = "ctEntry.modelClassPK = ?"; private static final String _FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_7 = "ctEntry.modelClassPK IN ("; private FinderPath _finderPathFetchByERC_C; private FinderPath _finderPathCountByERC_C; /** * Returns the ct entry where externalReferenceCode = ? and companyId = ? or throws a NoSuchEntryException if it could not be found. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the matching ct entry * @throws NoSuchEntryException if a matching ct entry could not be found */ @Override public CTEntry findByERC_C(String externalReferenceCode, long companyId) throws NoSuchEntryException { CTEntry ctEntry = fetchByERC_C(externalReferenceCode, companyId); if (ctEntry == null) { StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("externalReferenceCode="); sb.append(externalReferenceCode); sb.append(", companyId="); sb.append(companyId); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchEntryException(sb.toString()); } return ctEntry; } /** * Returns the ct entry where externalReferenceCode = ? and companyId = ? or returns null if it could not be found. Uses the finder cache. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the matching ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry fetchByERC_C(String externalReferenceCode, long companyId) { return fetchByERC_C(externalReferenceCode, companyId, true); } /** * Returns the ct entry where externalReferenceCode = ? and companyId = ? or returns null if it could not be found, optionally using the finder cache. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @param useFinderCache whether to use the finder cache * @return the matching ct entry, or null if a matching ct entry could not be found */ @Override public CTEntry fetchByERC_C( String externalReferenceCode, long companyId, boolean useFinderCache) { externalReferenceCode = Objects.toString(externalReferenceCode, ""); Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] {externalReferenceCode, companyId}; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByERC_C, finderArgs, this); } if (result instanceof CTEntry) { CTEntry ctEntry = (CTEntry)result; if (!Objects.equals( externalReferenceCode, ctEntry.getExternalReferenceCode()) || (companyId != ctEntry.getCompanyId())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_SELECT_CTENTRY_WHERE); boolean bindExternalReferenceCode = false; if (externalReferenceCode.isEmpty()) { sb.append(_FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_3); } else { bindExternalReferenceCode = true; sb.append(_FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_2); } sb.append(_FINDER_COLUMN_ERC_C_COMPANYID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindExternalReferenceCode) { queryPos.add(externalReferenceCode); } queryPos.add(companyId); List list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByERC_C, finderArgs, list); } } else { CTEntry ctEntry = list.get(0); result = ctEntry; cacheResult(ctEntry); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (CTEntry)result; } } /** * Removes the ct entry where externalReferenceCode = ? and companyId = ? from the database. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the ct entry that was removed */ @Override public CTEntry removeByERC_C(String externalReferenceCode, long companyId) throws NoSuchEntryException { CTEntry ctEntry = findByERC_C(externalReferenceCode, companyId); return remove(ctEntry); } /** * Returns the number of ct entries where externalReferenceCode = ? and companyId = ?. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the number of matching ct entries */ @Override public int countByERC_C(String externalReferenceCode, long companyId) { externalReferenceCode = Objects.toString(externalReferenceCode, ""); FinderPath finderPath = _finderPathCountByERC_C; Object[] finderArgs = new Object[] {externalReferenceCode, companyId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_CTENTRY_WHERE); boolean bindExternalReferenceCode = false; if (externalReferenceCode.isEmpty()) { sb.append(_FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_3); } else { bindExternalReferenceCode = true; sb.append(_FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_2); } sb.append(_FINDER_COLUMN_ERC_C_COMPANYID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindExternalReferenceCode) { queryPos.add(externalReferenceCode); } 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_ERC_C_EXTERNALREFERENCECODE_2 = "ctEntry.externalReferenceCode = ? AND "; private static final String _FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_3 = "(ctEntry.externalReferenceCode IS NULL OR ctEntry.externalReferenceCode = '') AND "; private static final String _FINDER_COLUMN_ERC_C_COMPANYID_2 = "ctEntry.companyId = ?"; public CTEntryPersistenceImpl() { Map dbColumnNames = new HashMap(); dbColumnNames.put("uuid", "uuid_"); setDBColumnNames(dbColumnNames); setModelClass(CTEntry.class); setModelImplClass(CTEntryImpl.class); setModelPKClass(long.class); setTable(CTEntryTable.INSTANCE); } /** * Caches the ct entry in the entity cache if it is enabled. * * @param ctEntry the ct entry */ @Override public void cacheResult(CTEntry ctEntry) { entityCache.putResult( CTEntryImpl.class, ctEntry.getPrimaryKey(), ctEntry); finderCache.putResult( _finderPathFetchByC_MCNI_MCPK, new Object[] { ctEntry.getCtCollectionId(), ctEntry.getModelClassNameId(), ctEntry.getModelClassPK() }, ctEntry); finderCache.putResult( _finderPathFetchByERC_C, new Object[] { ctEntry.getExternalReferenceCode(), ctEntry.getCompanyId() }, ctEntry); } private int _valueObjectFinderCacheListThreshold; /** * Caches the ct entries in the entity cache if it is enabled. * * @param ctEntries the ct entries */ @Override public void cacheResult(List ctEntries) { if ((_valueObjectFinderCacheListThreshold == 0) || ((_valueObjectFinderCacheListThreshold > 0) && (ctEntries.size() > _valueObjectFinderCacheListThreshold))) { return; } for (CTEntry ctEntry : ctEntries) { if (entityCache.getResult( CTEntryImpl.class, ctEntry.getPrimaryKey()) == null) { cacheResult(ctEntry); } } } /** * Clears the cache for all ct entries. * *

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

*/ @Override public void clearCache() { entityCache.clearCache(CTEntryImpl.class); finderCache.clearCache(CTEntryImpl.class); } /** * Clears the cache for the ct entry. * *

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

*/ @Override public void clearCache(CTEntry ctEntry) { entityCache.removeResult(CTEntryImpl.class, ctEntry); } @Override public void clearCache(List ctEntries) { for (CTEntry ctEntry : ctEntries) { entityCache.removeResult(CTEntryImpl.class, ctEntry); } } @Override public void clearCache(Set primaryKeys) { finderCache.clearCache(CTEntryImpl.class); for (Serializable primaryKey : primaryKeys) { entityCache.removeResult(CTEntryImpl.class, primaryKey); } } protected void cacheUniqueFindersCache(CTEntryModelImpl ctEntryModelImpl) { Object[] args = new Object[] { ctEntryModelImpl.getCtCollectionId(), ctEntryModelImpl.getModelClassNameId(), ctEntryModelImpl.getModelClassPK() }; finderCache.putResult( _finderPathCountByC_MCNI_MCPK, args, Long.valueOf(1)); finderCache.putResult( _finderPathFetchByC_MCNI_MCPK, args, ctEntryModelImpl); args = new Object[] { ctEntryModelImpl.getExternalReferenceCode(), ctEntryModelImpl.getCompanyId() }; finderCache.putResult(_finderPathCountByERC_C, args, Long.valueOf(1)); finderCache.putResult(_finderPathFetchByERC_C, args, ctEntryModelImpl); } /** * Creates a new ct entry with the primary key. Does not add the ct entry to the database. * * @param ctEntryId the primary key for the new ct entry * @return the new ct entry */ @Override public CTEntry create(long ctEntryId) { CTEntry ctEntry = new CTEntryImpl(); ctEntry.setNew(true); ctEntry.setPrimaryKey(ctEntryId); String uuid = PortalUUIDUtil.generate(); ctEntry.setUuid(uuid); ctEntry.setCompanyId(CompanyThreadLocal.getCompanyId()); return ctEntry; } /** * Removes the ct entry with the primary key from the database. Also notifies the appropriate model listeners. * * @param ctEntryId the primary key of the ct entry * @return the ct entry that was removed * @throws NoSuchEntryException if a ct entry with the primary key could not be found */ @Override public CTEntry remove(long ctEntryId) throws NoSuchEntryException { return remove((Serializable)ctEntryId); } /** * Removes the ct entry with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the ct entry * @return the ct entry that was removed * @throws NoSuchEntryException if a ct entry with the primary key could not be found */ @Override public CTEntry remove(Serializable primaryKey) throws NoSuchEntryException { Session session = null; try { session = openSession(); CTEntry ctEntry = (CTEntry)session.get( CTEntryImpl.class, primaryKey); if (ctEntry == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchEntryException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(ctEntry); } catch (NoSuchEntryException noSuchEntityException) { throw noSuchEntityException; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } @Override protected CTEntry removeImpl(CTEntry ctEntry) { Session session = null; try { session = openSession(); if (!session.contains(ctEntry)) { ctEntry = (CTEntry)session.get( CTEntryImpl.class, ctEntry.getPrimaryKeyObj()); } if (ctEntry != null) { session.delete(ctEntry); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } if (ctEntry != null) { clearCache(ctEntry); } return ctEntry; } @Override public CTEntry updateImpl(CTEntry ctEntry) { boolean isNew = ctEntry.isNew(); if (!(ctEntry instanceof CTEntryModelImpl)) { InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(ctEntry.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler(ctEntry); throw new IllegalArgumentException( "Implement ModelWrapper in ctEntry proxy " + invocationHandler.getClass()); } throw new IllegalArgumentException( "Implement ModelWrapper in custom CTEntry implementation " + ctEntry.getClass()); } CTEntryModelImpl ctEntryModelImpl = (CTEntryModelImpl)ctEntry; if (Validator.isNull(ctEntry.getUuid())) { String uuid = PortalUUIDUtil.generate(); ctEntry.setUuid(uuid); } if (Validator.isNull(ctEntry.getExternalReferenceCode())) { ctEntry.setExternalReferenceCode(ctEntry.getUuid()); } else { CTEntry ercCTEntry = fetchByERC_C( ctEntry.getExternalReferenceCode(), ctEntry.getCompanyId()); if (isNew) { if (ercCTEntry != null) { throw new DuplicateCTEntryExternalReferenceCodeException( "Duplicate ct entry with external reference code " + ctEntry.getExternalReferenceCode() + " and company " + ctEntry.getCompanyId()); } } else { if ((ercCTEntry != null) && (ctEntry.getCtEntryId() != ercCTEntry.getCtEntryId())) { throw new DuplicateCTEntryExternalReferenceCodeException( "Duplicate ct entry with external reference code " + ctEntry.getExternalReferenceCode() + " and company " + ctEntry.getCompanyId()); } } } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date date = new Date(); if (isNew && (ctEntry.getCreateDate() == null)) { if (serviceContext == null) { ctEntry.setCreateDate(date); } else { ctEntry.setCreateDate(serviceContext.getCreateDate(date)); } } if (!ctEntryModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { ctEntry.setModifiedDate(date); } else { ctEntry.setModifiedDate(serviceContext.getModifiedDate(date)); } } Session session = null; try { session = openSession(); if (isNew) { session.save(ctEntry); } else { ctEntry = (CTEntry)session.merge(ctEntry); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } entityCache.putResult(CTEntryImpl.class, ctEntryModelImpl, false, true); cacheUniqueFindersCache(ctEntryModelImpl); if (isNew) { ctEntry.setNew(false); } ctEntry.resetOriginalValues(); return ctEntry; } /** * Returns the ct entry 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 ct entry * @return the ct entry * @throws NoSuchEntryException if a ct entry with the primary key could not be found */ @Override public CTEntry findByPrimaryKey(Serializable primaryKey) throws NoSuchEntryException { CTEntry ctEntry = fetchByPrimaryKey(primaryKey); if (ctEntry == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchEntryException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return ctEntry; } /** * Returns the ct entry with the primary key or throws a NoSuchEntryException if it could not be found. * * @param ctEntryId the primary key of the ct entry * @return the ct entry * @throws NoSuchEntryException if a ct entry with the primary key could not be found */ @Override public CTEntry findByPrimaryKey(long ctEntryId) throws NoSuchEntryException { return findByPrimaryKey((Serializable)ctEntryId); } /** * Returns the ct entry with the primary key or returns null if it could not be found. * * @param ctEntryId the primary key of the ct entry * @return the ct entry, or null if a ct entry with the primary key could not be found */ @Override public CTEntry fetchByPrimaryKey(long ctEntryId) { return fetchByPrimaryKey((Serializable)ctEntryId); } /** * Returns all the ct entries. * * @return the ct entries */ @Override public List findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct entries. * *

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

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

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

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

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

* * @param start the lower bound of the range of ct entries * @param end the upper bound of the range of ct entries (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 ct entries */ @Override public List findAll( 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 = _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_CTENTRY); appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = sb.toString(); } else { sql = _SQL_SELECT_CTENTRY; sql = sql.concat(CTEntryModelImpl.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 ct entries from the database. * */ @Override public void removeAll() { for (CTEntry ctEntry : findAll()) { remove(ctEntry); } } /** * Returns the number of ct entries. * * @return the number of ct entries */ @Override public int countAll() { 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_CTENTRY); 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 "ctEntryId"; } @Override protected String getSelectSQL() { return _SQL_SELECT_CTENTRY; } @Override protected Map getTableColumnsMap() { return CTEntryModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the ct entry 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); _finderPathWithPaginationFindByUuid = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"uuid_"}, true); _finderPathWithoutPaginationFindByUuid = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid", new String[] {String.class.getName()}, new String[] {"uuid_"}, true); _finderPathCountByUuid = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid", new String[] {String.class.getName()}, new String[] {"uuid_"}, false); _finderPathWithPaginationFindByUuid_C = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"uuid_", "companyId"}, true); _finderPathWithoutPaginationFindByUuid_C = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C", new String[] {String.class.getName(), Long.class.getName()}, new String[] {"uuid_", "companyId"}, true); _finderPathCountByUuid_C = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C", new String[] {String.class.getName(), Long.class.getName()}, new String[] {"uuid_", "companyId"}, false); _finderPathWithPaginationFindByCtCollectionId = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCtCollectionId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"ctCollectionId"}, true); _finderPathWithoutPaginationFindByCtCollectionId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCtCollectionId", new String[] {Long.class.getName()}, new String[] {"ctCollectionId"}, true); _finderPathCountByCtCollectionId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCtCollectionId", new String[] {Long.class.getName()}, new String[] {"ctCollectionId"}, false); _finderPathWithPaginationFindByC_MCNI = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_MCNI", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"ctCollectionId", "modelClassNameId"}, true); _finderPathWithoutPaginationFindByC_MCNI = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_MCNI", new String[] {Long.class.getName(), Long.class.getName()}, new String[] {"ctCollectionId", "modelClassNameId"}, true); _finderPathCountByC_MCNI = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_MCNI", new String[] {Long.class.getName(), Long.class.getName()}, new String[] {"ctCollectionId", "modelClassNameId"}, false); _finderPathFetchByC_MCNI_MCPK = new FinderPath( FINDER_CLASS_NAME_ENTITY, "fetchByC_MCNI_MCPK", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }, new String[] {"ctCollectionId", "modelClassNameId", "modelClassPK"}, true); _finderPathCountByC_MCNI_MCPK = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_MCNI_MCPK", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }, new String[] {"ctCollectionId", "modelClassNameId", "modelClassPK"}, false); _finderPathWithPaginationFindByNotC_MCNI_MCPK = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByNotC_MCNI_MCPK", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"ctCollectionId", "modelClassNameId", "modelClassPK"}, true); _finderPathWithPaginationCountByNotC_MCNI_MCPK = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByNotC_MCNI_MCPK", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }, new String[] {"ctCollectionId", "modelClassNameId", "modelClassPK"}, false); _finderPathFetchByERC_C = new FinderPath( FINDER_CLASS_NAME_ENTITY, "fetchByERC_C", new String[] {String.class.getName(), Long.class.getName()}, new String[] {"externalReferenceCode", "companyId"}, true); _finderPathCountByERC_C = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByERC_C", new String[] {String.class.getName(), Long.class.getName()}, new String[] {"externalReferenceCode", "companyId"}, false); CTEntryUtil.setPersistence(this); } @Deactivate public void deactivate() { CTEntryUtil.setPersistence(null); entityCache.removeCache(CTEntryImpl.class.getName()); } @Override @Reference( target = CTPersistenceConstants.SERVICE_CONFIGURATION_FILTER, unbind = "-" ) public void setConfiguration(Configuration configuration) { } @Override @Reference( target = CTPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setDataSource(DataSource dataSource) { super.setDataSource(dataSource); } @Override @Reference( target = CTPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setSessionFactory(SessionFactory sessionFactory) { super.setSessionFactory(sessionFactory); } @Reference protected EntityCache entityCache; @Reference protected FinderCache finderCache; private static final String _SQL_SELECT_CTENTRY = "SELECT ctEntry FROM CTEntry ctEntry"; private static final String _SQL_SELECT_CTENTRY_WHERE = "SELECT ctEntry FROM CTEntry ctEntry WHERE "; private static final String _SQL_COUNT_CTENTRY = "SELECT COUNT(ctEntry) FROM CTEntry ctEntry"; private static final String _SQL_COUNT_CTENTRY_WHERE = "SELECT COUNT(ctEntry) FROM CTEntry ctEntry WHERE "; private static final String _ORDER_BY_ENTITY_ALIAS = "ctEntry."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No CTEntry exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No CTEntry exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( CTEntryPersistenceImpl.class); private static final Set _badColumnNames = SetUtil.fromArray( new String[] {"uuid"}); @Override protected FinderCache getFinderCache() { return finderCache; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy