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

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

There is a newer version: 3.0.107
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.DuplicateCTCollectionExternalReferenceCodeException;
import com.liferay.change.tracking.exception.NoSuchCollectionException;
import com.liferay.change.tracking.model.CTCollection;
import com.liferay.change.tracking.model.CTCollectionTable;
import com.liferay.change.tracking.model.impl.CTCollectionImpl;
import com.liferay.change.tracking.model.impl.CTCollectionModelImpl;
import com.liferay.change.tracking.service.persistence.CTCollectionPersistence;
import com.liferay.change.tracking.service.persistence.CTCollectionUtil;
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.SQLQuery;
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.security.permission.InlineSQLHelperUtil;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.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 collection service.
 *
 * 

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

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

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

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

* * @param uuid the uuid * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (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 collections */ @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 (CTCollection ctCollection : list) { if (!uuid.equals(ctCollection.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_CTCOLLECTION_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(CTCollectionModelImpl.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 collection 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 collection * @throws NoSuchCollectionException if a matching ct collection could not be found */ @Override public CTCollection findByUuid_First( String uuid, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = fetchByUuid_First(uuid, orderByComparator); if (ctCollection != null) { return ctCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append("}"); throw new NoSuchCollectionException(sb.toString()); } /** * Returns the first ct collection 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 collection, or null if a matching ct collection could not be found */ @Override public CTCollection 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 collection 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 collection * @throws NoSuchCollectionException if a matching ct collection could not be found */ @Override public CTCollection findByUuid_Last( String uuid, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = fetchByUuid_Last(uuid, orderByComparator); if (ctCollection != null) { return ctCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append("}"); throw new NoSuchCollectionException(sb.toString()); } /** * Returns the last ct collection 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 collection, or null if a matching ct collection could not be found */ @Override public CTCollection 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 collections before and after the current ct collection in the ordered set where uuid = ?. * * @param ctCollectionId the primary key of the current ct collection * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next ct collection * @throws NoSuchCollectionException if a ct collection with the primary key could not be found */ @Override public CTCollection[] findByUuid_PrevAndNext( long ctCollectionId, String uuid, OrderByComparator orderByComparator) throws NoSuchCollectionException { uuid = Objects.toString(uuid, ""); CTCollection ctCollection = findByPrimaryKey(ctCollectionId); Session session = null; try { session = openSession(); CTCollection[] array = new CTCollectionImpl[3]; array[0] = getByUuid_PrevAndNext( session, ctCollection, uuid, orderByComparator, true); array[1] = ctCollection; array[2] = getByUuid_PrevAndNext( session, ctCollection, uuid, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTCollection getByUuid_PrevAndNext( Session session, CTCollection ctCollection, 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_CTCOLLECTION_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(CTCollectionModelImpl.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(ctCollection)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the ct collections that the user has permission to view where uuid = ?. * * @param uuid the uuid * @return the matching ct collections that the user has permission to view */ @Override public List filterFindByUuid(String uuid) { return filterFindByUuid( uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct collections that the user has permission to view 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 CTCollectionModelImpl. *

* * @param uuid the uuid * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @return the range of matching ct collections that the user has permission to view */ @Override public List filterFindByUuid( String uuid, int start, int end) { return filterFindByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the ct collections that the user has permissions to view 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 CTCollectionModelImpl. *

* * @param uuid the uuid * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct collections that the user has permission to view */ @Override public List filterFindByUuid( String uuid, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled()) { return findByUuid(uuid, start, end, orderByComparator); } uuid = Objects.toString(uuid, ""); StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_CTCOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3_SQL); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2_SQL); } if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(CTCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(CTCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, CTCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, CTCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindUuid) { queryPos.add(uuid); } return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the ct collections before and after the current ct collection in the ordered set of ct collections that the user has permission to view where uuid = ?. * * @param ctCollectionId the primary key of the current ct collection * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next ct collection * @throws NoSuchCollectionException if a ct collection with the primary key could not be found */ @Override public CTCollection[] filterFindByUuid_PrevAndNext( long ctCollectionId, String uuid, OrderByComparator orderByComparator) throws NoSuchCollectionException { if (!InlineSQLHelperUtil.isEnabled()) { return findByUuid_PrevAndNext( ctCollectionId, uuid, orderByComparator); } uuid = Objects.toString(uuid, ""); CTCollection ctCollection = findByPrimaryKey(ctCollectionId); Session session = null; try { session = openSession(); CTCollection[] array = new CTCollectionImpl[3]; array[0] = filterGetByUuid_PrevAndNext( session, ctCollection, uuid, orderByComparator, true); array[1] = ctCollection; array[2] = filterGetByUuid_PrevAndNext( session, ctCollection, uuid, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTCollection filterGetByUuid_PrevAndNext( Session session, CTCollection ctCollection, String uuid, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_CTCOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3_SQL); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2_SQL); } if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(CTCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(CTCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, CTCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, CTCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindUuid) { queryPos.add(uuid); } if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(ctCollection)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the ct collections where uuid = ? from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (CTCollection ctCollection : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ctCollection); } } /** * Returns the number of ct collections where uuid = ?. * * @param uuid the uuid * @return the number of matching ct collections */ @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_CTCOLLECTION_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(); } /** * Returns the number of ct collections that the user has permission to view where uuid = ?. * * @param uuid the uuid * @return the number of matching ct collections that the user has permission to view */ @Override public int filterCountByUuid(String uuid) { if (!InlineSQLHelperUtil.isEnabled()) { return countByUuid(uuid); } uuid = Objects.toString(uuid, ""); StringBundler sb = new StringBundler(2); sb.append(_FILTER_SQL_COUNT_CTCOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3_SQL); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2_SQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindUuid) { queryPos.add(uuid); } Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_UUID_UUID_2 = "ctCollection.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(ctCollection.uuid IS NULL OR ctCollection.uuid = '')"; private static final String _FINDER_COLUMN_UUID_UUID_2_SQL = "ctCollection.uuid_ = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3_SQL = "(ctCollection.uuid_ IS NULL OR ctCollection.uuid_ = '')"; private FinderPath _finderPathWithPaginationFindByUuid_C; private FinderPath _finderPathWithoutPaginationFindByUuid_C; private FinderPath _finderPathCountByUuid_C; /** * Returns all the ct collections where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching ct collections */ @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 collections 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 CTCollectionModelImpl. *

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

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

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (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 collections */ @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 (CTCollection ctCollection : list) { if (!uuid.equals(ctCollection.getUuid()) || (companyId != ctCollection.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_CTCOLLECTION_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(CTCollectionModelImpl.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 collection 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 collection * @throws NoSuchCollectionException if a matching ct collection could not be found */ @Override public CTCollection findByUuid_C_First( String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = fetchByUuid_C_First( uuid, companyId, orderByComparator); if (ctCollection != null) { return ctCollection; } 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 NoSuchCollectionException(sb.toString()); } /** * Returns the first ct collection 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 collection, or null if a matching ct collection could not be found */ @Override public CTCollection 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 collection 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 collection * @throws NoSuchCollectionException if a matching ct collection could not be found */ @Override public CTCollection findByUuid_C_Last( String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = fetchByUuid_C_Last( uuid, companyId, orderByComparator); if (ctCollection != null) { return ctCollection; } 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 NoSuchCollectionException(sb.toString()); } /** * Returns the last ct collection 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 collection, or null if a matching ct collection could not be found */ @Override public CTCollection 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 collections before and after the current ct collection in the ordered set where uuid = ? and companyId = ?. * * @param ctCollectionId the primary key of the current ct collection * @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 collection * @throws NoSuchCollectionException if a ct collection with the primary key could not be found */ @Override public CTCollection[] findByUuid_C_PrevAndNext( long ctCollectionId, String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchCollectionException { uuid = Objects.toString(uuid, ""); CTCollection ctCollection = findByPrimaryKey(ctCollectionId); Session session = null; try { session = openSession(); CTCollection[] array = new CTCollectionImpl[3]; array[0] = getByUuid_C_PrevAndNext( session, ctCollection, uuid, companyId, orderByComparator, true); array[1] = ctCollection; array[2] = getByUuid_C_PrevAndNext( session, ctCollection, uuid, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTCollection getByUuid_C_PrevAndNext( Session session, CTCollection ctCollection, 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_CTCOLLECTION_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(CTCollectionModelImpl.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(ctCollection)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the ct collections that the user has permission to view where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching ct collections that the user has permission to view */ @Override public List filterFindByUuid_C(String uuid, long companyId) { return filterFindByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct collections that the user has permission to view 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 CTCollectionModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @return the range of matching ct collections that the user has permission to view */ @Override public List filterFindByUuid_C( String uuid, long companyId, int start, int end) { return filterFindByUuid_C(uuid, companyId, start, end, null); } /** * Returns an ordered range of all the ct collections that the user has permissions to view 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 CTCollectionModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct collections that the user has permission to view */ @Override public List filterFindByUuid_C( String uuid, long companyId, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByUuid_C(uuid, companyId, start, end, orderByComparator); } uuid = Objects.toString(uuid, ""); StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_CTCOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(CTCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(CTCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, CTCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, CTCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the ct collections before and after the current ct collection in the ordered set of ct collections that the user has permission to view where uuid = ? and companyId = ?. * * @param ctCollectionId the primary key of the current ct collection * @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 collection * @throws NoSuchCollectionException if a ct collection with the primary key could not be found */ @Override public CTCollection[] filterFindByUuid_C_PrevAndNext( long ctCollectionId, String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchCollectionException { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByUuid_C_PrevAndNext( ctCollectionId, uuid, companyId, orderByComparator); } uuid = Objects.toString(uuid, ""); CTCollection ctCollection = findByPrimaryKey(ctCollectionId); Session session = null; try { session = openSession(); CTCollection[] array = new CTCollectionImpl[3]; array[0] = filterGetByUuid_C_PrevAndNext( session, ctCollection, uuid, companyId, orderByComparator, true); array[1] = ctCollection; array[2] = filterGetByUuid_C_PrevAndNext( session, ctCollection, uuid, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTCollection filterGetByUuid_C_PrevAndNext( Session session, CTCollection ctCollection, String uuid, long companyId, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_CTCOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(CTCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(CTCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, CTCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, CTCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(ctCollection)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the ct collections 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 (CTCollection ctCollection : findByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ctCollection); } } /** * Returns the number of ct collections where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching ct collections */ @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_CTCOLLECTION_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(); } /** * Returns the number of ct collections that the user has permission to view where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching ct collections that the user has permission to view */ @Override public int filterCountByUuid_C(String uuid, long companyId) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return countByUuid_C(uuid, companyId); } uuid = Objects.toString(uuid, ""); StringBundler sb = new StringBundler(3); sb.append(_FILTER_SQL_COUNT_CTCOLLECTION_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "ctCollection.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(ctCollection.uuid IS NULL OR ctCollection.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL = "ctCollection.uuid_ = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL = "(ctCollection.uuid_ IS NULL OR ctCollection.uuid_ = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "ctCollection.companyId = ?"; private FinderPath _finderPathWithPaginationFindByCompanyId; private FinderPath _finderPathWithoutPaginationFindByCompanyId; private FinderPath _finderPathCountByCompanyId; /** * Returns all the ct collections where companyId = ?. * * @param companyId the company ID * @return the matching ct collections */ @Override public List findByCompanyId(long companyId) { return findByCompanyId( companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct collections where 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 CTCollectionModelImpl. *

* * @param companyId the company ID * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @return the range of matching ct collections */ @Override public List findByCompanyId( long companyId, int start, int end) { return findByCompanyId(companyId, start, end, null); } /** * Returns an ordered range of all the ct collections where 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 CTCollectionModelImpl. *

* * @param companyId the company ID * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct collections */ @Override public List findByCompanyId( long companyId, int start, int end, OrderByComparator orderByComparator) { return findByCompanyId(companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the ct collections where 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 CTCollectionModelImpl. *

* * @param companyId the company ID * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (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 collections */ @Override public List findByCompanyId( long companyId, 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 = _finderPathWithoutPaginationFindByCompanyId; finderArgs = new Object[] {companyId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByCompanyId; finderArgs = new Object[] { companyId, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (CTCollection ctCollection : list) { if (companyId != ctCollection.getCompanyId()) { 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_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(CTCollectionModelImpl.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(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 collection in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct collection * @throws NoSuchCollectionException if a matching ct collection could not be found */ @Override public CTCollection findByCompanyId_First( long companyId, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = fetchByCompanyId_First( companyId, orderByComparator); if (ctCollection != null) { return ctCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("companyId="); sb.append(companyId); sb.append("}"); throw new NoSuchCollectionException(sb.toString()); } /** * Returns the first ct collection in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct collection, or null if a matching ct collection could not be found */ @Override public CTCollection fetchByCompanyId_First( long companyId, OrderByComparator orderByComparator) { List list = findByCompanyId( companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last ct collection in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct collection * @throws NoSuchCollectionException if a matching ct collection could not be found */ @Override public CTCollection findByCompanyId_Last( long companyId, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = fetchByCompanyId_Last( companyId, orderByComparator); if (ctCollection != null) { return ctCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("companyId="); sb.append(companyId); sb.append("}"); throw new NoSuchCollectionException(sb.toString()); } /** * Returns the last ct collection in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct collection, or null if a matching ct collection could not be found */ @Override public CTCollection fetchByCompanyId_Last( long companyId, OrderByComparator orderByComparator) { int count = countByCompanyId(companyId); if (count == 0) { return null; } List list = findByCompanyId( companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the ct collections before and after the current ct collection in the ordered set where companyId = ?. * * @param ctCollectionId the primary key of the current ct collection * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next ct collection * @throws NoSuchCollectionException if a ct collection with the primary key could not be found */ @Override public CTCollection[] findByCompanyId_PrevAndNext( long ctCollectionId, long companyId, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = findByPrimaryKey(ctCollectionId); Session session = null; try { session = openSession(); CTCollection[] array = new CTCollectionImpl[3]; array[0] = getByCompanyId_PrevAndNext( session, ctCollection, companyId, orderByComparator, true); array[1] = ctCollection; array[2] = getByCompanyId_PrevAndNext( session, ctCollection, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTCollection getByCompanyId_PrevAndNext( Session session, CTCollection ctCollection, long companyId, 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_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_COMPANYID_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(CTCollectionModelImpl.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(companyId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(ctCollection)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the ct collections that the user has permission to view where companyId = ?. * * @param companyId the company ID * @return the matching ct collections that the user has permission to view */ @Override public List filterFindByCompanyId(long companyId) { return filterFindByCompanyId( companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct collections that the user has permission to view where 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 CTCollectionModelImpl. *

* * @param companyId the company ID * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @return the range of matching ct collections that the user has permission to view */ @Override public List filterFindByCompanyId( long companyId, int start, int end) { return filterFindByCompanyId(companyId, start, end, null); } /** * Returns an ordered range of all the ct collections that the user has permissions to view where 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 CTCollectionModelImpl. *

* * @param companyId the company ID * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct collections that the user has permission to view */ @Override public List filterFindByCompanyId( long companyId, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByCompanyId(companyId, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_CTCOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(CTCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(CTCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, CTCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, CTCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the ct collections before and after the current ct collection in the ordered set of ct collections that the user has permission to view where companyId = ?. * * @param ctCollectionId the primary key of the current ct collection * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next ct collection * @throws NoSuchCollectionException if a ct collection with the primary key could not be found */ @Override public CTCollection[] filterFindByCompanyId_PrevAndNext( long ctCollectionId, long companyId, OrderByComparator orderByComparator) throws NoSuchCollectionException { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByCompanyId_PrevAndNext( ctCollectionId, companyId, orderByComparator); } CTCollection ctCollection = findByPrimaryKey(ctCollectionId); Session session = null; try { session = openSession(); CTCollection[] array = new CTCollectionImpl[3]; array[0] = filterGetByCompanyId_PrevAndNext( session, ctCollection, companyId, orderByComparator, true); array[1] = ctCollection; array[2] = filterGetByCompanyId_PrevAndNext( session, ctCollection, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTCollection filterGetByCompanyId_PrevAndNext( Session session, CTCollection ctCollection, 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); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_CTCOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(CTCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(CTCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, CTCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, CTCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(ctCollection)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the ct collections where companyId = ? from the database. * * @param companyId the company ID */ @Override public void removeByCompanyId(long companyId) { for (CTCollection ctCollection : findByCompanyId( companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ctCollection); } } /** * Returns the number of ct collections where companyId = ?. * * @param companyId the company ID * @return the number of matching ct collections */ @Override public int countByCompanyId(long companyId) { FinderPath finderPath = _finderPathCountByCompanyId; Object[] finderArgs = new Object[] {companyId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(companyId); 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 collections that the user has permission to view where companyId = ?. * * @param companyId the company ID * @return the number of matching ct collections that the user has permission to view */ @Override public int filterCountByCompanyId(long companyId) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return countByCompanyId(companyId); } StringBundler sb = new StringBundler(2); sb.append(_FILTER_SQL_COUNT_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "ctCollection.companyId = ?"; private FinderPath _finderPathWithPaginationFindBySchemaVersionId; private FinderPath _finderPathWithoutPaginationFindBySchemaVersionId; private FinderPath _finderPathCountBySchemaVersionId; /** * Returns all the ct collections where schemaVersionId = ?. * * @param schemaVersionId the schema version ID * @return the matching ct collections */ @Override public List findBySchemaVersionId(long schemaVersionId) { return findBySchemaVersionId( schemaVersionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct collections where schemaVersionId = ?. * *

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

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

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

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

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

* * @param schemaVersionId the schema version ID * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (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 collections */ @Override public List findBySchemaVersionId( long schemaVersionId, 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 = _finderPathWithoutPaginationFindBySchemaVersionId; finderArgs = new Object[] {schemaVersionId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindBySchemaVersionId; finderArgs = new Object[] { schemaVersionId, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (CTCollection ctCollection : list) { if (schemaVersionId != ctCollection.getSchemaVersionId()) { 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_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_SCHEMAVERSIONID_SCHEMAVERSIONID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(CTCollectionModelImpl.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(schemaVersionId); 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 collection in the ordered set where schemaVersionId = ?. * * @param schemaVersionId the schema version ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct collection * @throws NoSuchCollectionException if a matching ct collection could not be found */ @Override public CTCollection findBySchemaVersionId_First( long schemaVersionId, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = fetchBySchemaVersionId_First( schemaVersionId, orderByComparator); if (ctCollection != null) { return ctCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("schemaVersionId="); sb.append(schemaVersionId); sb.append("}"); throw new NoSuchCollectionException(sb.toString()); } /** * Returns the first ct collection in the ordered set where schemaVersionId = ?. * * @param schemaVersionId the schema version ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct collection, or null if a matching ct collection could not be found */ @Override public CTCollection fetchBySchemaVersionId_First( long schemaVersionId, OrderByComparator orderByComparator) { List list = findBySchemaVersionId( schemaVersionId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last ct collection in the ordered set where schemaVersionId = ?. * * @param schemaVersionId the schema version ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct collection * @throws NoSuchCollectionException if a matching ct collection could not be found */ @Override public CTCollection findBySchemaVersionId_Last( long schemaVersionId, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = fetchBySchemaVersionId_Last( schemaVersionId, orderByComparator); if (ctCollection != null) { return ctCollection; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("schemaVersionId="); sb.append(schemaVersionId); sb.append("}"); throw new NoSuchCollectionException(sb.toString()); } /** * Returns the last ct collection in the ordered set where schemaVersionId = ?. * * @param schemaVersionId the schema version ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct collection, or null if a matching ct collection could not be found */ @Override public CTCollection fetchBySchemaVersionId_Last( long schemaVersionId, OrderByComparator orderByComparator) { int count = countBySchemaVersionId(schemaVersionId); if (count == 0) { return null; } List list = findBySchemaVersionId( schemaVersionId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the ct collections before and after the current ct collection in the ordered set where schemaVersionId = ?. * * @param ctCollectionId the primary key of the current ct collection * @param schemaVersionId the schema version ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next ct collection * @throws NoSuchCollectionException if a ct collection with the primary key could not be found */ @Override public CTCollection[] findBySchemaVersionId_PrevAndNext( long ctCollectionId, long schemaVersionId, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = findByPrimaryKey(ctCollectionId); Session session = null; try { session = openSession(); CTCollection[] array = new CTCollectionImpl[3]; array[0] = getBySchemaVersionId_PrevAndNext( session, ctCollection, schemaVersionId, orderByComparator, true); array[1] = ctCollection; array[2] = getBySchemaVersionId_PrevAndNext( session, ctCollection, schemaVersionId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTCollection getBySchemaVersionId_PrevAndNext( Session session, CTCollection ctCollection, long schemaVersionId, 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_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_SCHEMAVERSIONID_SCHEMAVERSIONID_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(CTCollectionModelImpl.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(schemaVersionId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(ctCollection)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the ct collections that the user has permission to view where schemaVersionId = ?. * * @param schemaVersionId the schema version ID * @return the matching ct collections that the user has permission to view */ @Override public List filterFindBySchemaVersionId( long schemaVersionId) { return filterFindBySchemaVersionId( schemaVersionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct collections that the user has permission to view where schemaVersionId = ?. * *

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

* * @param schemaVersionId the schema version ID * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @return the range of matching ct collections that the user has permission to view */ @Override public List filterFindBySchemaVersionId( long schemaVersionId, int start, int end) { return filterFindBySchemaVersionId(schemaVersionId, start, end, null); } /** * Returns an ordered range of all the ct collections that the user has permissions to view where schemaVersionId = ?. * *

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

* * @param schemaVersionId the schema version ID * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct collections that the user has permission to view */ @Override public List filterFindBySchemaVersionId( long schemaVersionId, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled()) { return findBySchemaVersionId( schemaVersionId, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_CTCOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_SCHEMAVERSIONID_SCHEMAVERSIONID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(CTCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(CTCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, CTCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, CTCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(schemaVersionId); return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the ct collections before and after the current ct collection in the ordered set of ct collections that the user has permission to view where schemaVersionId = ?. * * @param ctCollectionId the primary key of the current ct collection * @param schemaVersionId the schema version ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next ct collection * @throws NoSuchCollectionException if a ct collection with the primary key could not be found */ @Override public CTCollection[] filterFindBySchemaVersionId_PrevAndNext( long ctCollectionId, long schemaVersionId, OrderByComparator orderByComparator) throws NoSuchCollectionException { if (!InlineSQLHelperUtil.isEnabled()) { return findBySchemaVersionId_PrevAndNext( ctCollectionId, schemaVersionId, orderByComparator); } CTCollection ctCollection = findByPrimaryKey(ctCollectionId); Session session = null; try { session = openSession(); CTCollection[] array = new CTCollectionImpl[3]; array[0] = filterGetBySchemaVersionId_PrevAndNext( session, ctCollection, schemaVersionId, orderByComparator, true); array[1] = ctCollection; array[2] = filterGetBySchemaVersionId_PrevAndNext( session, ctCollection, schemaVersionId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTCollection filterGetBySchemaVersionId_PrevAndNext( Session session, CTCollection ctCollection, long schemaVersionId, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_CTCOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_SCHEMAVERSIONID_SCHEMAVERSIONID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(CTCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(CTCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, CTCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, CTCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(schemaVersionId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(ctCollection)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the ct collections where schemaVersionId = ? from the database. * * @param schemaVersionId the schema version ID */ @Override public void removeBySchemaVersionId(long schemaVersionId) { for (CTCollection ctCollection : findBySchemaVersionId( schemaVersionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ctCollection); } } /** * Returns the number of ct collections where schemaVersionId = ?. * * @param schemaVersionId the schema version ID * @return the number of matching ct collections */ @Override public int countBySchemaVersionId(long schemaVersionId) { FinderPath finderPath = _finderPathCountBySchemaVersionId; Object[] finderArgs = new Object[] {schemaVersionId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_SCHEMAVERSIONID_SCHEMAVERSIONID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(schemaVersionId); 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 collections that the user has permission to view where schemaVersionId = ?. * * @param schemaVersionId the schema version ID * @return the number of matching ct collections that the user has permission to view */ @Override public int filterCountBySchemaVersionId(long schemaVersionId) { if (!InlineSQLHelperUtil.isEnabled()) { return countBySchemaVersionId(schemaVersionId); } StringBundler sb = new StringBundler(2); sb.append(_FILTER_SQL_COUNT_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_SCHEMAVERSIONID_SCHEMAVERSIONID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(schemaVersionId); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_SCHEMAVERSIONID_SCHEMAVERSIONID_2 = "ctCollection.schemaVersionId = ?"; private FinderPath _finderPathWithPaginationFindByC_S; private FinderPath _finderPathWithoutPaginationFindByC_S; private FinderPath _finderPathCountByC_S; private FinderPath _finderPathWithPaginationCountByC_S; /** * Returns all the ct collections where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @return the matching ct collections */ @Override public List findByC_S(long companyId, int status) { return findByC_S( companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct collections where companyId = ? and status = ?. * *

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

* * @param companyId the company ID * @param status the status * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @return the range of matching ct collections */ @Override public List findByC_S( long companyId, int status, int start, int end) { return findByC_S(companyId, status, start, end, null); } /** * Returns an ordered range of all the ct collections where companyId = ? and status = ?. * *

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

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

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

* * @param companyId the company ID * @param status the status * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (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 collections */ @Override public List findByC_S( long companyId, int status, 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_S; finderArgs = new Object[] {companyId, status}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByC_S; finderArgs = new Object[] { companyId, status, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (CTCollection ctCollection : list) { if ((companyId != ctCollection.getCompanyId()) || (status != ctCollection.getStatus())) { 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_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_C_S_COMPANYID_2); sb.append(_FINDER_COLUMN_C_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(CTCollectionModelImpl.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(companyId); queryPos.add(status); 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 collection in the ordered set where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct collection * @throws NoSuchCollectionException if a matching ct collection could not be found */ @Override public CTCollection findByC_S_First( long companyId, int status, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = fetchByC_S_First( companyId, status, orderByComparator); if (ctCollection != null) { return ctCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("companyId="); sb.append(companyId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchCollectionException(sb.toString()); } /** * Returns the first ct collection in the ordered set where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching ct collection, or null if a matching ct collection could not be found */ @Override public CTCollection fetchByC_S_First( long companyId, int status, OrderByComparator orderByComparator) { List list = findByC_S( companyId, status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last ct collection in the ordered set where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct collection * @throws NoSuchCollectionException if a matching ct collection could not be found */ @Override public CTCollection findByC_S_Last( long companyId, int status, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = fetchByC_S_Last( companyId, status, orderByComparator); if (ctCollection != null) { return ctCollection; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("companyId="); sb.append(companyId); sb.append(", status="); sb.append(status); sb.append("}"); throw new NoSuchCollectionException(sb.toString()); } /** * Returns the last ct collection in the ordered set where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching ct collection, or null if a matching ct collection could not be found */ @Override public CTCollection fetchByC_S_Last( long companyId, int status, OrderByComparator orderByComparator) { int count = countByC_S(companyId, status); if (count == 0) { return null; } List list = findByC_S( companyId, status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the ct collections before and after the current ct collection in the ordered set where companyId = ? and status = ?. * * @param ctCollectionId the primary key of the current ct collection * @param companyId the company ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next ct collection * @throws NoSuchCollectionException if a ct collection with the primary key could not be found */ @Override public CTCollection[] findByC_S_PrevAndNext( long ctCollectionId, long companyId, int status, OrderByComparator orderByComparator) throws NoSuchCollectionException { CTCollection ctCollection = findByPrimaryKey(ctCollectionId); Session session = null; try { session = openSession(); CTCollection[] array = new CTCollectionImpl[3]; array[0] = getByC_S_PrevAndNext( session, ctCollection, companyId, status, orderByComparator, true); array[1] = ctCollection; array[2] = getByC_S_PrevAndNext( session, ctCollection, companyId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTCollection getByC_S_PrevAndNext( Session session, CTCollection ctCollection, long companyId, int status, 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_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_C_S_COMPANYID_2); sb.append(_FINDER_COLUMN_C_S_STATUS_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(CTCollectionModelImpl.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(companyId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(ctCollection)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the ct collections that the user has permission to view where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @return the matching ct collections that the user has permission to view */ @Override public List filterFindByC_S(long companyId, int status) { return filterFindByC_S( companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct collections that the user has permission to view where companyId = ? and status = ?. * *

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

* * @param companyId the company ID * @param status the status * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @return the range of matching ct collections that the user has permission to view */ @Override public List filterFindByC_S( long companyId, int status, int start, int end) { return filterFindByC_S(companyId, status, start, end, null); } /** * Returns an ordered range of all the ct collections that the user has permissions to view where companyId = ? and status = ?. * *

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

* * @param companyId the company ID * @param status the status * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct collections that the user has permission to view */ @Override public List filterFindByC_S( long companyId, int status, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByC_S(companyId, status, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_CTCOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_C_S_COMPANYID_2); sb.append(_FINDER_COLUMN_C_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(CTCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(CTCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, CTCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, CTCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); queryPos.add(status); return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the ct collections before and after the current ct collection in the ordered set of ct collections that the user has permission to view where companyId = ? and status = ?. * * @param ctCollectionId the primary key of the current ct collection * @param companyId the company ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next ct collection * @throws NoSuchCollectionException if a ct collection with the primary key could not be found */ @Override public CTCollection[] filterFindByC_S_PrevAndNext( long ctCollectionId, long companyId, int status, OrderByComparator orderByComparator) throws NoSuchCollectionException { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByC_S_PrevAndNext( ctCollectionId, companyId, status, orderByComparator); } CTCollection ctCollection = findByPrimaryKey(ctCollectionId); Session session = null; try { session = openSession(); CTCollection[] array = new CTCollectionImpl[3]; array[0] = filterGetByC_S_PrevAndNext( session, ctCollection, companyId, status, orderByComparator, true); array[1] = ctCollection; array[2] = filterGetByC_S_PrevAndNext( session, ctCollection, companyId, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected CTCollection filterGetByC_S_PrevAndNext( Session session, CTCollection ctCollection, long companyId, int status, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_CTCOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_C_S_COMPANYID_2); sb.append(_FINDER_COLUMN_C_S_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(CTCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(CTCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, CTCollectionImpl.class); } else { sqlQuery.addEntity(_FILTER_ENTITY_TABLE, CTCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(ctCollection)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the ct collections that the user has permission to view where companyId = ? and status = any ?. * * @param companyId the company ID * @param statuses the statuses * @return the matching ct collections that the user has permission to view */ @Override public List filterFindByC_S(long companyId, int[] statuses) { return filterFindByC_S( companyId, statuses, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct collections that the user has permission to view where companyId = ? and status = 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 CTCollectionModelImpl. *

* * @param companyId the company ID * @param statuses the statuses * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @return the range of matching ct collections that the user has permission to view */ @Override public List filterFindByC_S( long companyId, int[] statuses, int start, int end) { return filterFindByC_S(companyId, statuses, start, end, null); } /** * Returns an ordered range of all the ct collections that the user has permission to view where companyId = ? and status = 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 CTCollectionModelImpl. *

* * @param companyId the company ID * @param statuses the statuses * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct collections that the user has permission to view */ @Override public List filterFindByC_S( long companyId, int[] statuses, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByC_S( companyId, statuses, start, end, orderByComparator); } if (statuses == null) { statuses = new int[0]; } else if (statuses.length > 1) { statuses = ArrayUtil.sortedUnique(statuses); } StringBundler sb = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_CTCOLLECTION_WHERE); } else { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_C_S_COMPANYID_2); if (statuses.length > 0) { sb.append("("); sb.append(_FINDER_COLUMN_C_S_STATUS_7); sb.append(StringUtil.merge(statuses)); sb.append(")"); sb.append(")"); } sb.setStringAt( removeConjunction(sb.stringAt(sb.index() - 1)), sb.index() - 1); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(CTCollectionModelImpl.ORDER_BY_JPQL); } else { sb.append(CTCollectionModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, CTCollectionImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, CTCollectionImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns all the ct collections where companyId = ? and status = 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 CTCollectionModelImpl. *

* * @param companyId the company ID * @param statuses the statuses * @return the matching ct collections */ @Override public List findByC_S(long companyId, int[] statuses) { return findByC_S( companyId, statuses, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the ct collections where companyId = ? and status = 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 CTCollectionModelImpl. *

* * @param companyId the company ID * @param statuses the statuses * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @return the range of matching ct collections */ @Override public List findByC_S( long companyId, int[] statuses, int start, int end) { return findByC_S(companyId, statuses, start, end, null); } /** * Returns an ordered range of all the ct collections where companyId = ? and status = 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 CTCollectionModelImpl. *

* * @param companyId the company ID * @param statuses the statuses * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching ct collections */ @Override public List findByC_S( long companyId, int[] statuses, int start, int end, OrderByComparator orderByComparator) { return findByC_S( companyId, statuses, start, end, orderByComparator, true); } /** * Returns an ordered range of all the ct collections where companyId = ? and status = ?, 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 CTCollectionModelImpl. *

* * @param companyId the company ID * @param statuses the statuses * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (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 collections */ @Override public List findByC_S( long companyId, int[] statuses, int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { if (statuses == null) { statuses = new int[0]; } else if (statuses.length > 1) { statuses = ArrayUtil.sortedUnique(statuses); } if (statuses.length == 1) { return findByC_S( companyId, statuses[0], start, end, orderByComparator); } Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderArgs = new Object[] { companyId, StringUtil.merge(statuses) }; } } else if (useFinderCache) { finderArgs = new Object[] { companyId, StringUtil.merge(statuses), start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( _finderPathWithPaginationFindByC_S, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (CTCollection ctCollection : list) { if ((companyId != ctCollection.getCompanyId()) || !ArrayUtil.contains( statuses, ctCollection.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler sb = new StringBundler(); sb.append(_SQL_SELECT_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_C_S_COMPANYID_2); if (statuses.length > 0) { sb.append("("); sb.append(_FINDER_COLUMN_C_S_STATUS_7); sb.append(StringUtil.merge(statuses)); 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(CTCollectionModelImpl.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(companyId); list = (List)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult( _finderPathWithPaginationFindByC_S, finderArgs, list); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return list; } /** * Removes all the ct collections where companyId = ? and status = ? from the database. * * @param companyId the company ID * @param status the status */ @Override public void removeByC_S(long companyId, int status) { for (CTCollection ctCollection : findByC_S( companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(ctCollection); } } /** * Returns the number of ct collections where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @return the number of matching ct collections */ @Override public int countByC_S(long companyId, int status) { FinderPath finderPath = _finderPathCountByC_S; Object[] finderArgs = new Object[] {companyId, status}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_C_S_COMPANYID_2); sb.append(_FINDER_COLUMN_C_S_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(companyId); queryPos.add(status); 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 collections where companyId = ? and status = any ?. * * @param companyId the company ID * @param statuses the statuses * @return the number of matching ct collections */ @Override public int countByC_S(long companyId, int[] statuses) { if (statuses == null) { statuses = new int[0]; } else if (statuses.length > 1) { statuses = ArrayUtil.sortedUnique(statuses); } Object[] finderArgs = new Object[] { companyId, StringUtil.merge(statuses) }; Long count = (Long)finderCache.getResult( _finderPathWithPaginationCountByC_S, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(); sb.append(_SQL_COUNT_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_C_S_COMPANYID_2); if (statuses.length > 0) { sb.append("("); sb.append(_FINDER_COLUMN_C_S_STATUS_7); sb.append(StringUtil.merge(statuses)); 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(companyId); count = (Long)query.uniqueResult(); finderCache.putResult( _finderPathWithPaginationCountByC_S, finderArgs, count); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of ct collections that the user has permission to view where companyId = ? and status = ?. * * @param companyId the company ID * @param status the status * @return the number of matching ct collections that the user has permission to view */ @Override public int filterCountByC_S(long companyId, int status) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return countByC_S(companyId, status); } StringBundler sb = new StringBundler(3); sb.append(_FILTER_SQL_COUNT_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_C_S_COMPANYID_2); sb.append(_FINDER_COLUMN_C_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); queryPos.add(status); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the number of ct collections that the user has permission to view where companyId = ? and status = any ?. * * @param companyId the company ID * @param statuses the statuses * @return the number of matching ct collections that the user has permission to view */ @Override public int filterCountByC_S(long companyId, int[] statuses) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return countByC_S(companyId, statuses); } if (statuses == null) { statuses = new int[0]; } else if (statuses.length > 1) { statuses = ArrayUtil.sortedUnique(statuses); } StringBundler sb = new StringBundler(); sb.append(_FILTER_SQL_COUNT_CTCOLLECTION_WHERE); sb.append(_FINDER_COLUMN_C_S_COMPANYID_2); if (statuses.length > 0) { sb.append("("); sb.append(_FINDER_COLUMN_C_S_STATUS_7); sb.append(StringUtil.merge(statuses)); sb.append(")"); sb.append(")"); } sb.setStringAt( removeConjunction(sb.stringAt(sb.index() - 1)), sb.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), CTCollection.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "ctCollection.companyId = ? AND "; private static final String _FINDER_COLUMN_C_S_STATUS_2 = "ctCollection.status = ?"; private static final String _FINDER_COLUMN_C_S_STATUS_7 = "ctCollection.status IN ("; private FinderPath _finderPathFetchByERC_C; private FinderPath _finderPathCountByERC_C; /** * Returns the ct collection where externalReferenceCode = ? and companyId = ? or throws a NoSuchCollectionException if it could not be found. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the matching ct collection * @throws NoSuchCollectionException if a matching ct collection could not be found */ @Override public CTCollection findByERC_C( String externalReferenceCode, long companyId) throws NoSuchCollectionException { CTCollection ctCollection = fetchByERC_C( externalReferenceCode, companyId); if (ctCollection == 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 NoSuchCollectionException(sb.toString()); } return ctCollection; } /** * Returns the ct collection 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 collection, or null if a matching ct collection could not be found */ @Override public CTCollection fetchByERC_C( String externalReferenceCode, long companyId) { return fetchByERC_C(externalReferenceCode, companyId, true); } /** * Returns the ct collection 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 collection, or null if a matching ct collection could not be found */ @Override public CTCollection 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 CTCollection) { CTCollection ctCollection = (CTCollection)result; if (!Objects.equals( externalReferenceCode, ctCollection.getExternalReferenceCode()) || (companyId != ctCollection.getCompanyId())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_SELECT_CTCOLLECTION_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 { CTCollection ctCollection = list.get(0); result = ctCollection; cacheResult(ctCollection); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (CTCollection)result; } } /** * Removes the ct collection where externalReferenceCode = ? and companyId = ? from the database. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the ct collection that was removed */ @Override public CTCollection removeByERC_C( String externalReferenceCode, long companyId) throws NoSuchCollectionException { CTCollection ctCollection = findByERC_C( externalReferenceCode, companyId); return remove(ctCollection); } /** * Returns the number of ct collections where externalReferenceCode = ? and companyId = ?. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the number of matching ct collections */ @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_CTCOLLECTION_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 = "ctCollection.externalReferenceCode = ? AND "; private static final String _FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_3 = "(ctCollection.externalReferenceCode IS NULL OR ctCollection.externalReferenceCode = '') AND "; private static final String _FINDER_COLUMN_ERC_C_COMPANYID_2 = "ctCollection.companyId = ?"; public CTCollectionPersistenceImpl() { Map dbColumnNames = new HashMap(); dbColumnNames.put("uuid", "uuid_"); setDBColumnNames(dbColumnNames); setModelClass(CTCollection.class); setModelImplClass(CTCollectionImpl.class); setModelPKClass(long.class); setTable(CTCollectionTable.INSTANCE); } /** * Caches the ct collection in the entity cache if it is enabled. * * @param ctCollection the ct collection */ @Override public void cacheResult(CTCollection ctCollection) { entityCache.putResult( CTCollectionImpl.class, ctCollection.getPrimaryKey(), ctCollection); finderCache.putResult( _finderPathFetchByERC_C, new Object[] { ctCollection.getExternalReferenceCode(), ctCollection.getCompanyId() }, ctCollection); } private int _valueObjectFinderCacheListThreshold; /** * Caches the ct collections in the entity cache if it is enabled. * * @param ctCollections the ct collections */ @Override public void cacheResult(List ctCollections) { if ((_valueObjectFinderCacheListThreshold == 0) || ((_valueObjectFinderCacheListThreshold > 0) && (ctCollections.size() > _valueObjectFinderCacheListThreshold))) { return; } for (CTCollection ctCollection : ctCollections) { if (entityCache.getResult( CTCollectionImpl.class, ctCollection.getPrimaryKey()) == null) { cacheResult(ctCollection); } } } /** * Clears the cache for all ct collections. * *

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

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

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

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

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

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

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

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

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

* * @param start the lower bound of the range of ct collections * @param end the upper bound of the range of ct collections (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 collections */ @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_CTCOLLECTION); appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = sb.toString(); } else { sql = _SQL_SELECT_CTCOLLECTION; sql = sql.concat(CTCollectionModelImpl.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 collections from the database. * */ @Override public void removeAll() { for (CTCollection ctCollection : findAll()) { remove(ctCollection); } } /** * Returns the number of ct collections. * * @return the number of ct collections */ @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_CTCOLLECTION); 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 "ctCollectionId"; } @Override protected String getSelectSQL() { return _SQL_SELECT_CTCOLLECTION; } @Override protected Map getTableColumnsMap() { return CTCollectionModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the ct collection 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); _finderPathWithPaginationFindByCompanyId = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"companyId"}, true); _finderPathWithoutPaginationFindByCompanyId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId", new String[] {Long.class.getName()}, new String[] {"companyId"}, true); _finderPathCountByCompanyId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId", new String[] {Long.class.getName()}, new String[] {"companyId"}, false); _finderPathWithPaginationFindBySchemaVersionId = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findBySchemaVersionId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"schemaVersionId"}, true); _finderPathWithoutPaginationFindBySchemaVersionId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySchemaVersionId", new String[] {Long.class.getName()}, new String[] {"schemaVersionId"}, true); _finderPathCountBySchemaVersionId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySchemaVersionId", new String[] {Long.class.getName()}, new String[] {"schemaVersionId"}, false); _finderPathWithPaginationFindByC_S = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"companyId", "status"}, true); _finderPathWithoutPaginationFindByC_S = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S", new String[] {Long.class.getName(), Integer.class.getName()}, new String[] {"companyId", "status"}, true); _finderPathCountByC_S = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S", new String[] {Long.class.getName(), Integer.class.getName()}, new String[] {"companyId", "status"}, false); _finderPathWithPaginationCountByC_S = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_S", new String[] {Long.class.getName(), Integer.class.getName()}, new String[] {"companyId", "status"}, 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); CTCollectionUtil.setPersistence(this); } @Deactivate public void deactivate() { CTCollectionUtil.setPersistence(null); entityCache.removeCache(CTCollectionImpl.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_CTCOLLECTION = "SELECT ctCollection FROM CTCollection ctCollection"; private static final String _SQL_SELECT_CTCOLLECTION_WHERE = "SELECT ctCollection FROM CTCollection ctCollection WHERE "; private static final String _SQL_COUNT_CTCOLLECTION = "SELECT COUNT(ctCollection) FROM CTCollection ctCollection"; private static final String _SQL_COUNT_CTCOLLECTION_WHERE = "SELECT COUNT(ctCollection) FROM CTCollection ctCollection WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "ctCollection.ctCollectionId"; private static final String _FILTER_SQL_SELECT_CTCOLLECTION_WHERE = "SELECT DISTINCT {ctCollection.*} FROM CTCollection ctCollection WHERE "; private static final String _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {CTCollection.*} FROM (SELECT DISTINCT ctCollection.ctCollectionId FROM CTCollection ctCollection WHERE "; private static final String _FILTER_SQL_SELECT_CTCOLLECTION_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN CTCollection ON TEMP_TABLE.ctCollectionId = CTCollection.ctCollectionId"; private static final String _FILTER_SQL_COUNT_CTCOLLECTION_WHERE = "SELECT COUNT(DISTINCT ctCollection.ctCollectionId) AS COUNT_VALUE FROM CTCollection ctCollection WHERE "; private static final String _FILTER_ENTITY_ALIAS = "ctCollection"; private static final String _FILTER_ENTITY_TABLE = "CTCollection"; private static final String _ORDER_BY_ENTITY_ALIAS = "ctCollection."; private static final String _ORDER_BY_ENTITY_TABLE = "CTCollection."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No CTCollection exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No CTCollection exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( CTCollectionPersistenceImpl.class); private static final Set _badColumnNames = SetUtil.fromArray( new String[] {"uuid"}); @Override protected FinderCache getFinderCache() { return finderCache; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy