/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.bookmarks.service.persistence.impl; import aQute.bnd.annotation.ProviderType; import com.liferay.bookmarks.exception.NoSuchEntryException; import com.liferay.bookmarks.model.BookmarksEntry; import com.liferay.bookmarks.model.impl.BookmarksEntryImpl; import com.liferay.bookmarks.model.impl.BookmarksEntryModelImpl; import com.liferay.bookmarks.service.persistence.BookmarksEntryPersistence; import com.liferay.portal.kernel.dao.orm.EntityCache; import com.liferay.portal.kernel.dao.orm.FinderCache; import com.liferay.portal.kernel.dao.orm.FinderPath; import com.liferay.portal.kernel.dao.orm.Query; import com.liferay.portal.kernel.dao.orm.QueryPos; import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.dao.orm.Session; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; 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.CompanyProvider; import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper; import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl; import com.liferay.portal.kernel.util.ArrayUtil; import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.util.ReflectionUtil; import com.liferay.portal.kernel.util.SetUtil; import com.liferay.portal.kernel.util.StringBundler; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.uuid.PortalUUIDUtil; import com.liferay.portal.spring.extender.service.ServiceReference; import java.io.Serializable; import java.lang.reflect.Field; import java.util.Arrays; import java.util.Collections; import java.util.Date; 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; /** * The persistence implementation for the bookmarks entry service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author Brian Wing Shun Chan * @see BookmarksEntryPersistence * @see com.liferay.bookmarks.service.persistence.BookmarksEntryUtil * @generated */ @ProviderType public class BookmarksEntryPersistenceImpl extends BasePersistenceImpl<BookmarksEntry> implements BookmarksEntryPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use {@link BookmarksEntryUtil} to access the bookmarks entry persistence. Modify <code>service.xml</code> 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"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEBLOCKID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByResourceBlockId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourceBlockId", new String[] { Long.class.getName() }, BookmarksEntryModelImpl.RESOURCEBLOCKID_COLUMN_BITMASK | BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK | BookmarksEntryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEBLOCKID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByResourceBlockId", new String[] { Long.class.getName() }); /** * Returns all the bookmarks entries where resourceBlockId = ?. * * @param resourceBlockId the resource block ID * @return the matching bookmarks entries */ @Override public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId) { return findByResourceBlockId(resourceBlockId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the bookmarks entries where resourceBlockId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param resourceBlockId the resource block 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<BookmarksEntry> findByResourceBlockId(long resourceBlockId, int start, int end) { return findByResourceBlockId(resourceBlockId, start, end, null); } /** * Returns an ordered range of all the bookmarks entries where resourceBlockId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param resourceBlockId the resource block 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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByResourceBlockId(resourceBlockId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where resourceBlockId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param resourceBlockId the resource block 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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID; finderArgs = new Object[] { resourceBlockId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEBLOCKID; finderArgs = new Object[] { resourceBlockId, start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (BookmarksEntry bookmarksEntry : list) { if ((resourceBlockId != bookmarksEntry.getResourceBlockId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(resourceBlockId); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first bookmarks entry in the ordered set where resourceBlockId = ?. * * @param resourceBlockId the resource block ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching bookmarks entry * @throws NoSuchEntryException if a matching bookmarks entry could not be found */ @Override public BookmarksEntry findByResourceBlockId_First(long resourceBlockId, OrderByComparator<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByResourceBlockId_First(resourceBlockId, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("resourceBlockId="); msg.append(resourceBlockId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } /** * Returns the first bookmarks entry in the ordered set where resourceBlockId = ?. * * @param resourceBlockId the resource block ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByResourceBlockId_First(long resourceBlockId, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> list = findByResourceBlockId(resourceBlockId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last bookmarks entry in the ordered set where resourceBlockId = ?. * * @param resourceBlockId the resource block ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching bookmarks entry * @throws NoSuchEntryException if a matching bookmarks entry could not be found */ @Override public BookmarksEntry findByResourceBlockId_Last(long resourceBlockId, OrderByComparator<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByResourceBlockId_Last(resourceBlockId, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("resourceBlockId="); msg.append(resourceBlockId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } /** * Returns the last bookmarks entry in the ordered set where resourceBlockId = ?. * * @param resourceBlockId the resource block ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByResourceBlockId_Last(long resourceBlockId, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByResourceBlockId(resourceBlockId); if (count == 0) { return null; } List<BookmarksEntry> list = findByResourceBlockId(resourceBlockId, 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 resourceBlockId = ?. * * @param entryId the primary key of the current bookmarks entry * @param resourceBlockId the resource block ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @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[] findByResourceBlockId_PrevAndNext(long entryId, long resourceBlockId, OrderByComparator<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId); Session session = null; try { session = openSession(); BookmarksEntry[] array = new BookmarksEntryImpl[3]; array[0] = getByResourceBlockId_PrevAndNext(session, bookmarksEntry, resourceBlockId, orderByComparator, true); array[1] = bookmarksEntry; array[2] = getByResourceBlockId_PrevAndNext(session, bookmarksEntry, resourceBlockId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByResourceBlockId_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long resourceBlockId, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(resourceBlockId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the bookmarks entries where resourceBlockId = ? from the database. * * @param resourceBlockId the resource block ID */ @Override public void removeByResourceBlockId(long resourceBlockId) { for (BookmarksEntry bookmarksEntry : findByResourceBlockId( resourceBlockId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(bookmarksEntry); } } /** * Returns the number of bookmarks entries where resourceBlockId = ?. * * @param resourceBlockId the resource block ID * @return the number of matching bookmarks entries */ @Override public int countByResourceBlockId(long resourceBlockId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEBLOCKID; Object[] finderArgs = new Object[] { resourceBlockId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(resourceBlockId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2 = "bookmarksEntry.resourceBlockId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid", new String[] { String.class.getName() }, BookmarksEntryModelImpl.UUID_COLUMN_BITMASK | BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK | BookmarksEntryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid", new String[] { String.class.getName() }); /** * Returns all the bookmarks entries where uuid = ?. * * @param uuid the uuid * @return the matching bookmarks entries */ @Override public List<BookmarksEntry> findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the bookmarks entries where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> findByUuid(String uuid, int start, int end) { return findByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the bookmarks entries where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByUuid(String uuid, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByUuid(uuid, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByUuid(String uuid, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID; finderArgs = new Object[] { uuid }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID; finderArgs = new Object[] { uuid, start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (BookmarksEntry bookmarksEntry : list) { if (!Objects.equals(uuid, bookmarksEntry.getUuid())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByUuid_First(uuid, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByUuid_First(String uuid, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByUuid_Last(uuid, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByUuid_Last(String uuid, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByUuid(uuid); if (count == 0) { return null; } List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByUuid_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, String uuid, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID; Object[] finderArgs = new Object[] { uuid }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_UUID_1 = "bookmarksEntry.uuid IS NULL"; 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 = '')"; public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G", new String[] { String.class.getName(), Long.class.getName() }, BookmarksEntryModelImpl.UUID_COLUMN_BITMASK | BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G", new String[] { String.class.getName(), Long.class.getName() }); /** * Returns the bookmarks entry where uuid = ? and groupId = ? or throws a {@link 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 msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", groupId="); msg.append(groupId); msg.append(StringPool.CLOSE_CURLY_BRACE); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchEntryException(msg.toString()); } return bookmarksEntry; } /** * Returns the bookmarks entry where uuid = ? and groupId = ? or returns <code>null</code> 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 <code>null</code> 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 <code>null</code> if it could not be found, optionally using the finder cache. * * @param uuid the uuid * @param groupId the group ID * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByUUID_G(String uuid, long groupId, boolean retrieveFromCache) { Object[] finderArgs = new Object[] { uuid, groupId }; Object result = null; if (retrieveFromCache) { result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_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 query = new StringBundler(4); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_G_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_G_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_G_UUID_2); } query.append(_FINDER_COLUMN_UUID_G_GROUPID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(groupId); List<BookmarksEntry> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, list); } else { BookmarksEntry bookmarksEntry = list.get(0); result = bookmarksEntry; cacheResult(bookmarksEntry); if ((bookmarksEntry.getUuid() == null) || !bookmarksEntry.getUuid().equals(uuid) || (bookmarksEntry.getGroupId() != groupId)) { finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, bookmarksEntry); } } } catch (Exception e) { finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs); throw processException(e); } 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) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G; Object[] finderArgs = new Object[] { uuid, groupId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_G_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_G_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_G_UUID_2); } query.append(_FINDER_COLUMN_UUID_G_GROUPID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(groupId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "bookmarksEntry.uuid IS NULL AND "; 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 = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName() }, BookmarksEntryModelImpl.UUID_COLUMN_BITMASK | BookmarksEntryModelImpl.COMPANYID_COLUMN_BITMASK | BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK | BookmarksEntryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C", new String[] { String.class.getName(), Long.class.getName() }); /** * 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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByUuid_C(uuid, companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C; finderArgs = new Object[] { uuid, companyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C; finderArgs = new Object[] { uuid, companyId, start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (BookmarksEntry bookmarksEntry : list) { if (!Objects.equals(uuid, bookmarksEntry.getUuid()) || (companyId != bookmarksEntry.getCompanyId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByUuid_C_First(uuid, companyId, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByUuid_C_First(String uuid, long companyId, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByUuid_C_Last(uuid, companyId, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByUuid_C_Last(String uuid, long companyId, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByUuid_C(uuid, companyId); if (count == 0) { return null; } List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByUuid_C_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, String uuid, long companyId, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C; Object[] finderArgs = new Object[] { uuid, companyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "bookmarksEntry.uuid IS NULL AND "; 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 = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId", new String[] { Long.class.getName() }, BookmarksEntryModelImpl.COMPANYID_COLUMN_BITMASK | BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK | BookmarksEntryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId", new String[] { Long.class.getName() }); /** * Returns all the bookmarks entries where companyId = ?. * * @param companyId the company ID * @return the matching bookmarks entries */ @Override public List<BookmarksEntry> findByCompanyId(long companyId) { return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the bookmarks entries where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> findByCompanyId(long companyId, int start, int end) { return findByCompanyId(companyId, start, end, null); } /** * Returns an ordered range of all the bookmarks entries where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByCompanyId(long companyId, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByCompanyId(companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByCompanyId(long companyId, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID; finderArgs = new Object[] { companyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID; finderArgs = new Object[] { companyId, start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)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 query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByCompanyId_First(companyId, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByCompanyId_First(long companyId, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByCompanyId_Last(companyId, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByCompanyId_Last(long companyId, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByCompanyId(companyId); if (count == 0) { return null; } List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByCompanyId_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long companyId, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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) { FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID; Object[] finderArgs = new Object[] { companyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "bookmarksEntry.companyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F", new String[] { Long.class.getName(), Long.class.getName() }, BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK | BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK | BookmarksEntryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F", new String[] { Long.class.getName(), Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F", new String[] { Long.class.getName(), Long.class.getName() }); /** * 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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F(long groupId, long folderId, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByG_F(groupId, folderId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F(long groupId, long folderId, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F; finderArgs = new Object[] { groupId, folderId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F; finderArgs = new Object[] { groupId, folderId, start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)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 query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_GROUPID_2); query.append(_FINDER_COLUMN_G_F_FOLDERID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_F_First(groupId, folderId, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", folderId="); msg.append(folderId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_F_First(long groupId, long folderId, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_F_Last(groupId, folderId, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", folderId="); msg.append(folderId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_F_Last(long groupId, long folderId, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByG_F(groupId, folderId); if (count == 0) { return null; } List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByG_F_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long folderId, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_GROUPID_2); query.append(_FINDER_COLUMN_G_F_FOLDERID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view */ @Override public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_F(groupId, folderId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_GROUPID_2); query.append(_FINDER_COLUMN_G_F_FOLDERID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry filterGetByG_F_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long folderId, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_GROUPID_2); query.append(_FINDER_COLUMN_G_F_FOLDERID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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<BookmarksEntry> 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 ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view */ @Override public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds, int start, int end, OrderByComparator<BookmarksEntry> 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.unique(folderIds); Arrays.sort(folderIds); } StringBundler query = new StringBundler(); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_GROUPID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_F_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the bookmarks entries where groupId = ? and folderId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param folderIds the folder IDs * @return the matching bookmarks entries */ @Override public List<BookmarksEntry> 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 ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds, int start, int end, OrderByComparator<BookmarksEntry> 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. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { if (folderIds == null) { folderIds = new long[0]; } else if (folderIds.length > 1) { folderIds = ArrayUtil.unique(folderIds); Arrays.sort(folderIds); } if (folderIds.length == 1) { return findByG_F(groupId, folderIds[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) }; } else { finderArgs = new Object[] { groupId, StringUtil.merge(folderIds), start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_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 query = new StringBundler(); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_GROUPID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_F_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F, finderArgs); throw processException(e); } 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) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F; Object[] finderArgs = new Object[] { groupId, folderId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_GROUPID_2); query.append(_FINDER_COLUMN_G_F_FOLDERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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.unique(folderIds); Arrays.sort(folderIds); } Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_GROUPID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_F_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F, finderArgs); throw processException(e); } 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 query = new StringBundler(3); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_GROUPID_2); query.append(_FINDER_COLUMN_G_F_FOLDERID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } 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.unique(folderIds); Arrays.sort(folderIds); } StringBundler query = new StringBundler(); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_GROUPID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_F_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } 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 ("; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S", new String[] { Long.class.getName(), Integer.class.getName() }, BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK | BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK | BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK | BookmarksEntryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S", new String[] { Long.class.getName(), Integer.class.getName() }); /** * 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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_S(long groupId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByG_S(groupId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_S(long groupId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S; finderArgs = new Object[] { groupId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S; finderArgs = new Object[] { groupId, status, start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)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 query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_S_First(groupId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_S_First(long groupId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_S_Last(groupId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_S_Last(long groupId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByG_S(groupId, status); if (count == 0) { return null; } List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByG_S_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view */ @Override public List<BookmarksEntry> filterFindByG_S(long groupId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_S(groupId, status, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry filterGetByG_S_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S; Object[] finderArgs = new Object[] { groupId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 query = new StringBundler(3); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_S_GROUPID_2); query.append(_FINDER_COLUMN_G_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } 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 = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotS", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS", new String[] { Long.class.getName(), Integer.class.getName() }); /** * 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<BookmarksEntry> 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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_NotS(long groupId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByG_NotS(groupId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and status ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_NotS(long groupId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS; finderArgs = new Object[] { groupId, status, start, end, orderByComparator }; List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)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 query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTS_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_NotS_First(groupId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_NotS_First(long groupId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_NotS_Last(groupId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_NotS_Last(long groupId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByG_NotS(groupId, status); if (count == 0) { return null; } List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByG_NotS_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTS_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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<BookmarksEntry> 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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view */ @Override public List<BookmarksEntry> filterFindByG_NotS(long groupId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_NotS(groupId, status, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTS_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry filterGetByG_NotS_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTS_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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) { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS; Object[] finderArgs = new Object[] { groupId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTS_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 query = new StringBundler(3); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_NOTS_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } 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 != ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS", new String[] { Long.class.getName(), Integer.class.getName() }); /** * 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<BookmarksEntry> 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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByC_NotS(long companyId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByC_NotS(companyId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where companyId = ? and status ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByC_NotS(long companyId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS; finderArgs = new Object[] { companyId, status, start, end, orderByComparator }; List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)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 query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2); query.append(_FINDER_COLUMN_C_NOTS_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(status); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByC_NotS_First(companyId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByC_NotS_First(long companyId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByC_NotS_Last(companyId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByC_NotS_Last(long companyId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByC_NotS(companyId, status); if (count == 0) { return null; } List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByC_NotS_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long companyId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2); query.append(_FINDER_COLUMN_C_NOTS_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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) { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS; Object[] finderArgs = new Object[] { companyId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2); query.append(_FINDER_COLUMN_C_NOTS_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 != ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK | BookmarksEntryModelImpl.USERID_COLUMN_BITMASK | BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK | BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK | BookmarksEntryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * 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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_U_S(long groupId, long userId, int status, int start, int end, OrderByComparator<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_U_S(long groupId, long userId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S; finderArgs = new Object[] { groupId, userId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S; finderArgs = new Object[] { groupId, userId, status, start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)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 query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); query.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_U_S_First(groupId, userId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", userId="); msg.append(userId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_U_S_First(long groupId, long userId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_U_S_Last(groupId, userId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", userId="); msg.append(userId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_U_S_Last(long groupId, long userId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByG_U_S(groupId, userId, status); if (count == 0) { return null; } List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByG_U_S_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long userId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); query.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view */ @Override public List<BookmarksEntry> filterFindByG_U_S(long groupId, long userId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_S(groupId, userId, status, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); query.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry filterGetByG_U_S_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long userId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); query.append(_FINDER_COLUMN_G_U_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S; Object[] finderArgs = new Object[] { groupId, userId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); query.append(_FINDER_COLUMN_G_U_S_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 query = new StringBundler(4); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); query.append(_FINDER_COLUMN_G_U_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } 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 = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * 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<BookmarksEntry> 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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_U_NotS(long groupId, long userId, int status, int start, int end, OrderByComparator<BookmarksEntry> 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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_U_NotS(long groupId, long userId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS; finderArgs = new Object[] { groupId, userId, status, start, end, orderByComparator }; List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)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 query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2); query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_U_NotS_First(groupId, userId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", userId="); msg.append(userId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_U_NotS_First(long groupId, long userId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_U_NotS_Last(groupId, userId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", userId="); msg.append(userId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_U_NotS_Last(long groupId, long userId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByG_U_NotS(groupId, userId, status); if (count == 0) { return null; } List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByG_U_NotS_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long userId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2); query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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<BookmarksEntry> 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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view */ @Override public List<BookmarksEntry> filterFindByG_U_NotS(long groupId, long userId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_NotS(groupId, userId, status, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2); query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry filterGetByG_U_NotS_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long userId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2); query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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) { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS; Object[] finderArgs = new Object[] { groupId, userId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2); query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 query = new StringBundler(4); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2); query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } 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 != ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK | BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK | BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK | BookmarksEntryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_S", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * 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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F_S(long groupId, long folderId, int status, int start, int end, OrderByComparator<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F_S(long groupId, long folderId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S; finderArgs = new Object[] { groupId, folderId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S; finderArgs = new Object[] { groupId, folderId, status, start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)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 query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2); query.append(_FINDER_COLUMN_G_F_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); qPos.add(status); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_F_S_First(groupId, folderId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", folderId="); msg.append(folderId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_F_S_First(long groupId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_F_S_Last(groupId, folderId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", folderId="); msg.append(folderId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_F_S_Last(long groupId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByG_F_S(groupId, folderId, status); if (count == 0) { return null; } List<BookmarksEntry> 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByG_F_S_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2); query.append(_FINDER_COLUMN_G_F_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view */ @Override public List<BookmarksEntry> filterFindByG_F_S(long groupId, long folderId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_F_S(groupId, folderId, status, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2); query.append(_FINDER_COLUMN_G_F_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); qPos.add(status); return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } 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 <code>null</code>) * @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<BookmarksEntry> 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 e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry filterGetByG_F_S_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2); query.append(_FINDER_COLUMN_G_F_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view */ @Override public List<BookmarksEntry> filterFindByG_F_S(long groupId, long[] folderIds, int status, int start, int end, OrderByComparator<BookmarksEntry> 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.unique(folderIds); Arrays.sort(folderIds); } StringBundler query = new StringBundler(); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_S_GROUPID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_F_S_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the bookmarks entries where groupId = ? and folderId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param folderIds the folder IDs * @param status the status * @return the matching bookmarks entries */ @Override public List<BookmarksEntry> 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 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 */ @Override public List<BookmarksEntry> findByG_F_S(long groupId, long[] folderIds, int status, int start, int end) { return findByG_F_S(groupId, folderIds, status, start, end, null); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F_S(long groupId, long[] folderIds, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByG_F_S(groupId, folderIds, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = ? and status = ?, optionally using the finder cache. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F_S(long groupId, long[] folderIds, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { if (folderIds == null) { folderIds = new long[0]; } else if (folderIds.length > 1) { folderIds = ArrayUtil.unique(folderIds); Arrays.sort(folderIds); } if (folderIds.length == 1) { return findByG_F_S(groupId, folderIds[0], status, start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { groupId, StringUtil.merge(folderIds), status }; } else { finderArgs = new Object[] { groupId, StringUtil.merge(folderIds), status, start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (BookmarksEntry bookmarksEntry : list) { if ((groupId != bookmarksEntry.getGroupId()) || !ArrayUtil.contains(folderIds, bookmarksEntry.getFolderId()) || (status != bookmarksEntry.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_S_GROUPID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_F_S_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the bookmarks entries where groupId = ? and folderId = ? and status = ? from the database. * * @param groupId the group ID * @param folderId the folder ID * @param status the status */ @Override public void removeByG_F_S(long groupId, long folderId, int status) { for (BookmarksEntry bookmarksEntry : findByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(bookmarksEntry); } } /** * Returns the number of bookmarks entries where groupId = ? and folderId = ? and status = ?. * * @param groupId the group ID * @param folderId the folder ID * @param status the status * @return the number of matching bookmarks entries */ @Override public int countByG_F_S(long groupId, long folderId, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_S; Object[] finderArgs = new Object[] { groupId, folderId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2); query.append(_FINDER_COLUMN_G_F_S_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of bookmarks entries where groupId = ? and folderId = any ? and status = ?. * * @param groupId the group ID * @param folderIds the folder IDs * @param status the status * @return the number of matching bookmarks entries */ @Override public int countByG_F_S(long groupId, long[] folderIds, int status) { if (folderIds == null) { folderIds = new long[0]; } else if (folderIds.length > 1) { folderIds = ArrayUtil.unique(folderIds); Arrays.sort(folderIds); } Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds), status }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_S_GROUPID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_F_S_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of 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 number of matching bookmarks entries that the user has permission to view */ @Override public int filterCountByG_F_S(long groupId, long folderId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_F_S(groupId, folderId, status); } StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2); query.append(_FINDER_COLUMN_G_F_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of 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 number of matching bookmarks entries that the user has permission to view */ @Override public int filterCountByG_F_S(long groupId, long[] folderIds, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_F_S(groupId, folderIds, status); } if (folderIds == null) { folderIds = new long[0]; } else if (folderIds.length > 1) { folderIds = ArrayUtil.unique(folderIds); Arrays.sort(folderIds); } StringBundler query = new StringBundler(); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_S_GROUPID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_F_S_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_F_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND "; private static final String _FINDER_COLUMN_G_F_S_FOLDERID_2 = "bookmarksEntry.folderId = ? AND "; private static final String _FINDER_COLUMN_G_F_S_FOLDERID_7 = "bookmarksEntry.folderId IN ("; private static final String _FINDER_COLUMN_G_F_S_STATUS_2 = "bookmarksEntry.status = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F_NotS", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_NotS", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * 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<BookmarksEntry> findByG_F_NotS(long groupId, long folderId, int status) { return findByG_F_NotS(groupId, folderId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the bookmarks entries where groupId = ? and folderId = ? and status ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> findByG_F_NotS(long groupId, long folderId, int status, int start, int end) { return findByG_F_NotS(groupId, folderId, status, start, end, null); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = ? and status ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F_NotS(long groupId, long folderId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByG_F_NotS(groupId, folderId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = ? and status ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F_NotS(long groupId, long folderId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS; finderArgs = new Object[] { groupId, folderId, status, start, end, orderByComparator }; List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)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 query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2); query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); qPos.add(status); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } 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 <code>null</code>) * @return the first matching bookmarks entry * @throws NoSuchEntryException if a matching bookmarks entry could not be found */ @Override public BookmarksEntry findByG_F_NotS_First(long groupId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_F_NotS_First(groupId, folderId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", folderId="); msg.append(folderId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_F_NotS_First(long groupId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> list = findByG_F_NotS(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 <code>null</code>) * @return the last matching bookmarks entry * @throws NoSuchEntryException if a matching bookmarks entry could not be found */ @Override public BookmarksEntry findByG_F_NotS_Last(long groupId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_F_NotS_Last(groupId, folderId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", folderId="); msg.append(folderId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.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 <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_F_NotS_Last(long groupId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByG_F_NotS(groupId, folderId, status); if (count == 0) { return null; } List<BookmarksEntry> list = findByG_F_NotS(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 <code>null</code>) * @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_NotS_PrevAndNext(long entryId, long groupId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId); Session session = null; try { session = openSession(); BookmarksEntry[] array = new BookmarksEntryImpl[3]; array[0] = getByG_F_NotS_PrevAndNext(session, bookmarksEntry, groupId, folderId, status, orderByComparator, true); array[1] = bookmarksEntry; array[2] = getByG_F_NotS_PrevAndNext(session, bookmarksEntry, groupId, folderId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByG_F_NotS_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2); query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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<BookmarksEntry> filterFindByG_F_NotS(long groupId, long folderId, int status) { return filterFindByG_F_NotS(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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> filterFindByG_F_NotS(long groupId, long folderId, int status, int start, int end) { return filterFindByG_F_NotS(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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view */ @Override public List<BookmarksEntry> filterFindByG_F_NotS(long groupId, long folderId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_F_NotS(groupId, folderId, status, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2); query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); qPos.add(status); return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } 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 <code>null</code>) * @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_NotS_PrevAndNext(long entryId, long groupId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) throws NoSuchEntryException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_F_NotS_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_NotS_PrevAndNext(session, bookmarksEntry, groupId, folderId, status, orderByComparator, true); array[1] = bookmarksEntry; array[2] = filterGetByG_F_NotS_PrevAndNext(session, bookmarksEntry, groupId, folderId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry filterGetByG_F_NotS_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2); query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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<BookmarksEntry> filterFindByG_F_NotS(long groupId, long[] folderIds, int status) { return filterFindByG_F_NotS(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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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<BookmarksEntry> filterFindByG_F_NotS(long groupId, long[] folderIds, int status, int start, int end) { return filterFindByG_F_NotS(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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view */ @Override public List<BookmarksEntry> filterFindByG_F_NotS(long groupId, long[] folderIds, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_F_NotS(groupId, folderIds, status, start, end, orderByComparator); } if (folderIds == null) { folderIds = new long[0]; } else if (folderIds.length > 1) { folderIds = ArrayUtil.unique(folderIds); Arrays.sort(folderIds); } StringBundler query = new StringBundler(); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the bookmarks entries where groupId = ? and folderId = any ? and status ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param folderIds the folder IDs * @param status the status * @return the matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F_NotS(long groupId, long[] folderIds, int status) { return findByG_F_NotS(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 ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 */ @Override public List<BookmarksEntry> findByG_F_NotS(long groupId, long[] folderIds, int status, int start, int end) { return findByG_F_NotS(groupId, folderIds, status, start, end, null); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = any ? and status ≠ ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F_NotS(long groupId, long[] folderIds, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByG_F_NotS(groupId, folderIds, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = ? and status ≠ ?, optionally using the finder cache. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_F_NotS(long groupId, long[] folderIds, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { if (folderIds == null) { folderIds = new long[0]; } else if (folderIds.length > 1) { folderIds = ArrayUtil.unique(folderIds); Arrays.sort(folderIds); } if (folderIds.length == 1) { return findByG_F_NotS(groupId, folderIds[0], status, start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { groupId, StringUtil.merge(folderIds), status }; } else { finderArgs = new Object[] { groupId, StringUtil.merge(folderIds), status, start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (BookmarksEntry bookmarksEntry : list) { if ((groupId != bookmarksEntry.getGroupId()) || !ArrayUtil.contains(folderIds, bookmarksEntry.getFolderId()) || (status == bookmarksEntry.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the bookmarks entries where groupId = ? and folderId = ? and status ≠ ? from the database. * * @param groupId the group ID * @param folderId the folder ID * @param status the status */ @Override public void removeByG_F_NotS(long groupId, long folderId, int status) { for (BookmarksEntry bookmarksEntry : findByG_F_NotS(groupId, folderId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(bookmarksEntry); } } /** * Returns the number of bookmarks entries where groupId = ? and folderId = ? and status ≠ ?. * * @param groupId the group ID * @param folderId the folder ID * @param status the status * @return the number of matching bookmarks entries */ @Override public int countByG_F_NotS(long groupId, long folderId, int status) { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS; Object[] finderArgs = new Object[] { groupId, folderId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2); query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of bookmarks entries where groupId = ? and folderId = any ? and status ≠ ?. * * @param groupId the group ID * @param folderIds the folder IDs * @param status the status * @return the number of matching bookmarks entries */ @Override public int countByG_F_NotS(long groupId, long[] folderIds, int status) { if (folderIds == null) { folderIds = new long[0]; } else if (folderIds.length > 1) { folderIds = ArrayUtil.unique(folderIds); Arrays.sort(folderIds); } Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds), status }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of 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 number of matching bookmarks entries that the user has permission to view */ @Override public int filterCountByG_F_NotS(long groupId, long folderId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_F_NotS(groupId, folderId, status); } StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2); query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2); query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(folderId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of 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 number of matching bookmarks entries that the user has permission to view */ @Override public int filterCountByG_F_NotS(long groupId, long[] folderIds, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_F_NotS(groupId, folderIds, status); } if (folderIds == null) { folderIds = new long[0]; } else if (folderIds.length > 1) { folderIds = ArrayUtil.unique(folderIds); Arrays.sort(folderIds); } StringBundler query = new StringBundler(); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_F_NOTS_GROUPID_2 = "bookmarksEntry.groupId = ? AND "; private static final String _FINDER_COLUMN_G_F_NOTS_FOLDERID_2 = "bookmarksEntry.folderId = ? AND "; private static final String _FINDER_COLUMN_G_F_NOTS_FOLDERID_7 = "bookmarksEntry.folderId IN ("; private static final String _FINDER_COLUMN_G_F_NOTS_STATUS_2 = "bookmarksEntry.status != ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_F_S", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_F_S", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName() }, BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK | BookmarksEntryModelImpl.USERID_COLUMN_BITMASK | BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK | BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK | BookmarksEntryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_F_S", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_F_S", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * Returns all the bookmarks entries where groupId = ? and userId = ? and folderId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param folderId the folder ID * @param status the status * @return the matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId, long folderId, int status) { return findByG_U_F_S(groupId, userId, folderId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the bookmarks entries where groupId = ? and userId = ? and folderId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user 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<BookmarksEntry> findByG_U_F_S(long groupId, long userId, long folderId, int status, int start, int end) { return findByG_U_F_S(groupId, userId, folderId, status, start, end, null); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and userId = ? and folderId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user 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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId, long folderId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByG_U_F_S(groupId, userId, folderId, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and userId = ? and folderId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user 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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId, long folderId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S; finderArgs = new Object[] { groupId, userId, folderId, status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S; finderArgs = new Object[] { groupId, userId, folderId, status, start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (BookmarksEntry bookmarksEntry : list) { if ((groupId != bookmarksEntry.getGroupId()) || (userId != bookmarksEntry.getUserId()) || (folderId != bookmarksEntry.getFolderId()) || (status != bookmarksEntry.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(6); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_F_S_USERID_2); query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2); query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(folderId); qPos.add(status); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first bookmarks entry in the ordered set where groupId = ? and userId = ? and folderId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param folderId the folder ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching bookmarks entry * @throws NoSuchEntryException if a matching bookmarks entry could not be found */ @Override public BookmarksEntry findByG_U_F_S_First(long groupId, long userId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_U_F_S_First(groupId, userId, folderId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(10); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", userId="); msg.append(userId); msg.append(", folderId="); msg.append(folderId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } /** * Returns the first bookmarks entry in the ordered set where groupId = ? and userId = ? and folderId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param folderId the folder ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_U_F_S_First(long groupId, long userId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { List<BookmarksEntry> list = findByG_U_F_S(groupId, userId, 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 userId = ? and folderId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param folderId the folder ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching bookmarks entry * @throws NoSuchEntryException if a matching bookmarks entry could not be found */ @Override public BookmarksEntry findByG_U_F_S_Last(long groupId, long userId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByG_U_F_S_Last(groupId, userId, folderId, status, orderByComparator); if (bookmarksEntry != null) { return bookmarksEntry; } StringBundler msg = new StringBundler(10); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", userId="); msg.append(userId); msg.append(", folderId="); msg.append(folderId); msg.append(", status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } /** * Returns the last bookmarks entry in the ordered set where groupId = ? and userId = ? and folderId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param folderId the folder ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found */ @Override public BookmarksEntry fetchByG_U_F_S_Last(long groupId, long userId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) { int count = countByG_U_F_S(groupId, userId, folderId, status); if (count == 0) { return null; } List<BookmarksEntry> list = findByG_U_F_S(groupId, userId, 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 userId = ? and folderId = ? and status = ?. * * @param entryId the primary key of the current bookmarks entry * @param groupId the group ID * @param userId the user ID * @param folderId the folder ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @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_F_S_PrevAndNext(long entryId, long groupId, long userId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId); Session session = null; try { session = openSession(); BookmarksEntry[] array = new BookmarksEntryImpl[3]; array[0] = getByG_U_F_S_PrevAndNext(session, bookmarksEntry, groupId, userId, folderId, status, orderByComparator, true); array[1] = bookmarksEntry; array[2] = getByG_U_F_S_PrevAndNext(session, bookmarksEntry, groupId, userId, folderId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByG_U_F_S_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long userId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(7 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(6); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_F_S_USERID_2); query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2); query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(folderId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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 folderId = ? and status = ?. * * @param groupId the group ID * @param userId the user 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<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId, long folderId, int status) { return filterFindByG_U_F_S(groupId, userId, 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 userId = ? and folderId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user 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<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId, long folderId, int status, int start, int end) { return filterFindByG_U_F_S(groupId, userId, folderId, 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 folderId = ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user 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 <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view */ @Override public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId, long folderId, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_F_S(groupId, userId, folderId, status, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(6); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_F_S_USERID_2); query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2); query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(folderId); qPos.add(status); return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } 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 folderId = ? and status = ?. * * @param entryId the primary key of the current bookmarks entry * @param groupId the group ID * @param userId the user ID * @param folderId the folder ID * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @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_F_S_PrevAndNext(long entryId, long groupId, long userId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator) throws NoSuchEntryException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_F_S_PrevAndNext(entryId, groupId, userId, folderId, status, orderByComparator); } BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId); Session session = null; try { session = openSession(); BookmarksEntry[] array = new BookmarksEntryImpl[3]; array[0] = filterGetByG_U_F_S_PrevAndNext(session, bookmarksEntry, groupId, userId, folderId, status, orderByComparator, true); array[1] = bookmarksEntry; array[2] = filterGetByG_U_F_S_PrevAndNext(session, bookmarksEntry, groupId, userId, folderId, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry filterGetByG_U_F_S_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long userId, long folderId, int status, OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(7 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(6); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_F_S_USERID_2); query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2); query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(folderId); qPos.add(status); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry); for (Object value : values) { qPos.add(value); } } List<BookmarksEntry> list = q.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 folderId = any ? and status = ?. * * @param groupId the group ID * @param userId the user 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<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId, long[] folderIds, int status) { return filterFindByG_U_F_S(groupId, userId, 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 userId = ? and folderId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user 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<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId, long[] folderIds, int status, int start, int end) { return filterFindByG_U_F_S(groupId, userId, folderIds, status, start, end, null); } /** * Returns an ordered range of all the bookmarks entries that the user has permission to view where groupId = ? and userId = ? and folderId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user 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 <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view */ @Override public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId, long[] folderIds, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_F_S(groupId, userId, folderIds, status, start, end, orderByComparator); } if (folderIds == null) { folderIds = new long[0]; } else if (folderIds.length > 1) { folderIds = ArrayUtil.unique(folderIds); Arrays.sort(folderIds); } StringBundler query = new StringBundler(); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_F_S_USERID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the bookmarks entries where groupId = ? and userId = ? and folderId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user ID * @param folderIds the folder IDs * @param status the status * @return the matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId, long[] folderIds, int status) { return findByG_U_F_S(groupId, userId, folderIds, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the bookmarks entries where groupId = ? and userId = ? and folderId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user 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 */ @Override public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId, long[] folderIds, int status, int start, int end) { return findByG_U_F_S(groupId, userId, folderIds, status, start, end, null); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and userId = ? and folderId = any ? and status = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user 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 <code>null</code>) * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId, long[] folderIds, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findByG_U_F_S(groupId, userId, folderIds, status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and userId = ? and folderId = ? and status = ?, optionally using the finder cache. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user 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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching bookmarks entries */ @Override public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId, long[] folderIds, int status, int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { if (folderIds == null) { folderIds = new long[0]; } else if (folderIds.length > 1) { folderIds = ArrayUtil.unique(folderIds); Arrays.sort(folderIds); } if (folderIds.length == 1) { return findByG_U_F_S(groupId, userId, folderIds[0], status, start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { groupId, userId, StringUtil.merge(folderIds), status }; } else { finderArgs = new Object[] { groupId, userId, StringUtil.merge(folderIds), status, start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (BookmarksEntry bookmarksEntry : list) { if ((groupId != bookmarksEntry.getGroupId()) || (userId != bookmarksEntry.getUserId()) || !ArrayUtil.contains(folderIds, bookmarksEntry.getFolderId()) || (status != bookmarksEntry.getStatus())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_F_S_USERID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the bookmarks entries where groupId = ? and userId = ? and folderId = ? and status = ? from the database. * * @param groupId the group ID * @param userId the user ID * @param folderId the folder ID * @param status the status */ @Override public void removeByG_U_F_S(long groupId, long userId, long folderId, int status) { for (BookmarksEntry bookmarksEntry : findByG_U_F_S(groupId, userId, folderId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(bookmarksEntry); } } /** * Returns the number of bookmarks entries where groupId = ? and userId = ? and folderId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param folderId the folder ID * @param status the status * @return the number of matching bookmarks entries */ @Override public int countByG_U_F_S(long groupId, long userId, long folderId, int status) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_F_S; Object[] finderArgs = new Object[] { groupId, userId, folderId, status }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(5); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_F_S_USERID_2); query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2); query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(folderId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of bookmarks entries where groupId = ? and userId = ? and folderId = any ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param folderIds the folder IDs * @param status the status * @return the number of matching bookmarks entries */ @Override public int countByG_U_F_S(long groupId, long userId, long[] folderIds, int status) { if (folderIds == null) { folderIds = new long[0]; } else if (folderIds.length > 1) { folderIds = ArrayUtil.unique(folderIds); Arrays.sort(folderIds); } Object[] finderArgs = new Object[] { groupId, userId, StringUtil.merge(folderIds), status }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_F_S_USERID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of bookmarks entries that the user has permission to view where groupId = ? and userId = ? and folderId = ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param folderId the folder ID * @param status the status * @return the number of matching bookmarks entries that the user has permission to view */ @Override public int filterCountByG_U_F_S(long groupId, long userId, long folderId, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_U_F_S(groupId, userId, folderId, status); } StringBundler query = new StringBundler(5); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_F_S_USERID_2); query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2); query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(folderId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of bookmarks entries that the user has permission to view where groupId = ? and userId = ? and folderId = any ? and status = ?. * * @param groupId the group ID * @param userId the user ID * @param folderIds the folder IDs * @param status the status * @return the number of matching bookmarks entries that the user has permission to view */ @Override public int filterCountByG_U_F_S(long groupId, long userId, long[] folderIds, int status) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_U_F_S(groupId, userId, folderIds, status); } if (folderIds == null) { folderIds = new long[0]; } else if (folderIds.length > 1) { folderIds = ArrayUtil.unique(folderIds); Arrays.sort(folderIds); } StringBundler query = new StringBundler(); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_F_S_USERID_2); if (folderIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_7); query.append(StringUtil.merge(folderIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); qPos.add(status); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_U_F_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND "; private static final String _FINDER_COLUMN_G_U_F_S_USERID_2 = "bookmarksEntry.userId = ? AND "; private static final String _FINDER_COLUMN_G_U_F_S_FOLDERID_2 = "bookmarksEntry.folderId = ? AND "; private static final String _FINDER_COLUMN_G_U_F_S_FOLDERID_7 = "bookmarksEntry.folderId IN ("; private static final String _FINDER_COLUMN_G_U_F_S_STATUS_2 = "bookmarksEntry.status = ?"; public BookmarksEntryPersistenceImpl() { setModelClass(BookmarksEntry.class); try { Field field = ReflectionUtil.getDeclaredField(BasePersistenceImpl.class, "_dbColumnNames"); Map<String, String> dbColumnNames = new HashMap<String, String>(); dbColumnNames.put("uuid", "uuid_"); field.set(this, dbColumnNames); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } } } /** * Caches the bookmarks entry in the entity cache if it is enabled. * * @param bookmarksEntry the bookmarks entry */ @Override public void cacheResult(BookmarksEntry bookmarksEntry) { entityCache.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(), bookmarksEntry); finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, new Object[] { bookmarksEntry.getUuid(), bookmarksEntry.getGroupId() }, bookmarksEntry); bookmarksEntry.resetOriginalValues(); } /** * Caches the bookmarks entries in the entity cache if it is enabled. * * @param bookmarksEntries the bookmarks entries */ @Override public void cacheResult(List<BookmarksEntry> bookmarksEntries) { for (BookmarksEntry bookmarksEntry : bookmarksEntries) { if (entityCache.getResult( BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey()) == null) { cacheResult(bookmarksEntry); } else { bookmarksEntry.resetOriginalValues(); } } } /** * Clears the cache for all bookmarks entries. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache() { entityCache.clearCache(BookmarksEntryImpl.class); finderCache.clearCache(FINDER_CLASS_NAME_ENTITY); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the bookmarks entry. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache(BookmarksEntry bookmarksEntry) { entityCache.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey()); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((BookmarksEntryModelImpl)bookmarksEntry, true); } @Override public void clearCache(List<BookmarksEntry> bookmarksEntries) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (BookmarksEntry bookmarksEntry : bookmarksEntries) { entityCache.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey()); clearUniqueFindersCache((BookmarksEntryModelImpl)bookmarksEntry, true); } } protected void cacheUniqueFindersCache( BookmarksEntryModelImpl bookmarksEntryModelImpl) { Object[] args = new Object[] { bookmarksEntryModelImpl.getUuid(), bookmarksEntryModelImpl.getGroupId() }; finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args, Long.valueOf(1), false); finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args, bookmarksEntryModelImpl, false); } protected void clearUniqueFindersCache( BookmarksEntryModelImpl bookmarksEntryModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { bookmarksEntryModelImpl.getUuid(), bookmarksEntryModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args); } if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) { Object[] args = new Object[] { bookmarksEntryModelImpl.getOriginalUuid(), bookmarksEntryModelImpl.getOriginalGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args); } } /** * Creates a new bookmarks entry with the primary key. Does not add the bookmarks entry to the database. * * @param entryId the primary key for the new bookmarks entry * @return the new bookmarks entry */ @Override public BookmarksEntry create(long entryId) { BookmarksEntry bookmarksEntry = new BookmarksEntryImpl(); bookmarksEntry.setNew(true); bookmarksEntry.setPrimaryKey(entryId); String uuid = PortalUUIDUtil.generate(); bookmarksEntry.setUuid(uuid); bookmarksEntry.setCompanyId(companyProvider.getCompanyId()); return bookmarksEntry; } /** * Removes the bookmarks entry with the primary key from the database. Also notifies the appropriate model listeners. * * @param entryId the primary key of the bookmarks entry * @return the bookmarks entry that was removed * @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found */ @Override public BookmarksEntry remove(long entryId) throws NoSuchEntryException { return remove((Serializable)entryId); } /** * Removes the bookmarks entry with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the bookmarks entry * @return the bookmarks entry that was removed * @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found */ @Override public BookmarksEntry remove(Serializable primaryKey) throws NoSuchEntryException { Session session = null; try { session = openSession(); BookmarksEntry bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class, primaryKey); if (bookmarksEntry == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(bookmarksEntry); } catch (NoSuchEntryException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected BookmarksEntry removeImpl(BookmarksEntry bookmarksEntry) { bookmarksEntry = toUnwrappedModel(bookmarksEntry); Session session = null; try { session = openSession(); if (!session.contains(bookmarksEntry)) { bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKeyObj()); } if (bookmarksEntry != null) { session.delete(bookmarksEntry); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (bookmarksEntry != null) { clearCache(bookmarksEntry); } return bookmarksEntry; } @Override public BookmarksEntry updateImpl(BookmarksEntry bookmarksEntry) { bookmarksEntry = toUnwrappedModel(bookmarksEntry); boolean isNew = bookmarksEntry.isNew(); BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry; if (Validator.isNull(bookmarksEntry.getUuid())) { String uuid = PortalUUIDUtil.generate(); bookmarksEntry.setUuid(uuid); } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (bookmarksEntry.getCreateDate() == null)) { if (serviceContext == null) { bookmarksEntry.setCreateDate(now); } else { bookmarksEntry.setCreateDate(serviceContext.getCreateDate(now)); } } if (!bookmarksEntryModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { bookmarksEntry.setModifiedDate(now); } else { bookmarksEntry.setModifiedDate(serviceContext.getModifiedDate( now)); } } Session session = null; try { session = openSession(); if (bookmarksEntry.isNew()) { session.save(bookmarksEntry); bookmarksEntry.setNew(false); } else { bookmarksEntry = (BookmarksEntry)session.merge(bookmarksEntry); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!BookmarksEntryModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] { bookmarksEntryModelImpl.getResourceBlockId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID, args); args = new Object[] { bookmarksEntryModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { bookmarksEntryModelImpl.getUuid(), bookmarksEntryModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { bookmarksEntryModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { bookmarksEntryModelImpl.getGroupId(), bookmarksEntryModelImpl.getFolderId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F, args); args = new Object[] { bookmarksEntryModelImpl.getGroupId(), bookmarksEntryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S, args); args = new Object[] { bookmarksEntryModelImpl.getGroupId(), bookmarksEntryModelImpl.getUserId(), bookmarksEntryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S, args); args = new Object[] { bookmarksEntryModelImpl.getGroupId(), bookmarksEntryModelImpl.getFolderId(), bookmarksEntryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S, args); args = new Object[] { bookmarksEntryModelImpl.getGroupId(), bookmarksEntryModelImpl.getUserId(), bookmarksEntryModelImpl.getFolderId(), bookmarksEntryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_F_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S, args); finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL, FINDER_ARGS_EMPTY); } else { if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID.getColumnBitmask()) != 0) { Object[] args = new Object[] { bookmarksEntryModelImpl.getOriginalResourceBlockId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID, args); args = new Object[] { bookmarksEntryModelImpl.getResourceBlockId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID, args); } if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) { Object[] args = new Object[] { bookmarksEntryModelImpl.getOriginalUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { bookmarksEntryModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); } if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { bookmarksEntryModelImpl.getOriginalUuid(), bookmarksEntryModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { bookmarksEntryModelImpl.getUuid(), bookmarksEntryModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); } if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) { Object[] args = new Object[] { bookmarksEntryModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { bookmarksEntryModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); } if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) { Object[] args = new Object[] { bookmarksEntryModelImpl.getOriginalGroupId(), bookmarksEntryModelImpl.getOriginalFolderId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F, args); args = new Object[] { bookmarksEntryModelImpl.getGroupId(), bookmarksEntryModelImpl.getFolderId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F, args); } if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { bookmarksEntryModelImpl.getOriginalGroupId(), bookmarksEntryModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S, args); args = new Object[] { bookmarksEntryModelImpl.getGroupId(), bookmarksEntryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S, args); } if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { bookmarksEntryModelImpl.getOriginalGroupId(), bookmarksEntryModelImpl.getOriginalUserId(), bookmarksEntryModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S, args); args = new Object[] { bookmarksEntryModelImpl.getGroupId(), bookmarksEntryModelImpl.getUserId(), bookmarksEntryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S, args); } if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { bookmarksEntryModelImpl.getOriginalGroupId(), bookmarksEntryModelImpl.getOriginalFolderId(), bookmarksEntryModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S, args); args = new Object[] { bookmarksEntryModelImpl.getGroupId(), bookmarksEntryModelImpl.getFolderId(), bookmarksEntryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S, args); } if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S.getColumnBitmask()) != 0) { Object[] args = new Object[] { bookmarksEntryModelImpl.getOriginalGroupId(), bookmarksEntryModelImpl.getOriginalUserId(), bookmarksEntryModelImpl.getOriginalFolderId(), bookmarksEntryModelImpl.getOriginalStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_F_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S, args); args = new Object[] { bookmarksEntryModelImpl.getGroupId(), bookmarksEntryModelImpl.getUserId(), bookmarksEntryModelImpl.getFolderId(), bookmarksEntryModelImpl.getStatus() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_F_S, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S, args); } } entityCache.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(), bookmarksEntry, false); clearUniqueFindersCache(bookmarksEntryModelImpl, false); cacheUniqueFindersCache(bookmarksEntryModelImpl); bookmarksEntry.resetOriginalValues(); return bookmarksEntry; } protected BookmarksEntry toUnwrappedModel(BookmarksEntry bookmarksEntry) { if (bookmarksEntry instanceof BookmarksEntryImpl) { return bookmarksEntry; } BookmarksEntryImpl bookmarksEntryImpl = new BookmarksEntryImpl(); bookmarksEntryImpl.setNew(bookmarksEntry.isNew()); bookmarksEntryImpl.setPrimaryKey(bookmarksEntry.getPrimaryKey()); bookmarksEntryImpl.setUuid(bookmarksEntry.getUuid()); bookmarksEntryImpl.setEntryId(bookmarksEntry.getEntryId()); bookmarksEntryImpl.setGroupId(bookmarksEntry.getGroupId()); bookmarksEntryImpl.setCompanyId(bookmarksEntry.getCompanyId()); bookmarksEntryImpl.setUserId(bookmarksEntry.getUserId()); bookmarksEntryImpl.setUserName(bookmarksEntry.getUserName()); bookmarksEntryImpl.setCreateDate(bookmarksEntry.getCreateDate()); bookmarksEntryImpl.setModifiedDate(bookmarksEntry.getModifiedDate()); bookmarksEntryImpl.setResourceBlockId(bookmarksEntry.getResourceBlockId()); bookmarksEntryImpl.setFolderId(bookmarksEntry.getFolderId()); bookmarksEntryImpl.setTreePath(bookmarksEntry.getTreePath()); bookmarksEntryImpl.setName(bookmarksEntry.getName()); bookmarksEntryImpl.setUrl(bookmarksEntry.getUrl()); bookmarksEntryImpl.setDescription(bookmarksEntry.getDescription()); bookmarksEntryImpl.setVisits(bookmarksEntry.getVisits()); bookmarksEntryImpl.setPriority(bookmarksEntry.getPriority()); bookmarksEntryImpl.setLastPublishDate(bookmarksEntry.getLastPublishDate()); bookmarksEntryImpl.setStatus(bookmarksEntry.getStatus()); bookmarksEntryImpl.setStatusByUserId(bookmarksEntry.getStatusByUserId()); bookmarksEntryImpl.setStatusByUserName(bookmarksEntry.getStatusByUserName()); bookmarksEntryImpl.setStatusDate(bookmarksEntry.getStatusDate()); return bookmarksEntryImpl; } /** * Returns the bookmarks entry with the primary key or throws a {@link com.liferay.portal.kernel.exception.NoSuchModelException} if it could not be found. * * @param primaryKey the primary key of the bookmarks entry * @return the bookmarks entry * @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found */ @Override public BookmarksEntry findByPrimaryKey(Serializable primaryKey) throws NoSuchEntryException { BookmarksEntry bookmarksEntry = fetchByPrimaryKey(primaryKey); if (bookmarksEntry == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return bookmarksEntry; } /** * Returns the bookmarks entry with the primary key or throws a {@link NoSuchEntryException} if it could not be found. * * @param entryId the primary key of the bookmarks entry * @return the bookmarks entry * @throws NoSuchEntryException if a bookmarks entry with the primary key could not be found */ @Override public BookmarksEntry findByPrimaryKey(long entryId) throws NoSuchEntryException { return findByPrimaryKey((Serializable)entryId); } /** * Returns the bookmarks entry with the primary key or returns <code>null</code> if it could not be found. * * @param primaryKey the primary key of the bookmarks entry * @return the bookmarks entry, or <code>null</code> if a bookmarks entry with the primary key could not be found */ @Override public BookmarksEntry fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = entityCache.getResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, primaryKey); if (serializable == nullModel) { return null; } BookmarksEntry bookmarksEntry = (BookmarksEntry)serializable; if (bookmarksEntry == null) { Session session = null; try { session = openSession(); bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class, primaryKey); if (bookmarksEntry != null) { cacheResult(bookmarksEntry); } else { entityCache.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, primaryKey, nullModel); } } catch (Exception e) { entityCache.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return bookmarksEntry; } /** * Returns the bookmarks entry with the primary key or returns <code>null</code> if it could not be found. * * @param entryId the primary key of the bookmarks entry * @return the bookmarks entry, or <code>null</code> if a bookmarks entry with the primary key could not be found */ @Override public BookmarksEntry fetchByPrimaryKey(long entryId) { return fetchByPrimaryKey((Serializable)entryId); } @Override public Map<Serializable, BookmarksEntry> fetchByPrimaryKeys( Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map<Serializable, BookmarksEntry> map = new HashMap<Serializable, BookmarksEntry>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); BookmarksEntry bookmarksEntry = fetchByPrimaryKey(primaryKey); if (bookmarksEntry != null) { map.put(primaryKey, bookmarksEntry); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (BookmarksEntry)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long)primaryKey); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (BookmarksEntry bookmarksEntry : (List<BookmarksEntry>)q.list()) { map.put(bookmarksEntry.getPrimaryKeyObj(), bookmarksEntry); cacheResult(bookmarksEntry); uncachedPrimaryKeys.remove(bookmarksEntry.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the bookmarks entries. * * @return the bookmarks entries */ @Override public List<BookmarksEntry> findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the bookmarks entries. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 bookmarks entries */ @Override public List<BookmarksEntry> findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the bookmarks entries. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @return the ordered range of bookmarks entries */ @Override public List<BookmarksEntry> findAll(int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the bookmarks entries. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @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 <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of bookmarks entries */ @Override public List<BookmarksEntry> findAll(int start, int end, OrderByComparator<BookmarksEntry> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL; finderArgs = new Object[] { start, end, orderByComparator }; } List<BookmarksEntry> list = null; if (retrieveFromCache) { list = (List<BookmarksEntry>)finderCache.getResult(finderPath, finderArgs, this); } if (list == null) { StringBundler query = null; String sql = null; if (orderByComparator != null) { query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 2)); query.append(_SQL_SELECT_BOOKMARKSENTRY); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_BOOKMARKSENTRY; if (pagination) { sql = sql.concat(BookmarksEntryModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the bookmarks entries from the database. * */ @Override public void removeAll() { for (BookmarksEntry bookmarksEntry : findAll()) { remove(bookmarksEntry); } } /** * Returns the number of bookmarks entries. * * @return the number of bookmarks entries */ @Override public int countAll() { Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query q = session.createQuery(_SQL_COUNT_BOOKMARKSENTRY); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } @Override public Set<String> getBadColumnNames() { return _badColumnNames; } @Override protected Map<String, Integer> getTableColumnsMap() { return BookmarksEntryModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the bookmarks entry persistence. */ public void afterPropertiesSet() { } public void destroy() { entityCache.removeCache(BookmarksEntryImpl.class.getName()); finderCache.removeCache(FINDER_CLASS_NAME_ENTITY); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @ServiceReference(type = CompanyProviderWrapper.class) protected CompanyProvider companyProvider; @ServiceReference(type = EntityCache.class) protected EntityCache entityCache; @ServiceReference(type = FinderCache.class) protected FinderCache finderCache; private static final String _SQL_SELECT_BOOKMARKSENTRY = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry"; private static final String _SQL_SELECT_BOOKMARKSENTRY_WHERE_PKS_IN = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry WHERE entryId IN ("; private static final String _SQL_SELECT_BOOKMARKSENTRY_WHERE = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry WHERE "; private static final String _SQL_COUNT_BOOKMARKSENTRY = "SELECT COUNT(bookmarksEntry) FROM BookmarksEntry bookmarksEntry"; private static final String _SQL_COUNT_BOOKMARKSENTRY_WHERE = "SELECT COUNT(bookmarksEntry) FROM BookmarksEntry bookmarksEntry WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "bookmarksEntry.entryId"; private static final String _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN = "bookmarksEntry.userId"; private static final String _ORDER_BY_ENTITY_ALIAS = "bookmarksEntry."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BookmarksEntry exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BookmarksEntry exists with the key {"; private static final Log _log = LogFactoryUtil.getLog(BookmarksEntryPersistenceImpl.class); private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] { "uuid" }); }