Java tutorial
/** * Copyright (c) 2000-2012 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.portlet.bookmarks.service.persistence; import com.liferay.portal.NoSuchModelException; import com.liferay.portal.kernel.bean.BeanReference; import com.liferay.portal.kernel.cache.CacheRegistryUtil; import com.liferay.portal.kernel.dao.orm.EntityCacheUtil; import com.liferay.portal.kernel.dao.orm.FinderCacheUtil; 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.exception.SystemException; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.util.GetterUtil; import com.liferay.portal.kernel.util.InstanceFactory; import com.liferay.portal.kernel.util.OrderByComparator; 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.model.CacheModel; import com.liferay.portal.model.ModelListener; import com.liferay.portal.security.permission.InlineSQLHelperUtil; import com.liferay.portal.service.persistence.BatchSessionUtil; import com.liferay.portal.service.persistence.ResourcePersistence; import com.liferay.portal.service.persistence.UserPersistence; import com.liferay.portal.service.persistence.impl.BasePersistenceImpl; import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence; import com.liferay.portlet.asset.service.persistence.AssetLinkPersistence; import com.liferay.portlet.asset.service.persistence.AssetTagPersistence; import com.liferay.portlet.bookmarks.NoSuchEntryException; import com.liferay.portlet.bookmarks.model.BookmarksEntry; import com.liferay.portlet.bookmarks.model.impl.BookmarksEntryImpl; import com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl; import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * 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 BookmarksEntryUtil * @generated */ 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_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(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); 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); 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() }); 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(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); 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); 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() }); 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() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath( BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId", new String[] { Long.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID = new FinderPath( BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId", new String[] { Long.class.getName() }, BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath( BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId", new String[] { Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath( BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U", new String[] { Long.class.getName(), Long.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath( BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U", new String[] { Long.class.getName(), Long.class.getName() }, BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK | BookmarksEntryModelImpl.USERID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath( BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U", new String[] { Long.class.getName(), Long.class.getName() }); 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(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); 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); 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_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_WITHOUT_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_COUNT_ALL = new FinderPath( BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); /** * Caches the bookmarks entry in the entity cache if it is enabled. * * @param bookmarksEntry the bookmarks entry */ public void cacheResult(BookmarksEntry bookmarksEntry) { EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(), bookmarksEntry); FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, new Object[] { bookmarksEntry.getUuid(), Long.valueOf(bookmarksEntry.getGroupId()) }, bookmarksEntry); bookmarksEntry.resetOriginalValues(); } /** * Caches the bookmarks entries in the entity cache if it is enabled. * * @param bookmarksEntries the bookmarks entries */ public void cacheResult(List<BookmarksEntry> bookmarksEntries) { for (BookmarksEntry bookmarksEntry : bookmarksEntries) { if (EntityCacheUtil.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 com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache() { if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) { CacheRegistryUtil.clear(BookmarksEntryImpl.class.getName()); } EntityCacheUtil.clearCache(BookmarksEntryImpl.class.getName()); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the bookmarks entry. * * <p> * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache(BookmarksEntry bookmarksEntry) { EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey()); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache(bookmarksEntry); } @Override public void clearCache(List<BookmarksEntry> bookmarksEntries) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (BookmarksEntry bookmarksEntry : bookmarksEntries) { EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey()); clearUniqueFindersCache(bookmarksEntry); } } protected void clearUniqueFindersCache(BookmarksEntry bookmarksEntry) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, new Object[] { bookmarksEntry.getUuid(), Long.valueOf(bookmarksEntry.getGroupId()) }); } /** * 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 */ public BookmarksEntry create(long entryId) { BookmarksEntry bookmarksEntry = new BookmarksEntryImpl(); bookmarksEntry.setNew(true); bookmarksEntry.setPrimaryKey(entryId); String uuid = PortalUUIDUtil.generate(); bookmarksEntry.setUuid(uuid); 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 com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry remove(long entryId) throws NoSuchEntryException, SystemException { return remove(Long.valueOf(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 com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found * @throws SystemException if a system exception occurred */ @Override public BookmarksEntry remove(Serializable primaryKey) throws NoSuchEntryException, SystemException { Session session = null; try { session = openSession(); BookmarksEntry bookmarksEntry = (BookmarksEntry) session.get(BookmarksEntryImpl.class, primaryKey); if (bookmarksEntry == null) { if (_log.isWarnEnabled()) { _log.warn(_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) throws SystemException { bookmarksEntry = toUnwrappedModel(bookmarksEntry); Session session = null; try { session = openSession(); BatchSessionUtil.delete(session, bookmarksEntry); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } clearCache(bookmarksEntry); return bookmarksEntry; } @Override public BookmarksEntry updateImpl(com.liferay.portlet.bookmarks.model.BookmarksEntry bookmarksEntry, boolean merge) throws SystemException { bookmarksEntry = toUnwrappedModel(bookmarksEntry); boolean isNew = bookmarksEntry.isNew(); BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl) bookmarksEntry; if (Validator.isNull(bookmarksEntry.getUuid())) { String uuid = PortalUUIDUtil.generate(); bookmarksEntry.setUuid(uuid); } Session session = null; try { session = openSession(); BatchSessionUtil.update(session, bookmarksEntry, merge); bookmarksEntry.setNew(false); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !BookmarksEntryModelImpl.COLUMN_BITMASK_ENABLED) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(bookmarksEntryModelImpl.getOriginalResourceBlockId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID, args); args = new Object[] { Long.valueOf(bookmarksEntryModelImpl.getResourceBlockId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID, args); FinderCacheUtil.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() }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { bookmarksEntryModelImpl.getUuid() }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); } if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(bookmarksEntryModelImpl.getOriginalGroupId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); args = new Object[] { Long.valueOf(bookmarksEntryModelImpl.getGroupId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); } if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(bookmarksEntryModelImpl.getOriginalGroupId()), Long.valueOf(bookmarksEntryModelImpl.getOriginalUserId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U, args); args = new Object[] { Long.valueOf(bookmarksEntryModelImpl.getGroupId()), Long.valueOf(bookmarksEntryModelImpl.getUserId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U, args); } if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(bookmarksEntryModelImpl.getOriginalGroupId()), Long.valueOf(bookmarksEntryModelImpl.getOriginalFolderId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F, args); args = new Object[] { Long.valueOf(bookmarksEntryModelImpl.getGroupId()), Long.valueOf(bookmarksEntryModelImpl.getFolderId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F, args); } } EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(), bookmarksEntry); if (isNew) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, new Object[] { bookmarksEntry.getUuid(), Long.valueOf(bookmarksEntry.getGroupId()) }, bookmarksEntry); } else { if ((bookmarksEntryModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) { Object[] args = new Object[] { bookmarksEntryModelImpl.getOriginalUuid(), Long.valueOf(bookmarksEntryModelImpl.getOriginalGroupId()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args); FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args); FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, new Object[] { bookmarksEntry.getUuid(), Long.valueOf(bookmarksEntry.getGroupId()) }, bookmarksEntry); } } 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.setName(bookmarksEntry.getName()); bookmarksEntryImpl.setUrl(bookmarksEntry.getUrl()); bookmarksEntryImpl.setDescription(bookmarksEntry.getDescription()); bookmarksEntryImpl.setVisits(bookmarksEntry.getVisits()); bookmarksEntryImpl.setPriority(bookmarksEntry.getPriority()); return bookmarksEntryImpl; } /** * Returns the bookmarks entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found. * * @param primaryKey the primary key of the bookmarks entry * @return the bookmarks entry * @throws com.liferay.portal.NoSuchModelException if a bookmarks entry with the primary key could not be found * @throws SystemException if a system exception occurred */ @Override public BookmarksEntry findByPrimaryKey(Serializable primaryKey) throws NoSuchModelException, SystemException { return findByPrimaryKey(((Long) primaryKey).longValue()); } /** * Returns the bookmarks entry with the primary key or throws a {@link com.liferay.portlet.bookmarks.NoSuchEntryException} if it could not be found. * * @param entryId the primary key of the bookmarks entry * @return the bookmarks entry * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry findByPrimaryKey(long entryId) throws NoSuchEntryException, SystemException { BookmarksEntry bookmarksEntry = fetchByPrimaryKey(entryId); if (bookmarksEntry == null) { if (_log.isWarnEnabled()) { _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId); } throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId); } return bookmarksEntry; } /** * 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 * @throws SystemException if a system exception occurred */ @Override public BookmarksEntry fetchByPrimaryKey(Serializable primaryKey) throws SystemException { return fetchByPrimaryKey(((Long) primaryKey).longValue()); } /** * 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 * @throws SystemException if a system exception occurred */ public BookmarksEntry fetchByPrimaryKey(long entryId) throws SystemException { BookmarksEntry bookmarksEntry = (BookmarksEntry) EntityCacheUtil .getResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, entryId); if (bookmarksEntry == _nullBookmarksEntry) { return null; } if (bookmarksEntry == null) { Session session = null; boolean hasException = false; try { session = openSession(); bookmarksEntry = (BookmarksEntry) session.get(BookmarksEntryImpl.class, Long.valueOf(entryId)); } catch (Exception e) { hasException = true; throw processException(e); } finally { if (bookmarksEntry != null) { cacheResult(bookmarksEntry); } else if (!hasException) { EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, entryId, _nullBookmarksEntry); } closeSession(session); } } return bookmarksEntry; } /** * Returns all the bookmarks entries where resourceBlockId = ?. * * @param resourceBlockId the resource block ID * @return the matching bookmarks entries * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId, int start, int end) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { 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 = (List<BookmarksEntry>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(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) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { 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); list = (List<BookmarksEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first bookmarks entry in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry findByResourceBlockId_First(long resourceBlockId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { List<BookmarksEntry> list = findByResourceBlockId(resourceBlockId, 0, 1, orderByComparator); if (list.isEmpty()) { 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()); } else { return list.get(0); } } /** * Returns the last bookmarks entry in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry findByResourceBlockId_Last(long resourceBlockId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { int count = countByResourceBlockId(resourceBlockId); List<BookmarksEntry> list = findByResourceBlockId(resourceBlockId, count - 1, count, orderByComparator); if (list.isEmpty()) { 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()); } else { return list.get(0); } } /** * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry[] findByResourceBlockId_PrevAndNext(long entryId, long resourceBlockId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { 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 orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } 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; } } /** * Returns all the bookmarks entries where uuid = ?. * * @param uuid the uuid * @return the matching bookmarks entries * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByUuid(String uuid) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByUuid(String uuid, int start, int end) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByUuid(String uuid, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { 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 = (List<BookmarksEntry>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else { if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { query.append(_FINDER_COLUMN_UUID_UUID_2); } } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { 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 (uuid != null) { qPos.add(uuid); } list = (List<BookmarksEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first bookmarks entry in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching bookmarks entry * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry findByUuid_First(String uuid, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { List<BookmarksEntry> list = findByUuid(uuid, 0, 1, orderByComparator); if (list.isEmpty()) { 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()); } else { return list.get(0); } } /** * Returns the last bookmarks entry in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching bookmarks entry * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry findByUuid_Last(String uuid, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { int count = countByUuid(uuid); List<BookmarksEntry> list = findByUuid(uuid, count - 1, count, orderByComparator); if (list.isEmpty()) { 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()); } else { return list.get(0); } } /** * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry[] findByUuid_PrevAndNext(long entryId, String uuid, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { 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 orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else { if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { 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 (uuid != null) { 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; } } /** * Returns the bookmarks entry where uuid = ? and groupId = ? or throws a {@link com.liferay.portlet.bookmarks.NoSuchEntryException} if it could not be found. * * @param uuid the uuid * @param groupId the group ID * @return the matching bookmarks entry * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry findByUUID_G(String uuid, long groupId) throws NoSuchEntryException, SystemException { 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.isWarnEnabled()) { _log.warn(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 * @throws SystemException if a system exception occurred */ public BookmarksEntry fetchByUUID_G(String uuid, long groupId) throws SystemException { 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 use the finder cache * @return the matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry fetchByUUID_G(String uuid, long groupId, boolean retrieveFromCache) throws SystemException { Object[] finderArgs = new Object[] { uuid, groupId }; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, this); } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); 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 { query.append(_FINDER_COLUMN_UUID_G_UUID_2); } } query.append(_FINDER_COLUMN_UUID_G_GROUPID_2); 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 (uuid != null) { qPos.add(uuid); } qPos.add(groupId); List<BookmarksEntry> list = q.list(); result = list; BookmarksEntry bookmarksEntry = null; if (list.isEmpty()) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, list); } else { bookmarksEntry = list.get(0); cacheResult(bookmarksEntry); if ((bookmarksEntry.getUuid() == null) || !bookmarksEntry.getUuid().equals(uuid) || (bookmarksEntry.getGroupId() != groupId)) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, bookmarksEntry); } } return bookmarksEntry; } catch (Exception e) { throw processException(e); } finally { if (result == null) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs); } closeSession(session); } } else { if (result instanceof List<?>) { return null; } else { return (BookmarksEntry) result; } } } /** * Returns all the bookmarks entries where groupId = ?. * * @param groupId the group ID * @return the matching bookmarks entries * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByGroupId(long groupId) throws SystemException { return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the bookmarks entries where groupId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group 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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByGroupId(long groupId, int start, int end) throws SystemException { return findByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the bookmarks entries where groupId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group 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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByGroupId(long groupId, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID; finderArgs = new Object[] { groupId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID; finderArgs = new Object[] { groupId, start, end, orderByComparator }; } List<BookmarksEntry> list = (List<BookmarksEntry>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { 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); list = (List<BookmarksEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first bookmarks entry in the ordered set where groupId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching bookmarks entry * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry findByGroupId_First(long groupId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { List<BookmarksEntry> list = findByGroupId(groupId, 0, 1, orderByComparator); if (list.isEmpty()) { StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } else { return list.get(0); } } /** * Returns the last bookmarks entry in the ordered set where groupId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching bookmarks entry * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry findByGroupId_Last(long groupId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { int count = countByGroupId(groupId); List<BookmarksEntry> list = findByGroupId(groupId, count - 1, count, orderByComparator); if (list.isEmpty()) { StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } else { return list.get(0); } } /** * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param entryId the primary key of the current bookmarks entry * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next bookmarks entry * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry[] findByGroupId_PrevAndNext(long entryId, long groupId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId); Session session = null; try { session = openSession(); BookmarksEntry[] array = new BookmarksEntryImpl[3]; array[0] = getByGroupId_PrevAndNext(session, bookmarksEntry, groupId, orderByComparator, true); array[1] = bookmarksEntry; array[2] = getByGroupId_PrevAndNext(session, bookmarksEntry, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByGroupId_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_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); 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 = ?. * * @param groupId the group ID * @return the matching bookmarks entries that the user has permission to view * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByGroupId(long groupId) throws SystemException { return filterFindByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the bookmarks entries that the user has permission to view where groupId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group 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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByGroupId(long groupId, int start, int end) throws SystemException { return filterFindByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group 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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByGroupId(long groupId, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId(groupId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_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); 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 = ?. * * @param entryId the primary key of the current bookmarks entry * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next bookmarks entry * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry[] filterFindByGroupId_PrevAndNext(long entryId, long groupId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator); } BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId); Session session = null; try { session = openSession(); BookmarksEntry[] array = new BookmarksEntryImpl[3]; array[0] = filterGetByGroupId_PrevAndNext(session, bookmarksEntry, groupId, orderByComparator, true); array[1] = bookmarksEntry; array[2] = filterGetByGroupId_PrevAndNext(session, bookmarksEntry, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry filterGetByGroupId_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_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); 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 where groupId = ? and userId = ?. * * @param groupId the group ID * @param userId the user ID * @return the matching bookmarks entries * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByG_U(long groupId, long userId) throws SystemException { return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the bookmarks entries where groupId = ? and userId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param userId the user 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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByG_U(long groupId, long userId, int start, int end) throws SystemException { return findByG_U(groupId, userId, start, end, null); } /** * Returns an ordered range of all the bookmarks entries where groupId = ? and userId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param userId the user 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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByG_U(long groupId, long userId, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U; finderArgs = new Object[] { groupId, userId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U; finderArgs = new Object[] { groupId, userId, start, end, orderByComparator }; } List<BookmarksEntry> list = (List<BookmarksEntry>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_GROUPID_2); query.append(_FINDER_COLUMN_G_U_USERID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { 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); list = (List<BookmarksEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first bookmarks entry in the ordered set where groupId = ? and userId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching bookmarks entry * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry findByG_U_First(long groupId, long userId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { List<BookmarksEntry> list = findByG_U(groupId, userId, 0, 1, orderByComparator); if (list.isEmpty()) { StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", userId="); msg.append(userId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } else { return list.get(0); } } /** * Returns the last bookmarks entry in the ordered set where groupId = ? and userId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching bookmarks entry * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry findByG_U_Last(long groupId, long userId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { int count = countByG_U(groupId, userId); List<BookmarksEntry> list = findByG_U(groupId, userId, count - 1, count, orderByComparator); if (list.isEmpty()) { StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", userId="); msg.append(userId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchEntryException(msg.toString()); } else { return list.get(0); } } /** * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = ? and userId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param entryId the primary key of the current bookmarks entry * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next bookmarks entry * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry[] findByG_U_PrevAndNext(long entryId, long groupId, long userId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId); Session session = null; try { session = openSession(); BookmarksEntry[] array = new BookmarksEntryImpl[3]; array[0] = getByG_U_PrevAndNext(session, bookmarksEntry, groupId, userId, orderByComparator, true); array[1] = bookmarksEntry; array[2] = getByG_U_PrevAndNext(session, bookmarksEntry, groupId, userId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry getByG_U_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long userId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_GROUPID_2); query.append(_FINDER_COLUMN_G_U_USERID_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); 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 = ?. * * @param groupId the group ID * @param userId the user ID * @return the matching bookmarks entries that the user has permission to view * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByG_U(long groupId, long userId) throws SystemException { return filterFindByG_U(groupId, userId, 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 = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param userId the user 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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByG_U(long groupId, long userId, int start, int end) throws SystemException { return filterFindByG_U(groupId, userId, start, end, null); } /** * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = ? and userId = ?. * * <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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param userId the user 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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByG_U(long groupId, long userId, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U(groupId, userId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_GROUPID_2); query.append(_FINDER_COLUMN_G_U_USERID_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); 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 = ?. * * @param entryId the primary key of the current bookmarks entry * @param groupId the group ID * @param userId the user ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next bookmarks entry * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry[] filterFindByG_U_PrevAndNext(long entryId, long groupId, long userId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_PrevAndNext(entryId, groupId, userId, orderByComparator); } BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId); Session session = null; try { session = openSession(); BookmarksEntry[] array = new BookmarksEntryImpl[3]; array[0] = filterGetByG_U_PrevAndNext(session, bookmarksEntry, groupId, userId, orderByComparator, true); array[1] = bookmarksEntry; array[2] = filterGetByG_U_PrevAndNext(session, bookmarksEntry, groupId, userId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected BookmarksEntry filterGetByG_U_PrevAndNext(Session session, BookmarksEntry bookmarksEntry, long groupId, long userId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_GROUPID_2); query.append(_FINDER_COLUMN_G_U_USERID_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); 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 where groupId = ? and folderId = ?. * * @param groupId the group ID * @param folderId the folder ID * @return the matching bookmarks entries * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByG_F(long groupId, long folderId) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByG_F(long groupId, long folderId, int start, int end) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByG_F(long groupId, long folderId, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { 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 = (List<BookmarksEntry>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (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) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { 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); list = (List<BookmarksEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Returns the first bookmarks entry in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry findByG_F_First(long groupId, long folderId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { List<BookmarksEntry> list = findByG_F(groupId, folderId, 0, 1, orderByComparator); if (list.isEmpty()) { 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()); } else { return list.get(0); } } /** * Returns the last bookmarks entry in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry findByG_F_Last(long groupId, long folderId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { int count = countByG_F(groupId, folderId); List<BookmarksEntry> list = findByG_F(groupId, folderId, count - 1, count, orderByComparator); if (list.isEmpty()) { 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()); } else { return list.get(0); } } /** * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @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 com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry[] findByG_F_PrevAndNext(long entryId, long groupId, long folderId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { 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 orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } 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 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param folderIds the folder IDs * @return the matching bookmarks entries * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds, int start, int end) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F; finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F; finderArgs = new Object[] { groupId, StringUtil.merge(folderIds), start, end, orderByComparator }; } List<BookmarksEntry> list = (List<BookmarksEntry>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_GROUPID_5); conjunctionable = true; if ((folderIds == null) || (folderIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < folderIds.length; i++) { query.append(_FINDER_COLUMN_G_F_FOLDERID_5); if ((i + 1) < folderIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { 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 (folderIds != null) { qPos.add(folderIds); } list = (List<BookmarksEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * 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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId, int start, int end) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId, int start, int end, OrderByComparator orderByComparator) throws SystemException { 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 * 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) { 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 com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found * @throws SystemException if a system exception occurred */ public BookmarksEntry[] filterFindByG_F_PrevAndNext(long entryId, long groupId, long folderId, OrderByComparator orderByComparator) throws NoSuchEntryException, SystemException { 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 orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } 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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds, int start, int end) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_F(groupId, folderIds, start, end, orderByComparator); } StringBundler query = new StringBundler(); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_GROUPID_5); conjunctionable = true; if ((folderIds == null) || (folderIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < folderIds.length; i++) { query.append(_FINDER_COLUMN_G_F_FOLDERID_5); if ((i + 1) < folderIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } 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); if (folderIds != null) { qPos.add(folderIds); } return (List<BookmarksEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the bookmarks entries. * * @return the bookmarks entries * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findAll() throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findAll(int start, int end) throws SystemException { 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </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 * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findAll(int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = new Object[] { start, end, orderByComparator }; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL; finderArgs = new Object[] { start, end, orderByComparator }; } List<BookmarksEntry> list = (List<BookmarksEntry>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = null; String sql = null; if (orderByComparator != null) { query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 3)); query.append(_SQL_SELECT_BOOKMARKSENTRY); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_BOOKMARKSENTRY.concat(BookmarksEntryModelImpl.ORDER_BY_JPQL); } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (orderByComparator == null) { list = (List<BookmarksEntry>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); } else { list = (List<BookmarksEntry>) QueryUtil.list(q, getDialect(), start, end); } } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; } /** * Removes all the bookmarks entries where resourceBlockId = ? from the database. * * @param resourceBlockId the resource block ID * @throws SystemException if a system exception occurred */ public void removeByResourceBlockId(long resourceBlockId) throws SystemException { for (BookmarksEntry bookmarksEntry : findByResourceBlockId(resourceBlockId)) { remove(bookmarksEntry); } } /** * Removes all the bookmarks entries where uuid = ? from the database. * * @param uuid the uuid * @throws SystemException if a system exception occurred */ public void removeByUuid(String uuid) throws SystemException { for (BookmarksEntry bookmarksEntry : findByUuid(uuid)) { remove(bookmarksEntry); } } /** * Removes the bookmarks entry where uuid = ? and groupId = ? from the database. * * @param uuid the uuid * @param groupId the group ID * @throws SystemException if a system exception occurred */ public void removeByUUID_G(String uuid, long groupId) throws NoSuchEntryException, SystemException { BookmarksEntry bookmarksEntry = findByUUID_G(uuid, groupId); remove(bookmarksEntry); } /** * Removes all the bookmarks entries where groupId = ? from the database. * * @param groupId the group ID * @throws SystemException if a system exception occurred */ public void removeByGroupId(long groupId) throws SystemException { for (BookmarksEntry bookmarksEntry : findByGroupId(groupId)) { remove(bookmarksEntry); } } /** * Removes all the bookmarks entries where groupId = ? and userId = ? from the database. * * @param groupId the group ID * @param userId the user ID * @throws SystemException if a system exception occurred */ public void removeByG_U(long groupId, long userId) throws SystemException { for (BookmarksEntry bookmarksEntry : findByG_U(groupId, userId)) { remove(bookmarksEntry); } } /** * Removes all the bookmarks entries where groupId = ? and folderId = ? from the database. * * @param groupId the group ID * @param folderId the folder ID * @throws SystemException if a system exception occurred */ public void removeByG_F(long groupId, long folderId) throws SystemException { for (BookmarksEntry bookmarksEntry : findByG_F(groupId, folderId)) { remove(bookmarksEntry); } } /** * Removes all the bookmarks entries from the database. * * @throws SystemException if a system exception occurred */ public void removeAll() throws SystemException { for (BookmarksEntry bookmarksEntry : findAll()) { remove(bookmarksEntry); } } /** * Returns the number of bookmarks entries where resourceBlockId = ?. * * @param resourceBlockId the resource block ID * @return the number of matching bookmarks entries * @throws SystemException if a system exception occurred */ public int countByResourceBlockId(long resourceBlockId) throws SystemException { Object[] finderArgs = new Object[] { resourceBlockId }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID, 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(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of bookmarks entries where uuid = ?. * * @param uuid the uuid * @return the number of matching bookmarks entries * @throws SystemException if a system exception occurred */ public int countByUuid(String uuid) throws SystemException { Object[] finderArgs = new Object[] { uuid }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else { if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { 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 (uuid != null) { qPos.add(uuid); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * 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 * @throws SystemException if a system exception occurred */ public int countByUUID_G(String uuid, long groupId) throws SystemException { Object[] finderArgs = new Object[] { uuid, groupId }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); 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 { 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 (uuid != null) { qPos.add(uuid); } qPos.add(groupId); count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of bookmarks entries where groupId = ?. * * @param groupId the group ID * @return the number of matching bookmarks entries * @throws SystemException if a system exception occurred */ public int countByGroupId(long groupId) throws SystemException { Object[] finderArgs = new Object[] { groupId }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); 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(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of bookmarks entries that the user has permission to view where groupId = ?. * * @param groupId the group ID * @return the number of matching bookmarks entries that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByGroupId(long groupId) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByGroupId(groupId); } StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_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); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of bookmarks entries where groupId = ? and userId = ?. * * @param groupId the group ID * @param userId the user ID * @return the number of matching bookmarks entries * @throws SystemException if a system exception occurred */ public int countByG_U(long groupId, long userId) throws SystemException { Object[] finderArgs = new Object[] { groupId, userId }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_GROUPID_2); query.append(_FINDER_COLUMN_G_U_USERID_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); count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of bookmarks entries that the user has permission to view where groupId = ? and userId = ?. * * @param groupId the group ID * @param userId the user ID * @return the number of matching bookmarks entries that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_U(long groupId, long userId) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_U(groupId, userId); } StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_GROUPID_2); query.append(_FINDER_COLUMN_G_U_USERID_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); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * 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 * @throws SystemException if a system exception occurred */ public int countByG_F(long groupId, long folderId) throws SystemException { Object[] finderArgs = new Object[] { groupId, folderId }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F, 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(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs, count); 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 * @throws SystemException if a system exception occurred */ public int countByG_F(long groupId, long[] folderIds) throws SystemException { Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_GROUPID_5); conjunctionable = true; if ((folderIds == null) || (folderIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < folderIds.length; i++) { query.append(_FINDER_COLUMN_G_F_FOLDERID_5); if ((i + 1) < folderIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (folderIds != null) { qPos.add(folderIds); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs, count); 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 * @throws SystemException if a system exception occurred */ public int filterCountByG_F(long groupId, long folderId) throws SystemException { 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 * @throws SystemException if a system exception occurred */ public int filterCountByG_F(long groupId, long[] folderIds) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_F(groupId, folderIds); } StringBundler query = new StringBundler(); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_GROUPID_5); conjunctionable = true; if ((folderIds == null) || (folderIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < folderIds.length; i++) { query.append(_FINDER_COLUMN_G_F_FOLDERID_5); if ((i + 1) < folderIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } 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); if (folderIds != null) { qPos.add(folderIds); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of bookmarks entries. * * @return the number of bookmarks entries * @throws SystemException if a system exception occurred */ public int countAll() throws SystemException { Long count = (Long) FinderCacheUtil.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(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count); closeSession(session); } } return count.intValue(); } /** * Initializes the bookmarks entry persistence. */ public void afterPropertiesSet() { String[] listenerClassNames = StringUtil.split(GetterUtil.getString(com.liferay.portal.util.PropsUtil .get("value.object.listener.com.liferay.portlet.bookmarks.model.BookmarksEntry"))); if (listenerClassNames.length > 0) { try { List<ModelListener<BookmarksEntry>> listenersList = new ArrayList<ModelListener<BookmarksEntry>>(); for (String listenerClassName : listenerClassNames) { listenersList .add((ModelListener<BookmarksEntry>) InstanceFactory.newInstance(listenerClassName)); } listeners = listenersList.toArray(new ModelListener[listenersList.size()]); } catch (Exception e) { _log.error(e); } } } public void destroy() { EntityCacheUtil.removeCache(BookmarksEntryImpl.class.getName()); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @BeanReference(type = BookmarksEntryPersistence.class) protected BookmarksEntryPersistence bookmarksEntryPersistence; @BeanReference(type = BookmarksFolderPersistence.class) protected BookmarksFolderPersistence bookmarksFolderPersistence; @BeanReference(type = ResourcePersistence.class) protected ResourcePersistence resourcePersistence; @BeanReference(type = UserPersistence.class) protected UserPersistence userPersistence; @BeanReference(type = AssetEntryPersistence.class) protected AssetEntryPersistence assetEntryPersistence; @BeanReference(type = AssetLinkPersistence.class) protected AssetLinkPersistence assetLinkPersistence; @BeanReference(type = AssetTagPersistence.class) protected AssetTagPersistence assetTagPersistence; @BeanReference(type = ExpandoValuePersistence.class) protected ExpandoValuePersistence expandoValuePersistence; private static final String _SQL_SELECT_BOOKMARKSENTRY = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry"; 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 _FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2 = "bookmarksEntry.resourceBlockId = ?"; 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 = ?)"; 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 = ?"; private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "bookmarksEntry.groupId = ?"; private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "bookmarksEntry.groupId = ? AND "; private static final String _FINDER_COLUMN_G_U_USERID_2 = "bookmarksEntry.userId = ?"; private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "bookmarksEntry.groupId = ? AND "; private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" + _removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")"; private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "bookmarksEntry.folderId = ?"; private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" + _removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")"; private static String _removeConjunction(String sql) { int pos = sql.indexOf(" AND "); if (pos != -1) { sql = sql.substring(0, pos); } return sql; } 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 boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE; private static Log _log = LogFactoryUtil.getLog(BookmarksEntryPersistenceImpl.class); private static BookmarksEntry _nullBookmarksEntry = new BookmarksEntryImpl() { @Override public Object clone() { return this; } @Override public CacheModel<BookmarksEntry> toCacheModel() { return _nullBookmarksEntryCacheModel; } }; private static CacheModel<BookmarksEntry> _nullBookmarksEntryCacheModel = new CacheModel<BookmarksEntry>() { public BookmarksEntry toEntityModel() { return _nullBookmarksEntry; } }; }