--- /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.cantine.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.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.cantine.NoSuchCantineMenuException;
+import com.pentila.entSavoie.cantine.model.CantineMenu;
+import com.pentila.entSavoie.cantine.model.impl.CantineMenuImpl;
+import com.pentila.entSavoie.cantine.model.impl.CantineMenuModelImpl;
+
+import java.io.Serializable;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * The persistence implementation for the cantine menu service.
+ *
+ * <p>
+ * Caching information and settings can be found in <code>portal.properties</code>
+ * </p>
+ *
+ * @author Mathieu Amblard
+ * @see CantineMenuPersistence
+ * @see CantineMenuUtil
+ * @generated
+ */
+public class CantineMenuPersistenceImpl extends BasePersistenceImpl<CantineMenu>
+ implements CantineMenuPersistence {
+ /*
+ * NOTE FOR DEVELOPERS:
+ *
+ * Never modify or reference this class directly. Always use {@link CantineMenuUtil} to access the cantine menu persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
+ */
+ public static final String FINDER_CLASS_NAME_ENTITY = CantineMenuImpl.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_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE =
+ new FinderPath(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuModelImpl.FINDER_CACHE_ENABLED, CantineMenuImpl.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
+ "findBycantineDatePlanAlimentaireId_typeRecette",
+ new String[] {
+ Long.class.getName(), 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_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE =
+ new FinderPath(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuModelImpl.FINDER_CACHE_ENABLED, CantineMenuImpl.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
+ "findBycantineDatePlanAlimentaireId_typeRecette",
+ new String[] { Long.class.getName(), String.class.getName() },
+ CantineMenuModelImpl.CANTINEDATEPLANALIMENTAIREID_COLUMN_BITMASK |
+ CantineMenuModelImpl.TYPERECETTE_COLUMN_BITMASK);
+ public static final FinderPath FINDER_PATH_COUNT_BY_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE =
+ new FinderPath(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
+ "countBycantineDatePlanAlimentaireId_typeRecette",
+ new String[] { Long.class.getName(), String.class.getName() });
+ public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RECETTEID =
+ new FinderPath(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuModelImpl.FINDER_CACHE_ENABLED, CantineMenuImpl.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByrecetteId",
+ 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_RECETTEID =
+ new FinderPath(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuModelImpl.FINDER_CACHE_ENABLED, CantineMenuImpl.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByrecetteId",
+ new String[] { Long.class.getName() },
+ CantineMenuModelImpl.RECETTEID_COLUMN_BITMASK);
+ public static final FinderPath FINDER_PATH_COUNT_BY_RECETTEID = new FinderPath(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByrecetteId",
+ new String[] { Long.class.getName() });
+ public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CANTINEDATEPLANALIMENTAIREID =
+ new FinderPath(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuModelImpl.FINDER_CACHE_ENABLED, CantineMenuImpl.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
+ "findBycantineDatePlanAlimentaireId",
+ 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_CANTINEDATEPLANALIMENTAIREID =
+ new FinderPath(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuModelImpl.FINDER_CACHE_ENABLED, CantineMenuImpl.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
+ "findBycantineDatePlanAlimentaireId",
+ new String[] { Long.class.getName() },
+ CantineMenuModelImpl.CANTINEDATEPLANALIMENTAIREID_COLUMN_BITMASK);
+ public static final FinderPath FINDER_PATH_COUNT_BY_CANTINEDATEPLANALIMENTAIREID =
+ new FinderPath(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
+ "countBycantineDatePlanAlimentaireId",
+ new String[] { Long.class.getName() });
+ public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuModelImpl.FINDER_CACHE_ENABLED, CantineMenuImpl.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
+ public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuModelImpl.FINDER_CACHE_ENABLED, CantineMenuImpl.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
+ public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
+
+ /**
+ * Caches the cantine menu in the entity cache if it is enabled.
+ *
+ * @param cantineMenu the cantine menu
+ */
+ public void cacheResult(CantineMenu cantineMenu) {
+ EntityCacheUtil.putResult(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuImpl.class, cantineMenu.getPrimaryKey(), cantineMenu);
+
+ cantineMenu.resetOriginalValues();
+ }
+
+ /**
+ * Caches the cantine menus in the entity cache if it is enabled.
+ *
+ * @param cantineMenus the cantine menus
+ */
+ public void cacheResult(List<CantineMenu> cantineMenus) {
+ for (CantineMenu cantineMenu : cantineMenus) {
+ if (EntityCacheUtil.getResult(
+ CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuImpl.class, cantineMenu.getPrimaryKey()) == null) {
+ cacheResult(cantineMenu);
+ }
+ else {
+ cantineMenu.resetOriginalValues();
+ }
+ }
+ }
+
+ /**
+ * Clears the cache for all cantine menus.
+ *
+ * <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(CantineMenuImpl.class.getName());
+ }
+
+ EntityCacheUtil.clearCache(CantineMenuImpl.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 cantine menu.
+ *
+ * <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(CantineMenu cantineMenu) {
+ EntityCacheUtil.removeResult(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuImpl.class, cantineMenu.getPrimaryKey());
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ @Override
+ public void clearCache(List<CantineMenu> cantineMenus) {
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+
+ for (CantineMenu cantineMenu : cantineMenus) {
+ EntityCacheUtil.removeResult(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuImpl.class, cantineMenu.getPrimaryKey());
+ }
+ }
+
+ /**
+ * Creates a new cantine menu with the primary key. Does not add the cantine menu to the database.
+ *
+ * @param cantineMenuId the primary key for the new cantine menu
+ * @return the new cantine menu
+ */
+ public CantineMenu create(long cantineMenuId) {
+ CantineMenu cantineMenu = new CantineMenuImpl();
+
+ cantineMenu.setNew(true);
+ cantineMenu.setPrimaryKey(cantineMenuId);
+
+ return cantineMenu;
+ }
+
+ /**
+ * Removes the cantine menu with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param cantineMenuId the primary key of the cantine menu
+ * @return the cantine menu that was removed
+ * @throws com.pentila.entSavoie.cantine.NoSuchCantineMenuException if a cantine menu with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu remove(long cantineMenuId)
+ throws NoSuchCantineMenuException, SystemException {
+ return remove(Long.valueOf(cantineMenuId));
+ }
+
+ /**
+ * Removes the cantine menu with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param primaryKey the primary key of the cantine menu
+ * @return the cantine menu that was removed
+ * @throws com.pentila.entSavoie.cantine.NoSuchCantineMenuException if a cantine menu with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public CantineMenu remove(Serializable primaryKey)
+ throws NoSuchCantineMenuException, SystemException {
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ CantineMenu cantineMenu = (CantineMenu)session.get(CantineMenuImpl.class,
+ primaryKey);
+
+ if (cantineMenu == null) {
+ if (_log.isWarnEnabled()) {
+ _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
+ }
+
+ throw new NoSuchCantineMenuException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ primaryKey);
+ }
+
+ return remove(cantineMenu);
+ }
+ catch (NoSuchCantineMenuException nsee) {
+ throw nsee;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ @Override
+ protected CantineMenu removeImpl(CantineMenu cantineMenu)
+ throws SystemException {
+ cantineMenu = toUnwrappedModel(cantineMenu);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ BatchSessionUtil.delete(session, cantineMenu);
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+
+ clearCache(cantineMenu);
+
+ return cantineMenu;
+ }
+
+ @Override
+ public CantineMenu updateImpl(
+ com.pentila.entSavoie.cantine.model.CantineMenu cantineMenu,
+ boolean merge) throws SystemException {
+ cantineMenu = toUnwrappedModel(cantineMenu);
+
+ boolean isNew = cantineMenu.isNew();
+
+ CantineMenuModelImpl cantineMenuModelImpl = (CantineMenuModelImpl)cantineMenu;
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ BatchSessionUtil.update(session, cantineMenu, merge);
+
+ cantineMenu.setNew(false);
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+
+ if (isNew || !CantineMenuModelImpl.COLUMN_BITMASK_ENABLED) {
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ else {
+ if ((cantineMenuModelImpl.getColumnBitmask() &
+ FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE.getColumnBitmask()) != 0) {
+ Object[] args = new Object[] {
+ Long.valueOf(cantineMenuModelImpl.getOriginalCantineDatePlanAlimentaireId()),
+
+ cantineMenuModelImpl.getOriginalTypeRecette()
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE,
+ args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE,
+ args);
+
+ args = new Object[] {
+ Long.valueOf(cantineMenuModelImpl.getCantineDatePlanAlimentaireId()),
+
+ cantineMenuModelImpl.getTypeRecette()
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE,
+ args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE,
+ args);
+ }
+
+ if ((cantineMenuModelImpl.getColumnBitmask() &
+ FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECETTEID.getColumnBitmask()) != 0) {
+ Object[] args = new Object[] {
+ Long.valueOf(cantineMenuModelImpl.getOriginalRecetteId())
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RECETTEID,
+ args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECETTEID,
+ args);
+
+ args = new Object[] {
+ Long.valueOf(cantineMenuModelImpl.getRecetteId())
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RECETTEID,
+ args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECETTEID,
+ args);
+ }
+
+ if ((cantineMenuModelImpl.getColumnBitmask() &
+ FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CANTINEDATEPLANALIMENTAIREID.getColumnBitmask()) != 0) {
+ Object[] args = new Object[] {
+ Long.valueOf(cantineMenuModelImpl.getOriginalCantineDatePlanAlimentaireId())
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CANTINEDATEPLANALIMENTAIREID,
+ args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CANTINEDATEPLANALIMENTAIREID,
+ args);
+
+ args = new Object[] {
+ Long.valueOf(cantineMenuModelImpl.getCantineDatePlanAlimentaireId())
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CANTINEDATEPLANALIMENTAIREID,
+ args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CANTINEDATEPLANALIMENTAIREID,
+ args);
+ }
+ }
+
+ EntityCacheUtil.putResult(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuImpl.class, cantineMenu.getPrimaryKey(), cantineMenu);
+
+ return cantineMenu;
+ }
+
+ protected CantineMenu toUnwrappedModel(CantineMenu cantineMenu) {
+ if (cantineMenu instanceof CantineMenuImpl) {
+ return cantineMenu;
+ }
+
+ CantineMenuImpl cantineMenuImpl = new CantineMenuImpl();
+
+ cantineMenuImpl.setNew(cantineMenu.isNew());
+ cantineMenuImpl.setPrimaryKey(cantineMenu.getPrimaryKey());
+
+ cantineMenuImpl.setCantineMenuId(cantineMenu.getCantineMenuId());
+ cantineMenuImpl.setCantineDatePlanAlimentaireId(cantineMenu.getCantineDatePlanAlimentaireId());
+ cantineMenuImpl.setRecetteId(cantineMenu.getRecetteId());
+ cantineMenuImpl.setTypeRecette(cantineMenu.getTypeRecette());
+
+ return cantineMenuImpl;
+ }
+
+ /**
+ * Returns the cantine menu 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 cantine menu
+ * @return the cantine menu
+ * @throws com.liferay.portal.NoSuchModelException if a cantine menu with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public CantineMenu findByPrimaryKey(Serializable primaryKey)
+ throws NoSuchModelException, SystemException {
+ return findByPrimaryKey(((Long)primaryKey).longValue());
+ }
+
+ /**
+ * Returns the cantine menu with the primary key or throws a {@link com.pentila.entSavoie.cantine.NoSuchCantineMenuException} if it could not be found.
+ *
+ * @param cantineMenuId the primary key of the cantine menu
+ * @return the cantine menu
+ * @throws com.pentila.entSavoie.cantine.NoSuchCantineMenuException if a cantine menu with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu findByPrimaryKey(long cantineMenuId)
+ throws NoSuchCantineMenuException, SystemException {
+ CantineMenu cantineMenu = fetchByPrimaryKey(cantineMenuId);
+
+ if (cantineMenu == null) {
+ if (_log.isWarnEnabled()) {
+ _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + cantineMenuId);
+ }
+
+ throw new NoSuchCantineMenuException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ cantineMenuId);
+ }
+
+ return cantineMenu;
+ }
+
+ /**
+ * Returns the cantine menu with the primary key or returns <code>null</code> if it could not be found.
+ *
+ * @param primaryKey the primary key of the cantine menu
+ * @return the cantine menu, or <code>null</code> if a cantine menu with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public CantineMenu fetchByPrimaryKey(Serializable primaryKey)
+ throws SystemException {
+ return fetchByPrimaryKey(((Long)primaryKey).longValue());
+ }
+
+ /**
+ * Returns the cantine menu with the primary key or returns <code>null</code> if it could not be found.
+ *
+ * @param cantineMenuId the primary key of the cantine menu
+ * @return the cantine menu, or <code>null</code> if a cantine menu with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu fetchByPrimaryKey(long cantineMenuId)
+ throws SystemException {
+ CantineMenu cantineMenu = (CantineMenu)EntityCacheUtil.getResult(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuImpl.class, cantineMenuId);
+
+ if (cantineMenu == _nullCantineMenu) {
+ return null;
+ }
+
+ if (cantineMenu == null) {
+ Session session = null;
+
+ boolean hasException = false;
+
+ try {
+ session = openSession();
+
+ cantineMenu = (CantineMenu)session.get(CantineMenuImpl.class,
+ Long.valueOf(cantineMenuId));
+ }
+ catch (Exception e) {
+ hasException = true;
+
+ throw processException(e);
+ }
+ finally {
+ if (cantineMenu != null) {
+ cacheResult(cantineMenu);
+ }
+ else if (!hasException) {
+ EntityCacheUtil.putResult(CantineMenuModelImpl.ENTITY_CACHE_ENABLED,
+ CantineMenuImpl.class, cantineMenuId, _nullCantineMenu);
+ }
+
+ closeSession(session);
+ }
+ }
+
+ return cantineMenu;
+ }
+
+ /**
+ * Returns all the cantine menus where cantineDatePlanAlimentaireId = ? and typeRecette = ?.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param typeRecette the type recette
+ * @return the matching cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public List<CantineMenu> findBycantineDatePlanAlimentaireId_typeRecette(
+ long cantineDatePlanAlimentaireId, String typeRecette)
+ throws SystemException {
+ return findBycantineDatePlanAlimentaireId_typeRecette(cantineDatePlanAlimentaireId,
+ typeRecette, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
+ }
+
+ /**
+ * Returns a range of all the cantine menus where cantineDatePlanAlimentaireId = ? and typeRecette = ?.
+ *
+ * <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 cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param typeRecette the type recette
+ * @param start the lower bound of the range of cantine menus
+ * @param end the upper bound of the range of cantine menus (not inclusive)
+ * @return the range of matching cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public List<CantineMenu> findBycantineDatePlanAlimentaireId_typeRecette(
+ long cantineDatePlanAlimentaireId, String typeRecette, int start,
+ int end) throws SystemException {
+ return findBycantineDatePlanAlimentaireId_typeRecette(cantineDatePlanAlimentaireId,
+ typeRecette, start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the cantine menus where cantineDatePlanAlimentaireId = ? and typeRecette = ?.
+ *
+ * <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 cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param typeRecette the type recette
+ * @param start the lower bound of the range of cantine menus
+ * @param end the upper bound of the range of cantine menus (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of matching cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public List<CantineMenu> findBycantineDatePlanAlimentaireId_typeRecette(
+ long cantineDatePlanAlimentaireId, String typeRecette, 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_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE;
+ finderArgs = new Object[] { cantineDatePlanAlimentaireId, typeRecette };
+ }
+ else {
+ finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE;
+ finderArgs = new Object[] {
+ cantineDatePlanAlimentaireId, typeRecette,
+
+ start, end, orderByComparator
+ };
+ }
+
+ List<CantineMenu> list = (List<CantineMenu>)FinderCacheUtil.getResult(finderPath,
+ finderArgs, this);
+
+ if ((list != null) && !list.isEmpty()) {
+ for (CantineMenu cantineMenu : list) {
+ if ((cantineDatePlanAlimentaireId != cantineMenu.getCantineDatePlanAlimentaireId()) ||
+ !Validator.equals(typeRecette,
+ cantineMenu.getTypeRecette())) {
+ 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_CANTINEMENU_WHERE);
+
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_CANTINEDATEPLANALIMENTAIREID_2);
+
+ if (typeRecette == null) {
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_TYPERECETTE_1);
+ }
+ else {
+ if (typeRecette.equals(StringPool.BLANK)) {
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_TYPERECETTE_3);
+ }
+ else {
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_TYPERECETTE_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(cantineDatePlanAlimentaireId);
+
+ if (typeRecette != null) {
+ qPos.add(typeRecette);
+ }
+
+ list = (List<CantineMenu>)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 cantine menu in the ordered set where cantineDatePlanAlimentaireId = ? and typeRecette = ?.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param typeRecette the type recette
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching cantine menu
+ * @throws com.pentila.entSavoie.cantine.NoSuchCantineMenuException if a matching cantine menu could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu findBycantineDatePlanAlimentaireId_typeRecette_First(
+ long cantineDatePlanAlimentaireId, String typeRecette,
+ OrderByComparator orderByComparator)
+ throws NoSuchCantineMenuException, SystemException {
+ CantineMenu cantineMenu = fetchBycantineDatePlanAlimentaireId_typeRecette_First(cantineDatePlanAlimentaireId,
+ typeRecette, orderByComparator);
+
+ if (cantineMenu != null) {
+ return cantineMenu;
+ }
+
+ StringBundler msg = new StringBundler(6);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("cantineDatePlanAlimentaireId=");
+ msg.append(cantineDatePlanAlimentaireId);
+
+ msg.append(", typeRecette=");
+ msg.append(typeRecette);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchCantineMenuException(msg.toString());
+ }
+
+ /**
+ * Returns the first cantine menu in the ordered set where cantineDatePlanAlimentaireId = ? and typeRecette = ?.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param typeRecette the type recette
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching cantine menu, or <code>null</code> if a matching cantine menu could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu fetchBycantineDatePlanAlimentaireId_typeRecette_First(
+ long cantineDatePlanAlimentaireId, String typeRecette,
+ OrderByComparator orderByComparator) throws SystemException {
+ List<CantineMenu> list = findBycantineDatePlanAlimentaireId_typeRecette(cantineDatePlanAlimentaireId,
+ typeRecette, 0, 1, orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the last cantine menu in the ordered set where cantineDatePlanAlimentaireId = ? and typeRecette = ?.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param typeRecette the type recette
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching cantine menu
+ * @throws com.pentila.entSavoie.cantine.NoSuchCantineMenuException if a matching cantine menu could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu findBycantineDatePlanAlimentaireId_typeRecette_Last(
+ long cantineDatePlanAlimentaireId, String typeRecette,
+ OrderByComparator orderByComparator)
+ throws NoSuchCantineMenuException, SystemException {
+ CantineMenu cantineMenu = fetchBycantineDatePlanAlimentaireId_typeRecette_Last(cantineDatePlanAlimentaireId,
+ typeRecette, orderByComparator);
+
+ if (cantineMenu != null) {
+ return cantineMenu;
+ }
+
+ StringBundler msg = new StringBundler(6);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("cantineDatePlanAlimentaireId=");
+ msg.append(cantineDatePlanAlimentaireId);
+
+ msg.append(", typeRecette=");
+ msg.append(typeRecette);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchCantineMenuException(msg.toString());
+ }
+
+ /**
+ * Returns the last cantine menu in the ordered set where cantineDatePlanAlimentaireId = ? and typeRecette = ?.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param typeRecette the type recette
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching cantine menu, or <code>null</code> if a matching cantine menu could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu fetchBycantineDatePlanAlimentaireId_typeRecette_Last(
+ long cantineDatePlanAlimentaireId, String typeRecette,
+ OrderByComparator orderByComparator) throws SystemException {
+ int count = countBycantineDatePlanAlimentaireId_typeRecette(cantineDatePlanAlimentaireId,
+ typeRecette);
+
+ List<CantineMenu> list = findBycantineDatePlanAlimentaireId_typeRecette(cantineDatePlanAlimentaireId,
+ typeRecette, count - 1, count, orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the cantine menus before and after the current cantine menu in the ordered set where cantineDatePlanAlimentaireId = ? and typeRecette = ?.
+ *
+ * @param cantineMenuId the primary key of the current cantine menu
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param typeRecette the type recette
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the previous, current, and next cantine menu
+ * @throws com.pentila.entSavoie.cantine.NoSuchCantineMenuException if a cantine menu with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu[] findBycantineDatePlanAlimentaireId_typeRecette_PrevAndNext(
+ long cantineMenuId, long cantineDatePlanAlimentaireId,
+ String typeRecette, OrderByComparator orderByComparator)
+ throws NoSuchCantineMenuException, SystemException {
+ CantineMenu cantineMenu = findByPrimaryKey(cantineMenuId);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ CantineMenu[] array = new CantineMenuImpl[3];
+
+ array[0] = getBycantineDatePlanAlimentaireId_typeRecette_PrevAndNext(session,
+ cantineMenu, cantineDatePlanAlimentaireId, typeRecette,
+ orderByComparator, true);
+
+ array[1] = cantineMenu;
+
+ array[2] = getBycantineDatePlanAlimentaireId_typeRecette_PrevAndNext(session,
+ cantineMenu, cantineDatePlanAlimentaireId, typeRecette,
+ orderByComparator, false);
+
+ return array;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ protected CantineMenu getBycantineDatePlanAlimentaireId_typeRecette_PrevAndNext(
+ Session session, CantineMenu cantineMenu,
+ long cantineDatePlanAlimentaireId, String typeRecette,
+ 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_CANTINEMENU_WHERE);
+
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_CANTINEDATEPLANALIMENTAIREID_2);
+
+ if (typeRecette == null) {
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_TYPERECETTE_1);
+ }
+ else {
+ if (typeRecette.equals(StringPool.BLANK)) {
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_TYPERECETTE_3);
+ }
+ else {
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_TYPERECETTE_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(cantineDatePlanAlimentaireId);
+
+ if (typeRecette != null) {
+ qPos.add(typeRecette);
+ }
+
+ if (orderByComparator != null) {
+ Object[] values = orderByComparator.getOrderByConditionValues(cantineMenu);
+
+ for (Object value : values) {
+ qPos.add(value);
+ }
+ }
+
+ List<CantineMenu> list = q.list();
+
+ if (list.size() == 2) {
+ return list.get(1);
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns all the cantine menus where recetteId = ?.
+ *
+ * @param recetteId the recette ID
+ * @return the matching cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public List<CantineMenu> findByrecetteId(long recetteId)
+ throws SystemException {
+ return findByrecetteId(recetteId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
+ null);
+ }
+
+ /**
+ * Returns a range of all the cantine menus where recetteId = ?.
+ *
+ * <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 recetteId the recette ID
+ * @param start the lower bound of the range of cantine menus
+ * @param end the upper bound of the range of cantine menus (not inclusive)
+ * @return the range of matching cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public List<CantineMenu> findByrecetteId(long recetteId, int start, int end)
+ throws SystemException {
+ return findByrecetteId(recetteId, start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the cantine menus where recetteId = ?.
+ *
+ * <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 recetteId the recette ID
+ * @param start the lower bound of the range of cantine menus
+ * @param end the upper bound of the range of cantine menus (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of matching cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public List<CantineMenu> findByrecetteId(long recetteId, 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_RECETTEID;
+ finderArgs = new Object[] { recetteId };
+ }
+ else {
+ finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RECETTEID;
+ finderArgs = new Object[] { recetteId, start, end, orderByComparator };
+ }
+
+ List<CantineMenu> list = (List<CantineMenu>)FinderCacheUtil.getResult(finderPath,
+ finderArgs, this);
+
+ if ((list != null) && !list.isEmpty()) {
+ for (CantineMenu cantineMenu : list) {
+ if ((recetteId != cantineMenu.getRecetteId())) {
+ 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_CANTINEMENU_WHERE);
+
+ query.append(_FINDER_COLUMN_RECETTEID_RECETTEID_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(recetteId);
+
+ list = (List<CantineMenu>)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 cantine menu in the ordered set where recetteId = ?.
+ *
+ * @param recetteId the recette ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching cantine menu
+ * @throws com.pentila.entSavoie.cantine.NoSuchCantineMenuException if a matching cantine menu could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu findByrecetteId_First(long recetteId,
+ OrderByComparator orderByComparator)
+ throws NoSuchCantineMenuException, SystemException {
+ CantineMenu cantineMenu = fetchByrecetteId_First(recetteId,
+ orderByComparator);
+
+ if (cantineMenu != null) {
+ return cantineMenu;
+ }
+
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("recetteId=");
+ msg.append(recetteId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchCantineMenuException(msg.toString());
+ }
+
+ /**
+ * Returns the first cantine menu in the ordered set where recetteId = ?.
+ *
+ * @param recetteId the recette ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching cantine menu, or <code>null</code> if a matching cantine menu could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu fetchByrecetteId_First(long recetteId,
+ OrderByComparator orderByComparator) throws SystemException {
+ List<CantineMenu> list = findByrecetteId(recetteId, 0, 1,
+ orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the last cantine menu in the ordered set where recetteId = ?.
+ *
+ * @param recetteId the recette ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching cantine menu
+ * @throws com.pentila.entSavoie.cantine.NoSuchCantineMenuException if a matching cantine menu could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu findByrecetteId_Last(long recetteId,
+ OrderByComparator orderByComparator)
+ throws NoSuchCantineMenuException, SystemException {
+ CantineMenu cantineMenu = fetchByrecetteId_Last(recetteId,
+ orderByComparator);
+
+ if (cantineMenu != null) {
+ return cantineMenu;
+ }
+
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("recetteId=");
+ msg.append(recetteId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchCantineMenuException(msg.toString());
+ }
+
+ /**
+ * Returns the last cantine menu in the ordered set where recetteId = ?.
+ *
+ * @param recetteId the recette ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching cantine menu, or <code>null</code> if a matching cantine menu could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu fetchByrecetteId_Last(long recetteId,
+ OrderByComparator orderByComparator) throws SystemException {
+ int count = countByrecetteId(recetteId);
+
+ List<CantineMenu> list = findByrecetteId(recetteId, count - 1, count,
+ orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the cantine menus before and after the current cantine menu in the ordered set where recetteId = ?.
+ *
+ * @param cantineMenuId the primary key of the current cantine menu
+ * @param recetteId the recette ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the previous, current, and next cantine menu
+ * @throws com.pentila.entSavoie.cantine.NoSuchCantineMenuException if a cantine menu with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu[] findByrecetteId_PrevAndNext(long cantineMenuId,
+ long recetteId, OrderByComparator orderByComparator)
+ throws NoSuchCantineMenuException, SystemException {
+ CantineMenu cantineMenu = findByPrimaryKey(cantineMenuId);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ CantineMenu[] array = new CantineMenuImpl[3];
+
+ array[0] = getByrecetteId_PrevAndNext(session, cantineMenu,
+ recetteId, orderByComparator, true);
+
+ array[1] = cantineMenu;
+
+ array[2] = getByrecetteId_PrevAndNext(session, cantineMenu,
+ recetteId, orderByComparator, false);
+
+ return array;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ protected CantineMenu getByrecetteId_PrevAndNext(Session session,
+ CantineMenu cantineMenu, long recetteId,
+ 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_CANTINEMENU_WHERE);
+
+ query.append(_FINDER_COLUMN_RECETTEID_RECETTEID_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(recetteId);
+
+ if (orderByComparator != null) {
+ Object[] values = orderByComparator.getOrderByConditionValues(cantineMenu);
+
+ for (Object value : values) {
+ qPos.add(value);
+ }
+ }
+
+ List<CantineMenu> list = q.list();
+
+ if (list.size() == 2) {
+ return list.get(1);
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns all the cantine menus where cantineDatePlanAlimentaireId = ?.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @return the matching cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public List<CantineMenu> findBycantineDatePlanAlimentaireId(
+ long cantineDatePlanAlimentaireId) throws SystemException {
+ return findBycantineDatePlanAlimentaireId(cantineDatePlanAlimentaireId,
+ QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
+ }
+
+ /**
+ * Returns a range of all the cantine menus where cantineDatePlanAlimentaireId = ?.
+ *
+ * <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 cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param start the lower bound of the range of cantine menus
+ * @param end the upper bound of the range of cantine menus (not inclusive)
+ * @return the range of matching cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public List<CantineMenu> findBycantineDatePlanAlimentaireId(
+ long cantineDatePlanAlimentaireId, int start, int end)
+ throws SystemException {
+ return findBycantineDatePlanAlimentaireId(cantineDatePlanAlimentaireId,
+ start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the cantine menus where cantineDatePlanAlimentaireId = ?.
+ *
+ * <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 cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param start the lower bound of the range of cantine menus
+ * @param end the upper bound of the range of cantine menus (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of matching cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public List<CantineMenu> findBycantineDatePlanAlimentaireId(
+ long cantineDatePlanAlimentaireId, 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_CANTINEDATEPLANALIMENTAIREID;
+ finderArgs = new Object[] { cantineDatePlanAlimentaireId };
+ }
+ else {
+ finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CANTINEDATEPLANALIMENTAIREID;
+ finderArgs = new Object[] {
+ cantineDatePlanAlimentaireId,
+
+ start, end, orderByComparator
+ };
+ }
+
+ List<CantineMenu> list = (List<CantineMenu>)FinderCacheUtil.getResult(finderPath,
+ finderArgs, this);
+
+ if ((list != null) && !list.isEmpty()) {
+ for (CantineMenu cantineMenu : list) {
+ if ((cantineDatePlanAlimentaireId != cantineMenu.getCantineDatePlanAlimentaireId())) {
+ 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_CANTINEMENU_WHERE);
+
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_CANTINEDATEPLANALIMENTAIREID_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(cantineDatePlanAlimentaireId);
+
+ list = (List<CantineMenu>)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 cantine menu in the ordered set where cantineDatePlanAlimentaireId = ?.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching cantine menu
+ * @throws com.pentila.entSavoie.cantine.NoSuchCantineMenuException if a matching cantine menu could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu findBycantineDatePlanAlimentaireId_First(
+ long cantineDatePlanAlimentaireId, OrderByComparator orderByComparator)
+ throws NoSuchCantineMenuException, SystemException {
+ CantineMenu cantineMenu = fetchBycantineDatePlanAlimentaireId_First(cantineDatePlanAlimentaireId,
+ orderByComparator);
+
+ if (cantineMenu != null) {
+ return cantineMenu;
+ }
+
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("cantineDatePlanAlimentaireId=");
+ msg.append(cantineDatePlanAlimentaireId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchCantineMenuException(msg.toString());
+ }
+
+ /**
+ * Returns the first cantine menu in the ordered set where cantineDatePlanAlimentaireId = ?.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching cantine menu, or <code>null</code> if a matching cantine menu could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu fetchBycantineDatePlanAlimentaireId_First(
+ long cantineDatePlanAlimentaireId, OrderByComparator orderByComparator)
+ throws SystemException {
+ List<CantineMenu> list = findBycantineDatePlanAlimentaireId(cantineDatePlanAlimentaireId,
+ 0, 1, orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the last cantine menu in the ordered set where cantineDatePlanAlimentaireId = ?.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching cantine menu
+ * @throws com.pentila.entSavoie.cantine.NoSuchCantineMenuException if a matching cantine menu could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu findBycantineDatePlanAlimentaireId_Last(
+ long cantineDatePlanAlimentaireId, OrderByComparator orderByComparator)
+ throws NoSuchCantineMenuException, SystemException {
+ CantineMenu cantineMenu = fetchBycantineDatePlanAlimentaireId_Last(cantineDatePlanAlimentaireId,
+ orderByComparator);
+
+ if (cantineMenu != null) {
+ return cantineMenu;
+ }
+
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("cantineDatePlanAlimentaireId=");
+ msg.append(cantineDatePlanAlimentaireId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchCantineMenuException(msg.toString());
+ }
+
+ /**
+ * Returns the last cantine menu in the ordered set where cantineDatePlanAlimentaireId = ?.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching cantine menu, or <code>null</code> if a matching cantine menu could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu fetchBycantineDatePlanAlimentaireId_Last(
+ long cantineDatePlanAlimentaireId, OrderByComparator orderByComparator)
+ throws SystemException {
+ int count = countBycantineDatePlanAlimentaireId(cantineDatePlanAlimentaireId);
+
+ List<CantineMenu> list = findBycantineDatePlanAlimentaireId(cantineDatePlanAlimentaireId,
+ count - 1, count, orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the cantine menus before and after the current cantine menu in the ordered set where cantineDatePlanAlimentaireId = ?.
+ *
+ * @param cantineMenuId the primary key of the current cantine menu
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the previous, current, and next cantine menu
+ * @throws com.pentila.entSavoie.cantine.NoSuchCantineMenuException if a cantine menu with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public CantineMenu[] findBycantineDatePlanAlimentaireId_PrevAndNext(
+ long cantineMenuId, long cantineDatePlanAlimentaireId,
+ OrderByComparator orderByComparator)
+ throws NoSuchCantineMenuException, SystemException {
+ CantineMenu cantineMenu = findByPrimaryKey(cantineMenuId);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ CantineMenu[] array = new CantineMenuImpl[3];
+
+ array[0] = getBycantineDatePlanAlimentaireId_PrevAndNext(session,
+ cantineMenu, cantineDatePlanAlimentaireId,
+ orderByComparator, true);
+
+ array[1] = cantineMenu;
+
+ array[2] = getBycantineDatePlanAlimentaireId_PrevAndNext(session,
+ cantineMenu, cantineDatePlanAlimentaireId,
+ orderByComparator, false);
+
+ return array;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ protected CantineMenu getBycantineDatePlanAlimentaireId_PrevAndNext(
+ Session session, CantineMenu cantineMenu,
+ long cantineDatePlanAlimentaireId, 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_CANTINEMENU_WHERE);
+
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_CANTINEDATEPLANALIMENTAIREID_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(cantineDatePlanAlimentaireId);
+
+ if (orderByComparator != null) {
+ Object[] values = orderByComparator.getOrderByConditionValues(cantineMenu);
+
+ for (Object value : values) {
+ qPos.add(value);
+ }
+ }
+
+ List<CantineMenu> list = q.list();
+
+ if (list.size() == 2) {
+ return list.get(1);
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns all the cantine menus.
+ *
+ * @return the cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public List<CantineMenu> findAll() throws SystemException {
+ return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
+ }
+
+ /**
+ * Returns a range of all the cantine menus.
+ *
+ * <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 cantine menus
+ * @param end the upper bound of the range of cantine menus (not inclusive)
+ * @return the range of cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public List<CantineMenu> findAll(int start, int end)
+ throws SystemException {
+ return findAll(start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the cantine menus.
+ *
+ * <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 cantine menus
+ * @param end the upper bound of the range of cantine menus (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public List<CantineMenu> 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<CantineMenu> list = (List<CantineMenu>)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_CANTINEMENU);
+
+ appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
+ orderByComparator);
+
+ sql = query.toString();
+ }
+ else {
+ sql = _SQL_SELECT_CANTINEMENU;
+ }
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ if (orderByComparator == null) {
+ list = (List<CantineMenu>)QueryUtil.list(q, getDialect(),
+ start, end, false);
+
+ Collections.sort(list);
+ }
+ else {
+ list = (List<CantineMenu>)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 cantine menus where cantineDatePlanAlimentaireId = ? and typeRecette = ? from the database.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param typeRecette the type recette
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeBycantineDatePlanAlimentaireId_typeRecette(
+ long cantineDatePlanAlimentaireId, String typeRecette)
+ throws SystemException {
+ for (CantineMenu cantineMenu : findBycantineDatePlanAlimentaireId_typeRecette(
+ cantineDatePlanAlimentaireId, typeRecette)) {
+ remove(cantineMenu);
+ }
+ }
+
+ /**
+ * Removes all the cantine menus where recetteId = ? from the database.
+ *
+ * @param recetteId the recette ID
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeByrecetteId(long recetteId) throws SystemException {
+ for (CantineMenu cantineMenu : findByrecetteId(recetteId)) {
+ remove(cantineMenu);
+ }
+ }
+
+ /**
+ * Removes all the cantine menus where cantineDatePlanAlimentaireId = ? from the database.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeBycantineDatePlanAlimentaireId(
+ long cantineDatePlanAlimentaireId) throws SystemException {
+ for (CantineMenu cantineMenu : findBycantineDatePlanAlimentaireId(
+ cantineDatePlanAlimentaireId)) {
+ remove(cantineMenu);
+ }
+ }
+
+ /**
+ * Removes all the cantine menus from the database.
+ *
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeAll() throws SystemException {
+ for (CantineMenu cantineMenu : findAll()) {
+ remove(cantineMenu);
+ }
+ }
+
+ /**
+ * Returns the number of cantine menus where cantineDatePlanAlimentaireId = ? and typeRecette = ?.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @param typeRecette the type recette
+ * @return the number of matching cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public int countBycantineDatePlanAlimentaireId_typeRecette(
+ long cantineDatePlanAlimentaireId, String typeRecette)
+ throws SystemException {
+ Object[] finderArgs = new Object[] {
+ cantineDatePlanAlimentaireId, typeRecette
+ };
+
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE,
+ finderArgs, this);
+
+ if (count == null) {
+ StringBundler query = new StringBundler(3);
+
+ query.append(_SQL_COUNT_CANTINEMENU_WHERE);
+
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_CANTINEDATEPLANALIMENTAIREID_2);
+
+ if (typeRecette == null) {
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_TYPERECETTE_1);
+ }
+ else {
+ if (typeRecette.equals(StringPool.BLANK)) {
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_TYPERECETTE_3);
+ }
+ else {
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_TYPERECETTE_2);
+ }
+ }
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(cantineDatePlanAlimentaireId);
+
+ if (typeRecette != null) {
+ qPos.add(typeRecette);
+ }
+
+ count = (Long)q.uniqueResult();
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (count == null) {
+ count = Long.valueOf(0);
+ }
+
+ FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE,
+ finderArgs, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Returns the number of cantine menus where recetteId = ?.
+ *
+ * @param recetteId the recette ID
+ * @return the number of matching cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public int countByrecetteId(long recetteId) throws SystemException {
+ Object[] finderArgs = new Object[] { recetteId };
+
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RECETTEID,
+ finderArgs, this);
+
+ if (count == null) {
+ StringBundler query = new StringBundler(2);
+
+ query.append(_SQL_COUNT_CANTINEMENU_WHERE);
+
+ query.append(_FINDER_COLUMN_RECETTEID_RECETTEID_2);
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(recetteId);
+
+ count = (Long)q.uniqueResult();
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (count == null) {
+ count = Long.valueOf(0);
+ }
+
+ FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RECETTEID,
+ finderArgs, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Returns the number of cantine menus where cantineDatePlanAlimentaireId = ?.
+ *
+ * @param cantineDatePlanAlimentaireId the cantine date plan alimentaire ID
+ * @return the number of matching cantine menus
+ * @throws SystemException if a system exception occurred
+ */
+ public int countBycantineDatePlanAlimentaireId(
+ long cantineDatePlanAlimentaireId) throws SystemException {
+ Object[] finderArgs = new Object[] { cantineDatePlanAlimentaireId };
+
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CANTINEDATEPLANALIMENTAIREID,
+ finderArgs, this);
+
+ if (count == null) {
+ StringBundler query = new StringBundler(2);
+
+ query.append(_SQL_COUNT_CANTINEMENU_WHERE);
+
+ query.append(_FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_CANTINEDATEPLANALIMENTAIREID_2);
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(cantineDatePlanAlimentaireId);
+
+ count = (Long)q.uniqueResult();
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (count == null) {
+ count = Long.valueOf(0);
+ }
+
+ FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CANTINEDATEPLANALIMENTAIREID,
+ finderArgs, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Returns the number of cantine menus.
+ *
+ * @return the number of cantine menus
+ * @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_CANTINEMENU);
+
+ 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 cantine menu persistence.
+ */
+ public void afterPropertiesSet() {
+ String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
+ com.liferay.util.service.ServiceProps.get(
+ "value.object.listener.com.pentila.entSavoie.cantine.model.CantineMenu")));
+
+ if (listenerClassNames.length > 0) {
+ try {
+ List<ModelListener<CantineMenu>> listenersList = new ArrayList<ModelListener<CantineMenu>>();
+
+ for (String listenerClassName : listenerClassNames) {
+ listenersList.add((ModelListener<CantineMenu>)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(CantineMenuImpl.class.getName());
+ FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
+ FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ @BeanReference(type = CantineAlimentPersistence.class)
+ protected CantineAlimentPersistence cantineAlimentPersistence;
+ @BeanReference(type = CantineCategorieRecettePersistence.class)
+ protected CantineCategorieRecettePersistence cantineCategorieRecettePersistence;
+ @BeanReference(type = CantineCollegeConfigurationPersistence.class)
+ protected CantineCollegeConfigurationPersistence cantineCollegeConfigurationPersistence;
+ @BeanReference(type = CantineDatePlanAlimentairePersistence.class)
+ protected CantineDatePlanAlimentairePersistence cantineDatePlanAlimentairePersistence;
+ @BeanReference(type = CantineFamilleAlimentPersistence.class)
+ protected CantineFamilleAlimentPersistence cantineFamilleAlimentPersistence;
+ @BeanReference(type = CantineGEMRCNPersistence.class)
+ protected CantineGEMRCNPersistence cantineGEMRCNPersistence;
+ @BeanReference(type = CantineGEMRCNTypeRecettePersistence.class)
+ protected CantineGEMRCNTypeRecettePersistence cantineGEMRCNTypeRecettePersistence;
+ @BeanReference(type = CantineIngredientPersistence.class)
+ protected CantineIngredientPersistence cantineIngredientPersistence;
+ @BeanReference(type = CantineMenuPersistence.class)
+ protected CantineMenuPersistence cantineMenuPersistence;
+ @BeanReference(type = CantinePlanAlimentairePersistence.class)
+ protected CantinePlanAlimentairePersistence cantinePlanAlimentairePersistence;
+ @BeanReference(type = CantinePlanAlimentaireConfigurationPersistence.class)
+ protected CantinePlanAlimentaireConfigurationPersistence cantinePlanAlimentaireConfigurationPersistence;
+ @BeanReference(type = CantineRecettePersistence.class)
+ protected CantineRecettePersistence cantineRecettePersistence;
+ @BeanReference(type = CantineRecetteGEMRCNPersistence.class)
+ protected CantineRecetteGEMRCNPersistence cantineRecetteGEMRCNPersistence;
+ @BeanReference(type = ResourcePersistence.class)
+ protected ResourcePersistence resourcePersistence;
+ @BeanReference(type = UserPersistence.class)
+ protected UserPersistence userPersistence;
+ private static final String _SQL_SELECT_CANTINEMENU = "SELECT cantineMenu FROM CantineMenu cantineMenu";
+ private static final String _SQL_SELECT_CANTINEMENU_WHERE = "SELECT cantineMenu FROM CantineMenu cantineMenu WHERE ";
+ private static final String _SQL_COUNT_CANTINEMENU = "SELECT COUNT(cantineMenu) FROM CantineMenu cantineMenu";
+ private static final String _SQL_COUNT_CANTINEMENU_WHERE = "SELECT COUNT(cantineMenu) FROM CantineMenu cantineMenu WHERE ";
+ private static final String _FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_CANTINEDATEPLANALIMENTAIREID_2 =
+ "cantineMenu.cantineDatePlanAlimentaireId = ? AND ";
+ private static final String _FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_TYPERECETTE_1 =
+ "cantineMenu.typeRecette IS NULL";
+ private static final String _FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_TYPERECETTE_2 =
+ "cantineMenu.typeRecette = ?";
+ private static final String _FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_TYPERECETTE_TYPERECETTE_3 =
+ "(cantineMenu.typeRecette IS NULL OR cantineMenu.typeRecette = ?)";
+ private static final String _FINDER_COLUMN_RECETTEID_RECETTEID_2 = "cantineMenu.recetteId = ?";
+ private static final String _FINDER_COLUMN_CANTINEDATEPLANALIMENTAIREID_CANTINEDATEPLANALIMENTAIREID_2 =
+ "cantineMenu.cantineDatePlanAlimentaireId = ?";
+ private static final String _ORDER_BY_ENTITY_ALIAS = "cantineMenu.";
+ private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No CantineMenu exists with the primary key ";
+ private static final String _NO_SUCH_ENTITY_WITH_KEY = "No CantineMenu 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(CantineMenuPersistenceImpl.class);
+ private static CantineMenu _nullCantineMenu = new CantineMenuImpl() {
+ @Override
+ public Object clone() {
+ return this;
+ }
+
+ @Override
+ public CacheModel<CantineMenu> toCacheModel() {
+ return _nullCantineMenuCacheModel;
+ }
+ };
+
+ private static CacheModel<CantineMenu> _nullCantineMenuCacheModel = new CacheModel<CantineMenu>() {
+ public CantineMenu toEntityModel() {
+ return _nullCantineMenu;
+ }
+ };
+}
\ No newline at end of file