com.liferay.change.tracking.service.persistence.impl.CTCollectionPersistenceImpl Maven / Gradle / Ivy
Show all versions of com.liferay.change.tracking.service
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.change.tracking.service.persistence.impl;
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.impl.constants.CTPersistenceConstants;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.configuration.Configuration;
import com.liferay.portal.kernel.dao.orm.ArgumentsResolver;
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.model.BaseModel;
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.BasePersistence;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.HashMapDictionary;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringUtil;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.sql.DataSource;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
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, BasePersistence.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 _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);
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);
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);
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);
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);
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 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[] 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);
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);
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);
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 (";
public CTCollectionPersistenceImpl() {
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);
}
/**
* Caches the ct collections in the entity cache if it is enabled.
*
* @param ctCollections the ct collections
*/
@Override
public void cacheResult(List ctCollections) {
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);
}
}
/**
* 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);
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;
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);
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);
}
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);
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
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(BundleContext bundleContext) {
_bundleContext = bundleContext;
_argumentsResolverServiceRegistration = _bundleContext.registerService(
ArgumentsResolver.class, new CTCollectionModelArgumentsResolver(),
new HashMapDictionary<>());
_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);
_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);
}
@Deactivate
public void deactivate() {
entityCache.removeCache(CTCollectionImpl.class.getName());
_argumentsResolverServiceRegistration.unregister();
}
@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);
}
private BundleContext _bundleContext;
@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);
@Override
protected FinderCache getFinderCache() {
return finderCache;
}
private ServiceRegistration
_argumentsResolverServiceRegistration;
private static class CTCollectionModelArgumentsResolver
implements ArgumentsResolver {
@Override
public Object[] getArguments(
FinderPath finderPath, BaseModel> baseModel, boolean checkColumn,
boolean original) {
String[] columnNames = finderPath.getColumnNames();
if ((columnNames == null) || (columnNames.length == 0)) {
if (baseModel.isNew()) {
return FINDER_ARGS_EMPTY;
}
return null;
}
CTCollectionModelImpl ctCollectionModelImpl =
(CTCollectionModelImpl)baseModel;
long columnBitmask = ctCollectionModelImpl.getColumnBitmask();
if (!checkColumn || (columnBitmask == 0)) {
return _getValue(ctCollectionModelImpl, columnNames, original);
}
Long finderPathColumnBitmask = _finderPathColumnBitmasksCache.get(
finderPath);
if (finderPathColumnBitmask == null) {
finderPathColumnBitmask = 0L;
for (String columnName : columnNames) {
finderPathColumnBitmask |=
ctCollectionModelImpl.getColumnBitmask(columnName);
}
if (finderPath.isBaseModelResult() &&
(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION ==
finderPath.getCacheName())) {
finderPathColumnBitmask |= _ORDER_BY_COLUMNS_BITMASK;
}
_finderPathColumnBitmasksCache.put(
finderPath, finderPathColumnBitmask);
}
if ((columnBitmask & finderPathColumnBitmask) != 0) {
return _getValue(ctCollectionModelImpl, columnNames, original);
}
return null;
}
@Override
public String getClassName() {
return CTCollectionImpl.class.getName();
}
@Override
public String getTableName() {
return CTCollectionTable.INSTANCE.getTableName();
}
private static Object[] _getValue(
CTCollectionModelImpl ctCollectionModelImpl, String[] columnNames,
boolean original) {
Object[] arguments = new Object[columnNames.length];
for (int i = 0; i < arguments.length; i++) {
String columnName = columnNames[i];
if (original) {
arguments[i] = ctCollectionModelImpl.getColumnOriginalValue(
columnName);
}
else {
arguments[i] = ctCollectionModelImpl.getColumnValue(
columnName);
}
}
return arguments;
}
private static final Map
_finderPathColumnBitmasksCache = new ConcurrentHashMap<>();
private static final long _ORDER_BY_COLUMNS_BITMASK;
static {
long orderByColumnsBitmask = 0;
orderByColumnsBitmask |= CTCollectionModelImpl.getColumnBitmask(
"createDate");
_ORDER_BY_COLUMNS_BITMASK = orderByColumnsBitmask;
}
}
}