--- /dev/null
+/**
+ * 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.pentila.entSavoie.shortCuts.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.portlet.PortletClassLoaderUtil;
+import com.liferay.portal.kernel.util.CalendarUtil;
+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.PropsKeys;
+import com.liferay.portal.kernel.util.PropsUtil;
+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.model.CacheModel;
+import com.liferay.portal.model.ModelListener;
+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.pentila.entSavoie.shortCuts.NoSuchShortCutException;
+import com.pentila.entSavoie.shortCuts.model.ShortCut;
+import com.pentila.entSavoie.shortCuts.model.impl.ShortCutImpl;
+import com.pentila.entSavoie.shortCuts.model.impl.ShortCutModelImpl;
+
+import java.io.Serializable;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * The persistence implementation for the short cut service.
+ *
+ * <p>
+ * Caching information and settings can be found in <code>portal.properties</code>
+ * </p>
+ *
+ * @author Mathieu Amblard
+ * @see ShortCutPersistence
+ * @see ShortCutUtil
+ * @generated
+ */
+public class ShortCutPersistenceImpl extends BasePersistenceImpl<ShortCut>
+ implements ShortCutPersistence {
+ /*
+ * NOTE FOR DEVELOPERS:
+ *
+ * Never modify or reference this class directly. Always use {@link ShortCutUtil} to access the short cut persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
+ */
+ public static final String FINDER_CLASS_NAME_ENTITY = ShortCutImpl.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_USERID = new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, ShortCutImpl.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByuserId",
+ 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_USERID =
+ new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, ShortCutImpl.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByuserId",
+ new String[] { Long.class.getName() },
+ ShortCutModelImpl.USERID_COLUMN_BITMASK);
+ public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByuserId",
+ new String[] { Long.class.getName() });
+ public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_ENTRYID = new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, ShortCutImpl.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByentryId",
+ 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_ENTRYID =
+ new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, ShortCutImpl.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByentryId",
+ new String[] { Long.class.getName() },
+ ShortCutModelImpl.ENTRYID_COLUMN_BITMASK);
+ public static final FinderPath FINDER_PATH_COUNT_BY_ENTRYID = new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByentryId",
+ new String[] { Long.class.getName() });
+ public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SHORTCUTFOLDERID_USERID =
+ new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, ShortCutImpl.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
+ "findByshortCutFolderId_userId",
+ 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_SHORTCUTFOLDERID_USERID =
+ new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, ShortCutImpl.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
+ "findByshortCutFolderId_userId",
+ new String[] { Long.class.getName(), Long.class.getName() },
+ ShortCutModelImpl.SHORTCUTFOLDERID_COLUMN_BITMASK |
+ ShortCutModelImpl.USERID_COLUMN_BITMASK);
+ public static final FinderPath FINDER_PATH_COUNT_BY_SHORTCUTFOLDERID_USERID = new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
+ "countByshortCutFolderId_userId",
+ new String[] { Long.class.getName(), Long.class.getName() });
+ public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_DATESHORTCUT_USERID =
+ new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, ShortCutImpl.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
+ "findBydateShortCut_userId",
+ new String[] {
+ Date.class.getName(), Long.class.getName(),
+
+ "java.lang.Integer", "java.lang.Integer",
+ "com.liferay.portal.kernel.util.OrderByComparator"
+ });
+ public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_DATESHORTCUT_USERID =
+ new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
+ "countBydateShortCut_userId",
+ new String[] { Date.class.getName(), Long.class.getName() });
+ public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, ShortCutImpl.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
+ public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, ShortCutImpl.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
+ public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
+
+ /**
+ * Caches the short cut in the entity cache if it is enabled.
+ *
+ * @param shortCut the short cut
+ */
+ public void cacheResult(ShortCut shortCut) {
+ EntityCacheUtil.putResult(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutImpl.class, shortCut.getPrimaryKey(), shortCut);
+
+ shortCut.resetOriginalValues();
+ }
+
+ /**
+ * Caches the short cuts in the entity cache if it is enabled.
+ *
+ * @param shortCuts the short cuts
+ */
+ public void cacheResult(List<ShortCut> shortCuts) {
+ for (ShortCut shortCut : shortCuts) {
+ if (EntityCacheUtil.getResult(
+ ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutImpl.class, shortCut.getPrimaryKey()) == null) {
+ cacheResult(shortCut);
+ }
+ else {
+ shortCut.resetOriginalValues();
+ }
+ }
+ }
+
+ /**
+ * Clears the cache for all short cuts.
+ *
+ * <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(ShortCutImpl.class.getName());
+ }
+
+ EntityCacheUtil.clearCache(ShortCutImpl.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 short cut.
+ *
+ * <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(ShortCut shortCut) {
+ EntityCacheUtil.removeResult(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutImpl.class, shortCut.getPrimaryKey());
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ @Override
+ public void clearCache(List<ShortCut> shortCuts) {
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+
+ for (ShortCut shortCut : shortCuts) {
+ EntityCacheUtil.removeResult(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutImpl.class, shortCut.getPrimaryKey());
+ }
+ }
+
+ /**
+ * Creates a new short cut with the primary key. Does not add the short cut to the database.
+ *
+ * @param shortCutId the primary key for the new short cut
+ * @return the new short cut
+ */
+ public ShortCut create(long shortCutId) {
+ ShortCut shortCut = new ShortCutImpl();
+
+ shortCut.setNew(true);
+ shortCut.setPrimaryKey(shortCutId);
+
+ return shortCut;
+ }
+
+ /**
+ * Removes the short cut with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param shortCutId the primary key of the short cut
+ * @return the short cut that was removed
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a short cut with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut remove(long shortCutId)
+ throws NoSuchShortCutException, SystemException {
+ return remove(Long.valueOf(shortCutId));
+ }
+
+ /**
+ * Removes the short cut with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param primaryKey the primary key of the short cut
+ * @return the short cut that was removed
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a short cut with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public ShortCut remove(Serializable primaryKey)
+ throws NoSuchShortCutException, SystemException {
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ ShortCut shortCut = (ShortCut)session.get(ShortCutImpl.class,
+ primaryKey);
+
+ if (shortCut == null) {
+ if (_log.isWarnEnabled()) {
+ _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
+ }
+
+ throw new NoSuchShortCutException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ primaryKey);
+ }
+
+ return remove(shortCut);
+ }
+ catch (NoSuchShortCutException nsee) {
+ throw nsee;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ @Override
+ protected ShortCut removeImpl(ShortCut shortCut) throws SystemException {
+ shortCut = toUnwrappedModel(shortCut);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ BatchSessionUtil.delete(session, shortCut);
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+
+ clearCache(shortCut);
+
+ return shortCut;
+ }
+
+ @Override
+ public ShortCut updateImpl(
+ com.pentila.entSavoie.shortCuts.model.ShortCut shortCut, boolean merge)
+ throws SystemException {
+ shortCut = toUnwrappedModel(shortCut);
+
+ boolean isNew = shortCut.isNew();
+
+ ShortCutModelImpl shortCutModelImpl = (ShortCutModelImpl)shortCut;
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ BatchSessionUtil.update(session, shortCut, merge);
+
+ shortCut.setNew(false);
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+
+ if (isNew || !ShortCutModelImpl.COLUMN_BITMASK_ENABLED) {
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ else {
+ if ((shortCutModelImpl.getColumnBitmask() &
+ FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
+ Object[] args = new Object[] {
+ Long.valueOf(shortCutModelImpl.getOriginalUserId())
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
+ args);
+
+ args = new Object[] { Long.valueOf(shortCutModelImpl.getUserId()) };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
+ args);
+ }
+
+ if ((shortCutModelImpl.getColumnBitmask() &
+ FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ENTRYID.getColumnBitmask()) != 0) {
+ Object[] args = new Object[] {
+ Long.valueOf(shortCutModelImpl.getOriginalEntryId())
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ENTRYID, args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ENTRYID,
+ args);
+
+ args = new Object[] { Long.valueOf(shortCutModelImpl.getEntryId()) };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ENTRYID, args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ENTRYID,
+ args);
+ }
+
+ if ((shortCutModelImpl.getColumnBitmask() &
+ FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SHORTCUTFOLDERID_USERID.getColumnBitmask()) != 0) {
+ Object[] args = new Object[] {
+ Long.valueOf(shortCutModelImpl.getOriginalShortCutFolderId()),
+ Long.valueOf(shortCutModelImpl.getOriginalUserId())
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SHORTCUTFOLDERID_USERID,
+ args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SHORTCUTFOLDERID_USERID,
+ args);
+
+ args = new Object[] {
+ Long.valueOf(shortCutModelImpl.getShortCutFolderId()),
+ Long.valueOf(shortCutModelImpl.getUserId())
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SHORTCUTFOLDERID_USERID,
+ args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SHORTCUTFOLDERID_USERID,
+ args);
+ }
+ }
+
+ EntityCacheUtil.putResult(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutImpl.class, shortCut.getPrimaryKey(), shortCut);
+
+ return shortCut;
+ }
+
+ protected ShortCut toUnwrappedModel(ShortCut shortCut) {
+ if (shortCut instanceof ShortCutImpl) {
+ return shortCut;
+ }
+
+ ShortCutImpl shortCutImpl = new ShortCutImpl();
+
+ shortCutImpl.setNew(shortCut.isNew());
+ shortCutImpl.setPrimaryKey(shortCut.getPrimaryKey());
+
+ shortCutImpl.setShortCutId(shortCut.getShortCutId());
+ shortCutImpl.setShortCutName(shortCut.getShortCutName());
+ shortCutImpl.setEntryId(shortCut.getEntryId());
+ shortCutImpl.setUserId(shortCut.getUserId());
+ shortCutImpl.setShortCutUrl(shortCut.getShortCutUrl());
+ shortCutImpl.setType(shortCut.getType());
+ shortCutImpl.setDateShortCut(shortCut.getDateShortCut());
+ shortCutImpl.setShortCutFolderId(shortCut.getShortCutFolderId());
+
+ return shortCutImpl;
+ }
+
+ /**
+ * Returns the short cut 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 short cut
+ * @return the short cut
+ * @throws com.liferay.portal.NoSuchModelException if a short cut with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public ShortCut findByPrimaryKey(Serializable primaryKey)
+ throws NoSuchModelException, SystemException {
+ return findByPrimaryKey(((Long)primaryKey).longValue());
+ }
+
+ /**
+ * Returns the short cut with the primary key or throws a {@link com.pentila.entSavoie.shortCuts.NoSuchShortCutException} if it could not be found.
+ *
+ * @param shortCutId the primary key of the short cut
+ * @return the short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a short cut with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut findByPrimaryKey(long shortCutId)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = fetchByPrimaryKey(shortCutId);
+
+ if (shortCut == null) {
+ if (_log.isWarnEnabled()) {
+ _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + shortCutId);
+ }
+
+ throw new NoSuchShortCutException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ shortCutId);
+ }
+
+ return shortCut;
+ }
+
+ /**
+ * Returns the short cut with the primary key or returns <code>null</code> if it could not be found.
+ *
+ * @param primaryKey the primary key of the short cut
+ * @return the short cut, or <code>null</code> if a short cut with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public ShortCut fetchByPrimaryKey(Serializable primaryKey)
+ throws SystemException {
+ return fetchByPrimaryKey(((Long)primaryKey).longValue());
+ }
+
+ /**
+ * Returns the short cut with the primary key or returns <code>null</code> if it could not be found.
+ *
+ * @param shortCutId the primary key of the short cut
+ * @return the short cut, or <code>null</code> if a short cut with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut fetchByPrimaryKey(long shortCutId)
+ throws SystemException {
+ ShortCut shortCut = (ShortCut)EntityCacheUtil.getResult(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutImpl.class, shortCutId);
+
+ if (shortCut == _nullShortCut) {
+ return null;
+ }
+
+ if (shortCut == null) {
+ Session session = null;
+
+ boolean hasException = false;
+
+ try {
+ session = openSession();
+
+ shortCut = (ShortCut)session.get(ShortCutImpl.class,
+ Long.valueOf(shortCutId));
+ }
+ catch (Exception e) {
+ hasException = true;
+
+ throw processException(e);
+ }
+ finally {
+ if (shortCut != null) {
+ cacheResult(shortCut);
+ }
+ else if (!hasException) {
+ EntityCacheUtil.putResult(ShortCutModelImpl.ENTITY_CACHE_ENABLED,
+ ShortCutImpl.class, shortCutId, _nullShortCut);
+ }
+
+ closeSession(session);
+ }
+ }
+
+ return shortCut;
+ }
+
+ /**
+ * Returns all the short cuts where userId = ?.
+ *
+ * @param userId the user ID
+ * @return the matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findByuserId(long userId) throws SystemException {
+ return findByuserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
+ }
+
+ /**
+ * Returns a range of all the short cuts where 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 userId the user ID
+ * @param start the lower bound of the range of short cuts
+ * @param end the upper bound of the range of short cuts (not inclusive)
+ * @return the range of matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findByuserId(long userId, int start, int end)
+ throws SystemException {
+ return findByuserId(userId, start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the short cuts where 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 userId the user ID
+ * @param start the lower bound of the range of short cuts
+ * @param end the upper bound of the range of short cuts (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findByuserId(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_USERID;
+ finderArgs = new Object[] { userId };
+ }
+ else {
+ finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
+ finderArgs = new Object[] { userId, start, end, orderByComparator };
+ }
+
+ List<ShortCut> list = (List<ShortCut>)FinderCacheUtil.getResult(finderPath,
+ finderArgs, this);
+
+ if ((list != null) && !list.isEmpty()) {
+ for (ShortCut shortCut : list) {
+ if ((userId != shortCut.getUserId())) {
+ list = null;
+
+ break;
+ }
+ }
+ }
+
+ if (list == null) {
+ StringBundler query = null;
+
+ if (orderByComparator != null) {
+ query = new StringBundler(3 +
+ (orderByComparator.getOrderByFields().length * 3));
+ }
+ else {
+ query = new StringBundler(2);
+ }
+
+ query.append(_SQL_SELECT_SHORTCUT_WHERE);
+
+ query.append(_FINDER_COLUMN_USERID_USERID_2);
+
+ if (orderByComparator != null) {
+ appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
+ orderByComparator);
+ }
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(userId);
+
+ list = (List<ShortCut>)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 short cut in the ordered set where userId = ?.
+ *
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut findByuserId_First(long userId,
+ OrderByComparator orderByComparator)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = fetchByuserId_First(userId, orderByComparator);
+
+ if (shortCut != null) {
+ return shortCut;
+ }
+
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("userId=");
+ msg.append(userId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchShortCutException(msg.toString());
+ }
+
+ /**
+ * Returns the first short cut in the ordered set where userId = ?.
+ *
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching short cut, or <code>null</code> if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut fetchByuserId_First(long userId,
+ OrderByComparator orderByComparator) throws SystemException {
+ List<ShortCut> list = findByuserId(userId, 0, 1, orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the last short cut in the ordered set where userId = ?.
+ *
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut findByuserId_Last(long userId,
+ OrderByComparator orderByComparator)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = fetchByuserId_Last(userId, orderByComparator);
+
+ if (shortCut != null) {
+ return shortCut;
+ }
+
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("userId=");
+ msg.append(userId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchShortCutException(msg.toString());
+ }
+
+ /**
+ * Returns the last short cut in the ordered set where userId = ?.
+ *
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching short cut, or <code>null</code> if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut fetchByuserId_Last(long userId,
+ OrderByComparator orderByComparator) throws SystemException {
+ int count = countByuserId(userId);
+
+ List<ShortCut> list = findByuserId(userId, count - 1, count,
+ orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the short cuts before and after the current short cut in the ordered set where userId = ?.
+ *
+ * @param shortCutId the primary key of the current short cut
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the previous, current, and next short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a short cut with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut[] findByuserId_PrevAndNext(long shortCutId, long userId,
+ OrderByComparator orderByComparator)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = findByPrimaryKey(shortCutId);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ ShortCut[] array = new ShortCutImpl[3];
+
+ array[0] = getByuserId_PrevAndNext(session, shortCut, userId,
+ orderByComparator, true);
+
+ array[1] = shortCut;
+
+ array[2] = getByuserId_PrevAndNext(session, shortCut, userId,
+ orderByComparator, false);
+
+ return array;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ protected ShortCut getByuserId_PrevAndNext(Session session,
+ ShortCut shortCut, 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_SHORTCUT_WHERE);
+
+ query.append(_FINDER_COLUMN_USERID_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);
+ }
+ }
+ }
+ }
+
+ String sql = query.toString();
+
+ Query q = session.createQuery(sql);
+
+ q.setFirstResult(0);
+ q.setMaxResults(2);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(userId);
+
+ if (orderByComparator != null) {
+ Object[] values = orderByComparator.getOrderByConditionValues(shortCut);
+
+ for (Object value : values) {
+ qPos.add(value);
+ }
+ }
+
+ List<ShortCut> list = q.list();
+
+ if (list.size() == 2) {
+ return list.get(1);
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns all the short cuts where entryId = ?.
+ *
+ * @param entryId the entry ID
+ * @return the matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findByentryId(long entryId) throws SystemException {
+ return findByentryId(entryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
+ }
+
+ /**
+ * Returns a range of all the short cuts where entryId = ?.
+ *
+ * <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 entry ID
+ * @param start the lower bound of the range of short cuts
+ * @param end the upper bound of the range of short cuts (not inclusive)
+ * @return the range of matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findByentryId(long entryId, int start, int end)
+ throws SystemException {
+ return findByentryId(entryId, start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the short cuts where entryId = ?.
+ *
+ * <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 entry ID
+ * @param start the lower bound of the range of short cuts
+ * @param end the upper bound of the range of short cuts (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findByentryId(long entryId, 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_ENTRYID;
+ finderArgs = new Object[] { entryId };
+ }
+ else {
+ finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_ENTRYID;
+ finderArgs = new Object[] { entryId, start, end, orderByComparator };
+ }
+
+ List<ShortCut> list = (List<ShortCut>)FinderCacheUtil.getResult(finderPath,
+ finderArgs, this);
+
+ if ((list != null) && !list.isEmpty()) {
+ for (ShortCut shortCut : list) {
+ if ((entryId != shortCut.getEntryId())) {
+ list = null;
+
+ break;
+ }
+ }
+ }
+
+ if (list == null) {
+ StringBundler query = null;
+
+ if (orderByComparator != null) {
+ query = new StringBundler(3 +
+ (orderByComparator.getOrderByFields().length * 3));
+ }
+ else {
+ query = new StringBundler(2);
+ }
+
+ query.append(_SQL_SELECT_SHORTCUT_WHERE);
+
+ query.append(_FINDER_COLUMN_ENTRYID_ENTRYID_2);
+
+ if (orderByComparator != null) {
+ appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
+ orderByComparator);
+ }
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(entryId);
+
+ list = (List<ShortCut>)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 short cut in the ordered set where entryId = ?.
+ *
+ * @param entryId the entry ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut findByentryId_First(long entryId,
+ OrderByComparator orderByComparator)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = fetchByentryId_First(entryId, orderByComparator);
+
+ if (shortCut != null) {
+ return shortCut;
+ }
+
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("entryId=");
+ msg.append(entryId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchShortCutException(msg.toString());
+ }
+
+ /**
+ * Returns the first short cut in the ordered set where entryId = ?.
+ *
+ * @param entryId the entry ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching short cut, or <code>null</code> if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut fetchByentryId_First(long entryId,
+ OrderByComparator orderByComparator) throws SystemException {
+ List<ShortCut> list = findByentryId(entryId, 0, 1, orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the last short cut in the ordered set where entryId = ?.
+ *
+ * @param entryId the entry ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut findByentryId_Last(long entryId,
+ OrderByComparator orderByComparator)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = fetchByentryId_Last(entryId, orderByComparator);
+
+ if (shortCut != null) {
+ return shortCut;
+ }
+
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("entryId=");
+ msg.append(entryId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchShortCutException(msg.toString());
+ }
+
+ /**
+ * Returns the last short cut in the ordered set where entryId = ?.
+ *
+ * @param entryId the entry ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching short cut, or <code>null</code> if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut fetchByentryId_Last(long entryId,
+ OrderByComparator orderByComparator) throws SystemException {
+ int count = countByentryId(entryId);
+
+ List<ShortCut> list = findByentryId(entryId, count - 1, count,
+ orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the short cuts before and after the current short cut in the ordered set where entryId = ?.
+ *
+ * @param shortCutId the primary key of the current short cut
+ * @param entryId the entry ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the previous, current, and next short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a short cut with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut[] findByentryId_PrevAndNext(long shortCutId, long entryId,
+ OrderByComparator orderByComparator)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = findByPrimaryKey(shortCutId);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ ShortCut[] array = new ShortCutImpl[3];
+
+ array[0] = getByentryId_PrevAndNext(session, shortCut, entryId,
+ orderByComparator, true);
+
+ array[1] = shortCut;
+
+ array[2] = getByentryId_PrevAndNext(session, shortCut, entryId,
+ orderByComparator, false);
+
+ return array;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ protected ShortCut getByentryId_PrevAndNext(Session session,
+ ShortCut shortCut, long entryId, 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_SHORTCUT_WHERE);
+
+ query.append(_FINDER_COLUMN_ENTRYID_ENTRYID_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);
+ }
+ }
+ }
+ }
+
+ String sql = query.toString();
+
+ Query q = session.createQuery(sql);
+
+ q.setFirstResult(0);
+ q.setMaxResults(2);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(entryId);
+
+ if (orderByComparator != null) {
+ Object[] values = orderByComparator.getOrderByConditionValues(shortCut);
+
+ for (Object value : values) {
+ qPos.add(value);
+ }
+ }
+
+ List<ShortCut> list = q.list();
+
+ if (list.size() == 2) {
+ return list.get(1);
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns all the short cuts where shortCutFolderId = ? and userId = ?.
+ *
+ * @param shortCutFolderId the short cut folder ID
+ * @param userId the user ID
+ * @return the matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findByshortCutFolderId_userId(long shortCutFolderId,
+ long userId) throws SystemException {
+ return findByshortCutFolderId_userId(shortCutFolderId, userId,
+ QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
+ }
+
+ /**
+ * Returns a range of all the short cuts where shortCutFolderId = ? 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 shortCutFolderId the short cut folder ID
+ * @param userId the user ID
+ * @param start the lower bound of the range of short cuts
+ * @param end the upper bound of the range of short cuts (not inclusive)
+ * @return the range of matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findByshortCutFolderId_userId(long shortCutFolderId,
+ long userId, int start, int end) throws SystemException {
+ return findByshortCutFolderId_userId(shortCutFolderId, userId, start,
+ end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the short cuts where shortCutFolderId = ? 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 shortCutFolderId the short cut folder ID
+ * @param userId the user ID
+ * @param start the lower bound of the range of short cuts
+ * @param end the upper bound of the range of short cuts (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findByshortCutFolderId_userId(long shortCutFolderId,
+ 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_SHORTCUTFOLDERID_USERID;
+ finderArgs = new Object[] { shortCutFolderId, userId };
+ }
+ else {
+ finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SHORTCUTFOLDERID_USERID;
+ finderArgs = new Object[] {
+ shortCutFolderId, userId,
+
+ start, end, orderByComparator
+ };
+ }
+
+ List<ShortCut> list = (List<ShortCut>)FinderCacheUtil.getResult(finderPath,
+ finderArgs, this);
+
+ if ((list != null) && !list.isEmpty()) {
+ for (ShortCut shortCut : list) {
+ if ((shortCutFolderId != shortCut.getShortCutFolderId()) ||
+ (userId != shortCut.getUserId())) {
+ list = null;
+
+ break;
+ }
+ }
+ }
+
+ if (list == null) {
+ StringBundler query = null;
+
+ if (orderByComparator != null) {
+ query = new StringBundler(4 +
+ (orderByComparator.getOrderByFields().length * 3));
+ }
+ else {
+ query = new StringBundler(3);
+ }
+
+ query.append(_SQL_SELECT_SHORTCUT_WHERE);
+
+ query.append(_FINDER_COLUMN_SHORTCUTFOLDERID_USERID_SHORTCUTFOLDERID_2);
+
+ query.append(_FINDER_COLUMN_SHORTCUTFOLDERID_USERID_USERID_2);
+
+ if (orderByComparator != null) {
+ appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
+ orderByComparator);
+ }
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(shortCutFolderId);
+
+ qPos.add(userId);
+
+ list = (List<ShortCut>)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 short cut in the ordered set where shortCutFolderId = ? and userId = ?.
+ *
+ * @param shortCutFolderId the short cut folder ID
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut findByshortCutFolderId_userId_First(long shortCutFolderId,
+ long userId, OrderByComparator orderByComparator)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = fetchByshortCutFolderId_userId_First(shortCutFolderId,
+ userId, orderByComparator);
+
+ if (shortCut != null) {
+ return shortCut;
+ }
+
+ StringBundler msg = new StringBundler(6);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("shortCutFolderId=");
+ msg.append(shortCutFolderId);
+
+ msg.append(", userId=");
+ msg.append(userId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchShortCutException(msg.toString());
+ }
+
+ /**
+ * Returns the first short cut in the ordered set where shortCutFolderId = ? and userId = ?.
+ *
+ * @param shortCutFolderId the short cut folder ID
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching short cut, or <code>null</code> if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut fetchByshortCutFolderId_userId_First(
+ long shortCutFolderId, long userId, OrderByComparator orderByComparator)
+ throws SystemException {
+ List<ShortCut> list = findByshortCutFolderId_userId(shortCutFolderId,
+ userId, 0, 1, orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the last short cut in the ordered set where shortCutFolderId = ? and userId = ?.
+ *
+ * @param shortCutFolderId the short cut folder ID
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut findByshortCutFolderId_userId_Last(long shortCutFolderId,
+ long userId, OrderByComparator orderByComparator)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = fetchByshortCutFolderId_userId_Last(shortCutFolderId,
+ userId, orderByComparator);
+
+ if (shortCut != null) {
+ return shortCut;
+ }
+
+ StringBundler msg = new StringBundler(6);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("shortCutFolderId=");
+ msg.append(shortCutFolderId);
+
+ msg.append(", userId=");
+ msg.append(userId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchShortCutException(msg.toString());
+ }
+
+ /**
+ * Returns the last short cut in the ordered set where shortCutFolderId = ? and userId = ?.
+ *
+ * @param shortCutFolderId the short cut folder ID
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching short cut, or <code>null</code> if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut fetchByshortCutFolderId_userId_Last(long shortCutFolderId,
+ long userId, OrderByComparator orderByComparator)
+ throws SystemException {
+ int count = countByshortCutFolderId_userId(shortCutFolderId, userId);
+
+ List<ShortCut> list = findByshortCutFolderId_userId(shortCutFolderId,
+ userId, count - 1, count, orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the short cuts before and after the current short cut in the ordered set where shortCutFolderId = ? and userId = ?.
+ *
+ * @param shortCutId the primary key of the current short cut
+ * @param shortCutFolderId the short cut folder 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 short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a short cut with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut[] findByshortCutFolderId_userId_PrevAndNext(
+ long shortCutId, long shortCutFolderId, long userId,
+ OrderByComparator orderByComparator)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = findByPrimaryKey(shortCutId);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ ShortCut[] array = new ShortCutImpl[3];
+
+ array[0] = getByshortCutFolderId_userId_PrevAndNext(session,
+ shortCut, shortCutFolderId, userId, orderByComparator, true);
+
+ array[1] = shortCut;
+
+ array[2] = getByshortCutFolderId_userId_PrevAndNext(session,
+ shortCut, shortCutFolderId, userId, orderByComparator, false);
+
+ return array;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ protected ShortCut getByshortCutFolderId_userId_PrevAndNext(
+ Session session, ShortCut shortCut, long shortCutFolderId, 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_SHORTCUT_WHERE);
+
+ query.append(_FINDER_COLUMN_SHORTCUTFOLDERID_USERID_SHORTCUTFOLDERID_2);
+
+ query.append(_FINDER_COLUMN_SHORTCUTFOLDERID_USERID_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);
+ }
+ }
+ }
+ }
+
+ String sql = query.toString();
+
+ Query q = session.createQuery(sql);
+
+ q.setFirstResult(0);
+ q.setMaxResults(2);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(shortCutFolderId);
+
+ qPos.add(userId);
+
+ if (orderByComparator != null) {
+ Object[] values = orderByComparator.getOrderByConditionValues(shortCut);
+
+ for (Object value : values) {
+ qPos.add(value);
+ }
+ }
+
+ List<ShortCut> list = q.list();
+
+ if (list.size() == 2) {
+ return list.get(1);
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns all the short cuts where dateShortCut ≥ ? and userId = ?.
+ *
+ * @param dateShortCut the date short cut
+ * @param userId the user ID
+ * @return the matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findBydateShortCut_userId(Date dateShortCut,
+ long userId) throws SystemException {
+ return findBydateShortCut_userId(dateShortCut, userId,
+ QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
+ }
+
+ /**
+ * Returns a range of all the short cuts where dateShortCut ≥ ? 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 dateShortCut the date short cut
+ * @param userId the user ID
+ * @param start the lower bound of the range of short cuts
+ * @param end the upper bound of the range of short cuts (not inclusive)
+ * @return the range of matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findBydateShortCut_userId(Date dateShortCut,
+ long userId, int start, int end) throws SystemException {
+ return findBydateShortCut_userId(dateShortCut, userId, start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the short cuts where dateShortCut ≥ ? 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 dateShortCut the date short cut
+ * @param userId the user ID
+ * @param start the lower bound of the range of short cuts
+ * @param end the upper bound of the range of short cuts (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findBydateShortCut_userId(Date dateShortCut,
+ long userId, int start, int end, OrderByComparator orderByComparator)
+ throws SystemException {
+ FinderPath finderPath = null;
+ Object[] finderArgs = null;
+
+ finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_DATESHORTCUT_USERID;
+ finderArgs = new Object[] {
+ dateShortCut, userId,
+
+ start, end, orderByComparator
+ };
+
+ List<ShortCut> list = (List<ShortCut>)FinderCacheUtil.getResult(finderPath,
+ finderArgs, this);
+
+ if ((list != null) && !list.isEmpty()) {
+ for (ShortCut shortCut : list) {
+ if (!Validator.equals(dateShortCut, shortCut.getDateShortCut()) ||
+ (userId != shortCut.getUserId())) {
+ list = null;
+
+ break;
+ }
+ }
+ }
+
+ if (list == null) {
+ StringBundler query = null;
+
+ if (orderByComparator != null) {
+ query = new StringBundler(4 +
+ (orderByComparator.getOrderByFields().length * 3));
+ }
+ else {
+ query = new StringBundler(3);
+ }
+
+ query.append(_SQL_SELECT_SHORTCUT_WHERE);
+
+ if (dateShortCut == null) {
+ query.append(_FINDER_COLUMN_DATESHORTCUT_USERID_DATESHORTCUT_1);
+ }
+ else {
+ query.append(_FINDER_COLUMN_DATESHORTCUT_USERID_DATESHORTCUT_2);
+ }
+
+ query.append(_FINDER_COLUMN_DATESHORTCUT_USERID_USERID_2);
+
+ if (orderByComparator != null) {
+ appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
+ orderByComparator);
+ }
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ if (dateShortCut != null) {
+ qPos.add(CalendarUtil.getTimestamp(dateShortCut));
+ }
+
+ qPos.add(userId);
+
+ list = (List<ShortCut>)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 short cut in the ordered set where dateShortCut ≥ ? and userId = ?.
+ *
+ * @param dateShortCut the date short cut
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut findBydateShortCut_userId_First(Date dateShortCut,
+ long userId, OrderByComparator orderByComparator)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = fetchBydateShortCut_userId_First(dateShortCut,
+ userId, orderByComparator);
+
+ if (shortCut != null) {
+ return shortCut;
+ }
+
+ StringBundler msg = new StringBundler(6);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("dateShortCut=");
+ msg.append(dateShortCut);
+
+ msg.append(", userId=");
+ msg.append(userId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchShortCutException(msg.toString());
+ }
+
+ /**
+ * Returns the first short cut in the ordered set where dateShortCut ≥ ? and userId = ?.
+ *
+ * @param dateShortCut the date short cut
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching short cut, or <code>null</code> if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut fetchBydateShortCut_userId_First(Date dateShortCut,
+ long userId, OrderByComparator orderByComparator)
+ throws SystemException {
+ List<ShortCut> list = findBydateShortCut_userId(dateShortCut, userId,
+ 0, 1, orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the last short cut in the ordered set where dateShortCut ≥ ? and userId = ?.
+ *
+ * @param dateShortCut the date short cut
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut findBydateShortCut_userId_Last(Date dateShortCut,
+ long userId, OrderByComparator orderByComparator)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = fetchBydateShortCut_userId_Last(dateShortCut,
+ userId, orderByComparator);
+
+ if (shortCut != null) {
+ return shortCut;
+ }
+
+ StringBundler msg = new StringBundler(6);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("dateShortCut=");
+ msg.append(dateShortCut);
+
+ msg.append(", userId=");
+ msg.append(userId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchShortCutException(msg.toString());
+ }
+
+ /**
+ * Returns the last short cut in the ordered set where dateShortCut ≥ ? and userId = ?.
+ *
+ * @param dateShortCut the date short cut
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching short cut, or <code>null</code> if a matching short cut could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut fetchBydateShortCut_userId_Last(Date dateShortCut,
+ long userId, OrderByComparator orderByComparator)
+ throws SystemException {
+ int count = countBydateShortCut_userId(dateShortCut, userId);
+
+ List<ShortCut> list = findBydateShortCut_userId(dateShortCut, userId,
+ count - 1, count, orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the short cuts before and after the current short cut in the ordered set where dateShortCut ≥ ? and userId = ?.
+ *
+ * @param shortCutId the primary key of the current short cut
+ * @param dateShortCut the date short cut
+ * @param userId the user ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the previous, current, and next short cut
+ * @throws com.pentila.entSavoie.shortCuts.NoSuchShortCutException if a short cut with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public ShortCut[] findBydateShortCut_userId_PrevAndNext(long shortCutId,
+ Date dateShortCut, long userId, OrderByComparator orderByComparator)
+ throws NoSuchShortCutException, SystemException {
+ ShortCut shortCut = findByPrimaryKey(shortCutId);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ ShortCut[] array = new ShortCutImpl[3];
+
+ array[0] = getBydateShortCut_userId_PrevAndNext(session, shortCut,
+ dateShortCut, userId, orderByComparator, true);
+
+ array[1] = shortCut;
+
+ array[2] = getBydateShortCut_userId_PrevAndNext(session, shortCut,
+ dateShortCut, userId, orderByComparator, false);
+
+ return array;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ protected ShortCut getBydateShortCut_userId_PrevAndNext(Session session,
+ ShortCut shortCut, Date dateShortCut, 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_SHORTCUT_WHERE);
+
+ if (dateShortCut == null) {
+ query.append(_FINDER_COLUMN_DATESHORTCUT_USERID_DATESHORTCUT_1);
+ }
+ else {
+ query.append(_FINDER_COLUMN_DATESHORTCUT_USERID_DATESHORTCUT_2);
+ }
+
+ query.append(_FINDER_COLUMN_DATESHORTCUT_USERID_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);
+ }
+ }
+ }
+ }
+
+ String sql = query.toString();
+
+ Query q = session.createQuery(sql);
+
+ q.setFirstResult(0);
+ q.setMaxResults(2);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ if (dateShortCut != null) {
+ qPos.add(CalendarUtil.getTimestamp(dateShortCut));
+ }
+
+ qPos.add(userId);
+
+ if (orderByComparator != null) {
+ Object[] values = orderByComparator.getOrderByConditionValues(shortCut);
+
+ for (Object value : values) {
+ qPos.add(value);
+ }
+ }
+
+ List<ShortCut> list = q.list();
+
+ if (list.size() == 2) {
+ return list.get(1);
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns all the short cuts.
+ *
+ * @return the short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findAll() throws SystemException {
+ return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
+ }
+
+ /**
+ * Returns a range of all the short cuts.
+ *
+ * <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 short cuts
+ * @param end the upper bound of the range of short cuts (not inclusive)
+ * @return the range of short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> findAll(int start, int end) throws SystemException {
+ return findAll(start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the short cuts.
+ *
+ * <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 short cuts
+ * @param end the upper bound of the range of short cuts (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public List<ShortCut> 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_WITHOUT_PAGINATION_FIND_ALL;
+ finderArgs = FINDER_ARGS_EMPTY;
+ }
+ else {
+ finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
+ finderArgs = new Object[] { start, end, orderByComparator };
+ }
+
+ List<ShortCut> list = (List<ShortCut>)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_SHORTCUT);
+
+ appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
+ orderByComparator);
+
+ sql = query.toString();
+ }
+ else {
+ sql = _SQL_SELECT_SHORTCUT;
+ }
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ if (orderByComparator == null) {
+ list = (List<ShortCut>)QueryUtil.list(q, getDialect(),
+ start, end, false);
+
+ Collections.sort(list);
+ }
+ else {
+ list = (List<ShortCut>)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 short cuts where userId = ? from the database.
+ *
+ * @param userId the user ID
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeByuserId(long userId) throws SystemException {
+ for (ShortCut shortCut : findByuserId(userId)) {
+ remove(shortCut);
+ }
+ }
+
+ /**
+ * Removes all the short cuts where entryId = ? from the database.
+ *
+ * @param entryId the entry ID
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeByentryId(long entryId) throws SystemException {
+ for (ShortCut shortCut : findByentryId(entryId)) {
+ remove(shortCut);
+ }
+ }
+
+ /**
+ * Removes all the short cuts where shortCutFolderId = ? and userId = ? from the database.
+ *
+ * @param shortCutFolderId the short cut folder ID
+ * @param userId the user ID
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeByshortCutFolderId_userId(long shortCutFolderId,
+ long userId) throws SystemException {
+ for (ShortCut shortCut : findByshortCutFolderId_userId(
+ shortCutFolderId, userId)) {
+ remove(shortCut);
+ }
+ }
+
+ /**
+ * Removes all the short cuts where dateShortCut ≥ ? and userId = ? from the database.
+ *
+ * @param dateShortCut the date short cut
+ * @param userId the user ID
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeBydateShortCut_userId(Date dateShortCut, long userId)
+ throws SystemException {
+ for (ShortCut shortCut : findBydateShortCut_userId(dateShortCut, userId)) {
+ remove(shortCut);
+ }
+ }
+
+ /**
+ * Removes all the short cuts from the database.
+ *
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeAll() throws SystemException {
+ for (ShortCut shortCut : findAll()) {
+ remove(shortCut);
+ }
+ }
+
+ /**
+ * Returns the number of short cuts where userId = ?.
+ *
+ * @param userId the user ID
+ * @return the number of matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public int countByuserId(long userId) throws SystemException {
+ Object[] finderArgs = new Object[] { userId };
+
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
+ finderArgs, this);
+
+ if (count == null) {
+ StringBundler query = new StringBundler(2);
+
+ query.append(_SQL_COUNT_SHORTCUT_WHERE);
+
+ query.append(_FINDER_COLUMN_USERID_USERID_2);
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ 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_USERID,
+ finderArgs, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Returns the number of short cuts where entryId = ?.
+ *
+ * @param entryId the entry ID
+ * @return the number of matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public int countByentryId(long entryId) throws SystemException {
+ Object[] finderArgs = new Object[] { entryId };
+
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ENTRYID,
+ finderArgs, this);
+
+ if (count == null) {
+ StringBundler query = new StringBundler(2);
+
+ query.append(_SQL_COUNT_SHORTCUT_WHERE);
+
+ query.append(_FINDER_COLUMN_ENTRYID_ENTRYID_2);
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(entryId);
+
+ count = (Long)q.uniqueResult();
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (count == null) {
+ count = Long.valueOf(0);
+ }
+
+ FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ENTRYID,
+ finderArgs, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Returns the number of short cuts where shortCutFolderId = ? and userId = ?.
+ *
+ * @param shortCutFolderId the short cut folder ID
+ * @param userId the user ID
+ * @return the number of matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public int countByshortCutFolderId_userId(long shortCutFolderId, long userId)
+ throws SystemException {
+ Object[] finderArgs = new Object[] { shortCutFolderId, userId };
+
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SHORTCUTFOLDERID_USERID,
+ finderArgs, this);
+
+ if (count == null) {
+ StringBundler query = new StringBundler(3);
+
+ query.append(_SQL_COUNT_SHORTCUT_WHERE);
+
+ query.append(_FINDER_COLUMN_SHORTCUTFOLDERID_USERID_SHORTCUTFOLDERID_2);
+
+ query.append(_FINDER_COLUMN_SHORTCUTFOLDERID_USERID_USERID_2);
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(shortCutFolderId);
+
+ 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_SHORTCUTFOLDERID_USERID,
+ finderArgs, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Returns the number of short cuts where dateShortCut ≥ ? and userId = ?.
+ *
+ * @param dateShortCut the date short cut
+ * @param userId the user ID
+ * @return the number of matching short cuts
+ * @throws SystemException if a system exception occurred
+ */
+ public int countBydateShortCut_userId(Date dateShortCut, long userId)
+ throws SystemException {
+ Object[] finderArgs = new Object[] { dateShortCut, userId };
+
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_DATESHORTCUT_USERID,
+ finderArgs, this);
+
+ if (count == null) {
+ StringBundler query = new StringBundler(3);
+
+ query.append(_SQL_COUNT_SHORTCUT_WHERE);
+
+ if (dateShortCut == null) {
+ query.append(_FINDER_COLUMN_DATESHORTCUT_USERID_DATESHORTCUT_1);
+ }
+ else {
+ query.append(_FINDER_COLUMN_DATESHORTCUT_USERID_DATESHORTCUT_2);
+ }
+
+ query.append(_FINDER_COLUMN_DATESHORTCUT_USERID_USERID_2);
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ if (dateShortCut != null) {
+ qPos.add(CalendarUtil.getTimestamp(dateShortCut));
+ }
+
+ 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_WITH_PAGINATION_COUNT_BY_DATESHORTCUT_USERID,
+ finderArgs, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Returns the number of short cuts.
+ *
+ * @return the number of short cuts
+ * @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_SHORTCUT);
+
+ 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 short cut persistence.
+ */
+ public void afterPropertiesSet() {
+ String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
+ com.liferay.util.service.ServiceProps.get(
+ "value.object.listener.com.pentila.entSavoie.shortCuts.model.ShortCut")));
+
+ if (listenerClassNames.length > 0) {
+ try {
+ List<ModelListener<ShortCut>> listenersList = new ArrayList<ModelListener<ShortCut>>();
+
+ for (String listenerClassName : listenerClassNames) {
+ listenersList.add((ModelListener<ShortCut>)InstanceFactory.newInstance(
+ PortletClassLoaderUtil.getClassLoader(),
+ listenerClassName, (Class<?>[])null, (Object[])null));
+ }
+
+ listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
+ }
+ catch (Exception e) {
+ _log.error(e);
+ }
+ }
+ }
+
+ public void destroy() {
+ EntityCacheUtil.removeCache(ShortCutImpl.class.getName());
+ FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
+ FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ @BeanReference(type = ShortCutPersistence.class)
+ protected ShortCutPersistence shortCutPersistence;
+ @BeanReference(type = ShortCutFolderPersistence.class)
+ protected ShortCutFolderPersistence shortCutFolderPersistence;
+ @BeanReference(type = ResourcePersistence.class)
+ protected ResourcePersistence resourcePersistence;
+ @BeanReference(type = UserPersistence.class)
+ protected UserPersistence userPersistence;
+ private static final String _SQL_SELECT_SHORTCUT = "SELECT shortCut FROM ShortCut shortCut";
+ private static final String _SQL_SELECT_SHORTCUT_WHERE = "SELECT shortCut FROM ShortCut shortCut WHERE ";
+ private static final String _SQL_COUNT_SHORTCUT = "SELECT COUNT(shortCut) FROM ShortCut shortCut";
+ private static final String _SQL_COUNT_SHORTCUT_WHERE = "SELECT COUNT(shortCut) FROM ShortCut shortCut WHERE ";
+ private static final String _FINDER_COLUMN_USERID_USERID_2 = "shortCut.userId = ?";
+ private static final String _FINDER_COLUMN_ENTRYID_ENTRYID_2 = "shortCut.entryId = ?";
+ private static final String _FINDER_COLUMN_SHORTCUTFOLDERID_USERID_SHORTCUTFOLDERID_2 =
+ "shortCut.shortCutFolderId = ? AND ";
+ private static final String _FINDER_COLUMN_SHORTCUTFOLDERID_USERID_USERID_2 = "shortCut.userId = ?";
+ private static final String _FINDER_COLUMN_DATESHORTCUT_USERID_DATESHORTCUT_1 =
+ "shortCut.dateShortCut >= NULL AND ";
+ private static final String _FINDER_COLUMN_DATESHORTCUT_USERID_DATESHORTCUT_2 =
+ "shortCut.dateShortCut >= ? AND ";
+ private static final String _FINDER_COLUMN_DATESHORTCUT_USERID_USERID_2 = "shortCut.userId = ?";
+ private static final String _ORDER_BY_ENTITY_ALIAS = "shortCut.";
+ private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ShortCut exists with the primary key ";
+ private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ShortCut exists with the key {";
+ private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = GetterUtil.getBoolean(PropsUtil.get(
+ PropsKeys.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE));
+ private static Log _log = LogFactoryUtil.getLog(ShortCutPersistenceImpl.class);
+ private static ShortCut _nullShortCut = new ShortCutImpl() {
+ @Override
+ public Object clone() {
+ return this;
+ }
+
+ @Override
+ public CacheModel<ShortCut> toCacheModel() {
+ return _nullShortCutCacheModel;
+ }
+ };
+
+ private static CacheModel<ShortCut> _nullShortCutCacheModel = new CacheModel<ShortCut>() {
+ public ShortCut toEntityModel() {
+ return _nullShortCut;
+ }
+ };
+}
\ No newline at end of file