com.liferay.fragment.service.persistence.impl.FragmentEntryVersionPersistenceImpl Maven / Gradle / Ivy
/**
* 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.fragment.service.persistence.impl;
import com.liferay.fragment.exception.NoSuchEntryVersionException;
import com.liferay.fragment.model.FragmentEntryVersion;
import com.liferay.fragment.model.FragmentEntryVersionTable;
import com.liferay.fragment.model.impl.FragmentEntryVersionImpl;
import com.liferay.fragment.model.impl.FragmentEntryVersionModelImpl;
import com.liferay.fragment.service.persistence.FragmentEntryVersionPersistence;
import com.liferay.fragment.service.persistence.FragmentEntryVersionUtil;
import com.liferay.fragment.service.persistence.impl.constants.FragmentPersistenceConstants;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.change.tracking.CTColumnResolutionType;
import com.liferay.portal.kernel.configuration.Configuration;
import com.liferay.portal.kernel.dao.orm.EntityCache;
import com.liferay.portal.kernel.dao.orm.FinderCache;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.dao.orm.SessionFactory;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.BasePersistence;
import com.liferay.portal.kernel.service.persistence.change.tracking.helper.CTPersistenceHelper;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.sql.DataSource;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
/**
* The persistence implementation for the fragment entry version service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Brian Wing Shun Chan
* @generated
*/
@Component(
service = {FragmentEntryVersionPersistence.class, BasePersistence.class}
)
public class FragmentEntryVersionPersistenceImpl
extends BasePersistenceImpl
implements FragmentEntryVersionPersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use FragmentEntryVersionUtil
to access the fragment entry version persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY =
FragmentEntryVersionImpl.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 _finderPathWithPaginationFindByFragmentEntryId;
private FinderPath _finderPathWithoutPaginationFindByFragmentEntryId;
private FinderPath _finderPathCountByFragmentEntryId;
/**
* Returns all the fragment entry versions where fragmentEntryId = ?.
*
* @param fragmentEntryId the fragment entry ID
* @return the matching fragment entry versions
*/
@Override
public List findByFragmentEntryId(
long fragmentEntryId) {
return findByFragmentEntryId(
fragmentEntryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the fragment entry versions where fragmentEntryId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param fragmentEntryId the fragment entry ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByFragmentEntryId(
long fragmentEntryId, int start, int end) {
return findByFragmentEntryId(fragmentEntryId, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where fragmentEntryId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param fragmentEntryId the fragment entry ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByFragmentEntryId(
long fragmentEntryId, int start, int end,
OrderByComparator orderByComparator) {
return findByFragmentEntryId(
fragmentEntryId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where fragmentEntryId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param fragmentEntryId the fragment entry ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByFragmentEntryId(
long fragmentEntryId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByFragmentEntryId;
finderArgs = new Object[] {fragmentEntryId};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByFragmentEntryId;
finderArgs = new Object[] {
fragmentEntryId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if (fragmentEntryId !=
fragmentEntryVersion.getFragmentEntryId()) {
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_FRAGMENTENTRYID_FRAGMENTENTRYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.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(fragmentEntryId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where fragmentEntryId = ?.
*
* @param fragmentEntryId the fragment entry ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByFragmentEntryId_First(
long fragmentEntryId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion =
fetchByFragmentEntryId_First(fragmentEntryId, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("fragmentEntryId=");
sb.append(fragmentEntryId);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where fragmentEntryId = ?.
*
* @param fragmentEntryId the fragment entry ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByFragmentEntryId_First(
long fragmentEntryId,
OrderByComparator orderByComparator) {
List list = findByFragmentEntryId(
fragmentEntryId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where fragmentEntryId = ?.
*
* @param fragmentEntryId the fragment entry ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByFragmentEntryId_Last(
long fragmentEntryId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByFragmentEntryId_Last(
fragmentEntryId, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("fragmentEntryId=");
sb.append(fragmentEntryId);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where fragmentEntryId = ?.
*
* @param fragmentEntryId the fragment entry ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByFragmentEntryId_Last(
long fragmentEntryId,
OrderByComparator orderByComparator) {
int count = countByFragmentEntryId(fragmentEntryId);
if (count == 0) {
return null;
}
List list = findByFragmentEntryId(
fragmentEntryId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where fragmentEntryId = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param fragmentEntryId the fragment entry ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[] findByFragmentEntryId_PrevAndNext(
long fragmentEntryVersionId, long fragmentEntryId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByFragmentEntryId_PrevAndNext(
session, fragmentEntryVersion, fragmentEntryId,
orderByComparator, true);
array[1] = fragmentEntryVersion;
array[2] = getByFragmentEntryId_PrevAndNext(
session, fragmentEntryVersion, fragmentEntryId,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion getByFragmentEntryId_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion,
long fragmentEntryId,
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_FRAGMENTENTRYID_FRAGMENTENTRYID_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(FragmentEntryVersionModelImpl.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(fragmentEntryId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where fragmentEntryId = ? from the database.
*
* @param fragmentEntryId the fragment entry ID
*/
@Override
public void removeByFragmentEntryId(long fragmentEntryId) {
for (FragmentEntryVersion fragmentEntryVersion :
findByFragmentEntryId(
fragmentEntryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where fragmentEntryId = ?.
*
* @param fragmentEntryId the fragment entry ID
* @return the number of matching fragment entry versions
*/
@Override
public int countByFragmentEntryId(long fragmentEntryId) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByFragmentEntryId;
finderArgs = new Object[] {fragmentEntryId};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_FRAGMENTENTRYID_FRAGMENTENTRYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(fragmentEntryId);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String
_FINDER_COLUMN_FRAGMENTENTRYID_FRAGMENTENTRYID_2 =
"fragmentEntryVersion.fragmentEntryId = ?";
private FinderPath _finderPathFetchByFragmentEntryId_Version;
private FinderPath _finderPathCountByFragmentEntryId_Version;
/**
* Returns the fragment entry version where fragmentEntryId = ? and version = ? or throws a NoSuchEntryVersionException
if it could not be found.
*
* @param fragmentEntryId the fragment entry ID
* @param version the version
* @return the matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByFragmentEntryId_Version(
long fragmentEntryId, int version)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion =
fetchByFragmentEntryId_Version(fragmentEntryId, version);
if (fragmentEntryVersion == null) {
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("fragmentEntryId=");
sb.append(fragmentEntryId);
sb.append(", version=");
sb.append(version);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchEntryVersionException(sb.toString());
}
return fragmentEntryVersion;
}
/**
* Returns the fragment entry version where fragmentEntryId = ? and version = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param fragmentEntryId the fragment entry ID
* @param version the version
* @return the matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByFragmentEntryId_Version(
long fragmentEntryId, int version) {
return fetchByFragmentEntryId_Version(fragmentEntryId, version, true);
}
/**
* Returns the fragment entry version where fragmentEntryId = ? and version = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param fragmentEntryId the fragment entry ID
* @param version the version
* @param useFinderCache whether to use the finder cache
* @return the matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByFragmentEntryId_Version(
long fragmentEntryId, int version, boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
Object[] finderArgs = null;
if (useFinderCache && productionMode) {
finderArgs = new Object[] {fragmentEntryId, version};
}
Object result = null;
if (useFinderCache && productionMode) {
result = finderCache.getResult(
_finderPathFetchByFragmentEntryId_Version, finderArgs);
}
if (result instanceof FragmentEntryVersion) {
FragmentEntryVersion fragmentEntryVersion =
(FragmentEntryVersion)result;
if ((fragmentEntryId !=
fragmentEntryVersion.getFragmentEntryId()) ||
(version != fragmentEntryVersion.getVersion())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_SELECT_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_FRAGMENTENTRYID_VERSION_FRAGMENTENTRYID_2);
sb.append(_FINDER_COLUMN_FRAGMENTENTRYID_VERSION_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(fragmentEntryId);
queryPos.add(version);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache && productionMode) {
finderCache.putResult(
_finderPathFetchByFragmentEntryId_Version,
finderArgs, list);
}
}
else {
FragmentEntryVersion fragmentEntryVersion = list.get(0);
result = fragmentEntryVersion;
cacheResult(fragmentEntryVersion);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (FragmentEntryVersion)result;
}
}
/**
* Removes the fragment entry version where fragmentEntryId = ? and version = ? from the database.
*
* @param fragmentEntryId the fragment entry ID
* @param version the version
* @return the fragment entry version that was removed
*/
@Override
public FragmentEntryVersion removeByFragmentEntryId_Version(
long fragmentEntryId, int version)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion =
findByFragmentEntryId_Version(fragmentEntryId, version);
return remove(fragmentEntryVersion);
}
/**
* Returns the number of fragment entry versions where fragmentEntryId = ? and version = ?.
*
* @param fragmentEntryId the fragment entry ID
* @param version the version
* @return the number of matching fragment entry versions
*/
@Override
public int countByFragmentEntryId_Version(
long fragmentEntryId, int version) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByFragmentEntryId_Version;
finderArgs = new Object[] {fragmentEntryId, version};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_FRAGMENTENTRYID_VERSION_FRAGMENTENTRYID_2);
sb.append(_FINDER_COLUMN_FRAGMENTENTRYID_VERSION_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(fragmentEntryId);
queryPos.add(version);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String
_FINDER_COLUMN_FRAGMENTENTRYID_VERSION_FRAGMENTENTRYID_2 =
"fragmentEntryVersion.fragmentEntryId = ? AND ";
private static final String
_FINDER_COLUMN_FRAGMENTENTRYID_VERSION_VERSION_2 =
"fragmentEntryVersion.version = ?";
private FinderPath _finderPathWithPaginationFindByUuid;
private FinderPath _finderPathWithoutPaginationFindByUuid;
private FinderPath _finderPathCountByUuid;
/**
* Returns all the fragment entry versions where uuid = ?.
*
* @param uuid the uuid
* @return the matching fragment entry versions
*/
@Override
public List findByUuid(String uuid) {
return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the fragment entry versions where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByUuid(
String uuid, int start, int end) {
return findByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid(uuid, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByUuid;
finderArgs = new Object[] {uuid};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByUuid;
finderArgs = new Object[] {uuid, start, end, orderByComparator};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if (!uuid.equals(fragmentEntryVersion.getUuid())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByUuid_First(
String uuid,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByUuid_First(
uuid, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByUuid_First(
String uuid,
OrderByComparator orderByComparator) {
List list = findByUuid(
uuid, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByUuid_Last(
String uuid,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByUuid_Last(
uuid, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByUuid_Last(
String uuid,
OrderByComparator orderByComparator) {
int count = countByUuid(uuid);
if (count == 0) {
return null;
}
List list = findByUuid(
uuid, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where uuid = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[] findByUuid_PrevAndNext(
long fragmentEntryVersionId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
uuid = Objects.toString(uuid, "");
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByUuid_PrevAndNext(
session, fragmentEntryVersion, uuid, orderByComparator, true);
array[1] = fragmentEntryVersion;
array[2] = getByUuid_PrevAndNext(
session, fragmentEntryVersion, uuid, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion getByUuid_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion, String uuid,
OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(FragmentEntryVersionModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
for (FragmentEntryVersion fragmentEntryVersion :
findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching fragment entry versions
*/
@Override
public int countByUuid(String uuid) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByUuid;
finderArgs = new Object[] {uuid};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_UUID_2 =
"fragmentEntryVersion.uuid = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3 =
"(fragmentEntryVersion.uuid IS NULL OR fragmentEntryVersion.uuid = '')";
private FinderPath _finderPathWithPaginationFindByUuid_Version;
private FinderPath _finderPathWithoutPaginationFindByUuid_Version;
private FinderPath _finderPathCountByUuid_Version;
/**
* Returns all the fragment entry versions where uuid = ? and version = ?.
*
* @param uuid the uuid
* @param version the version
* @return the matching fragment entry versions
*/
@Override
public List findByUuid_Version(
String uuid, int version) {
return findByUuid_Version(
uuid, version, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the fragment entry versions where uuid = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByUuid_Version(
String uuid, int version, int start, int end) {
return findByUuid_Version(uuid, version, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where uuid = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByUuid_Version(
String uuid, int version, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid_Version(
uuid, version, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where uuid = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByUuid_Version(
String uuid, int version, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByUuid_Version;
finderArgs = new Object[] {uuid, version};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByUuid_Version;
finderArgs = new Object[] {
uuid, version, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if (!uuid.equals(fragmentEntryVersion.getUuid()) ||
(version != fragmentEntryVersion.getVersion())) {
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_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_VERSION_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_VERSION_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_VERSION_VERSION_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(version);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where uuid = ? and version = ?.
*
* @param uuid the uuid
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByUuid_Version_First(
String uuid, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByUuid_Version_First(
uuid, version, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", version=");
sb.append(version);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where uuid = ? and version = ?.
*
* @param uuid the uuid
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByUuid_Version_First(
String uuid, int version,
OrderByComparator orderByComparator) {
List list = findByUuid_Version(
uuid, version, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where uuid = ? and version = ?.
*
* @param uuid the uuid
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByUuid_Version_Last(
String uuid, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByUuid_Version_Last(
uuid, version, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", version=");
sb.append(version);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where uuid = ? and version = ?.
*
* @param uuid the uuid
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByUuid_Version_Last(
String uuid, int version,
OrderByComparator orderByComparator) {
int count = countByUuid_Version(uuid, version);
if (count == 0) {
return null;
}
List list = findByUuid_Version(
uuid, version, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where uuid = ? and version = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param uuid the uuid
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[] findByUuid_Version_PrevAndNext(
long fragmentEntryVersionId, String uuid, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
uuid = Objects.toString(uuid, "");
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByUuid_Version_PrevAndNext(
session, fragmentEntryVersion, uuid, version, orderByComparator,
true);
array[1] = fragmentEntryVersion;
array[2] = getByUuid_Version_PrevAndNext(
session, fragmentEntryVersion, uuid, version, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion getByUuid_Version_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion, String uuid,
int version, 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_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_VERSION_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_VERSION_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_VERSION_VERSION_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(FragmentEntryVersionModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(version);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where uuid = ? and version = ? from the database.
*
* @param uuid the uuid
* @param version the version
*/
@Override
public void removeByUuid_Version(String uuid, int version) {
for (FragmentEntryVersion fragmentEntryVersion :
findByUuid_Version(
uuid, version, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where uuid = ? and version = ?.
*
* @param uuid the uuid
* @param version the version
* @return the number of matching fragment entry versions
*/
@Override
public int countByUuid_Version(String uuid, int version) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByUuid_Version;
finderArgs = new Object[] {uuid, version};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_VERSION_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_VERSION_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_VERSION_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(version);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_VERSION_UUID_2 =
"fragmentEntryVersion.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_VERSION_UUID_3 =
"(fragmentEntryVersion.uuid IS NULL OR fragmentEntryVersion.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_VERSION_VERSION_2 =
"fragmentEntryVersion.version = ?";
private FinderPath _finderPathWithPaginationFindByUUID_G;
private FinderPath _finderPathWithoutPaginationFindByUUID_G;
private FinderPath _finderPathCountByUUID_G;
/**
* Returns all the fragment entry versions where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching fragment entry versions
*/
@Override
public List findByUUID_G(String uuid, long groupId) {
return findByUUID_G(
uuid, groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the fragment entry versions where uuid = ? and groupId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param groupId the group ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByUUID_G(
String uuid, long groupId, int start, int end) {
return findByUUID_G(uuid, groupId, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where uuid = ? and groupId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param groupId the group ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByUUID_G(
String uuid, long groupId, int start, int end,
OrderByComparator orderByComparator) {
return findByUUID_G(uuid, groupId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where uuid = ? and groupId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param groupId the group ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByUUID_G(
String uuid, long groupId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByUUID_G;
finderArgs = new Object[] {uuid, groupId};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByUUID_G;
finderArgs = new Object[] {
uuid, groupId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if (!uuid.equals(fragmentEntryVersion.getUuid()) ||
(groupId != fragmentEntryVersion.getGroupId())) {
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_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(groupId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByUUID_G_First(
String uuid, long groupId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByUUID_G_First(
uuid, groupId, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", groupId=");
sb.append(groupId);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByUUID_G_First(
String uuid, long groupId,
OrderByComparator orderByComparator) {
List list = findByUUID_G(
uuid, groupId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByUUID_G_Last(
String uuid, long groupId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByUUID_G_Last(
uuid, groupId, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", groupId=");
sb.append(groupId);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByUUID_G_Last(
String uuid, long groupId,
OrderByComparator orderByComparator) {
int count = countByUUID_G(uuid, groupId);
if (count == 0) {
return null;
}
List list = findByUUID_G(
uuid, groupId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where uuid = ? and groupId = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param uuid the uuid
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[] findByUUID_G_PrevAndNext(
long fragmentEntryVersionId, String uuid, long groupId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
uuid = Objects.toString(uuid, "");
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByUUID_G_PrevAndNext(
session, fragmentEntryVersion, uuid, groupId, orderByComparator,
true);
array[1] = fragmentEntryVersion;
array[2] = getByUUID_G_PrevAndNext(
session, fragmentEntryVersion, uuid, groupId, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion getByUUID_G_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion, String uuid,
long groupId, 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_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_G_GROUPID_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(FragmentEntryVersionModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(groupId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where uuid = ? and groupId = ? from the database.
*
* @param uuid the uuid
* @param groupId the group ID
*/
@Override
public void removeByUUID_G(String uuid, long groupId) {
for (FragmentEntryVersion fragmentEntryVersion :
findByUUID_G(
uuid, groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the number of matching fragment entry versions
*/
@Override
public int countByUUID_G(String uuid, long groupId) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByUUID_G;
finderArgs = new Object[] {uuid, groupId};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(groupId);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_G_UUID_2 =
"fragmentEntryVersion.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_G_UUID_3 =
"(fragmentEntryVersion.uuid IS NULL OR fragmentEntryVersion.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 =
"fragmentEntryVersion.groupId = ?";
private FinderPath _finderPathFetchByUUID_G_Version;
private FinderPath _finderPathCountByUUID_G_Version;
/**
* Returns the fragment entry version where uuid = ? and groupId = ? and version = ? or throws a NoSuchEntryVersionException
if it could not be found.
*
* @param uuid the uuid
* @param groupId the group ID
* @param version the version
* @return the matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByUUID_G_Version(
String uuid, long groupId, int version)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByUUID_G_Version(
uuid, groupId, version);
if (fragmentEntryVersion == null) {
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", groupId=");
sb.append(groupId);
sb.append(", version=");
sb.append(version);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchEntryVersionException(sb.toString());
}
return fragmentEntryVersion;
}
/**
* Returns the fragment entry version where uuid = ? and groupId = ? and version = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @param version the version
* @return the matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByUUID_G_Version(
String uuid, long groupId, int version) {
return fetchByUUID_G_Version(uuid, groupId, version, true);
}
/**
* Returns the fragment entry version where uuid = ? and groupId = ? and version = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @param version the version
* @param useFinderCache whether to use the finder cache
* @return the matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByUUID_G_Version(
String uuid, long groupId, int version, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
Object[] finderArgs = null;
if (useFinderCache && productionMode) {
finderArgs = new Object[] {uuid, groupId, version};
}
Object result = null;
if (useFinderCache && productionMode) {
result = finderCache.getResult(
_finderPathFetchByUUID_G_Version, finderArgs);
}
if (result instanceof FragmentEntryVersion) {
FragmentEntryVersion fragmentEntryVersion =
(FragmentEntryVersion)result;
if (!Objects.equals(uuid, fragmentEntryVersion.getUuid()) ||
(groupId != fragmentEntryVersion.getGroupId()) ||
(version != fragmentEntryVersion.getVersion())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(5);
sb.append(_SQL_SELECT_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_G_VERSION_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_G_VERSION_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_G_VERSION_GROUPID_2);
sb.append(_FINDER_COLUMN_UUID_G_VERSION_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(groupId);
queryPos.add(version);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache && productionMode) {
finderCache.putResult(
_finderPathFetchByUUID_G_Version, finderArgs, list);
}
}
else {
FragmentEntryVersion fragmentEntryVersion = list.get(0);
result = fragmentEntryVersion;
cacheResult(fragmentEntryVersion);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (FragmentEntryVersion)result;
}
}
/**
* Removes the fragment entry version where uuid = ? and groupId = ? and version = ? from the database.
*
* @param uuid the uuid
* @param groupId the group ID
* @param version the version
* @return the fragment entry version that was removed
*/
@Override
public FragmentEntryVersion removeByUUID_G_Version(
String uuid, long groupId, int version)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = findByUUID_G_Version(
uuid, groupId, version);
return remove(fragmentEntryVersion);
}
/**
* Returns the number of fragment entry versions where uuid = ? and groupId = ? and version = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @param version the version
* @return the number of matching fragment entry versions
*/
@Override
public int countByUUID_G_Version(String uuid, long groupId, int version) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByUUID_G_Version;
finderArgs = new Object[] {uuid, groupId, version};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_G_VERSION_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_G_VERSION_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_G_VERSION_GROUPID_2);
sb.append(_FINDER_COLUMN_UUID_G_VERSION_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(groupId);
queryPos.add(version);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_G_VERSION_UUID_2 =
"fragmentEntryVersion.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_G_VERSION_UUID_3 =
"(fragmentEntryVersion.uuid IS NULL OR fragmentEntryVersion.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_G_VERSION_GROUPID_2 =
"fragmentEntryVersion.groupId = ? AND ";
private static final String _FINDER_COLUMN_UUID_G_VERSION_VERSION_2 =
"fragmentEntryVersion.version = ?";
private FinderPath _finderPathWithPaginationFindByUuid_C;
private FinderPath _finderPathWithoutPaginationFindByUuid_C;
private FinderPath _finderPathCountByUuid_C;
/**
* Returns all the fragment entry versions where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching fragment entry versions
*/
@Override
public List findByUuid_C(
String uuid, long companyId) {
return findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the fragment entry versions where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end) {
return findByUuid_C(uuid, companyId, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid_C(
uuid, companyId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByUuid_C;
finderArgs = new Object[] {uuid, companyId};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByUuid_C;
finderArgs = new Object[] {
uuid, companyId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if (!uuid.equals(fragmentEntryVersion.getUuid()) ||
(companyId != fragmentEntryVersion.getCompanyId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByUuid_C_First(
uuid, companyId, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator) {
List list = findByUuid_C(
uuid, companyId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByUuid_C_Last(
uuid, companyId, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator) {
int count = countByUuid_C(uuid, companyId);
if (count == 0) {
return null;
}
List list = findByUuid_C(
uuid, companyId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where uuid = ? and companyId = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[] findByUuid_C_PrevAndNext(
long fragmentEntryVersionId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
uuid = Objects.toString(uuid, "");
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByUuid_C_PrevAndNext(
session, fragmentEntryVersion, uuid, companyId,
orderByComparator, true);
array[1] = fragmentEntryVersion;
array[2] = getByUuid_C_PrevAndNext(
session, fragmentEntryVersion, uuid, companyId,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion getByUuid_C_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion, String uuid,
long companyId,
OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(FragmentEntryVersionModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where uuid = ? and companyId = ? from the database.
*
* @param uuid the uuid
* @param companyId the company ID
*/
@Override
public void removeByUuid_C(String uuid, long companyId) {
for (FragmentEntryVersion fragmentEntryVersion :
findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching fragment entry versions
*/
@Override
public int countByUuid_C(String uuid, long companyId) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByUuid_C;
finderArgs = new Object[] {uuid, companyId};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_C_UUID_2 =
"fragmentEntryVersion.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3 =
"(fragmentEntryVersion.uuid IS NULL OR fragmentEntryVersion.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 =
"fragmentEntryVersion.companyId = ?";
private FinderPath _finderPathWithPaginationFindByUuid_C_Version;
private FinderPath _finderPathWithoutPaginationFindByUuid_C_Version;
private FinderPath _finderPathCountByUuid_C_Version;
/**
* Returns all the fragment entry versions where uuid = ? and companyId = ? and version = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param version the version
* @return the matching fragment entry versions
*/
@Override
public List findByUuid_C_Version(
String uuid, long companyId, int version) {
return findByUuid_C_Version(
uuid, companyId, version, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the fragment entry versions where uuid = ? and companyId = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByUuid_C_Version(
String uuid, long companyId, int version, int start, int end) {
return findByUuid_C_Version(uuid, companyId, version, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where uuid = ? and companyId = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByUuid_C_Version(
String uuid, long companyId, int version, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid_C_Version(
uuid, companyId, version, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where uuid = ? and companyId = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByUuid_C_Version(
String uuid, long companyId, int version, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByUuid_C_Version;
finderArgs = new Object[] {uuid, companyId, version};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByUuid_C_Version;
finderArgs = new Object[] {
uuid, companyId, version, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if (!uuid.equals(fragmentEntryVersion.getUuid()) ||
(companyId != fragmentEntryVersion.getCompanyId()) ||
(version != fragmentEntryVersion.getVersion())) {
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_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_VERSION_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_VERSION_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_VERSION_COMPANYID_2);
sb.append(_FINDER_COLUMN_UUID_C_VERSION_VERSION_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
queryPos.add(version);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where uuid = ? and companyId = ? and version = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByUuid_C_Version_First(
String uuid, long companyId, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByUuid_C_Version_First(
uuid, companyId, version, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append(", version=");
sb.append(version);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where uuid = ? and companyId = ? and version = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByUuid_C_Version_First(
String uuid, long companyId, int version,
OrderByComparator orderByComparator) {
List list = findByUuid_C_Version(
uuid, companyId, version, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where uuid = ? and companyId = ? and version = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByUuid_C_Version_Last(
String uuid, long companyId, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByUuid_C_Version_Last(
uuid, companyId, version, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append(", version=");
sb.append(version);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where uuid = ? and companyId = ? and version = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByUuid_C_Version_Last(
String uuid, long companyId, int version,
OrderByComparator orderByComparator) {
int count = countByUuid_C_Version(uuid, companyId, version);
if (count == 0) {
return null;
}
List list = findByUuid_C_Version(
uuid, companyId, version, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where uuid = ? and companyId = ? and version = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param uuid the uuid
* @param companyId the company ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[] findByUuid_C_Version_PrevAndNext(
long fragmentEntryVersionId, String uuid, long companyId,
int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
uuid = Objects.toString(uuid, "");
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByUuid_C_Version_PrevAndNext(
session, fragmentEntryVersion, uuid, companyId, version,
orderByComparator, true);
array[1] = fragmentEntryVersion;
array[2] = getByUuid_C_Version_PrevAndNext(
session, fragmentEntryVersion, uuid, companyId, version,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion getByUuid_C_Version_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion, String uuid,
long companyId, int version,
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_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_VERSION_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_VERSION_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_VERSION_COMPANYID_2);
sb.append(_FINDER_COLUMN_UUID_C_VERSION_VERSION_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(FragmentEntryVersionModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
queryPos.add(version);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where uuid = ? and companyId = ? and version = ? from the database.
*
* @param uuid the uuid
* @param companyId the company ID
* @param version the version
*/
@Override
public void removeByUuid_C_Version(
String uuid, long companyId, int version) {
for (FragmentEntryVersion fragmentEntryVersion :
findByUuid_C_Version(
uuid, companyId, version, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where uuid = ? and companyId = ? and version = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param version the version
* @return the number of matching fragment entry versions
*/
@Override
public int countByUuid_C_Version(String uuid, long companyId, int version) {
uuid = Objects.toString(uuid, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByUuid_C_Version;
finderArgs = new Object[] {uuid, companyId, version};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_VERSION_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_VERSION_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_VERSION_COMPANYID_2);
sb.append(_FINDER_COLUMN_UUID_C_VERSION_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
queryPos.add(version);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_UUID_C_VERSION_UUID_2 =
"fragmentEntryVersion.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_VERSION_UUID_3 =
"(fragmentEntryVersion.uuid IS NULL OR fragmentEntryVersion.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_VERSION_COMPANYID_2 =
"fragmentEntryVersion.companyId = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_VERSION_VERSION_2 =
"fragmentEntryVersion.version = ?";
private FinderPath _finderPathWithPaginationFindByGroupId;
private FinderPath _finderPathWithoutPaginationFindByGroupId;
private FinderPath _finderPathCountByGroupId;
/**
* Returns all the fragment entry versions where groupId = ?.
*
* @param groupId the group ID
* @return the matching fragment entry versions
*/
@Override
public List findByGroupId(long groupId) {
return findByGroupId(
groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the fragment entry versions where groupId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByGroupId(
long groupId, int start, int end) {
return findByGroupId(groupId, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where groupId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByGroupId(
long groupId, int start, int end,
OrderByComparator orderByComparator) {
return findByGroupId(groupId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where groupId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByGroupId(
long groupId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByGroupId;
finderArgs = new Object[] {groupId};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByGroupId;
finderArgs = new Object[] {groupId, start, end, orderByComparator};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if (groupId != fragmentEntryVersion.getGroupId()) {
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.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(groupId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByGroupId_First(
long groupId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByGroupId_First(
groupId, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByGroupId_First(
long groupId,
OrderByComparator orderByComparator) {
List list = findByGroupId(
groupId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByGroupId_Last(
long groupId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByGroupId_Last(
groupId, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where groupId = ?.
*
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByGroupId_Last(
long groupId,
OrderByComparator orderByComparator) {
int count = countByGroupId(groupId);
if (count == 0) {
return null;
}
List list = findByGroupId(
groupId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where groupId = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param groupId the group ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[] findByGroupId_PrevAndNext(
long fragmentEntryVersionId, long groupId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByGroupId_PrevAndNext(
session, fragmentEntryVersion, groupId, orderByComparator,
true);
array[1] = fragmentEntryVersion;
array[2] = getByGroupId_PrevAndNext(
session, fragmentEntryVersion, groupId, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion getByGroupId_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion,
long groupId, 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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_GROUPID_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(FragmentEntryVersionModelImpl.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(groupId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where groupId = ? from the database.
*
* @param groupId the group ID
*/
@Override
public void removeByGroupId(long groupId) {
for (FragmentEntryVersion fragmentEntryVersion :
findByGroupId(
groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where groupId = ?.
*
* @param groupId the group ID
* @return the number of matching fragment entry versions
*/
@Override
public int countByGroupId(long groupId) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByGroupId;
finderArgs = new Object[] {groupId};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 =
"fragmentEntryVersion.groupId = ?";
private FinderPath _finderPathWithPaginationFindByGroupId_Version;
private FinderPath _finderPathWithoutPaginationFindByGroupId_Version;
private FinderPath _finderPathCountByGroupId_Version;
/**
* Returns all the fragment entry versions where groupId = ? and version = ?.
*
* @param groupId the group ID
* @param version the version
* @return the matching fragment entry versions
*/
@Override
public List findByGroupId_Version(
long groupId, int version) {
return findByGroupId_Version(
groupId, version, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the fragment entry versions where groupId = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByGroupId_Version(
long groupId, int version, int start, int end) {
return findByGroupId_Version(groupId, version, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where groupId = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByGroupId_Version(
long groupId, int version, int start, int end,
OrderByComparator orderByComparator) {
return findByGroupId_Version(
groupId, version, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where groupId = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByGroupId_Version(
long groupId, int version, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByGroupId_Version;
finderArgs = new Object[] {groupId, version};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByGroupId_Version;
finderArgs = new Object[] {
groupId, version, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if ((groupId != fragmentEntryVersion.getGroupId()) ||
(version != fragmentEntryVersion.getVersion())) {
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_VERSION_GROUPID_2);
sb.append(_FINDER_COLUMN_GROUPID_VERSION_VERSION_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.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(groupId);
queryPos.add(version);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where groupId = ? and version = ?.
*
* @param groupId the group ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByGroupId_Version_First(
long groupId, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion =
fetchByGroupId_Version_First(groupId, version, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", version=");
sb.append(version);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where groupId = ? and version = ?.
*
* @param groupId the group ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByGroupId_Version_First(
long groupId, int version,
OrderByComparator orderByComparator) {
List list = findByGroupId_Version(
groupId, version, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where groupId = ? and version = ?.
*
* @param groupId the group ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByGroupId_Version_Last(
long groupId, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByGroupId_Version_Last(
groupId, version, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", version=");
sb.append(version);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where groupId = ? and version = ?.
*
* @param groupId the group ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByGroupId_Version_Last(
long groupId, int version,
OrderByComparator orderByComparator) {
int count = countByGroupId_Version(groupId, version);
if (count == 0) {
return null;
}
List list = findByGroupId_Version(
groupId, version, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where groupId = ? and version = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param groupId the group ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[] findByGroupId_Version_PrevAndNext(
long fragmentEntryVersionId, long groupId, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByGroupId_Version_PrevAndNext(
session, fragmentEntryVersion, groupId, version,
orderByComparator, true);
array[1] = fragmentEntryVersion;
array[2] = getByGroupId_Version_PrevAndNext(
session, fragmentEntryVersion, groupId, version,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion getByGroupId_Version_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion,
long groupId, int version,
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_VERSION_GROUPID_2);
sb.append(_FINDER_COLUMN_GROUPID_VERSION_VERSION_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(FragmentEntryVersionModelImpl.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(groupId);
queryPos.add(version);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where groupId = ? and version = ? from the database.
*
* @param groupId the group ID
* @param version the version
*/
@Override
public void removeByGroupId_Version(long groupId, int version) {
for (FragmentEntryVersion fragmentEntryVersion :
findByGroupId_Version(
groupId, version, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where groupId = ? and version = ?.
*
* @param groupId the group ID
* @param version the version
* @return the number of matching fragment entry versions
*/
@Override
public int countByGroupId_Version(long groupId, int version) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByGroupId_Version;
finderArgs = new Object[] {groupId, version};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_GROUPID_VERSION_GROUPID_2);
sb.append(_FINDER_COLUMN_GROUPID_VERSION_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(version);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_GROUPID_VERSION_GROUPID_2 =
"fragmentEntryVersion.groupId = ? AND ";
private static final String _FINDER_COLUMN_GROUPID_VERSION_VERSION_2 =
"fragmentEntryVersion.version = ?";
private FinderPath _finderPathWithPaginationFindByFragmentCollectionId;
private FinderPath _finderPathWithoutPaginationFindByFragmentCollectionId;
private FinderPath _finderPathCountByFragmentCollectionId;
/**
* Returns all the fragment entry versions where fragmentCollectionId = ?.
*
* @param fragmentCollectionId the fragment collection ID
* @return the matching fragment entry versions
*/
@Override
public List findByFragmentCollectionId(
long fragmentCollectionId) {
return findByFragmentCollectionId(
fragmentCollectionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the fragment entry versions where fragmentCollectionId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param fragmentCollectionId the fragment collection ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByFragmentCollectionId(
long fragmentCollectionId, int start, int end) {
return findByFragmentCollectionId(
fragmentCollectionId, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where fragmentCollectionId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param fragmentCollectionId the fragment collection ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByFragmentCollectionId(
long fragmentCollectionId, int start, int end,
OrderByComparator orderByComparator) {
return findByFragmentCollectionId(
fragmentCollectionId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where fragmentCollectionId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param fragmentCollectionId the fragment collection ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByFragmentCollectionId(
long fragmentCollectionId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath =
_finderPathWithoutPaginationFindByFragmentCollectionId;
finderArgs = new Object[] {fragmentCollectionId};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByFragmentCollectionId;
finderArgs = new Object[] {
fragmentCollectionId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if (fragmentCollectionId !=
fragmentEntryVersion.getFragmentCollectionId()) {
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(
_FINDER_COLUMN_FRAGMENTCOLLECTIONID_FRAGMENTCOLLECTIONID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.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(fragmentCollectionId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where fragmentCollectionId = ?.
*
* @param fragmentCollectionId the fragment collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByFragmentCollectionId_First(
long fragmentCollectionId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion =
fetchByFragmentCollectionId_First(
fragmentCollectionId, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("fragmentCollectionId=");
sb.append(fragmentCollectionId);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where fragmentCollectionId = ?.
*
* @param fragmentCollectionId the fragment collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByFragmentCollectionId_First(
long fragmentCollectionId,
OrderByComparator orderByComparator) {
List list = findByFragmentCollectionId(
fragmentCollectionId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where fragmentCollectionId = ?.
*
* @param fragmentCollectionId the fragment collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByFragmentCollectionId_Last(
long fragmentCollectionId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion =
fetchByFragmentCollectionId_Last(
fragmentCollectionId, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("fragmentCollectionId=");
sb.append(fragmentCollectionId);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where fragmentCollectionId = ?.
*
* @param fragmentCollectionId the fragment collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByFragmentCollectionId_Last(
long fragmentCollectionId,
OrderByComparator orderByComparator) {
int count = countByFragmentCollectionId(fragmentCollectionId);
if (count == 0) {
return null;
}
List list = findByFragmentCollectionId(
fragmentCollectionId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where fragmentCollectionId = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param fragmentCollectionId the fragment collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[] findByFragmentCollectionId_PrevAndNext(
long fragmentEntryVersionId, long fragmentCollectionId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByFragmentCollectionId_PrevAndNext(
session, fragmentEntryVersion, fragmentCollectionId,
orderByComparator, true);
array[1] = fragmentEntryVersion;
array[2] = getByFragmentCollectionId_PrevAndNext(
session, fragmentEntryVersion, fragmentCollectionId,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion getByFragmentCollectionId_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion,
long fragmentCollectionId,
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_FRAGMENTCOLLECTIONID_FRAGMENTCOLLECTIONID_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(FragmentEntryVersionModelImpl.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(fragmentCollectionId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where fragmentCollectionId = ? from the database.
*
* @param fragmentCollectionId the fragment collection ID
*/
@Override
public void removeByFragmentCollectionId(long fragmentCollectionId) {
for (FragmentEntryVersion fragmentEntryVersion :
findByFragmentCollectionId(
fragmentCollectionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where fragmentCollectionId = ?.
*
* @param fragmentCollectionId the fragment collection ID
* @return the number of matching fragment entry versions
*/
@Override
public int countByFragmentCollectionId(long fragmentCollectionId) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByFragmentCollectionId;
finderArgs = new Object[] {fragmentCollectionId};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
sb.append(
_FINDER_COLUMN_FRAGMENTCOLLECTIONID_FRAGMENTCOLLECTIONID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(fragmentCollectionId);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String
_FINDER_COLUMN_FRAGMENTCOLLECTIONID_FRAGMENTCOLLECTIONID_2 =
"fragmentEntryVersion.fragmentCollectionId = ?";
private FinderPath
_finderPathWithPaginationFindByFragmentCollectionId_Version;
private FinderPath
_finderPathWithoutPaginationFindByFragmentCollectionId_Version;
private FinderPath _finderPathCountByFragmentCollectionId_Version;
/**
* Returns all the fragment entry versions where fragmentCollectionId = ? and version = ?.
*
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @return the matching fragment entry versions
*/
@Override
public List findByFragmentCollectionId_Version(
long fragmentCollectionId, int version) {
return findByFragmentCollectionId_Version(
fragmentCollectionId, version, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the fragment entry versions where fragmentCollectionId = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByFragmentCollectionId_Version(
long fragmentCollectionId, int version, int start, int end) {
return findByFragmentCollectionId_Version(
fragmentCollectionId, version, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where fragmentCollectionId = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByFragmentCollectionId_Version(
long fragmentCollectionId, int version, int start, int end,
OrderByComparator orderByComparator) {
return findByFragmentCollectionId_Version(
fragmentCollectionId, version, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where fragmentCollectionId = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByFragmentCollectionId_Version(
long fragmentCollectionId, int version, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath =
_finderPathWithoutPaginationFindByFragmentCollectionId_Version;
finderArgs = new Object[] {fragmentCollectionId, version};
}
}
else if (useFinderCache && productionMode) {
finderPath =
_finderPathWithPaginationFindByFragmentCollectionId_Version;
finderArgs = new Object[] {
fragmentCollectionId, version, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if ((fragmentCollectionId !=
fragmentEntryVersion.getFragmentCollectionId()) ||
(version != fragmentEntryVersion.getVersion())) {
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(
_FINDER_COLUMN_FRAGMENTCOLLECTIONID_VERSION_FRAGMENTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_FRAGMENTCOLLECTIONID_VERSION_VERSION_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.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(fragmentCollectionId);
queryPos.add(version);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where fragmentCollectionId = ? and version = ?.
*
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByFragmentCollectionId_Version_First(
long fragmentCollectionId, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion =
fetchByFragmentCollectionId_Version_First(
fragmentCollectionId, version, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("fragmentCollectionId=");
sb.append(fragmentCollectionId);
sb.append(", version=");
sb.append(version);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where fragmentCollectionId = ? and version = ?.
*
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByFragmentCollectionId_Version_First(
long fragmentCollectionId, int version,
OrderByComparator orderByComparator) {
List list = findByFragmentCollectionId_Version(
fragmentCollectionId, version, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where fragmentCollectionId = ? and version = ?.
*
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByFragmentCollectionId_Version_Last(
long fragmentCollectionId, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion =
fetchByFragmentCollectionId_Version_Last(
fragmentCollectionId, version, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("fragmentCollectionId=");
sb.append(fragmentCollectionId);
sb.append(", version=");
sb.append(version);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where fragmentCollectionId = ? and version = ?.
*
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByFragmentCollectionId_Version_Last(
long fragmentCollectionId, int version,
OrderByComparator orderByComparator) {
int count = countByFragmentCollectionId_Version(
fragmentCollectionId, version);
if (count == 0) {
return null;
}
List list = findByFragmentCollectionId_Version(
fragmentCollectionId, version, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where fragmentCollectionId = ? and version = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[]
findByFragmentCollectionId_Version_PrevAndNext(
long fragmentEntryVersionId, long fragmentCollectionId,
int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByFragmentCollectionId_Version_PrevAndNext(
session, fragmentEntryVersion, fragmentCollectionId, version,
orderByComparator, true);
array[1] = fragmentEntryVersion;
array[2] = getByFragmentCollectionId_Version_PrevAndNext(
session, fragmentEntryVersion, fragmentCollectionId, version,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion
getByFragmentCollectionId_Version_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion,
long fragmentCollectionId, int version,
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(
_FINDER_COLUMN_FRAGMENTCOLLECTIONID_VERSION_FRAGMENTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_FRAGMENTCOLLECTIONID_VERSION_VERSION_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(FragmentEntryVersionModelImpl.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(fragmentCollectionId);
queryPos.add(version);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where fragmentCollectionId = ? and version = ? from the database.
*
* @param fragmentCollectionId the fragment collection ID
* @param version the version
*/
@Override
public void removeByFragmentCollectionId_Version(
long fragmentCollectionId, int version) {
for (FragmentEntryVersion fragmentEntryVersion :
findByFragmentCollectionId_Version(
fragmentCollectionId, version, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where fragmentCollectionId = ? and version = ?.
*
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @return the number of matching fragment entry versions
*/
@Override
public int countByFragmentCollectionId_Version(
long fragmentCollectionId, int version) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByFragmentCollectionId_Version;
finderArgs = new Object[] {fragmentCollectionId, version};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
sb.append(
_FINDER_COLUMN_FRAGMENTCOLLECTIONID_VERSION_FRAGMENTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_FRAGMENTCOLLECTIONID_VERSION_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(fragmentCollectionId);
queryPos.add(version);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String
_FINDER_COLUMN_FRAGMENTCOLLECTIONID_VERSION_FRAGMENTCOLLECTIONID_2 =
"fragmentEntryVersion.fragmentCollectionId = ? AND ";
private static final String
_FINDER_COLUMN_FRAGMENTCOLLECTIONID_VERSION_VERSION_2 =
"fragmentEntryVersion.version = ?";
private FinderPath _finderPathWithPaginationFindByG_FCI;
private FinderPath _finderPathWithoutPaginationFindByG_FCI;
private FinderPath _finderPathCountByG_FCI;
/**
* Returns all the fragment entry versions where groupId = ? and fragmentCollectionId = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @return the matching fragment entry versions
*/
@Override
public List findByG_FCI(
long groupId, long fragmentCollectionId) {
return findByG_FCI(
groupId, fragmentCollectionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the fragment entry versions where groupId = ? and fragmentCollectionId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByG_FCI(
long groupId, long fragmentCollectionId, int start, int end) {
return findByG_FCI(groupId, fragmentCollectionId, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where groupId = ? and fragmentCollectionId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByG_FCI(
long groupId, long fragmentCollectionId, int start, int end,
OrderByComparator orderByComparator) {
return findByG_FCI(
groupId, fragmentCollectionId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where groupId = ? and fragmentCollectionId = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByG_FCI(
long groupId, long fragmentCollectionId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByG_FCI;
finderArgs = new Object[] {groupId, fragmentCollectionId};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByG_FCI;
finderArgs = new Object[] {
groupId, fragmentCollectionId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if ((groupId != fragmentEntryVersion.getGroupId()) ||
(fragmentCollectionId !=
fragmentEntryVersion.getFragmentCollectionId())) {
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_G_FCI_GROUPID_2);
sb.append(_FINDER_COLUMN_G_FCI_FRAGMENTCOLLECTIONID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.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(groupId);
queryPos.add(fragmentCollectionId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByG_FCI_First(
long groupId, long fragmentCollectionId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByG_FCI_First(
groupId, fragmentCollectionId, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", fragmentCollectionId=");
sb.append(fragmentCollectionId);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByG_FCI_First(
long groupId, long fragmentCollectionId,
OrderByComparator orderByComparator) {
List list = findByG_FCI(
groupId, fragmentCollectionId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByG_FCI_Last(
long groupId, long fragmentCollectionId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByG_FCI_Last(
groupId, fragmentCollectionId, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", fragmentCollectionId=");
sb.append(fragmentCollectionId);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByG_FCI_Last(
long groupId, long fragmentCollectionId,
OrderByComparator orderByComparator) {
int count = countByG_FCI(groupId, fragmentCollectionId);
if (count == 0) {
return null;
}
List list = findByG_FCI(
groupId, fragmentCollectionId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[] findByG_FCI_PrevAndNext(
long fragmentEntryVersionId, long groupId,
long fragmentCollectionId,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByG_FCI_PrevAndNext(
session, fragmentEntryVersion, groupId, fragmentCollectionId,
orderByComparator, true);
array[1] = fragmentEntryVersion;
array[2] = getByG_FCI_PrevAndNext(
session, fragmentEntryVersion, groupId, fragmentCollectionId,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion getByG_FCI_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion,
long groupId, long fragmentCollectionId,
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_G_FCI_GROUPID_2);
sb.append(_FINDER_COLUMN_G_FCI_FRAGMENTCOLLECTIONID_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(FragmentEntryVersionModelImpl.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(groupId);
queryPos.add(fragmentCollectionId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where groupId = ? and fragmentCollectionId = ? from the database.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
*/
@Override
public void removeByG_FCI(long groupId, long fragmentCollectionId) {
for (FragmentEntryVersion fragmentEntryVersion :
findByG_FCI(
groupId, fragmentCollectionId, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where groupId = ? and fragmentCollectionId = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @return the number of matching fragment entry versions
*/
@Override
public int countByG_FCI(long groupId, long fragmentCollectionId) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByG_FCI;
finderArgs = new Object[] {groupId, fragmentCollectionId};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_G_FCI_GROUPID_2);
sb.append(_FINDER_COLUMN_G_FCI_FRAGMENTCOLLECTIONID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(fragmentCollectionId);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_G_FCI_GROUPID_2 =
"fragmentEntryVersion.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_FCI_FRAGMENTCOLLECTIONID_2 =
"fragmentEntryVersion.fragmentCollectionId = ?";
private FinderPath _finderPathWithPaginationFindByG_FCI_Version;
private FinderPath _finderPathWithoutPaginationFindByG_FCI_Version;
private FinderPath _finderPathCountByG_FCI_Version;
/**
* Returns all the fragment entry versions where groupId = ? and fragmentCollectionId = ? and version = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @return the matching fragment entry versions
*/
@Override
public List findByG_FCI_Version(
long groupId, long fragmentCollectionId, int version) {
return findByG_FCI_Version(
groupId, fragmentCollectionId, version, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the fragment entry versions where groupId = ? and fragmentCollectionId = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByG_FCI_Version(
long groupId, long fragmentCollectionId, int version, int start,
int end) {
return findByG_FCI_Version(
groupId, fragmentCollectionId, version, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where groupId = ? and fragmentCollectionId = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByG_FCI_Version(
long groupId, long fragmentCollectionId, int version, int start,
int end, OrderByComparator orderByComparator) {
return findByG_FCI_Version(
groupId, fragmentCollectionId, version, start, end,
orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where groupId = ? and fragmentCollectionId = ? and version = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByG_FCI_Version(
long groupId, long fragmentCollectionId, int version, int start,
int end, OrderByComparator orderByComparator,
boolean useFinderCache) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByG_FCI_Version;
finderArgs = new Object[] {
groupId, fragmentCollectionId, version
};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByG_FCI_Version;
finderArgs = new Object[] {
groupId, fragmentCollectionId, version, start, end,
orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if ((groupId != fragmentEntryVersion.getGroupId()) ||
(fragmentCollectionId !=
fragmentEntryVersion.getFragmentCollectionId()) ||
(version != fragmentEntryVersion.getVersion())) {
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_G_FCI_VERSION_GROUPID_2);
sb.append(_FINDER_COLUMN_G_FCI_VERSION_FRAGMENTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_G_FCI_VERSION_VERSION_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.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(groupId);
queryPos.add(fragmentCollectionId);
queryPos.add(version);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ? and version = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByG_FCI_Version_First(
long groupId, long fragmentCollectionId, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByG_FCI_Version_First(
groupId, fragmentCollectionId, version, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", fragmentCollectionId=");
sb.append(fragmentCollectionId);
sb.append(", version=");
sb.append(version);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ? and version = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByG_FCI_Version_First(
long groupId, long fragmentCollectionId, int version,
OrderByComparator orderByComparator) {
List list = findByG_FCI_Version(
groupId, fragmentCollectionId, version, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ? and version = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByG_FCI_Version_Last(
long groupId, long fragmentCollectionId, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByG_FCI_Version_Last(
groupId, fragmentCollectionId, version, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", fragmentCollectionId=");
sb.append(fragmentCollectionId);
sb.append(", version=");
sb.append(version);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ? and version = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByG_FCI_Version_Last(
long groupId, long fragmentCollectionId, int version,
OrderByComparator orderByComparator) {
int count = countByG_FCI_Version(
groupId, fragmentCollectionId, version);
if (count == 0) {
return null;
}
List list = findByG_FCI_Version(
groupId, fragmentCollectionId, version, count - 1, count,
orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ? and version = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[] findByG_FCI_Version_PrevAndNext(
long fragmentEntryVersionId, long groupId,
long fragmentCollectionId, int version,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByG_FCI_Version_PrevAndNext(
session, fragmentEntryVersion, groupId, fragmentCollectionId,
version, orderByComparator, true);
array[1] = fragmentEntryVersion;
array[2] = getByG_FCI_Version_PrevAndNext(
session, fragmentEntryVersion, groupId, fragmentCollectionId,
version, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion getByG_FCI_Version_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion,
long groupId, long fragmentCollectionId, int version,
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_G_FCI_VERSION_GROUPID_2);
sb.append(_FINDER_COLUMN_G_FCI_VERSION_FRAGMENTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_G_FCI_VERSION_VERSION_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(FragmentEntryVersionModelImpl.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(groupId);
queryPos.add(fragmentCollectionId);
queryPos.add(version);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where groupId = ? and fragmentCollectionId = ? and version = ? from the database.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param version the version
*/
@Override
public void removeByG_FCI_Version(
long groupId, long fragmentCollectionId, int version) {
for (FragmentEntryVersion fragmentEntryVersion :
findByG_FCI_Version(
groupId, fragmentCollectionId, version, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where groupId = ? and fragmentCollectionId = ? and version = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param version the version
* @return the number of matching fragment entry versions
*/
@Override
public int countByG_FCI_Version(
long groupId, long fragmentCollectionId, int version) {
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByG_FCI_Version;
finderArgs = new Object[] {groupId, fragmentCollectionId, version};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_G_FCI_VERSION_GROUPID_2);
sb.append(_FINDER_COLUMN_G_FCI_VERSION_FRAGMENTCOLLECTIONID_2);
sb.append(_FINDER_COLUMN_G_FCI_VERSION_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(fragmentCollectionId);
queryPos.add(version);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_G_FCI_VERSION_GROUPID_2 =
"fragmentEntryVersion.groupId = ? AND ";
private static final String
_FINDER_COLUMN_G_FCI_VERSION_FRAGMENTCOLLECTIONID_2 =
"fragmentEntryVersion.fragmentCollectionId = ? AND ";
private static final String _FINDER_COLUMN_G_FCI_VERSION_VERSION_2 =
"fragmentEntryVersion.version = ?";
private FinderPath _finderPathWithPaginationFindByG_FEK;
private FinderPath _finderPathWithoutPaginationFindByG_FEK;
private FinderPath _finderPathCountByG_FEK;
/**
* Returns all the fragment entry versions where groupId = ? and fragmentEntryKey = ?.
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @return the matching fragment entry versions
*/
@Override
public List findByG_FEK(
long groupId, String fragmentEntryKey) {
return findByG_FEK(
groupId, fragmentEntryKey, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the fragment entry versions where groupId = ? and fragmentEntryKey = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByG_FEK(
long groupId, String fragmentEntryKey, int start, int end) {
return findByG_FEK(groupId, fragmentEntryKey, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where groupId = ? and fragmentEntryKey = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByG_FEK(
long groupId, String fragmentEntryKey, int start, int end,
OrderByComparator orderByComparator) {
return findByG_FEK(
groupId, fragmentEntryKey, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the fragment entry versions where groupId = ? and fragmentEntryKey = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByG_FEK(
long groupId, String fragmentEntryKey, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
fragmentEntryKey = Objects.toString(fragmentEntryKey, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByG_FEK;
finderArgs = new Object[] {groupId, fragmentEntryKey};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByG_FEK;
finderArgs = new Object[] {
groupId, fragmentEntryKey, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if ((groupId != fragmentEntryVersion.getGroupId()) ||
!fragmentEntryKey.equals(
fragmentEntryVersion.getFragmentEntryKey())) {
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_G_FEK_GROUPID_2);
boolean bindFragmentEntryKey = false;
if (fragmentEntryKey.isEmpty()) {
sb.append(_FINDER_COLUMN_G_FEK_FRAGMENTENTRYKEY_3);
}
else {
bindFragmentEntryKey = true;
sb.append(_FINDER_COLUMN_G_FEK_FRAGMENTENTRYKEY_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.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(groupId);
if (bindFragmentEntryKey) {
queryPos.add(fragmentEntryKey);
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where groupId = ? and fragmentEntryKey = ?.
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByG_FEK_First(
long groupId, String fragmentEntryKey,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByG_FEK_First(
groupId, fragmentEntryKey, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", fragmentEntryKey=");
sb.append(fragmentEntryKey);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where groupId = ? and fragmentEntryKey = ?.
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByG_FEK_First(
long groupId, String fragmentEntryKey,
OrderByComparator orderByComparator) {
List list = findByG_FEK(
groupId, fragmentEntryKey, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where groupId = ? and fragmentEntryKey = ?.
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByG_FEK_Last(
long groupId, String fragmentEntryKey,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByG_FEK_Last(
groupId, fragmentEntryKey, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", fragmentEntryKey=");
sb.append(fragmentEntryKey);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the last fragment entry version in the ordered set where groupId = ? and fragmentEntryKey = ?.
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByG_FEK_Last(
long groupId, String fragmentEntryKey,
OrderByComparator orderByComparator) {
int count = countByG_FEK(groupId, fragmentEntryKey);
if (count == 0) {
return null;
}
List list = findByG_FEK(
groupId, fragmentEntryKey, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the fragment entry versions before and after the current fragment entry version in the ordered set where groupId = ? and fragmentEntryKey = ?.
*
* @param fragmentEntryVersionId the primary key of the current fragment entry version
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next fragment entry version
* @throws NoSuchEntryVersionException if a fragment entry version with the primary key could not be found
*/
@Override
public FragmentEntryVersion[] findByG_FEK_PrevAndNext(
long fragmentEntryVersionId, long groupId, String fragmentEntryKey,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
fragmentEntryKey = Objects.toString(fragmentEntryKey, "");
FragmentEntryVersion fragmentEntryVersion = findByPrimaryKey(
fragmentEntryVersionId);
Session session = null;
try {
session = openSession();
FragmentEntryVersion[] array = new FragmentEntryVersionImpl[3];
array[0] = getByG_FEK_PrevAndNext(
session, fragmentEntryVersion, groupId, fragmentEntryKey,
orderByComparator, true);
array[1] = fragmentEntryVersion;
array[2] = getByG_FEK_PrevAndNext(
session, fragmentEntryVersion, groupId, fragmentEntryKey,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected FragmentEntryVersion getByG_FEK_PrevAndNext(
Session session, FragmentEntryVersion fragmentEntryVersion,
long groupId, String fragmentEntryKey,
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_G_FEK_GROUPID_2);
boolean bindFragmentEntryKey = false;
if (fragmentEntryKey.isEmpty()) {
sb.append(_FINDER_COLUMN_G_FEK_FRAGMENTENTRYKEY_3);
}
else {
bindFragmentEntryKey = true;
sb.append(_FINDER_COLUMN_G_FEK_FRAGMENTENTRYKEY_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(FragmentEntryVersionModelImpl.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(groupId);
if (bindFragmentEntryKey) {
queryPos.add(fragmentEntryKey);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
fragmentEntryVersion)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the fragment entry versions where groupId = ? and fragmentEntryKey = ? from the database.
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
*/
@Override
public void removeByG_FEK(long groupId, String fragmentEntryKey) {
for (FragmentEntryVersion fragmentEntryVersion :
findByG_FEK(
groupId, fragmentEntryKey, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(fragmentEntryVersion);
}
}
/**
* Returns the number of fragment entry versions where groupId = ? and fragmentEntryKey = ?.
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @return the number of matching fragment entry versions
*/
@Override
public int countByG_FEK(long groupId, String fragmentEntryKey) {
fragmentEntryKey = Objects.toString(fragmentEntryKey, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByG_FEK;
finderArgs = new Object[] {groupId, fragmentEntryKey};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_G_FEK_GROUPID_2);
boolean bindFragmentEntryKey = false;
if (fragmentEntryKey.isEmpty()) {
sb.append(_FINDER_COLUMN_G_FEK_FRAGMENTENTRYKEY_3);
}
else {
bindFragmentEntryKey = true;
sb.append(_FINDER_COLUMN_G_FEK_FRAGMENTENTRYKEY_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
if (bindFragmentEntryKey) {
queryPos.add(fragmentEntryKey);
}
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_G_FEK_GROUPID_2 =
"fragmentEntryVersion.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_FEK_FRAGMENTENTRYKEY_2 =
"fragmentEntryVersion.fragmentEntryKey = ?";
private static final String _FINDER_COLUMN_G_FEK_FRAGMENTENTRYKEY_3 =
"(fragmentEntryVersion.fragmentEntryKey IS NULL OR fragmentEntryVersion.fragmentEntryKey = '')";
private FinderPath _finderPathFetchByG_FEK_Version;
private FinderPath _finderPathCountByG_FEK_Version;
/**
* Returns the fragment entry version where groupId = ? and fragmentEntryKey = ? and version = ? or throws a NoSuchEntryVersionException
if it could not be found.
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param version the version
* @return the matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByG_FEK_Version(
long groupId, String fragmentEntryKey, int version)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByG_FEK_Version(
groupId, fragmentEntryKey, version);
if (fragmentEntryVersion == null) {
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", fragmentEntryKey=");
sb.append(fragmentEntryKey);
sb.append(", version=");
sb.append(version);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchEntryVersionException(sb.toString());
}
return fragmentEntryVersion;
}
/**
* Returns the fragment entry version where groupId = ? and fragmentEntryKey = ? and version = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param version the version
* @return the matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByG_FEK_Version(
long groupId, String fragmentEntryKey, int version) {
return fetchByG_FEK_Version(groupId, fragmentEntryKey, version, true);
}
/**
* Returns the fragment entry version where groupId = ? and fragmentEntryKey = ? and version = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param version the version
* @param useFinderCache whether to use the finder cache
* @return the matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByG_FEK_Version(
long groupId, String fragmentEntryKey, int version,
boolean useFinderCache) {
fragmentEntryKey = Objects.toString(fragmentEntryKey, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
Object[] finderArgs = null;
if (useFinderCache && productionMode) {
finderArgs = new Object[] {groupId, fragmentEntryKey, version};
}
Object result = null;
if (useFinderCache && productionMode) {
result = finderCache.getResult(
_finderPathFetchByG_FEK_Version, finderArgs);
}
if (result instanceof FragmentEntryVersion) {
FragmentEntryVersion fragmentEntryVersion =
(FragmentEntryVersion)result;
if ((groupId != fragmentEntryVersion.getGroupId()) ||
!Objects.equals(
fragmentEntryKey,
fragmentEntryVersion.getFragmentEntryKey()) ||
(version != fragmentEntryVersion.getVersion())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(5);
sb.append(_SQL_SELECT_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_G_FEK_VERSION_GROUPID_2);
boolean bindFragmentEntryKey = false;
if (fragmentEntryKey.isEmpty()) {
sb.append(_FINDER_COLUMN_G_FEK_VERSION_FRAGMENTENTRYKEY_3);
}
else {
bindFragmentEntryKey = true;
sb.append(_FINDER_COLUMN_G_FEK_VERSION_FRAGMENTENTRYKEY_2);
}
sb.append(_FINDER_COLUMN_G_FEK_VERSION_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
if (bindFragmentEntryKey) {
queryPos.add(fragmentEntryKey);
}
queryPos.add(version);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache && productionMode) {
finderCache.putResult(
_finderPathFetchByG_FEK_Version, finderArgs, list);
}
}
else {
FragmentEntryVersion fragmentEntryVersion = list.get(0);
result = fragmentEntryVersion;
cacheResult(fragmentEntryVersion);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (FragmentEntryVersion)result;
}
}
/**
* Removes the fragment entry version where groupId = ? and fragmentEntryKey = ? and version = ? from the database.
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param version the version
* @return the fragment entry version that was removed
*/
@Override
public FragmentEntryVersion removeByG_FEK_Version(
long groupId, String fragmentEntryKey, int version)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = findByG_FEK_Version(
groupId, fragmentEntryKey, version);
return remove(fragmentEntryVersion);
}
/**
* Returns the number of fragment entry versions where groupId = ? and fragmentEntryKey = ? and version = ?.
*
* @param groupId the group ID
* @param fragmentEntryKey the fragment entry key
* @param version the version
* @return the number of matching fragment entry versions
*/
@Override
public int countByG_FEK_Version(
long groupId, String fragmentEntryKey, int version) {
fragmentEntryKey = Objects.toString(fragmentEntryKey, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
Long count = null;
if (productionMode) {
finderPath = _finderPathCountByG_FEK_Version;
finderArgs = new Object[] {groupId, fragmentEntryKey, version};
count = (Long)finderCache.getResult(finderPath, finderArgs);
}
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_G_FEK_VERSION_GROUPID_2);
boolean bindFragmentEntryKey = false;
if (fragmentEntryKey.isEmpty()) {
sb.append(_FINDER_COLUMN_G_FEK_VERSION_FRAGMENTENTRYKEY_3);
}
else {
bindFragmentEntryKey = true;
sb.append(_FINDER_COLUMN_G_FEK_VERSION_FRAGMENTENTRYKEY_2);
}
sb.append(_FINDER_COLUMN_G_FEK_VERSION_VERSION_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
if (bindFragmentEntryKey) {
queryPos.add(fragmentEntryKey);
}
queryPos.add(version);
count = (Long)query.uniqueResult();
if (productionMode) {
finderCache.putResult(finderPath, finderArgs, count);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_G_FEK_VERSION_GROUPID_2 =
"fragmentEntryVersion.groupId = ? AND ";
private static final String
_FINDER_COLUMN_G_FEK_VERSION_FRAGMENTENTRYKEY_2 =
"fragmentEntryVersion.fragmentEntryKey = ? AND ";
private static final String
_FINDER_COLUMN_G_FEK_VERSION_FRAGMENTENTRYKEY_3 =
"(fragmentEntryVersion.fragmentEntryKey IS NULL OR fragmentEntryVersion.fragmentEntryKey = '') AND ";
private static final String _FINDER_COLUMN_G_FEK_VERSION_VERSION_2 =
"fragmentEntryVersion.version = ?";
private FinderPath _finderPathWithPaginationFindByG_FCI_LikeN;
private FinderPath _finderPathWithoutPaginationFindByG_FCI_LikeN;
private FinderPath _finderPathCountByG_FCI_LikeN;
/**
* Returns all the fragment entry versions where groupId = ? and fragmentCollectionId = ? and name = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param name the name
* @return the matching fragment entry versions
*/
@Override
public List findByG_FCI_LikeN(
long groupId, long fragmentCollectionId, String name) {
return findByG_FCI_LikeN(
groupId, fragmentCollectionId, name, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the fragment entry versions where groupId = ? and fragmentCollectionId = ? and name = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param name the name
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @return the range of matching fragment entry versions
*/
@Override
public List findByG_FCI_LikeN(
long groupId, long fragmentCollectionId, String name, int start,
int end) {
return findByG_FCI_LikeN(
groupId, fragmentCollectionId, name, start, end, null);
}
/**
* Returns an ordered range of all the fragment entry versions where groupId = ? and fragmentCollectionId = ? and name = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param name the name
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching fragment entry versions
*/
@Override
public List findByG_FCI_LikeN(
long groupId, long fragmentCollectionId, String name, int start,
int end, OrderByComparator orderByComparator) {
return findByG_FCI_LikeN(
groupId, fragmentCollectionId, name, start, end, orderByComparator,
true);
}
/**
* Returns an ordered range of all the fragment entry versions where groupId = ? and fragmentCollectionId = ? and name = ?.
*
*
* 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 FragmentEntryVersionModelImpl
.
*
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param name the name
* @param start the lower bound of the range of fragment entry versions
* @param end the upper bound of the range of fragment entry versions (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 fragment entry versions
*/
@Override
public List findByG_FCI_LikeN(
long groupId, long fragmentCollectionId, String name, int start,
int end, OrderByComparator orderByComparator,
boolean useFinderCache) {
name = Objects.toString(name, "");
boolean productionMode = ctPersistenceHelper.isProductionMode(
FragmentEntryVersion.class);
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache && productionMode) {
finderPath = _finderPathWithoutPaginationFindByG_FCI_LikeN;
finderArgs = new Object[] {groupId, fragmentCollectionId, name};
}
}
else if (useFinderCache && productionMode) {
finderPath = _finderPathWithPaginationFindByG_FCI_LikeN;
finderArgs = new Object[] {
groupId, fragmentCollectionId, name, start, end,
orderByComparator
};
}
List list = null;
if (useFinderCache && productionMode) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (FragmentEntryVersion fragmentEntryVersion : list) {
if ((groupId != fragmentEntryVersion.getGroupId()) ||
(fragmentCollectionId !=
fragmentEntryVersion.getFragmentCollectionId()) ||
!name.equals(fragmentEntryVersion.getName())) {
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_FRAGMENTENTRYVERSION_WHERE);
sb.append(_FINDER_COLUMN_G_FCI_LIKEN_GROUPID_2);
sb.append(_FINDER_COLUMN_G_FCI_LIKEN_FRAGMENTCOLLECTIONID_2);
boolean bindName = false;
if (name.isEmpty()) {
sb.append(_FINDER_COLUMN_G_FCI_LIKEN_NAME_3);
}
else {
bindName = true;
sb.append(_FINDER_COLUMN_G_FCI_LIKEN_NAME_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(FragmentEntryVersionModelImpl.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(groupId);
queryPos.add(fragmentCollectionId);
if (bindName) {
queryPos.add(name);
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache && productionMode) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ? and name = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param name the name
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version
* @throws NoSuchEntryVersionException if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion findByG_FCI_LikeN_First(
long groupId, long fragmentCollectionId, String name,
OrderByComparator orderByComparator)
throws NoSuchEntryVersionException {
FragmentEntryVersion fragmentEntryVersion = fetchByG_FCI_LikeN_First(
groupId, fragmentCollectionId, name, orderByComparator);
if (fragmentEntryVersion != null) {
return fragmentEntryVersion;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", fragmentCollectionId=");
sb.append(fragmentCollectionId);
sb.append(", name=");
sb.append(name);
sb.append("}");
throw new NoSuchEntryVersionException(sb.toString());
}
/**
* Returns the first fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ? and name = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param name the name
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching fragment entry version, or null
if a matching fragment entry version could not be found
*/
@Override
public FragmentEntryVersion fetchByG_FCI_LikeN_First(
long groupId, long fragmentCollectionId, String name,
OrderByComparator orderByComparator) {
List list = findByG_FCI_LikeN(
groupId, fragmentCollectionId, name, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last fragment entry version in the ordered set where groupId = ? and fragmentCollectionId = ? and name = ?.
*
* @param groupId the group ID
* @param fragmentCollectionId the fragment collection ID
* @param name the name
* @param orderByComparator the comparator to order the set by (optionally