com.liferay.bookmarks.service.persistence.impl.BookmarksEntryPersistenceImpl Maven / Gradle / Ivy
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.bookmarks.service.persistence.impl;
import com.liferay.bookmarks.exception.NoSuchEntryException;
import com.liferay.bookmarks.model.BookmarksEntry;
import com.liferay.bookmarks.model.BookmarksEntryTable;
import com.liferay.bookmarks.model.impl.BookmarksEntryImpl;
import com.liferay.bookmarks.model.impl.BookmarksEntryModelImpl;
import com.liferay.bookmarks.service.persistence.BookmarksEntryPersistence;
import com.liferay.bookmarks.service.persistence.BookmarksEntryUtil;
import com.liferay.bookmarks.service.persistence.impl.constants.BookmarksPersistenceConstants;
import com.liferay.petra.lang.SafeCloseable;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.change.tracking.CTCollectionThreadLocal;
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.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.dao.orm.SessionFactory;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.change.tracking.helper.CTPersistenceHelper;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.util.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 bookmarks entry service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Brian Wing Shun Chan
* @generated
*/
@Component(service = BookmarksEntryPersistence.class)
public class BookmarksEntryPersistenceImpl
extends BasePersistenceImpl
implements BookmarksEntryPersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use BookmarksEntryUtil
to access the bookmarks entry persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY =
BookmarksEntryImpl.class.getName();
public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION =
FINDER_CLASS_NAME_ENTITY + ".List1";
public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION =
FINDER_CLASS_NAME_ENTITY + ".List2";
private FinderPath _finderPathWithPaginationFindAll;
private FinderPath _finderPathWithoutPaginationFindAll;
private FinderPath _finderPathCountAll;
private FinderPath _finderPathWithPaginationFindByUuid;
private FinderPath _finderPathWithoutPaginationFindByUuid;
private FinderPath _finderPathCountByUuid;
/**
* Returns all the bookmarks entries where uuid = ?.
*
* @param uuid the uuid
* @return the matching bookmarks entries
*/
@Override
public List findByUuid(String uuid) {
return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the bookmarks entries where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries
*/
@Override
public List findByUuid(String uuid, int start, int end) {
return findByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid(uuid, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the bookmarks entries where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUuid;
finderArgs = new Object[] {uuid};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUuid;
finderArgs = new Object[] {uuid, start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BookmarksEntry bookmarksEntry : list) {
if (!uuid.equals(bookmarksEntry.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_BOOKMARKSENTRY_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(BookmarksEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
}
/**
* Returns the first bookmarks entry in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByUuid_First(
String uuid, OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByUuid_First(
uuid, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first bookmarks entry in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry 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 bookmarks entry in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByUuid_Last(
String uuid, OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByUuid_Last(
uuid, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last bookmarks entry in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry 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 bookmarks entries before and after the current bookmarks entry in the ordered set where uuid = ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] findByUuid_PrevAndNext(
long entryId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
uuid = Objects.toString(uuid, "");
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = getByUuid_PrevAndNext(
session, bookmarksEntry, uuid, orderByComparator, true);
array[1] = bookmarksEntry;
array[2] = getByUuid_PrevAndNext(
session, bookmarksEntry, uuid, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry getByUuid_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, 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_BOOKMARKSENTRY_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(BookmarksEntryModelImpl.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(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the bookmarks entries where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
for (BookmarksEntry bookmarksEntry :
findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(bookmarksEntry);
}
}
/**
* Returns the number of bookmarks entries where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching bookmarks entries
*/
@Override
public int countByUuid(String uuid) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid;
Object[] finderArgs = new Object[] {uuid};
Long count = (Long)finderCache.getResult(
finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
}
private static final String _FINDER_COLUMN_UUID_UUID_2 =
"bookmarksEntry.uuid = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3 =
"(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = '')";
private FinderPath _finderPathFetchByUUID_G;
private FinderPath _finderPathCountByUUID_G;
/**
* Returns the bookmarks entry where uuid = ? and groupId = ? or throws a NoSuchEntryException
if it could not be found.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByUUID_G(String uuid, long groupId)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByUUID_G(uuid, groupId);
if (bookmarksEntry == null) {
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("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchEntryException(sb.toString());
}
return bookmarksEntry;
}
/**
* Returns the bookmarks entry where uuid = ? and groupId = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByUUID_G(String uuid, long groupId) {
return fetchByUUID_G(uuid, groupId, true);
}
/**
* Returns the bookmarks entry where uuid = ? and groupId = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @param useFinderCache whether to use the finder cache
* @return the matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByUUID_G(
String uuid, long groupId, boolean useFinderCache) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
uuid = Objects.toString(uuid, "");
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {uuid, groupId};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByUUID_G, finderArgs, this);
}
if (result instanceof BookmarksEntry) {
BookmarksEntry bookmarksEntry = (BookmarksEntry)result;
if (!Objects.equals(uuid, bookmarksEntry.getUuid()) ||
(groupId != bookmarksEntry.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_SELECT_BOOKMARKSENTRY_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);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByUUID_G, finderArgs, list);
}
}
else {
BookmarksEntry bookmarksEntry = list.get(0);
result = bookmarksEntry;
cacheResult(bookmarksEntry);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (BookmarksEntry)result;
}
}
}
/**
* Removes the bookmarks entry where uuid = ? and groupId = ? from the database.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the bookmarks entry that was removed
*/
@Override
public BookmarksEntry removeByUUID_G(String uuid, long groupId)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = findByUUID_G(uuid, groupId);
return remove(bookmarksEntry);
}
/**
* Returns the number of bookmarks entries where uuid = ? and groupId = ?.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the number of matching bookmarks entries
*/
@Override
public int countByUUID_G(String uuid, long groupId) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUUID_G;
Object[] finderArgs = new Object[] {uuid, groupId};
Long count = (Long)finderCache.getResult(
finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_BOOKMARKSENTRY_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();
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 =
"bookmarksEntry.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_G_UUID_3 =
"(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 =
"bookmarksEntry.groupId = ?";
private FinderPath _finderPathWithPaginationFindByUuid_C;
private FinderPath _finderPathWithoutPaginationFindByUuid_C;
private FinderPath _finderPathCountByUuid_C;
/**
* Returns all the bookmarks entries where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching bookmarks entries
*/
@Override
public List findByUuid_C(String uuid, long companyId) {
return findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the bookmarks entries where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end) {
return findByUuid_C(uuid, companyId, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid_C(
uuid, companyId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the bookmarks entries where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUuid_C;
finderArgs = new Object[] {uuid, companyId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUuid_C;
finderArgs = new Object[] {
uuid, companyId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BookmarksEntry bookmarksEntry : list) {
if (!uuid.equals(bookmarksEntry.getUuid()) ||
(companyId != bookmarksEntry.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_BOOKMARKSENTRY_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(BookmarksEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
}
/**
* Returns the first bookmarks entry in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByUuid_C_First(
uuid, companyId, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first bookmarks entry in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry 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 bookmarks entry in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByUuid_C_Last(
uuid, companyId, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last bookmarks entry in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry 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 bookmarks entries before and after the current bookmarks entry in the ordered set where uuid = ? and companyId = ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] findByUuid_C_PrevAndNext(
long entryId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
uuid = Objects.toString(uuid, "");
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = getByUuid_C_PrevAndNext(
session, bookmarksEntry, uuid, companyId, orderByComparator,
true);
array[1] = bookmarksEntry;
array[2] = getByUuid_C_PrevAndNext(
session, bookmarksEntry, uuid, companyId, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry getByUuid_C_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, 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_BOOKMARKSENTRY_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(BookmarksEntryModelImpl.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(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the bookmarks entries where uuid = ? and companyId = ? from the database.
*
* @param uuid the uuid
* @param companyId the company ID
*/
@Override
public void removeByUuid_C(String uuid, long companyId) {
for (BookmarksEntry bookmarksEntry :
findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(bookmarksEntry);
}
}
/**
* Returns the number of bookmarks entries where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching bookmarks entries
*/
@Override
public int countByUuid_C(String uuid, long companyId) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid_C;
Object[] finderArgs = new Object[] {uuid, companyId};
Long count = (Long)finderCache.getResult(
finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
}
private static final String _FINDER_COLUMN_UUID_C_UUID_2 =
"bookmarksEntry.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3 =
"(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 =
"bookmarksEntry.companyId = ?";
private FinderPath _finderPathWithPaginationFindByCompanyId;
private FinderPath _finderPathWithoutPaginationFindByCompanyId;
private FinderPath _finderPathCountByCompanyId;
/**
* Returns all the bookmarks entries where companyId = ?.
*
* @param companyId the company ID
* @return the matching bookmarks entries
*/
@Override
public List findByCompanyId(long companyId) {
return findByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the bookmarks entries where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries
*/
@Override
public List findByCompanyId(
long companyId, int start, int end) {
return findByCompanyId(companyId, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByCompanyId(
long companyId, int start, int end,
OrderByComparator orderByComparator) {
return findByCompanyId(companyId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the bookmarks entries where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByCompanyId(
long companyId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByCompanyId;
finderArgs = new Object[] {companyId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByCompanyId;
finderArgs = new Object[] {
companyId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BookmarksEntry bookmarksEntry : list) {
if (companyId != bookmarksEntry.getCompanyId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
}
/**
* Returns the first bookmarks entry in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByCompanyId_First(
long companyId, OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByCompanyId_First(
companyId, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first bookmarks entry in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByCompanyId_First(
long companyId, OrderByComparator orderByComparator) {
List list = findByCompanyId(
companyId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last bookmarks entry in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByCompanyId_Last(
long companyId, OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByCompanyId_Last(
companyId, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last bookmarks entry in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByCompanyId_Last(
long companyId, OrderByComparator orderByComparator) {
int count = countByCompanyId(companyId);
if (count == 0) {
return null;
}
List list = findByCompanyId(
companyId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where companyId = ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] findByCompanyId_PrevAndNext(
long entryId, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = getByCompanyId_PrevAndNext(
session, bookmarksEntry, companyId, orderByComparator, true);
array[1] = bookmarksEntry;
array[2] = getByCompanyId_PrevAndNext(
session, bookmarksEntry, companyId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry getByCompanyId_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long companyId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the bookmarks entries where companyId = ? from the database.
*
* @param companyId the company ID
*/
@Override
public void removeByCompanyId(long companyId) {
for (BookmarksEntry bookmarksEntry :
findByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(bookmarksEntry);
}
}
/**
* Returns the number of bookmarks entries where companyId = ?.
*
* @param companyId the company ID
* @return the number of matching bookmarks entries
*/
@Override
public int countByCompanyId(long companyId) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = _finderPathCountByCompanyId;
Object[] finderArgs = new Object[] {companyId};
Long count = (Long)finderCache.getResult(
finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
}
private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 =
"bookmarksEntry.companyId = ?";
private FinderPath _finderPathWithPaginationFindByG_F;
private FinderPath _finderPathWithoutPaginationFindByG_F;
private FinderPath _finderPathCountByG_F;
private FinderPath _finderPathWithPaginationCountByG_F;
/**
* Returns all the bookmarks entries where groupId = ? and folderId = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @return the matching bookmarks entries
*/
@Override
public List findByG_F(long groupId, long folderId) {
return findByG_F(
groupId, folderId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the bookmarks entries where groupId = ? and folderId = ?.
*
*
* 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 BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderId the folder ID
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries
*/
@Override
public List findByG_F(
long groupId, long folderId, int start, int end) {
return findByG_F(groupId, folderId, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = ?.
*
*
* 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 BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderId the folder ID
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_F(
long groupId, long folderId, int start, int end,
OrderByComparator orderByComparator) {
return findByG_F(
groupId, folderId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = ?.
*
*
* 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 BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderId the folder ID
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_F(
long groupId, long folderId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByG_F;
finderArgs = new Object[] {groupId, folderId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByG_F;
finderArgs = new Object[] {
groupId, folderId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BookmarksEntry bookmarksEntry : list) {
if ((groupId != bookmarksEntry.getGroupId()) ||
(folderId != bookmarksEntry.getFolderId())) {
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_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_F_GROUPID_2);
sb.append(_FINDER_COLUMN_G_F_FOLDERID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(BookmarksEntryModelImpl.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(folderId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
}
/**
* Returns the first bookmarks entry in the ordered set where groupId = ? and folderId = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByG_F_First(
long groupId, long folderId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByG_F_First(
groupId, folderId, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", folderId=");
sb.append(folderId);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first bookmarks entry in the ordered set where groupId = ? and folderId = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByG_F_First(
long groupId, long folderId,
OrderByComparator orderByComparator) {
List list = findByG_F(
groupId, folderId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last bookmarks entry in the ordered set where groupId = ? and folderId = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByG_F_Last(
long groupId, long folderId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByG_F_Last(
groupId, folderId, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", folderId=");
sb.append(folderId);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last bookmarks entry in the ordered set where groupId = ? and folderId = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByG_F_Last(
long groupId, long folderId,
OrderByComparator orderByComparator) {
int count = countByG_F(groupId, folderId);
if (count == 0) {
return null;
}
List list = findByG_F(
groupId, folderId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = ? and folderId = ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param groupId the group ID
* @param folderId the folder ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] findByG_F_PrevAndNext(
long entryId, long groupId, long folderId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = getByG_F_PrevAndNext(
session, bookmarksEntry, groupId, folderId, orderByComparator,
true);
array[1] = bookmarksEntry;
array[2] = getByG_F_PrevAndNext(
session, bookmarksEntry, groupId, folderId, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry getByG_F_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long groupId,
long folderId, 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_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_F_GROUPID_2);
sb.append(_FINDER_COLUMN_G_F_FOLDERID_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(BookmarksEntryModelImpl.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(folderId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the bookmarks entries that the user has permission to view where groupId = ? and folderId = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @return the matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_F(long groupId, long folderId) {
return filterFindByG_F(
groupId, folderId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the bookmarks entries that the user has permission to view where groupId = ? and folderId = ?.
*
*
* 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 BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderId the folder ID
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_F(
long groupId, long folderId, int start, int end) {
return filterFindByG_F(groupId, folderId, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = ? and folderId = ?.
*
*
* 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 BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderId the folder ID
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_F(
long groupId, long folderId, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_F(groupId, folderId, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_F_GROUPID_2);
sb.append(_FINDER_COLUMN_G_F_FOLDERID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(folderId);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = ? and folderId = ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param groupId the group ID
* @param folderId the folder ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] filterFindByG_F_PrevAndNext(
long entryId, long groupId, long folderId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_F_PrevAndNext(
entryId, groupId, folderId, orderByComparator);
}
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = filterGetByG_F_PrevAndNext(
session, bookmarksEntry, groupId, folderId, orderByComparator,
true);
array[1] = bookmarksEntry;
array[2] = filterGetByG_F_PrevAndNext(
session, bookmarksEntry, groupId, folderId, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry filterGetByG_F_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long groupId,
long folderId, OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_F_GROUPID_2);
sb.append(_FINDER_COLUMN_G_F_FOLDERID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(folderId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the bookmarks entries that the user has permission to view where groupId = ? and folderId = any ?.
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @return the matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_F(
long groupId, long[] folderIds) {
return filterFindByG_F(
groupId, folderIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the bookmarks entries that the user has permission to view where groupId = ? and folderId = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_F(
long groupId, long[] folderIds, int start, int end) {
return filterFindByG_F(groupId, folderIds, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries that the user has permission to view where groupId = ? and folderId = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_F(
long groupId, long[] folderIds, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_F(groupId, folderIds, start, end, orderByComparator);
}
if (folderIds == null) {
folderIds = new long[0];
}
else if (folderIds.length > 1) {
folderIds = ArrayUtil.sortedUnique(folderIds);
}
StringBundler sb = new StringBundler();
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_F_GROUPID_2);
if (folderIds.length > 0) {
sb.append("(");
sb.append(_FINDER_COLUMN_G_F_FOLDERID_7);
sb.append(StringUtil.merge(folderIds));
sb.append(")");
sb.append(")");
}
sb.setStringAt(
removeConjunction(sb.stringAt(sb.index() - 1)), sb.index() - 1);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns all the bookmarks entries where groupId = ? and folderId = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @return the matching bookmarks entries
*/
@Override
public List findByG_F(long groupId, long[] folderIds) {
return findByG_F(
groupId, folderIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the bookmarks entries where groupId = ? and folderId = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries
*/
@Override
public List findByG_F(
long groupId, long[] folderIds, int start, int end) {
return findByG_F(groupId, folderIds, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = any ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_F(
long groupId, long[] folderIds, int start, int end,
OrderByComparator orderByComparator) {
return findByG_F(
groupId, folderIds, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = ?, optionally using the finder cache.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_F(
long groupId, long[] folderIds, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
if (folderIds == null) {
folderIds = new long[0];
}
else if (folderIds.length > 1) {
folderIds = ArrayUtil.sortedUnique(folderIds);
}
if (folderIds.length == 1) {
return findByG_F(
groupId, folderIds[0], start, end, orderByComparator);
}
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderArgs = new Object[] {
groupId, StringUtil.merge(folderIds)
};
}
}
else if (useFinderCache) {
finderArgs = new Object[] {
groupId, StringUtil.merge(folderIds), start, end,
orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
_finderPathWithPaginationFindByG_F, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BookmarksEntry bookmarksEntry : list) {
if ((groupId != bookmarksEntry.getGroupId()) ||
!ArrayUtil.contains(
folderIds, bookmarksEntry.getFolderId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = new StringBundler();
sb.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_F_GROUPID_2);
if (folderIds.length > 0) {
sb.append("(");
sb.append(_FINDER_COLUMN_G_F_FOLDERID_7);
sb.append(StringUtil.merge(folderIds));
sb.append(")");
sb.append(")");
}
sb.setStringAt(
removeConjunction(sb.stringAt(sb.index() - 1)),
sb.index() - 1);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(BookmarksEntryModelImpl.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) {
finderCache.putResult(
_finderPathWithPaginationFindByG_F, finderArgs,
list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
}
/**
* Removes all the bookmarks entries where groupId = ? and folderId = ? from the database.
*
* @param groupId the group ID
* @param folderId the folder ID
*/
@Override
public void removeByG_F(long groupId, long folderId) {
for (BookmarksEntry bookmarksEntry :
findByG_F(
groupId, folderId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(bookmarksEntry);
}
}
/**
* Returns the number of bookmarks entries where groupId = ? and folderId = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @return the number of matching bookmarks entries
*/
@Override
public int countByG_F(long groupId, long folderId) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = _finderPathCountByG_F;
Object[] finderArgs = new Object[] {groupId, folderId};
Long count = (Long)finderCache.getResult(
finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_F_GROUPID_2);
sb.append(_FINDER_COLUMN_G_F_FOLDERID_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(folderId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
}
/**
* Returns the number of bookmarks entries where groupId = ? and folderId = any ?.
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @return the number of matching bookmarks entries
*/
@Override
public int countByG_F(long groupId, long[] folderIds) {
if (folderIds == null) {
folderIds = new long[0];
}
else if (folderIds.length > 1) {
folderIds = ArrayUtil.sortedUnique(folderIds);
}
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
Object[] finderArgs = new Object[] {
groupId, StringUtil.merge(folderIds)
};
Long count = (Long)finderCache.getResult(
_finderPathWithPaginationCountByG_F, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler();
sb.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_F_GROUPID_2);
if (folderIds.length > 0) {
sb.append("(");
sb.append(_FINDER_COLUMN_G_F_FOLDERID_7);
sb.append(StringUtil.merge(folderIds));
sb.append(")");
sb.append(")");
}
sb.setStringAt(
removeConjunction(sb.stringAt(sb.index() - 1)),
sb.index() - 1);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
count = (Long)query.uniqueResult();
finderCache.putResult(
_finderPathWithPaginationCountByG_F, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
}
/**
* Returns the number of bookmarks entries that the user has permission to view where groupId = ? and folderId = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @return the number of matching bookmarks entries that the user has permission to view
*/
@Override
public int filterCountByG_F(long groupId, long folderId) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_F(groupId, folderId);
}
StringBundler sb = new StringBundler(3);
sb.append(_FILTER_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_F_GROUPID_2);
sb.append(_FINDER_COLUMN_G_F_FOLDERID_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(folderId);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the number of bookmarks entries that the user has permission to view where groupId = ? and folderId = any ?.
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @return the number of matching bookmarks entries that the user has permission to view
*/
@Override
public int filterCountByG_F(long groupId, long[] folderIds) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_F(groupId, folderIds);
}
if (folderIds == null) {
folderIds = new long[0];
}
else if (folderIds.length > 1) {
folderIds = ArrayUtil.sortedUnique(folderIds);
}
StringBundler sb = new StringBundler();
sb.append(_FILTER_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_F_GROUPID_2);
if (folderIds.length > 0) {
sb.append("(");
sb.append(_FINDER_COLUMN_G_F_FOLDERID_7);
sb.append(StringUtil.merge(folderIds));
sb.append(")");
sb.append(")");
}
sb.setStringAt(
removeConjunction(sb.stringAt(sb.index() - 1)), sb.index() - 1);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_F_GROUPID_2 =
"bookmarksEntry.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_F_FOLDERID_2 =
"bookmarksEntry.folderId = ?";
private static final String _FINDER_COLUMN_G_F_FOLDERID_7 =
"bookmarksEntry.folderId IN (";
private FinderPath _finderPathWithPaginationFindByG_S;
private FinderPath _finderPathWithoutPaginationFindByG_S;
private FinderPath _finderPathCountByG_S;
/**
* Returns all the bookmarks entries where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @return the matching bookmarks entries
*/
@Override
public List findByG_S(long groupId, int status) {
return findByG_S(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the bookmarks entries where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries
*/
@Override
public List findByG_S(
long groupId, int status, int start, int end) {
return findByG_S(groupId, status, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_S(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByG_S(groupId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_S(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByG_S;
finderArgs = new Object[] {groupId, status};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByG_S;
finderArgs = new Object[] {
groupId, status, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BookmarksEntry bookmarksEntry : list) {
if ((groupId != bookmarksEntry.getGroupId()) ||
(status != bookmarksEntry.getStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_S_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(BookmarksEntryModelImpl.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(status);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
}
/**
* Returns the first bookmarks entry in the ordered set where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByG_S_First(
long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByG_S_First(
groupId, status, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first bookmarks entry in the ordered set where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByG_S_First(
long groupId, int status,
OrderByComparator orderByComparator) {
List list = findByG_S(
groupId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last bookmarks entry in the ordered set where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByG_S_Last(
long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByG_S_Last(
groupId, status, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last bookmarks entry in the ordered set where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByG_S_Last(
long groupId, int status,
OrderByComparator orderByComparator) {
int count = countByG_S(groupId, status);
if (count == 0) {
return null;
}
List list = findByG_S(
groupId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = ? and status = ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] findByG_S_PrevAndNext(
long entryId, long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = getByG_S_PrevAndNext(
session, bookmarksEntry, groupId, status, orderByComparator,
true);
array[1] = bookmarksEntry;
array[2] = getByG_S_PrevAndNext(
session, bookmarksEntry, groupId, status, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry getByG_S_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long groupId,
int status, OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_S_STATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(BookmarksEntryModelImpl.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(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the bookmarks entries that the user has permission to view where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @return the matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_S(long groupId, int status) {
return filterFindByG_S(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the bookmarks entries that the user has permission to view where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_S(
long groupId, int status, int start, int end) {
return filterFindByG_S(groupId, status, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_S(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_S(groupId, status, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_S_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(status);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = ? and status = ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] filterFindByG_S_PrevAndNext(
long entryId, long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_S_PrevAndNext(
entryId, groupId, status, orderByComparator);
}
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = filterGetByG_S_PrevAndNext(
session, bookmarksEntry, groupId, status, orderByComparator,
true);
array[1] = bookmarksEntry;
array[2] = filterGetByG_S_PrevAndNext(
session, bookmarksEntry, groupId, status, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry filterGetByG_S_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long groupId,
int status, OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_S_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the bookmarks entries where groupId = ? and status = ? from the database.
*
* @param groupId the group ID
* @param status the status
*/
@Override
public void removeByG_S(long groupId, int status) {
for (BookmarksEntry bookmarksEntry :
findByG_S(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(bookmarksEntry);
}
}
/**
* Returns the number of bookmarks entries where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @return the number of matching bookmarks entries
*/
@Override
public int countByG_S(long groupId, int status) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = _finderPathCountByG_S;
Object[] finderArgs = new Object[] {groupId, status};
Long count = (Long)finderCache.getResult(
finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_S_STATUS_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(status);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
}
/**
* Returns the number of bookmarks entries that the user has permission to view where groupId = ? and status = ?.
*
* @param groupId the group ID
* @param status the status
* @return the number of matching bookmarks entries that the user has permission to view
*/
@Override
public int filterCountByG_S(long groupId, int status) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_S(groupId, status);
}
StringBundler sb = new StringBundler(3);
sb.append(_FILTER_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_S_STATUS_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(status);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_S_GROUPID_2 =
"bookmarksEntry.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_S_STATUS_2 =
"bookmarksEntry.status = ?";
private FinderPath _finderPathWithPaginationFindByG_NotS;
private FinderPath _finderPathWithPaginationCountByG_NotS;
/**
* Returns all the bookmarks entries where groupId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param status the status
* @return the matching bookmarks entries
*/
@Override
public List findByG_NotS(long groupId, int status) {
return findByG_NotS(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the bookmarks entries where groupId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries
*/
@Override
public List findByG_NotS(
long groupId, int status, int start, int end) {
return findByG_NotS(groupId, status, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_NotS(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByG_NotS(
groupId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_NotS(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = null;
Object[] finderArgs = null;
finderPath = _finderPathWithPaginationFindByG_NotS;
finderArgs = new Object[] {
groupId, status, start, end, orderByComparator
};
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BookmarksEntry bookmarksEntry : list) {
if ((groupId != bookmarksEntry.getGroupId()) ||
(status == bookmarksEntry.getStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
sb.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(BookmarksEntryModelImpl.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(status);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
}
/**
* Returns the first bookmarks entry in the ordered set where groupId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByG_NotS_First(
long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByG_NotS_First(
groupId, status, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", status!=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first bookmarks entry in the ordered set where groupId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByG_NotS_First(
long groupId, int status,
OrderByComparator orderByComparator) {
List list = findByG_NotS(
groupId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last bookmarks entry in the ordered set where groupId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByG_NotS_Last(
long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByG_NotS_Last(
groupId, status, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", status!=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last bookmarks entry in the ordered set where groupId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByG_NotS_Last(
long groupId, int status,
OrderByComparator orderByComparator) {
int count = countByG_NotS(groupId, status);
if (count == 0) {
return null;
}
List list = findByG_NotS(
groupId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = ? and status ≠ ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] findByG_NotS_PrevAndNext(
long entryId, long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = getByG_NotS_PrevAndNext(
session, bookmarksEntry, groupId, status, orderByComparator,
true);
array[1] = bookmarksEntry;
array[2] = getByG_NotS_PrevAndNext(
session, bookmarksEntry, groupId, status, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry getByG_NotS_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long groupId,
int status, OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
sb.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(BookmarksEntryModelImpl.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(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the bookmarks entries that the user has permission to view where groupId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param status the status
* @return the matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_NotS(long groupId, int status) {
return filterFindByG_NotS(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the bookmarks entries that the user has permission to view where groupId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_NotS(
long groupId, int status, int start, int end) {
return filterFindByG_NotS(groupId, status, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_NotS(
long groupId, int status, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_NotS(groupId, status, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
sb.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(status);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = ? and status ≠ ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param groupId the group ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] filterFindByG_NotS_PrevAndNext(
long entryId, long groupId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_NotS_PrevAndNext(
entryId, groupId, status, orderByComparator);
}
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = filterGetByG_NotS_PrevAndNext(
session, bookmarksEntry, groupId, status, orderByComparator,
true);
array[1] = bookmarksEntry;
array[2] = filterGetByG_NotS_PrevAndNext(
session, bookmarksEntry, groupId, status, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry filterGetByG_NotS_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long groupId,
int status, OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
sb.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the bookmarks entries where groupId = ? and status ≠ ? from the database.
*
* @param groupId the group ID
* @param status the status
*/
@Override
public void removeByG_NotS(long groupId, int status) {
for (BookmarksEntry bookmarksEntry :
findByG_NotS(
groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(bookmarksEntry);
}
}
/**
* Returns the number of bookmarks entries where groupId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param status the status
* @return the number of matching bookmarks entries
*/
@Override
public int countByG_NotS(long groupId, int status) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = _finderPathWithPaginationCountByG_NotS;
Object[] finderArgs = new Object[] {groupId, status};
Long count = (Long)finderCache.getResult(
finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
sb.append(_FINDER_COLUMN_G_NOTS_STATUS_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(status);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
}
/**
* Returns the number of bookmarks entries that the user has permission to view where groupId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param status the status
* @return the number of matching bookmarks entries that the user has permission to view
*/
@Override
public int filterCountByG_NotS(long groupId, int status) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_NotS(groupId, status);
}
StringBundler sb = new StringBundler(3);
sb.append(_FILTER_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
sb.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(status);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 =
"bookmarksEntry.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 =
"bookmarksEntry.status != ?";
private FinderPath _finderPathWithPaginationFindByC_NotS;
private FinderPath _finderPathWithPaginationCountByC_NotS;
/**
* Returns all the bookmarks entries where companyId = ? and status ≠ ?.
*
* @param companyId the company ID
* @param status the status
* @return the matching bookmarks entries
*/
@Override
public List findByC_NotS(long companyId, int status) {
return findByC_NotS(
companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the bookmarks entries where companyId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param companyId the company ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries
*/
@Override
public List findByC_NotS(
long companyId, int status, int start, int end) {
return findByC_NotS(companyId, status, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries where companyId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param companyId the company ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByC_NotS(
long companyId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByC_NotS(
companyId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the bookmarks entries where companyId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param companyId the company ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByC_NotS(
long companyId, int status, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = null;
Object[] finderArgs = null;
finderPath = _finderPathWithPaginationFindByC_NotS;
finderArgs = new Object[] {
companyId, status, start, end, orderByComparator
};
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BookmarksEntry bookmarksEntry : list) {
if ((companyId != bookmarksEntry.getCompanyId()) ||
(status == bookmarksEntry.getStatus())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
queryPos.add(status);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
}
/**
* Returns the first bookmarks entry in the ordered set where companyId = ? and status ≠ ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByC_NotS_First(
long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByC_NotS_First(
companyId, status, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append(", status!=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first bookmarks entry in the ordered set where companyId = ? and status ≠ ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByC_NotS_First(
long companyId, int status,
OrderByComparator orderByComparator) {
List list = findByC_NotS(
companyId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last bookmarks entry in the ordered set where companyId = ? and status ≠ ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByC_NotS_Last(
long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByC_NotS_Last(
companyId, status, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append(", status!=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last bookmarks entry in the ordered set where companyId = ? and status ≠ ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByC_NotS_Last(
long companyId, int status,
OrderByComparator orderByComparator) {
int count = countByC_NotS(companyId, status);
if (count == 0) {
return null;
}
List list = findByC_NotS(
companyId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where companyId = ? and status ≠ ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] findByC_NotS_PrevAndNext(
long entryId, long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = getByC_NotS_PrevAndNext(
session, bookmarksEntry, companyId, status, orderByComparator,
true);
array[1] = bookmarksEntry;
array[2] = getByC_NotS_PrevAndNext(
session, bookmarksEntry, companyId, status, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry getByC_NotS_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long companyId,
int status, OrderByComparator orderByComparator,
boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the bookmarks entries where companyId = ? and status ≠ ? from the database.
*
* @param companyId the company ID
* @param status the status
*/
@Override
public void removeByC_NotS(long companyId, int status) {
for (BookmarksEntry bookmarksEntry :
findByC_NotS(
companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(bookmarksEntry);
}
}
/**
* Returns the number of bookmarks entries where companyId = ? and status ≠ ?.
*
* @param companyId the company ID
* @param status the status
* @return the number of matching bookmarks entries
*/
@Override
public int countByC_NotS(long companyId, int status) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = _finderPathWithPaginationCountByC_NotS;
Object[] finderArgs = new Object[] {companyId, status};
Long count = (Long)finderCache.getResult(
finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
queryPos.add(status);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
}
private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 =
"bookmarksEntry.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 =
"bookmarksEntry.status != ?";
private FinderPath _finderPathWithPaginationFindByG_U_S;
private FinderPath _finderPathWithoutPaginationFindByG_U_S;
private FinderPath _finderPathCountByG_U_S;
/**
* Returns all the bookmarks entries where groupId = ? and userId = ? and status = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @return the matching bookmarks entries
*/
@Override
public List findByG_U_S(
long groupId, long userId, int status) {
return findByG_U_S(
groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the bookmarks entries where groupId = ? and userId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries
*/
@Override
public List findByG_U_S(
long groupId, long userId, int status, int start, int end) {
return findByG_U_S(groupId, userId, status, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and userId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_U_S(
long groupId, long userId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByG_U_S(
groupId, userId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and userId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_U_S(
long groupId, long userId, int status, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByG_U_S;
finderArgs = new Object[] {groupId, userId, status};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByG_U_S;
finderArgs = new Object[] {
groupId, userId, status, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BookmarksEntry bookmarksEntry : list) {
if ((groupId != bookmarksEntry.getGroupId()) ||
(userId != bookmarksEntry.getUserId()) ||
(status != bookmarksEntry.getStatus())) {
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_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_S_USERID_2);
sb.append(_FINDER_COLUMN_G_U_S_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(BookmarksEntryModelImpl.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(userId);
queryPos.add(status);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
}
/**
* Returns the first bookmarks entry in the ordered set where groupId = ? and userId = ? and status = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByG_U_S_First(
long groupId, long userId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByG_U_S_First(
groupId, userId, status, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", userId=");
sb.append(userId);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first bookmarks entry in the ordered set where groupId = ? and userId = ? and status = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByG_U_S_First(
long groupId, long userId, int status,
OrderByComparator orderByComparator) {
List list = findByG_U_S(
groupId, userId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last bookmarks entry in the ordered set where groupId = ? and userId = ? and status = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByG_U_S_Last(
long groupId, long userId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByG_U_S_Last(
groupId, userId, status, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", userId=");
sb.append(userId);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last bookmarks entry in the ordered set where groupId = ? and userId = ? and status = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByG_U_S_Last(
long groupId, long userId, int status,
OrderByComparator orderByComparator) {
int count = countByG_U_S(groupId, userId, status);
if (count == 0) {
return null;
}
List list = findByG_U_S(
groupId, userId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = ? and userId = ? and status = ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] findByG_U_S_PrevAndNext(
long entryId, long groupId, long userId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = getByG_U_S_PrevAndNext(
session, bookmarksEntry, groupId, userId, status,
orderByComparator, true);
array[1] = bookmarksEntry;
array[2] = getByG_U_S_PrevAndNext(
session, bookmarksEntry, groupId, userId, status,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry getByG_U_S_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long groupId,
long userId, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_S_USERID_2);
sb.append(_FINDER_COLUMN_G_U_S_STATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(BookmarksEntryModelImpl.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(userId);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the bookmarks entries that the user has permission to view where groupId = ? and userId = ? and status = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @return the matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_U_S(
long groupId, long userId, int status) {
return filterFindByG_U_S(
groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the bookmarks entries that the user has permission to view where groupId = ? and userId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_U_S(
long groupId, long userId, int status, int start, int end) {
return filterFindByG_U_S(groupId, userId, status, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = ? and userId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_U_S(
long groupId, long userId, int status, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_U_S(
groupId, userId, status, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(6);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_S_USERID_2);
sb.append(_FINDER_COLUMN_G_U_S_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(status);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = ? and userId = ? and status = ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] filterFindByG_U_S_PrevAndNext(
long entryId, long groupId, long userId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_U_S_PrevAndNext(
entryId, groupId, userId, status, orderByComparator);
}
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = filterGetByG_U_S_PrevAndNext(
session, bookmarksEntry, groupId, userId, status,
orderByComparator, true);
array[1] = bookmarksEntry;
array[2] = filterGetByG_U_S_PrevAndNext(
session, bookmarksEntry, groupId, userId, status,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry filterGetByG_U_S_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long groupId,
long userId, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
7 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(6);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_S_USERID_2);
sb.append(_FINDER_COLUMN_G_U_S_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the bookmarks entries where groupId = ? and userId = ? and status = ? from the database.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
*/
@Override
public void removeByG_U_S(long groupId, long userId, int status) {
for (BookmarksEntry bookmarksEntry :
findByG_U_S(
groupId, userId, status, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(bookmarksEntry);
}
}
/**
* Returns the number of bookmarks entries where groupId = ? and userId = ? and status = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @return the number of matching bookmarks entries
*/
@Override
public int countByG_U_S(long groupId, long userId, int status) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = _finderPathCountByG_U_S;
Object[] finderArgs = new Object[] {groupId, userId, status};
Long count = (Long)finderCache.getResult(
finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_S_USERID_2);
sb.append(_FINDER_COLUMN_G_U_S_STATUS_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(status);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
}
/**
* Returns the number of bookmarks entries that the user has permission to view where groupId = ? and userId = ? and status = ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @return the number of matching bookmarks entries that the user has permission to view
*/
@Override
public int filterCountByG_U_S(long groupId, long userId, int status) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_U_S(groupId, userId, status);
}
StringBundler sb = new StringBundler(4);
sb.append(_FILTER_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_S_USERID_2);
sb.append(_FINDER_COLUMN_G_U_S_STATUS_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(status);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 =
"bookmarksEntry.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_U_S_USERID_2 =
"bookmarksEntry.userId = ? AND ";
private static final String _FINDER_COLUMN_G_U_S_STATUS_2 =
"bookmarksEntry.status = ?";
private FinderPath _finderPathWithPaginationFindByG_U_NotS;
private FinderPath _finderPathWithPaginationCountByG_U_NotS;
/**
* Returns all the bookmarks entries where groupId = ? and userId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @return the matching bookmarks entries
*/
@Override
public List findByG_U_NotS(
long groupId, long userId, int status) {
return findByG_U_NotS(
groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the bookmarks entries where groupId = ? and userId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries
*/
@Override
public List findByG_U_NotS(
long groupId, long userId, int status, int start, int end) {
return findByG_U_NotS(groupId, userId, status, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and userId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_U_NotS(
long groupId, long userId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByG_U_NotS(
groupId, userId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and userId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_U_NotS(
long groupId, long userId, int status, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = null;
Object[] finderArgs = null;
finderPath = _finderPathWithPaginationFindByG_U_NotS;
finderArgs = new Object[] {
groupId, userId, status, start, end, orderByComparator
};
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BookmarksEntry bookmarksEntry : list) {
if ((groupId != bookmarksEntry.getGroupId()) ||
(userId != bookmarksEntry.getUserId()) ||
(status == bookmarksEntry.getStatus())) {
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_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
sb.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(BookmarksEntryModelImpl.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(userId);
queryPos.add(status);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
}
/**
* Returns the first bookmarks entry in the ordered set where groupId = ? and userId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByG_U_NotS_First(
long groupId, long userId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByG_U_NotS_First(
groupId, userId, status, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", userId=");
sb.append(userId);
sb.append(", status!=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first bookmarks entry in the ordered set where groupId = ? and userId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByG_U_NotS_First(
long groupId, long userId, int status,
OrderByComparator orderByComparator) {
List list = findByG_U_NotS(
groupId, userId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last bookmarks entry in the ordered set where groupId = ? and userId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByG_U_NotS_Last(
long groupId, long userId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByG_U_NotS_Last(
groupId, userId, status, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", userId=");
sb.append(userId);
sb.append(", status!=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last bookmarks entry in the ordered set where groupId = ? and userId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByG_U_NotS_Last(
long groupId, long userId, int status,
OrderByComparator orderByComparator) {
int count = countByG_U_NotS(groupId, userId, status);
if (count == 0) {
return null;
}
List list = findByG_U_NotS(
groupId, userId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = ? and userId = ? and status ≠ ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] findByG_U_NotS_PrevAndNext(
long entryId, long groupId, long userId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = getByG_U_NotS_PrevAndNext(
session, bookmarksEntry, groupId, userId, status,
orderByComparator, true);
array[1] = bookmarksEntry;
array[2] = getByG_U_NotS_PrevAndNext(
session, bookmarksEntry, groupId, userId, status,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry getByG_U_NotS_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long groupId,
long userId, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
sb.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(BookmarksEntryModelImpl.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(userId);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the bookmarks entries that the user has permission to view where groupId = ? and userId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @return the matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_U_NotS(
long groupId, long userId, int status) {
return filterFindByG_U_NotS(
groupId, userId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the bookmarks entries that the user has permission to view where groupId = ? and userId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_U_NotS(
long groupId, long userId, int status, int start, int end) {
return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = ? and userId = ? and status ≠ ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_U_NotS(
long groupId, long userId, int status, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_U_NotS(
groupId, userId, status, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(6);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
sb.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(status);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = ? and userId = ? and status ≠ ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] filterFindByG_U_NotS_PrevAndNext(
long entryId, long groupId, long userId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_U_NotS_PrevAndNext(
entryId, groupId, userId, status, orderByComparator);
}
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = filterGetByG_U_NotS_PrevAndNext(
session, bookmarksEntry, groupId, userId, status,
orderByComparator, true);
array[1] = bookmarksEntry;
array[2] = filterGetByG_U_NotS_PrevAndNext(
session, bookmarksEntry, groupId, userId, status,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry filterGetByG_U_NotS_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long groupId,
long userId, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
7 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(6);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
sb.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the bookmarks entries where groupId = ? and userId = ? and status ≠ ? from the database.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
*/
@Override
public void removeByG_U_NotS(long groupId, long userId, int status) {
for (BookmarksEntry bookmarksEntry :
findByG_U_NotS(
groupId, userId, status, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(bookmarksEntry);
}
}
/**
* Returns the number of bookmarks entries where groupId = ? and userId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @return the number of matching bookmarks entries
*/
@Override
public int countByG_U_NotS(long groupId, long userId, int status) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = _finderPathWithPaginationCountByG_U_NotS;
Object[] finderArgs = new Object[] {groupId, userId, status};
Long count = (Long)finderCache.getResult(
finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
sb.append(_FINDER_COLUMN_G_U_NOTS_STATUS_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(userId);
queryPos.add(status);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
}
/**
* Returns the number of bookmarks entries that the user has permission to view where groupId = ? and userId = ? and status ≠ ?.
*
* @param groupId the group ID
* @param userId the user ID
* @param status the status
* @return the number of matching bookmarks entries that the user has permission to view
*/
@Override
public int filterCountByG_U_NotS(long groupId, long userId, int status) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return countByG_U_NotS(groupId, userId, status);
}
StringBundler sb = new StringBundler(4);
sb.append(_FILTER_SQL_COUNT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
sb.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
sb.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(userId);
queryPos.add(status);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 =
"bookmarksEntry.groupId = ? AND ";
private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 =
"bookmarksEntry.userId = ? AND ";
private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 =
"bookmarksEntry.status != ?";
private FinderPath _finderPathWithPaginationFindByG_F_S;
private FinderPath _finderPathWithoutPaginationFindByG_F_S;
private FinderPath _finderPathCountByG_F_S;
private FinderPath _finderPathWithPaginationCountByG_F_S;
/**
* Returns all the bookmarks entries where groupId = ? and folderId = ? and status = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @return the matching bookmarks entries
*/
@Override
public List findByG_F_S(
long groupId, long folderId, int status) {
return findByG_F_S(
groupId, folderId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the bookmarks entries where groupId = ? and folderId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries
*/
@Override
public List findByG_F_S(
long groupId, long folderId, int status, int start, int end) {
return findByG_F_S(groupId, folderId, status, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_F_S(
long groupId, long folderId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByG_F_S(
groupId, folderId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bookmarks entries
*/
@Override
public List findByG_F_S(
long groupId, long folderId, int status, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
try (SafeCloseable safeCloseable =
ctPersistenceHelper.setCTCollectionIdWithSafeCloseable(
BookmarksEntry.class)) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByG_F_S;
finderArgs = new Object[] {groupId, folderId, status};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByG_F_S;
finderArgs = new Object[] {
groupId, folderId, status, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (BookmarksEntry bookmarksEntry : list) {
if ((groupId != bookmarksEntry.getGroupId()) ||
(folderId != bookmarksEntry.getFolderId()) ||
(status != bookmarksEntry.getStatus())) {
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_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
sb.append(_FINDER_COLUMN_G_F_S_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(BookmarksEntryModelImpl.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(folderId);
queryPos.add(status);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
}
/**
* Returns the first bookmarks entry in the ordered set where groupId = ? and folderId = ? and status = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByG_F_S_First(
long groupId, long folderId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByG_F_S_First(
groupId, folderId, status, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", folderId=");
sb.append(folderId);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first bookmarks entry in the ordered set where groupId = ? and folderId = ? and status = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByG_F_S_First(
long groupId, long folderId, int status,
OrderByComparator orderByComparator) {
List list = findByG_F_S(
groupId, folderId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last bookmarks entry in the ordered set where groupId = ? and folderId = ? and status = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry
* @throws NoSuchEntryException if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry findByG_F_S_Last(
long groupId, long folderId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = fetchByG_F_S_Last(
groupId, folderId, status, orderByComparator);
if (bookmarksEntry != null) {
return bookmarksEntry;
}
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("groupId=");
sb.append(groupId);
sb.append(", folderId=");
sb.append(folderId);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last bookmarks entry in the ordered set where groupId = ? and folderId = ? and status = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching bookmarks entry, or null
if a matching bookmarks entry could not be found
*/
@Override
public BookmarksEntry fetchByG_F_S_Last(
long groupId, long folderId, int status,
OrderByComparator orderByComparator) {
int count = countByG_F_S(groupId, folderId, status);
if (count == 0) {
return null;
}
List list = findByG_F_S(
groupId, folderId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = ? and folderId = ? and status = ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] findByG_F_S_PrevAndNext(
long entryId, long groupId, long folderId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = getByG_F_S_PrevAndNext(
session, bookmarksEntry, groupId, folderId, status,
orderByComparator, true);
array[1] = bookmarksEntry;
array[2] = getByG_F_S_PrevAndNext(
session, bookmarksEntry, groupId, folderId, status,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry getByG_F_S_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long groupId,
long folderId, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
sb.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
sb.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
sb.append(_FINDER_COLUMN_G_F_S_STATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(BookmarksEntryModelImpl.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(folderId);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the bookmarks entries that the user has permission to view where groupId = ? and folderId = ? and status = ?.
*
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @return the matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_F_S(
long groupId, long folderId, int status) {
return filterFindByG_F_S(
groupId, folderId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the bookmarks entries that the user has permission to view where groupId = ? and folderId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_F_S(
long groupId, long folderId, int status, int start, int end) {
return filterFindByG_F_S(groupId, folderId, status, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = ? and folderId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_F_S(
long groupId, long folderId, int status, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_F_S(
groupId, folderId, status, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(6);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
sb.append(_FINDER_COLUMN_G_F_S_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(folderId);
queryPos.add(status);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = ? and folderId = ? and status = ?.
*
* @param entryId the primary key of the current bookmarks entry
* @param groupId the group ID
* @param folderId the folder ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next bookmarks entry
* @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found
*/
@Override
public BookmarksEntry[] filterFindByG_F_S_PrevAndNext(
long entryId, long groupId, long folderId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_F_S_PrevAndNext(
entryId, groupId, folderId, status, orderByComparator);
}
BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
Session session = null;
try {
session = openSession();
BookmarksEntry[] array = new BookmarksEntryImpl[3];
array[0] = filterGetByG_F_S_PrevAndNext(
session, bookmarksEntry, groupId, folderId, status,
orderByComparator, true);
array[1] = bookmarksEntry;
array[2] = filterGetByG_F_S_PrevAndNext(
session, bookmarksEntry, groupId, folderId, status,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected BookmarksEntry filterGetByG_F_S_PrevAndNext(
Session session, BookmarksEntry bookmarksEntry, long groupId,
long folderId, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
7 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(6);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
sb.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
sb.append(_FINDER_COLUMN_G_F_S_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(folderId);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(
bookmarksEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the bookmarks entries that the user has permission to view where groupId = ? and folderId = any ? and status = ?.
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @param status the status
* @return the matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_F_S(
long groupId, long[] folderIds, int status) {
return filterFindByG_F_S(
groupId, folderIds, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the bookmarks entries that the user has permission to view where groupId = ? and folderId = any ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @return the range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_F_S(
long groupId, long[] folderIds, int status, int start, int end) {
return filterFindByG_F_S(groupId, folderIds, status, start, end, null);
}
/**
* Returns an ordered range of all the bookmarks entries that the user has permission to view where groupId = ? and folderId = any ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @param status the status
* @param start the lower bound of the range of bookmarks entries
* @param end the upper bound of the range of bookmarks entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching bookmarks entries that the user has permission to view
*/
@Override
public List filterFindByG_F_S(
long groupId, long[] folderIds, int status, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(groupId)) {
return findByG_F_S(
groupId, folderIds, status, start, end, orderByComparator);
}
if (folderIds == null) {
folderIds = new long[0];
}
else if (folderIds.length > 1) {
folderIds = ArrayUtil.sortedUnique(folderIds);
}
StringBundler sb = new StringBundler();
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_BOOKMARKSENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
if (folderIds.length > 0) {
sb.append("(");
sb.append(_FINDER_COLUMN_G_F_S_FOLDERID_7);
sb.append(StringUtil.merge(folderIds));
sb.append(")");
sb.append(")");
sb.append(WHERE_AND);
}
sb.append(_FINDER_COLUMN_G_F_S_STATUS_2);
sb.setStringAt(
removeConjunction(sb.stringAt(sb.index() - 1)), sb.index() - 1);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_BOOKMARKSENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(BookmarksEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), BookmarksEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, BookmarksEntryImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, BookmarksEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(groupId);
queryPos.add(status);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns all the bookmarks entries where groupId = ? and folderId = any ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from BookmarksEntryModelImpl
.
*
*
* @param groupId the group ID
* @param folderIds the folder IDs
* @param status the status
* @return the matching bookmarks entries
*/
@Override
public List findByG_F_S(
long groupId, long[] folderIds, int status) {
return findByG_F_S(
groupId, folderIds, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null);
}
/**
* Returns a range of all the bookmarks entries where groupId = ? and folderId = any ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of