com.liferay.change.tracking.service.persistence.impl.CTEntryPersistenceImpl 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.NoSuchEntryException;
import com.liferay.change.tracking.model.CTEntry;
import com.liferay.change.tracking.model.CTEntryTable;
import com.liferay.change.tracking.model.impl.CTEntryImpl;
import com.liferay.change.tracking.model.impl.CTEntryModelImpl;
import com.liferay.change.tracking.service.persistence.CTEntryPersistence;
import com.liferay.change.tracking.service.persistence.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.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.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 entry service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Brian Wing Shun Chan
* @generated
*/
@Component(service = {CTEntryPersistence.class, BasePersistence.class})
public class CTEntryPersistenceImpl
extends BasePersistenceImpl implements CTEntryPersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use CTEntryUtil
to access the ct entry persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY =
CTEntryImpl.class.getName();
public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION =
FINDER_CLASS_NAME_ENTITY + ".List1";
public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION =
FINDER_CLASS_NAME_ENTITY + ".List2";
private FinderPath _finderPathWithPaginationFindAll;
private FinderPath _finderPathWithoutPaginationFindAll;
private FinderPath _finderPathCountAll;
private FinderPath _finderPathWithPaginationFindByCTCollectionId;
private FinderPath _finderPathWithoutPaginationFindByCTCollectionId;
private FinderPath _finderPathCountByCTCollectionId;
/**
* Returns all the ct entries where ctCollectionId = ?.
*
* @param ctCollectionId the ct collection ID
* @return the matching ct entries
*/
@Override
public List findByCTCollectionId(long ctCollectionId) {
return findByCTCollectionId(
ctCollectionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the ct entries where ctCollectionId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @return the range of matching ct entries
*/
@Override
public List findByCTCollectionId(
long ctCollectionId, int start, int end) {
return findByCTCollectionId(ctCollectionId, start, end, null);
}
/**
* Returns an ordered range of all the ct entries where ctCollectionId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching ct entries
*/
@Override
public List findByCTCollectionId(
long ctCollectionId, int start, int end,
OrderByComparator orderByComparator) {
return findByCTCollectionId(
ctCollectionId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the ct entries where ctCollectionId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching ct entries
*/
@Override
public List findByCTCollectionId(
long ctCollectionId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByCTCollectionId;
finderArgs = new Object[] {ctCollectionId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByCTCollectionId;
finderArgs = new Object[] {
ctCollectionId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (CTEntry ctEntry : list) {
if (ctCollectionId != ctEntry.getCtCollectionId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_CTCOLLECTIONID_CTCOLLECTIONID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CTEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first ct entry in the ordered set where ctCollectionId = ?.
*
* @param ctCollectionId the ct collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching ct entry
* @throws NoSuchEntryException if a matching ct entry could not be found
*/
@Override
public CTEntry findByCTCollectionId_First(
long ctCollectionId, OrderByComparator orderByComparator)
throws NoSuchEntryException {
CTEntry ctEntry = fetchByCTCollectionId_First(
ctCollectionId, orderByComparator);
if (ctEntry != null) {
return ctEntry;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("ctCollectionId=");
sb.append(ctCollectionId);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first ct entry in the ordered set where ctCollectionId = ?.
*
* @param ctCollectionId the ct collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching ct entry, or null
if a matching ct entry could not be found
*/
@Override
public CTEntry fetchByCTCollectionId_First(
long ctCollectionId, OrderByComparator orderByComparator) {
List list = findByCTCollectionId(
ctCollectionId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last ct entry in the ordered set where ctCollectionId = ?.
*
* @param ctCollectionId the ct collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching ct entry
* @throws NoSuchEntryException if a matching ct entry could not be found
*/
@Override
public CTEntry findByCTCollectionId_Last(
long ctCollectionId, OrderByComparator orderByComparator)
throws NoSuchEntryException {
CTEntry ctEntry = fetchByCTCollectionId_Last(
ctCollectionId, orderByComparator);
if (ctEntry != null) {
return ctEntry;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("ctCollectionId=");
sb.append(ctCollectionId);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last ct entry in the ordered set where ctCollectionId = ?.
*
* @param ctCollectionId the ct collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching ct entry, or null
if a matching ct entry could not be found
*/
@Override
public CTEntry fetchByCTCollectionId_Last(
long ctCollectionId, OrderByComparator orderByComparator) {
int count = countByCTCollectionId(ctCollectionId);
if (count == 0) {
return null;
}
List list = findByCTCollectionId(
ctCollectionId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the ct entries before and after the current ct entry in the ordered set where ctCollectionId = ?.
*
* @param ctEntryId the primary key of the current ct entry
* @param ctCollectionId the ct collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next ct entry
* @throws NoSuchEntryException if a ct entry with the primary key could not be found
*/
@Override
public CTEntry[] findByCTCollectionId_PrevAndNext(
long ctEntryId, long ctCollectionId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
CTEntry ctEntry = findByPrimaryKey(ctEntryId);
Session session = null;
try {
session = openSession();
CTEntry[] array = new CTEntryImpl[3];
array[0] = getByCTCollectionId_PrevAndNext(
session, ctEntry, ctCollectionId, orderByComparator, true);
array[1] = ctEntry;
array[2] = getByCTCollectionId_PrevAndNext(
session, ctEntry, ctCollectionId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CTEntry getByCTCollectionId_PrevAndNext(
Session session, CTEntry ctEntry, long ctCollectionId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_CTCOLLECTIONID_CTCOLLECTIONID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CTEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(ctEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the ct entries where ctCollectionId = ? from the database.
*
* @param ctCollectionId the ct collection ID
*/
@Override
public void removeByCTCollectionId(long ctCollectionId) {
for (CTEntry ctEntry :
findByCTCollectionId(
ctCollectionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(ctEntry);
}
}
/**
* Returns the number of ct entries where ctCollectionId = ?.
*
* @param ctCollectionId the ct collection ID
* @return the number of matching ct entries
*/
@Override
public int countByCTCollectionId(long ctCollectionId) {
FinderPath finderPath = _finderPathCountByCTCollectionId;
Object[] finderArgs = new Object[] {ctCollectionId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_CTCOLLECTIONID_CTCOLLECTIONID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_CTCOLLECTIONID_CTCOLLECTIONID_2 =
"ctEntry.ctCollectionId = ?";
private FinderPath _finderPathWithPaginationFindByC_MCNI;
private FinderPath _finderPathWithoutPaginationFindByC_MCNI;
private FinderPath _finderPathCountByC_MCNI;
/**
* Returns all the ct entries where ctCollectionId = ? and modelClassNameId = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @return the matching ct entries
*/
@Override
public List findByC_MCNI(
long ctCollectionId, long modelClassNameId) {
return findByC_MCNI(
ctCollectionId, modelClassNameId, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the ct entries where ctCollectionId = ? and modelClassNameId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @return the range of matching ct entries
*/
@Override
public List findByC_MCNI(
long ctCollectionId, long modelClassNameId, int start, int end) {
return findByC_MCNI(ctCollectionId, modelClassNameId, start, end, null);
}
/**
* Returns an ordered range of all the ct entries where ctCollectionId = ? and modelClassNameId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching ct entries
*/
@Override
public List findByC_MCNI(
long ctCollectionId, long modelClassNameId, int start, int end,
OrderByComparator orderByComparator) {
return findByC_MCNI(
ctCollectionId, modelClassNameId, start, end, orderByComparator,
true);
}
/**
* Returns an ordered range of all the ct entries where ctCollectionId = ? and modelClassNameId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching ct entries
*/
@Override
public List findByC_MCNI(
long ctCollectionId, long modelClassNameId, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByC_MCNI;
finderArgs = new Object[] {ctCollectionId, modelClassNameId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByC_MCNI;
finderArgs = new Object[] {
ctCollectionId, modelClassNameId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (CTEntry ctEntry : list) {
if ((ctCollectionId != ctEntry.getCtCollectionId()) ||
(modelClassNameId != ctEntry.getModelClassNameId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_MCNI_CTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_C_MCNI_MODELCLASSNAMEID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CTEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
queryPos.add(modelClassNameId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first ct entry in the ordered set where ctCollectionId = ? and modelClassNameId = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching ct entry
* @throws NoSuchEntryException if a matching ct entry could not be found
*/
@Override
public CTEntry findByC_MCNI_First(
long ctCollectionId, long modelClassNameId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
CTEntry ctEntry = fetchByC_MCNI_First(
ctCollectionId, modelClassNameId, orderByComparator);
if (ctEntry != null) {
return ctEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("ctCollectionId=");
sb.append(ctCollectionId);
sb.append(", modelClassNameId=");
sb.append(modelClassNameId);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first ct entry in the ordered set where ctCollectionId = ? and modelClassNameId = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching ct entry, or null
if a matching ct entry could not be found
*/
@Override
public CTEntry fetchByC_MCNI_First(
long ctCollectionId, long modelClassNameId,
OrderByComparator orderByComparator) {
List list = findByC_MCNI(
ctCollectionId, modelClassNameId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last ct entry in the ordered set where ctCollectionId = ? and modelClassNameId = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching ct entry
* @throws NoSuchEntryException if a matching ct entry could not be found
*/
@Override
public CTEntry findByC_MCNI_Last(
long ctCollectionId, long modelClassNameId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
CTEntry ctEntry = fetchByC_MCNI_Last(
ctCollectionId, modelClassNameId, orderByComparator);
if (ctEntry != null) {
return ctEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("ctCollectionId=");
sb.append(ctCollectionId);
sb.append(", modelClassNameId=");
sb.append(modelClassNameId);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last ct entry in the ordered set where ctCollectionId = ? and modelClassNameId = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching ct entry, or null
if a matching ct entry could not be found
*/
@Override
public CTEntry fetchByC_MCNI_Last(
long ctCollectionId, long modelClassNameId,
OrderByComparator orderByComparator) {
int count = countByC_MCNI(ctCollectionId, modelClassNameId);
if (count == 0) {
return null;
}
List list = findByC_MCNI(
ctCollectionId, modelClassNameId, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the ct entries before and after the current ct entry in the ordered set where ctCollectionId = ? and modelClassNameId = ?.
*
* @param ctEntryId the primary key of the current ct entry
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next ct entry
* @throws NoSuchEntryException if a ct entry with the primary key could not be found
*/
@Override
public CTEntry[] findByC_MCNI_PrevAndNext(
long ctEntryId, long ctCollectionId, long modelClassNameId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
CTEntry ctEntry = findByPrimaryKey(ctEntryId);
Session session = null;
try {
session = openSession();
CTEntry[] array = new CTEntryImpl[3];
array[0] = getByC_MCNI_PrevAndNext(
session, ctEntry, ctCollectionId, modelClassNameId,
orderByComparator, true);
array[1] = ctEntry;
array[2] = getByC_MCNI_PrevAndNext(
session, ctEntry, ctCollectionId, modelClassNameId,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CTEntry getByC_MCNI_PrevAndNext(
Session session, CTEntry ctEntry, long ctCollectionId,
long modelClassNameId, OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_MCNI_CTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_C_MCNI_MODELCLASSNAMEID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CTEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
queryPos.add(modelClassNameId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(ctEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the ct entries where ctCollectionId = ? and modelClassNameId = ? from the database.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
*/
@Override
public void removeByC_MCNI(long ctCollectionId, long modelClassNameId) {
for (CTEntry ctEntry :
findByC_MCNI(
ctCollectionId, modelClassNameId, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(ctEntry);
}
}
/**
* Returns the number of ct entries where ctCollectionId = ? and modelClassNameId = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @return the number of matching ct entries
*/
@Override
public int countByC_MCNI(long ctCollectionId, long modelClassNameId) {
FinderPath finderPath = _finderPathCountByC_MCNI;
Object[] finderArgs = new Object[] {ctCollectionId, modelClassNameId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_MCNI_CTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_C_MCNI_MODELCLASSNAMEID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
queryPos.add(modelClassNameId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_C_MCNI_CTCOLLECTIONID_2 =
"ctEntry.ctCollectionId = ? AND ";
private static final String _FINDER_COLUMN_C_MCNI_MODELCLASSNAMEID_2 =
"ctEntry.modelClassNameId = ?";
private FinderPath _finderPathFetchByC_MCNI_MCPK;
private FinderPath _finderPathCountByC_MCNI_MCPK;
/**
* Returns the ct entry where ctCollectionId = ? and modelClassNameId = ? and modelClassPK = ? or throws a NoSuchEntryException
if it could not be found.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @return the matching ct entry
* @throws NoSuchEntryException if a matching ct entry could not be found
*/
@Override
public CTEntry findByC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long modelClassPK)
throws NoSuchEntryException {
CTEntry ctEntry = fetchByC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPK);
if (ctEntry == null) {
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("ctCollectionId=");
sb.append(ctCollectionId);
sb.append(", modelClassNameId=");
sb.append(modelClassNameId);
sb.append(", modelClassPK=");
sb.append(modelClassPK);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchEntryException(sb.toString());
}
return ctEntry;
}
/**
* Returns the ct entry where ctCollectionId = ? and modelClassNameId = ? and modelClassPK = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @return the matching ct entry, or null
if a matching ct entry could not be found
*/
@Override
public CTEntry fetchByC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long modelClassPK) {
return fetchByC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPK, true);
}
/**
* Returns the ct entry where ctCollectionId = ? and modelClassNameId = ? and modelClassPK = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @param useFinderCache whether to use the finder cache
* @return the matching ct entry, or null
if a matching ct entry could not be found
*/
@Override
public CTEntry fetchByC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long modelClassPK,
boolean useFinderCache) {
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {
ctCollectionId, modelClassNameId, modelClassPK
};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByC_MCNI_MCPK, finderArgs);
}
if (result instanceof CTEntry) {
CTEntry ctEntry = (CTEntry)result;
if ((ctCollectionId != ctEntry.getCtCollectionId()) ||
(modelClassNameId != ctEntry.getModelClassNameId()) ||
(modelClassPK != ctEntry.getModelClassPK())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(5);
sb.append(_SQL_SELECT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_MCNI_MCPK_CTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_C_MCNI_MCPK_MODELCLASSNAMEID_2);
sb.append(_FINDER_COLUMN_C_MCNI_MCPK_MODELCLASSPK_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
queryPos.add(modelClassNameId);
queryPos.add(modelClassPK);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByC_MCNI_MCPK, finderArgs, list);
}
}
else {
CTEntry ctEntry = list.get(0);
result = ctEntry;
cacheResult(ctEntry);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (CTEntry)result;
}
}
/**
* Removes the ct entry where ctCollectionId = ? and modelClassNameId = ? and modelClassPK = ? from the database.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @return the ct entry that was removed
*/
@Override
public CTEntry removeByC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long modelClassPK)
throws NoSuchEntryException {
CTEntry ctEntry = findByC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPK);
return remove(ctEntry);
}
/**
* Returns the number of ct entries where ctCollectionId = ? and modelClassNameId = ? and modelClassPK = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @return the number of matching ct entries
*/
@Override
public int countByC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long modelClassPK) {
FinderPath finderPath = _finderPathCountByC_MCNI_MCPK;
Object[] finderArgs = new Object[] {
ctCollectionId, modelClassNameId, modelClassPK
};
Long count = (Long)finderCache.getResult(finderPath, finderArgs);
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_MCNI_MCPK_CTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_C_MCNI_MCPK_MODELCLASSNAMEID_2);
sb.append(_FINDER_COLUMN_C_MCNI_MCPK_MODELCLASSPK_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
queryPos.add(modelClassNameId);
queryPos.add(modelClassPK);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_C_MCNI_MCPK_CTCOLLECTIONID_2 =
"ctEntry.ctCollectionId = ? AND ";
private static final String _FINDER_COLUMN_C_MCNI_MCPK_MODELCLASSNAMEID_2 =
"ctEntry.modelClassNameId = ? AND ";
private static final String _FINDER_COLUMN_C_MCNI_MCPK_MODELCLASSPK_2 =
"ctEntry.modelClassPK = ?";
private FinderPath _finderPathWithPaginationFindByNotC_MCNI_MCPK;
private FinderPath _finderPathWithPaginationCountByNotC_MCNI_MCPK;
/**
* Returns all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @return the matching ct entries
*/
@Override
public List findByNotC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long modelClassPK) {
return findByNotC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPK, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @return the range of matching ct entries
*/
@Override
public List findByNotC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long modelClassPK,
int start, int end) {
return findByNotC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPK, start, end, null);
}
/**
* Returns an ordered range of all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching ct entries
*/
@Override
public List findByNotC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long modelClassPK,
int start, int end, OrderByComparator orderByComparator) {
return findByNotC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPK, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching ct entries
*/
@Override
public List findByNotC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long modelClassPK,
int start, int end, OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
finderPath = _finderPathWithPaginationFindByNotC_MCNI_MCPK;
finderArgs = new Object[] {
ctCollectionId, modelClassNameId, modelClassPK, start, end,
orderByComparator
};
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (CTEntry ctEntry : list) {
if ((ctCollectionId == ctEntry.getCtCollectionId()) ||
(modelClassNameId != ctEntry.getModelClassNameId()) ||
(modelClassPK != ctEntry.getModelClassPK())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_CTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSNAMEID_2);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CTEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
queryPos.add(modelClassNameId);
queryPos.add(modelClassPK);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first ct entry in the ordered set where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching ct entry
* @throws NoSuchEntryException if a matching ct entry could not be found
*/
@Override
public CTEntry findByNotC_MCNI_MCPK_First(
long ctCollectionId, long modelClassNameId, long modelClassPK,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
CTEntry ctEntry = fetchByNotC_MCNI_MCPK_First(
ctCollectionId, modelClassNameId, modelClassPK, orderByComparator);
if (ctEntry != null) {
return ctEntry;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("ctCollectionId!=");
sb.append(ctCollectionId);
sb.append(", modelClassNameId=");
sb.append(modelClassNameId);
sb.append(", modelClassPK=");
sb.append(modelClassPK);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first ct entry in the ordered set where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching ct entry, or null
if a matching ct entry could not be found
*/
@Override
public CTEntry fetchByNotC_MCNI_MCPK_First(
long ctCollectionId, long modelClassNameId, long modelClassPK,
OrderByComparator orderByComparator) {
List list = findByNotC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPK, 0, 1,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last ct entry in the ordered set where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching ct entry
* @throws NoSuchEntryException if a matching ct entry could not be found
*/
@Override
public CTEntry findByNotC_MCNI_MCPK_Last(
long ctCollectionId, long modelClassNameId, long modelClassPK,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
CTEntry ctEntry = fetchByNotC_MCNI_MCPK_Last(
ctCollectionId, modelClassNameId, modelClassPK, orderByComparator);
if (ctEntry != null) {
return ctEntry;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("ctCollectionId!=");
sb.append(ctCollectionId);
sb.append(", modelClassNameId=");
sb.append(modelClassNameId);
sb.append(", modelClassPK=");
sb.append(modelClassPK);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last ct entry in the ordered set where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching ct entry, or null
if a matching ct entry could not be found
*/
@Override
public CTEntry fetchByNotC_MCNI_MCPK_Last(
long ctCollectionId, long modelClassNameId, long modelClassPK,
OrderByComparator orderByComparator) {
int count = countByNotC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPK);
if (count == 0) {
return null;
}
List list = findByNotC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPK, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the ct entries before and after the current ct entry in the ordered set where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?.
*
* @param ctEntryId the primary key of the current ct entry
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next ct entry
* @throws NoSuchEntryException if a ct entry with the primary key could not be found
*/
@Override
public CTEntry[] findByNotC_MCNI_MCPK_PrevAndNext(
long ctEntryId, long ctCollectionId, long modelClassNameId,
long modelClassPK, OrderByComparator orderByComparator)
throws NoSuchEntryException {
CTEntry ctEntry = findByPrimaryKey(ctEntryId);
Session session = null;
try {
session = openSession();
CTEntry[] array = new CTEntryImpl[3];
array[0] = getByNotC_MCNI_MCPK_PrevAndNext(
session, ctEntry, ctCollectionId, modelClassNameId,
modelClassPK, orderByComparator, true);
array[1] = ctEntry;
array[2] = getByNotC_MCNI_MCPK_PrevAndNext(
session, ctEntry, ctCollectionId, modelClassNameId,
modelClassPK, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected CTEntry getByNotC_MCNI_MCPK_PrevAndNext(
Session session, CTEntry ctEntry, long ctCollectionId,
long modelClassNameId, long modelClassPK,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_CTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSNAMEID_2);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(CTEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
queryPos.add(modelClassNameId);
queryPos.add(modelClassPK);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(ctEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPKs the model class pks
* @return the matching ct entries
*/
@Override
public List findByNotC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long[] modelClassPKs) {
return findByNotC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPKs, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPKs the model class pks
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @return the range of matching ct entries
*/
@Override
public List findByNotC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long[] modelClassPKs,
int start, int end) {
return findByNotC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPKs, start, end, null);
}
/**
* Returns an ordered range of all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPKs the model class pks
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching ct entries
*/
@Override
public List findByNotC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long[] modelClassPKs,
int start, int end, OrderByComparator orderByComparator) {
return findByNotC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPKs, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?, optionally using the finder cache.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching ct entries
*/
@Override
public List findByNotC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long[] modelClassPKs,
int start, int end, OrderByComparator orderByComparator,
boolean useFinderCache) {
if (modelClassPKs == null) {
modelClassPKs = new long[0];
}
else if (modelClassPKs.length > 1) {
modelClassPKs = ArrayUtil.sortedUnique(modelClassPKs);
}
if (modelClassPKs.length == 1) {
return findByNotC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPKs[0], start, end,
orderByComparator);
}
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderArgs = new Object[] {
ctCollectionId, modelClassNameId,
StringUtil.merge(modelClassPKs)
};
}
}
else if (useFinderCache) {
finderArgs = new Object[] {
ctCollectionId, modelClassNameId,
StringUtil.merge(modelClassPKs), start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
_finderPathWithPaginationFindByNotC_MCNI_MCPK, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (CTEntry ctEntry : list) {
if ((ctCollectionId == ctEntry.getCtCollectionId()) ||
(modelClassNameId != ctEntry.getModelClassNameId()) ||
!ArrayUtil.contains(
modelClassPKs, ctEntry.getModelClassPK())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = new StringBundler();
sb.append(_SQL_SELECT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_CTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSNAMEID_2);
if (modelClassPKs.length > 0) {
sb.append("(");
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_7);
sb.append(StringUtil.merge(modelClassPKs));
sb.append(")");
sb.append(")");
}
sb.setStringAt(
removeConjunction(sb.stringAt(sb.index() - 1)), sb.index() - 1);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(CTEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
queryPos.add(modelClassNameId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(
_finderPathWithPaginationFindByNotC_MCNI_MCPK,
finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ? from the database.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
*/
@Override
public void removeByNotC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long modelClassPK) {
for (CTEntry ctEntry :
findByNotC_MCNI_MCPK(
ctCollectionId, modelClassNameId, modelClassPK,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(ctEntry);
}
}
/**
* Returns the number of ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPK the model class pk
* @return the number of matching ct entries
*/
@Override
public int countByNotC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long modelClassPK) {
FinderPath finderPath = _finderPathWithPaginationCountByNotC_MCNI_MCPK;
Object[] finderArgs = new Object[] {
ctCollectionId, modelClassNameId, modelClassPK
};
Long count = (Long)finderCache.getResult(finderPath, finderArgs);
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_CTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSNAMEID_2);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
queryPos.add(modelClassNameId);
queryPos.add(modelClassPK);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of ct entries where ctCollectionId ≠ ? and modelClassNameId = ? and modelClassPK = any ?.
*
* @param ctCollectionId the ct collection ID
* @param modelClassNameId the model class name ID
* @param modelClassPKs the model class pks
* @return the number of matching ct entries
*/
@Override
public int countByNotC_MCNI_MCPK(
long ctCollectionId, long modelClassNameId, long[] modelClassPKs) {
if (modelClassPKs == null) {
modelClassPKs = new long[0];
}
else if (modelClassPKs.length > 1) {
modelClassPKs = ArrayUtil.sortedUnique(modelClassPKs);
}
Object[] finderArgs = new Object[] {
ctCollectionId, modelClassNameId, StringUtil.merge(modelClassPKs)
};
Long count = (Long)finderCache.getResult(
_finderPathWithPaginationCountByNotC_MCNI_MCPK, finderArgs);
if (count == null) {
StringBundler sb = new StringBundler();
sb.append(_SQL_COUNT_CTENTRY_WHERE);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_CTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSNAMEID_2);
if (modelClassPKs.length > 0) {
sb.append("(");
sb.append(_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_7);
sb.append(StringUtil.merge(modelClassPKs));
sb.append(")");
sb.append(")");
}
sb.setStringAt(
removeConjunction(sb.stringAt(sb.index() - 1)), sb.index() - 1);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(ctCollectionId);
queryPos.add(modelClassNameId);
count = (Long)query.uniqueResult();
finderCache.putResult(
_finderPathWithPaginationCountByNotC_MCNI_MCPK, finderArgs,
count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_NOTC_MCNI_MCPK_CTCOLLECTIONID_2 =
"ctEntry.ctCollectionId != ? AND ";
private static final String
_FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSNAMEID_2 =
"ctEntry.modelClassNameId = ? AND ";
private static final String _FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_2 =
"ctEntry.modelClassPK = ?";
private static final String _FINDER_COLUMN_NOTC_MCNI_MCPK_MODELCLASSPK_7 =
"ctEntry.modelClassPK IN (";
public CTEntryPersistenceImpl() {
setModelClass(CTEntry.class);
setModelImplClass(CTEntryImpl.class);
setModelPKClass(long.class);
setTable(CTEntryTable.INSTANCE);
}
/**
* Caches the ct entry in the entity cache if it is enabled.
*
* @param ctEntry the ct entry
*/
@Override
public void cacheResult(CTEntry ctEntry) {
entityCache.putResult(
CTEntryImpl.class, ctEntry.getPrimaryKey(), ctEntry);
finderCache.putResult(
_finderPathFetchByC_MCNI_MCPK,
new Object[] {
ctEntry.getCtCollectionId(), ctEntry.getModelClassNameId(),
ctEntry.getModelClassPK()
},
ctEntry);
}
/**
* Caches the ct entries in the entity cache if it is enabled.
*
* @param ctEntries the ct entries
*/
@Override
public void cacheResult(List ctEntries) {
for (CTEntry ctEntry : ctEntries) {
if (entityCache.getResult(
CTEntryImpl.class, ctEntry.getPrimaryKey()) == null) {
cacheResult(ctEntry);
}
}
}
/**
* Clears the cache for all ct entries.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache() {
entityCache.clearCache(CTEntryImpl.class);
finderCache.clearCache(CTEntryImpl.class);
}
/**
* Clears the cache for the ct entry.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache(CTEntry ctEntry) {
entityCache.removeResult(CTEntryImpl.class, ctEntry);
}
@Override
public void clearCache(List ctEntries) {
for (CTEntry ctEntry : ctEntries) {
entityCache.removeResult(CTEntryImpl.class, ctEntry);
}
}
@Override
public void clearCache(Set primaryKeys) {
finderCache.clearCache(CTEntryImpl.class);
for (Serializable primaryKey : primaryKeys) {
entityCache.removeResult(CTEntryImpl.class, primaryKey);
}
}
protected void cacheUniqueFindersCache(CTEntryModelImpl ctEntryModelImpl) {
Object[] args = new Object[] {
ctEntryModelImpl.getCtCollectionId(),
ctEntryModelImpl.getModelClassNameId(),
ctEntryModelImpl.getModelClassPK()
};
finderCache.putResult(
_finderPathCountByC_MCNI_MCPK, args, Long.valueOf(1));
finderCache.putResult(
_finderPathFetchByC_MCNI_MCPK, args, ctEntryModelImpl);
}
/**
* Creates a new ct entry with the primary key. Does not add the ct entry to the database.
*
* @param ctEntryId the primary key for the new ct entry
* @return the new ct entry
*/
@Override
public CTEntry create(long ctEntryId) {
CTEntry ctEntry = new CTEntryImpl();
ctEntry.setNew(true);
ctEntry.setPrimaryKey(ctEntryId);
ctEntry.setCompanyId(CompanyThreadLocal.getCompanyId());
return ctEntry;
}
/**
* Removes the ct entry with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param ctEntryId the primary key of the ct entry
* @return the ct entry that was removed
* @throws NoSuchEntryException if a ct entry with the primary key could not be found
*/
@Override
public CTEntry remove(long ctEntryId) throws NoSuchEntryException {
return remove((Serializable)ctEntryId);
}
/**
* Removes the ct entry with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param primaryKey the primary key of the ct entry
* @return the ct entry that was removed
* @throws NoSuchEntryException if a ct entry with the primary key could not be found
*/
@Override
public CTEntry remove(Serializable primaryKey) throws NoSuchEntryException {
Session session = null;
try {
session = openSession();
CTEntry ctEntry = (CTEntry)session.get(
CTEntryImpl.class, primaryKey);
if (ctEntry == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchEntryException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return remove(ctEntry);
}
catch (NoSuchEntryException noSuchEntityException) {
throw noSuchEntityException;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
@Override
protected CTEntry removeImpl(CTEntry ctEntry) {
Session session = null;
try {
session = openSession();
if (!session.contains(ctEntry)) {
ctEntry = (CTEntry)session.get(
CTEntryImpl.class, ctEntry.getPrimaryKeyObj());
}
if (ctEntry != null) {
session.delete(ctEntry);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
if (ctEntry != null) {
clearCache(ctEntry);
}
return ctEntry;
}
@Override
public CTEntry updateImpl(CTEntry ctEntry) {
boolean isNew = ctEntry.isNew();
if (!(ctEntry instanceof CTEntryModelImpl)) {
InvocationHandler invocationHandler = null;
if (ProxyUtil.isProxyClass(ctEntry.getClass())) {
invocationHandler = ProxyUtil.getInvocationHandler(ctEntry);
throw new IllegalArgumentException(
"Implement ModelWrapper in ctEntry proxy " +
invocationHandler.getClass());
}
throw new IllegalArgumentException(
"Implement ModelWrapper in custom CTEntry implementation " +
ctEntry.getClass());
}
CTEntryModelImpl ctEntryModelImpl = (CTEntryModelImpl)ctEntry;
ServiceContext serviceContext =
ServiceContextThreadLocal.getServiceContext();
Date date = new Date();
if (isNew && (ctEntry.getCreateDate() == null)) {
if (serviceContext == null) {
ctEntry.setCreateDate(date);
}
else {
ctEntry.setCreateDate(serviceContext.getCreateDate(date));
}
}
if (!ctEntryModelImpl.hasSetModifiedDate()) {
if (serviceContext == null) {
ctEntry.setModifiedDate(date);
}
else {
ctEntry.setModifiedDate(serviceContext.getModifiedDate(date));
}
}
Session session = null;
try {
session = openSession();
if (isNew) {
session.save(ctEntry);
}
else {
ctEntry = (CTEntry)session.merge(ctEntry);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
entityCache.putResult(CTEntryImpl.class, ctEntryModelImpl, false, true);
cacheUniqueFindersCache(ctEntryModelImpl);
if (isNew) {
ctEntry.setNew(false);
}
ctEntry.resetOriginalValues();
return ctEntry;
}
/**
* Returns the ct entry with the primary key or throws a com.liferay.portal.kernel.exception.NoSuchModelException
if it could not be found.
*
* @param primaryKey the primary key of the ct entry
* @return the ct entry
* @throws NoSuchEntryException if a ct entry with the primary key could not be found
*/
@Override
public CTEntry findByPrimaryKey(Serializable primaryKey)
throws NoSuchEntryException {
CTEntry ctEntry = fetchByPrimaryKey(primaryKey);
if (ctEntry == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchEntryException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return ctEntry;
}
/**
* Returns the ct entry with the primary key or throws a NoSuchEntryException
if it could not be found.
*
* @param ctEntryId the primary key of the ct entry
* @return the ct entry
* @throws NoSuchEntryException if a ct entry with the primary key could not be found
*/
@Override
public CTEntry findByPrimaryKey(long ctEntryId)
throws NoSuchEntryException {
return findByPrimaryKey((Serializable)ctEntryId);
}
/**
* Returns the ct entry with the primary key or returns null
if it could not be found.
*
* @param ctEntryId the primary key of the ct entry
* @return the ct entry, or null
if a ct entry with the primary key could not be found
*/
@Override
public CTEntry fetchByPrimaryKey(long ctEntryId) {
return fetchByPrimaryKey((Serializable)ctEntryId);
}
/**
* Returns all the ct entries.
*
* @return the ct entries
*/
@Override
public List findAll() {
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the ct entries.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @return the range of ct entries
*/
@Override
public List findAll(int start, int end) {
return findAll(start, end, null);
}
/**
* Returns an ordered range of all the ct entries.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of ct entries
*/
@Override
public List findAll(
int start, int end, OrderByComparator orderByComparator) {
return findAll(start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the ct entries.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from CTEntryModelImpl
.
*
*
* @param start the lower bound of the range of ct entries
* @param end the upper bound of the range of ct entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of ct entries
*/
@Override
public List findAll(
int start, int end, OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindAll;
finderArgs = FINDER_ARGS_EMPTY;
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindAll;
finderArgs = new Object[] {start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(finderPath, finderArgs);
}
if (list == null) {
StringBundler sb = null;
String sql = null;
if (orderByComparator != null) {
sb = new StringBundler(
2 + (orderByComparator.getOrderByFields().length * 2));
sb.append(_SQL_SELECT_CTENTRY);
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = sb.toString();
}
else {
sql = _SQL_SELECT_CTENTRY;
sql = sql.concat(CTEntryModelImpl.ORDER_BY_JPQL);
}
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the ct entries from the database.
*
*/
@Override
public void removeAll() {
for (CTEntry ctEntry : findAll()) {
remove(ctEntry);
}
}
/**
* Returns the number of ct entries.
*
* @return the number of ct entries
*/
@Override
public int countAll() {
Long count = (Long)finderCache.getResult(
_finderPathCountAll, FINDER_ARGS_EMPTY);
if (count == null) {
Session session = null;
try {
session = openSession();
Query query = session.createQuery(_SQL_COUNT_CTENTRY);
count = (Long)query.uniqueResult();
finderCache.putResult(
_finderPathCountAll, FINDER_ARGS_EMPTY, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
@Override
protected EntityCache getEntityCache() {
return entityCache;
}
@Override
protected String getPKDBName() {
return "ctEntryId";
}
@Override
protected String getSelectSQL() {
return _SQL_SELECT_CTENTRY;
}
@Override
protected Map getTableColumnsMap() {
return CTEntryModelImpl.TABLE_COLUMNS_MAP;
}
/**
* Initializes the ct entry persistence.
*/
@Activate
public void activate(BundleContext bundleContext) {
_bundleContext = bundleContext;
_argumentsResolverServiceRegistration = _bundleContext.registerService(
ArgumentsResolver.class, new CTEntryModelArgumentsResolver(),
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);
_finderPathWithPaginationFindByCTCollectionId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCTCollectionId",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"ctCollectionId"}, true);
_finderPathWithoutPaginationFindByCTCollectionId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCTCollectionId",
new String[] {Long.class.getName()},
new String[] {"ctCollectionId"}, true);
_finderPathCountByCTCollectionId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCTCollectionId",
new String[] {Long.class.getName()},
new String[] {"ctCollectionId"}, false);
_finderPathWithPaginationFindByC_MCNI = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_MCNI",
new String[] {
Long.class.getName(), Long.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
},
new String[] {"ctCollectionId", "modelClassNameId"}, true);
_finderPathWithoutPaginationFindByC_MCNI = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_MCNI",
new String[] {Long.class.getName(), Long.class.getName()},
new String[] {"ctCollectionId", "modelClassNameId"}, true);
_finderPathCountByC_MCNI = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_MCNI",
new String[] {Long.class.getName(), Long.class.getName()},
new String[] {"ctCollectionId", "modelClassNameId"}, false);
_finderPathFetchByC_MCNI_MCPK = new FinderPath(
FINDER_CLASS_NAME_ENTITY, "fetchByC_MCNI_MCPK",
new String[] {
Long.class.getName(), Long.class.getName(), Long.class.getName()
},
new String[] {"ctCollectionId", "modelClassNameId", "modelClassPK"},
true);
_finderPathCountByC_MCNI_MCPK = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_MCNI_MCPK",
new String[] {
Long.class.getName(), Long.class.getName(), Long.class.getName()
},
new String[] {"ctCollectionId", "modelClassNameId", "modelClassPK"},
false);
_finderPathWithPaginationFindByNotC_MCNI_MCPK = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByNotC_MCNI_MCPK",
new String[] {
Long.class.getName(), Long.class.getName(),
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"ctCollectionId", "modelClassNameId", "modelClassPK"},
true);
_finderPathWithPaginationCountByNotC_MCNI_MCPK = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByNotC_MCNI_MCPK",
new String[] {
Long.class.getName(), Long.class.getName(), Long.class.getName()
},
new String[] {"ctCollectionId", "modelClassNameId", "modelClassPK"},
false);
}
@Deactivate
public void deactivate() {
entityCache.removeCache(CTEntryImpl.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_CTENTRY =
"SELECT ctEntry FROM CTEntry ctEntry";
private static final String _SQL_SELECT_CTENTRY_WHERE =
"SELECT ctEntry FROM CTEntry ctEntry WHERE ";
private static final String _SQL_COUNT_CTENTRY =
"SELECT COUNT(ctEntry) FROM CTEntry ctEntry";
private static final String _SQL_COUNT_CTENTRY_WHERE =
"SELECT COUNT(ctEntry) FROM CTEntry ctEntry WHERE ";
private static final String _ORDER_BY_ENTITY_ALIAS = "ctEntry.";
private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY =
"No CTEntry exists with the primary key ";
private static final String _NO_SUCH_ENTITY_WITH_KEY =
"No CTEntry exists with the key {";
private static final Log _log = LogFactoryUtil.getLog(
CTEntryPersistenceImpl.class);
@Override
protected FinderCache getFinderCache() {
return finderCache;
}
private ServiceRegistration
_argumentsResolverServiceRegistration;
private static class CTEntryModelArgumentsResolver
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;
}
CTEntryModelImpl ctEntryModelImpl = (CTEntryModelImpl)baseModel;
long columnBitmask = ctEntryModelImpl.getColumnBitmask();
if (!checkColumn || (columnBitmask == 0)) {
return _getValue(ctEntryModelImpl, columnNames, original);
}
Long finderPathColumnBitmask = _finderPathColumnBitmasksCache.get(
finderPath);
if (finderPathColumnBitmask == null) {
finderPathColumnBitmask = 0L;
for (String columnName : columnNames) {
finderPathColumnBitmask |=
ctEntryModelImpl.getColumnBitmask(columnName);
}
_finderPathColumnBitmasksCache.put(
finderPath, finderPathColumnBitmask);
}
if ((columnBitmask & finderPathColumnBitmask) != 0) {
return _getValue(ctEntryModelImpl, columnNames, original);
}
return null;
}
@Override
public String getClassName() {
return CTEntryImpl.class.getName();
}
@Override
public String getTableName() {
return CTEntryTable.INSTANCE.getTableName();
}
private static Object[] _getValue(
CTEntryModelImpl ctEntryModelImpl, 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] = ctEntryModelImpl.getColumnOriginalValue(
columnName);
}
else {
arguments[i] = ctEntryModelImpl.getColumnValue(columnName);
}
}
return arguments;
}
private static final Map
_finderPathColumnBitmasksCache = new ConcurrentHashMap<>();
}
}