--- /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.gestionMenus.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.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.gestionMenus.NoSuchMenuIconMappingException;
+import com.pentila.entSavoie.gestionMenus.model.MenuIconMapping;
+import com.pentila.entSavoie.gestionMenus.model.impl.MenuIconMappingImpl;
+import com.pentila.entSavoie.gestionMenus.model.impl.MenuIconMappingModelImpl;
+
+import java.io.Serializable;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * The persistence implementation for the menu icon mapping service.
+ *
+ * <p>
+ * Caching information and settings can be found in <code>portal.properties</code>
+ * </p>
+ *
+ * @author DIMIER Cedric et TARDY Camille
+ * @see MenuIconMappingPersistence
+ * @see MenuIconMappingUtil
+ * @generated
+ */
+public class MenuIconMappingPersistenceImpl extends BasePersistenceImpl<MenuIconMapping>
+ implements MenuIconMappingPersistence {
+ /*
+ * NOTE FOR DEVELOPERS:
+ *
+ * Never modify or reference this class directly. Always use {@link MenuIconMappingUtil} to access the menu icon mapping persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
+ */
+ public static final String FINDER_CLASS_NAME_ENTITY = MenuIconMappingImpl.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_FETCH_BY_APPROLEID = new FinderPath(MenuIconMappingModelImpl.ENTITY_CACHE_ENABLED,
+ MenuIconMappingModelImpl.FINDER_CACHE_ENABLED,
+ MenuIconMappingImpl.class, FINDER_CLASS_NAME_ENTITY,
+ "fetchByappRoleId", new String[] { Long.class.getName() },
+ MenuIconMappingModelImpl.APPROLEID_COLUMN_BITMASK);
+ public static final FinderPath FINDER_PATH_COUNT_BY_APPROLEID = new FinderPath(MenuIconMappingModelImpl.ENTITY_CACHE_ENABLED,
+ MenuIconMappingModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByappRoleId",
+ new String[] { Long.class.getName() });
+ public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MenuIconMappingModelImpl.ENTITY_CACHE_ENABLED,
+ MenuIconMappingModelImpl.FINDER_CACHE_ENABLED,
+ MenuIconMappingImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
+ "findAll", new String[0]);
+ public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MenuIconMappingModelImpl.ENTITY_CACHE_ENABLED,
+ MenuIconMappingModelImpl.FINDER_CACHE_ENABLED,
+ MenuIconMappingImpl.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
+ public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MenuIconMappingModelImpl.ENTITY_CACHE_ENABLED,
+ MenuIconMappingModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
+
+ /**
+ * Caches the menu icon mapping in the entity cache if it is enabled.
+ *
+ * @param menuIconMapping the menu icon mapping
+ */
+ public void cacheResult(MenuIconMapping menuIconMapping) {
+ EntityCacheUtil.putResult(MenuIconMappingModelImpl.ENTITY_CACHE_ENABLED,
+ MenuIconMappingImpl.class, menuIconMapping.getPrimaryKey(),
+ menuIconMapping);
+
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_APPROLEID,
+ new Object[] { Long.valueOf(menuIconMapping.getAppRoleId()) },
+ menuIconMapping);
+
+ menuIconMapping.resetOriginalValues();
+ }
+
+ /**
+ * Caches the menu icon mappings in the entity cache if it is enabled.
+ *
+ * @param menuIconMappings the menu icon mappings
+ */
+ public void cacheResult(List<MenuIconMapping> menuIconMappings) {
+ for (MenuIconMapping menuIconMapping : menuIconMappings) {
+ if (EntityCacheUtil.getResult(
+ MenuIconMappingModelImpl.ENTITY_CACHE_ENABLED,
+ MenuIconMappingImpl.class,
+ menuIconMapping.getPrimaryKey()) == null) {
+ cacheResult(menuIconMapping);
+ }
+ else {
+ menuIconMapping.resetOriginalValues();
+ }
+ }
+ }
+
+ /**
+ * Clears the cache for all menu icon mappings.
+ *
+ * <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(MenuIconMappingImpl.class.getName());
+ }
+
+ EntityCacheUtil.clearCache(MenuIconMappingImpl.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 menu icon mapping.
+ *
+ * <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(MenuIconMapping menuIconMapping) {
+ EntityCacheUtil.removeResult(MenuIconMappingModelImpl.ENTITY_CACHE_ENABLED,
+ MenuIconMappingImpl.class, menuIconMapping.getPrimaryKey());
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+
+ clearUniqueFindersCache(menuIconMapping);
+ }
+
+ @Override
+ public void clearCache(List<MenuIconMapping> menuIconMappings) {
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+
+ for (MenuIconMapping menuIconMapping : menuIconMappings) {
+ EntityCacheUtil.removeResult(MenuIconMappingModelImpl.ENTITY_CACHE_ENABLED,
+ MenuIconMappingImpl.class, menuIconMapping.getPrimaryKey());
+
+ clearUniqueFindersCache(menuIconMapping);
+ }
+ }
+
+ protected void clearUniqueFindersCache(MenuIconMapping menuIconMapping) {
+ FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_APPROLEID,
+ new Object[] { Long.valueOf(menuIconMapping.getAppRoleId()) });
+ }
+
+ /**
+ * Creates a new menu icon mapping with the primary key. Does not add the menu icon mapping to the database.
+ *
+ * @param appRoleId the primary key for the new menu icon mapping
+ * @return the new menu icon mapping
+ */
+ public MenuIconMapping create(long appRoleId) {
+ MenuIconMapping menuIconMapping = new MenuIconMappingImpl();
+
+ menuIconMapping.setNew(true);
+ menuIconMapping.setPrimaryKey(appRoleId);
+
+ return menuIconMapping;
+ }
+
+ /**
+ * Removes the menu icon mapping with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param appRoleId the primary key of the menu icon mapping
+ * @return the menu icon mapping that was removed
+ * @throws com.pentila.entSavoie.gestionMenus.NoSuchMenuIconMappingException if a menu icon mapping with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public MenuIconMapping remove(long appRoleId)
+ throws NoSuchMenuIconMappingException, SystemException {
+ return remove(Long.valueOf(appRoleId));
+ }
+
+ /**
+ * Removes the menu icon mapping with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param primaryKey the primary key of the menu icon mapping
+ * @return the menu icon mapping that was removed
+ * @throws com.pentila.entSavoie.gestionMenus.NoSuchMenuIconMappingException if a menu icon mapping with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public MenuIconMapping remove(Serializable primaryKey)
+ throws NoSuchMenuIconMappingException, SystemException {
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ MenuIconMapping menuIconMapping = (MenuIconMapping)session.get(MenuIconMappingImpl.class,
+ primaryKey);
+
+ if (menuIconMapping == null) {
+ if (_log.isWarnEnabled()) {
+ _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
+ }
+
+ throw new NoSuchMenuIconMappingException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ primaryKey);
+ }
+
+ return remove(menuIconMapping);
+ }
+ catch (NoSuchMenuIconMappingException nsee) {
+ throw nsee;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ @Override
+ protected MenuIconMapping removeImpl(MenuIconMapping menuIconMapping)
+ throws SystemException {
+ menuIconMapping = toUnwrappedModel(menuIconMapping);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ BatchSessionUtil.delete(session, menuIconMapping);
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+
+ clearCache(menuIconMapping);
+
+ return menuIconMapping;
+ }
+
+ @Override
+ public MenuIconMapping updateImpl(
+ com.pentila.entSavoie.gestionMenus.model.MenuIconMapping menuIconMapping,
+ boolean merge) throws SystemException {
+ menuIconMapping = toUnwrappedModel(menuIconMapping);
+
+ boolean isNew = menuIconMapping.isNew();
+
+ MenuIconMappingModelImpl menuIconMappingModelImpl = (MenuIconMappingModelImpl)menuIconMapping;
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ BatchSessionUtil.update(session, menuIconMapping, merge);
+
+ menuIconMapping.setNew(false);
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+
+ if (isNew || !MenuIconMappingModelImpl.COLUMN_BITMASK_ENABLED) {
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ EntityCacheUtil.putResult(MenuIconMappingModelImpl.ENTITY_CACHE_ENABLED,
+ MenuIconMappingImpl.class, menuIconMapping.getPrimaryKey(),
+ menuIconMapping);
+
+ if (isNew) {
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_APPROLEID,
+ new Object[] { Long.valueOf(menuIconMapping.getAppRoleId()) },
+ menuIconMapping);
+ }
+ else {
+ if ((menuIconMappingModelImpl.getColumnBitmask() &
+ FINDER_PATH_FETCH_BY_APPROLEID.getColumnBitmask()) != 0) {
+ Object[] args = new Object[] {
+ Long.valueOf(menuIconMappingModelImpl.getOriginalAppRoleId())
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_APPROLEID,
+ args);
+
+ FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_APPROLEID,
+ args);
+
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_APPROLEID,
+ new Object[] { Long.valueOf(menuIconMapping.getAppRoleId()) },
+ menuIconMapping);
+ }
+ }
+
+ return menuIconMapping;
+ }
+
+ protected MenuIconMapping toUnwrappedModel(MenuIconMapping menuIconMapping) {
+ if (menuIconMapping instanceof MenuIconMappingImpl) {
+ return menuIconMapping;
+ }
+
+ MenuIconMappingImpl menuIconMappingImpl = new MenuIconMappingImpl();
+
+ menuIconMappingImpl.setNew(menuIconMapping.isNew());
+ menuIconMappingImpl.setPrimaryKey(menuIconMapping.getPrimaryKey());
+
+ menuIconMappingImpl.setAppRoleId(menuIconMapping.getAppRoleId());
+ menuIconMappingImpl.setDefaultIconClass(menuIconMapping.getDefaultIconClass());
+
+ return menuIconMappingImpl;
+ }
+
+ /**
+ * Returns the menu icon mapping 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 menu icon mapping
+ * @return the menu icon mapping
+ * @throws com.liferay.portal.NoSuchModelException if a menu icon mapping with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public MenuIconMapping findByPrimaryKey(Serializable primaryKey)
+ throws NoSuchModelException, SystemException {
+ return findByPrimaryKey(((Long)primaryKey).longValue());
+ }
+
+ /**
+ * Returns the menu icon mapping with the primary key or throws a {@link com.pentila.entSavoie.gestionMenus.NoSuchMenuIconMappingException} if it could not be found.
+ *
+ * @param appRoleId the primary key of the menu icon mapping
+ * @return the menu icon mapping
+ * @throws com.pentila.entSavoie.gestionMenus.NoSuchMenuIconMappingException if a menu icon mapping with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public MenuIconMapping findByPrimaryKey(long appRoleId)
+ throws NoSuchMenuIconMappingException, SystemException {
+ MenuIconMapping menuIconMapping = fetchByPrimaryKey(appRoleId);
+
+ if (menuIconMapping == null) {
+ if (_log.isWarnEnabled()) {
+ _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + appRoleId);
+ }
+
+ throw new NoSuchMenuIconMappingException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ appRoleId);
+ }
+
+ return menuIconMapping;
+ }
+
+ /**
+ * Returns the menu icon mapping with the primary key or returns <code>null</code> if it could not be found.
+ *
+ * @param primaryKey the primary key of the menu icon mapping
+ * @return the menu icon mapping, or <code>null</code> if a menu icon mapping with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public MenuIconMapping fetchByPrimaryKey(Serializable primaryKey)
+ throws SystemException {
+ return fetchByPrimaryKey(((Long)primaryKey).longValue());
+ }
+
+ /**
+ * Returns the menu icon mapping with the primary key or returns <code>null</code> if it could not be found.
+ *
+ * @param appRoleId the primary key of the menu icon mapping
+ * @return the menu icon mapping, or <code>null</code> if a menu icon mapping with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public MenuIconMapping fetchByPrimaryKey(long appRoleId)
+ throws SystemException {
+ MenuIconMapping menuIconMapping = (MenuIconMapping)EntityCacheUtil.getResult(MenuIconMappingModelImpl.ENTITY_CACHE_ENABLED,
+ MenuIconMappingImpl.class, appRoleId);
+
+ if (menuIconMapping == _nullMenuIconMapping) {
+ return null;
+ }
+
+ if (menuIconMapping == null) {
+ Session session = null;
+
+ boolean hasException = false;
+
+ try {
+ session = openSession();
+
+ menuIconMapping = (MenuIconMapping)session.get(MenuIconMappingImpl.class,
+ Long.valueOf(appRoleId));
+ }
+ catch (Exception e) {
+ hasException = true;
+
+ throw processException(e);
+ }
+ finally {
+ if (menuIconMapping != null) {
+ cacheResult(menuIconMapping);
+ }
+ else if (!hasException) {
+ EntityCacheUtil.putResult(MenuIconMappingModelImpl.ENTITY_CACHE_ENABLED,
+ MenuIconMappingImpl.class, appRoleId,
+ _nullMenuIconMapping);
+ }
+
+ closeSession(session);
+ }
+ }
+
+ return menuIconMapping;
+ }
+
+ /**
+ * Returns the menu icon mapping where appRoleId = ? or throws a {@link com.pentila.entSavoie.gestionMenus.NoSuchMenuIconMappingException} if it could not be found.
+ *
+ * @param appRoleId the app role ID
+ * @return the matching menu icon mapping
+ * @throws com.pentila.entSavoie.gestionMenus.NoSuchMenuIconMappingException if a matching menu icon mapping could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public MenuIconMapping findByappRoleId(long appRoleId)
+ throws NoSuchMenuIconMappingException, SystemException {
+ MenuIconMapping menuIconMapping = fetchByappRoleId(appRoleId);
+
+ if (menuIconMapping == null) {
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("appRoleId=");
+ msg.append(appRoleId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ if (_log.isWarnEnabled()) {
+ _log.warn(msg.toString());
+ }
+
+ throw new NoSuchMenuIconMappingException(msg.toString());
+ }
+
+ return menuIconMapping;
+ }
+
+ /**
+ * Returns the menu icon mapping where appRoleId = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
+ *
+ * @param appRoleId the app role ID
+ * @return the matching menu icon mapping, or <code>null</code> if a matching menu icon mapping could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public MenuIconMapping fetchByappRoleId(long appRoleId)
+ throws SystemException {
+ return fetchByappRoleId(appRoleId, true);
+ }
+
+ /**
+ * Returns the menu icon mapping where appRoleId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache.
+ *
+ * @param appRoleId the app role ID
+ * @param retrieveFromCache whether to use the finder cache
+ * @return the matching menu icon mapping, or <code>null</code> if a matching menu icon mapping could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public MenuIconMapping fetchByappRoleId(long appRoleId,
+ boolean retrieveFromCache) throws SystemException {
+ Object[] finderArgs = new Object[] { appRoleId };
+
+ Object result = null;
+
+ if (retrieveFromCache) {
+ result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_APPROLEID,
+ finderArgs, this);
+ }
+
+ if (result instanceof MenuIconMapping) {
+ MenuIconMapping menuIconMapping = (MenuIconMapping)result;
+
+ if ((appRoleId != menuIconMapping.getAppRoleId())) {
+ result = null;
+ }
+ }
+
+ if (result == null) {
+ StringBundler query = new StringBundler(2);
+
+ query.append(_SQL_SELECT_MENUICONMAPPING_WHERE);
+
+ query.append(_FINDER_COLUMN_APPROLEID_APPROLEID_2);
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(appRoleId);
+
+ List<MenuIconMapping> list = q.list();
+
+ result = list;
+
+ MenuIconMapping menuIconMapping = null;
+
+ if (list.isEmpty()) {
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_APPROLEID,
+ finderArgs, list);
+ }
+ else {
+ menuIconMapping = list.get(0);
+
+ cacheResult(menuIconMapping);
+
+ if ((menuIconMapping.getAppRoleId() != appRoleId)) {
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_APPROLEID,
+ finderArgs, menuIconMapping);
+ }
+ }
+
+ return menuIconMapping;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (result == null) {
+ FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_APPROLEID,
+ finderArgs);
+ }
+
+ closeSession(session);
+ }
+ }
+ else {
+ if (result instanceof List<?>) {
+ return null;
+ }
+ else {
+ return (MenuIconMapping)result;
+ }
+ }
+ }
+
+ /**
+ * Returns all the menu icon mappings.
+ *
+ * @return the menu icon mappings
+ * @throws SystemException if a system exception occurred
+ */
+ public List<MenuIconMapping> findAll() throws SystemException {
+ return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
+ }
+
+ /**
+ * Returns a range of all the menu icon mappings.
+ *
+ * <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 menu icon mappings
+ * @param end the upper bound of the range of menu icon mappings (not inclusive)
+ * @return the range of menu icon mappings
+ * @throws SystemException if a system exception occurred
+ */
+ public List<MenuIconMapping> findAll(int start, int end)
+ throws SystemException {
+ return findAll(start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the menu icon mappings.
+ *
+ * <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 menu icon mappings
+ * @param end the upper bound of the range of menu icon mappings (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of menu icon mappings
+ * @throws SystemException if a system exception occurred
+ */
+ public List<MenuIconMapping> 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<MenuIconMapping> list = (List<MenuIconMapping>)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_MENUICONMAPPING);
+
+ appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
+ orderByComparator);
+
+ sql = query.toString();
+ }
+ else {
+ sql = _SQL_SELECT_MENUICONMAPPING;
+ }
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ if (orderByComparator == null) {
+ list = (List<MenuIconMapping>)QueryUtil.list(q,
+ getDialect(), start, end, false);
+
+ Collections.sort(list);
+ }
+ else {
+ list = (List<MenuIconMapping>)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 the menu icon mapping where appRoleId = ? from the database.
+ *
+ * @param appRoleId the app role ID
+ * @return the menu icon mapping that was removed
+ * @throws SystemException if a system exception occurred
+ */
+ public MenuIconMapping removeByappRoleId(long appRoleId)
+ throws NoSuchMenuIconMappingException, SystemException {
+ MenuIconMapping menuIconMapping = findByappRoleId(appRoleId);
+
+ return remove(menuIconMapping);
+ }
+
+ /**
+ * Removes all the menu icon mappings from the database.
+ *
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeAll() throws SystemException {
+ for (MenuIconMapping menuIconMapping : findAll()) {
+ remove(menuIconMapping);
+ }
+ }
+
+ /**
+ * Returns the number of menu icon mappings where appRoleId = ?.
+ *
+ * @param appRoleId the app role ID
+ * @return the number of matching menu icon mappings
+ * @throws SystemException if a system exception occurred
+ */
+ public int countByappRoleId(long appRoleId) throws SystemException {
+ Object[] finderArgs = new Object[] { appRoleId };
+
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_APPROLEID,
+ finderArgs, this);
+
+ if (count == null) {
+ StringBundler query = new StringBundler(2);
+
+ query.append(_SQL_COUNT_MENUICONMAPPING_WHERE);
+
+ query.append(_FINDER_COLUMN_APPROLEID_APPROLEID_2);
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(appRoleId);
+
+ count = (Long)q.uniqueResult();
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (count == null) {
+ count = Long.valueOf(0);
+ }
+
+ FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_APPROLEID,
+ finderArgs, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Returns the number of menu icon mappings.
+ *
+ * @return the number of menu icon mappings
+ * @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_MENUICONMAPPING);
+
+ 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 menu icon mapping persistence.
+ */
+ public void afterPropertiesSet() {
+ String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
+ com.liferay.util.service.ServiceProps.get(
+ "value.object.listener.com.pentila.entSavoie.gestionMenus.model.MenuIconMapping")));
+
+ if (listenerClassNames.length > 0) {
+ try {
+ List<ModelListener<MenuIconMapping>> listenersList = new ArrayList<ModelListener<MenuIconMapping>>();
+
+ for (String listenerClassName : listenerClassNames) {
+ listenersList.add((ModelListener<MenuIconMapping>)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(MenuIconMappingImpl.class.getName());
+ FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
+ FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ @BeanReference(type = EntityMenuPersistence.class)
+ protected EntityMenuPersistence entityMenuPersistence;
+ @BeanReference(type = InternationalMenuPersistence.class)
+ protected InternationalMenuPersistence internationalMenuPersistence;
+ @BeanReference(type = LinkEtabPersistence.class)
+ protected LinkEtabPersistence linkEtabPersistence;
+ @BeanReference(type = MenuIconMappingPersistence.class)
+ protected MenuIconMappingPersistence menuIconMappingPersistence;
+ @BeanReference(type = PronoteLinkPersistence.class)
+ protected PronoteLinkPersistence pronoteLinkPersistence;
+ @BeanReference(type = ResourcePersistence.class)
+ protected ResourcePersistence resourcePersistence;
+ @BeanReference(type = UserPersistence.class)
+ protected UserPersistence userPersistence;
+ private static final String _SQL_SELECT_MENUICONMAPPING = "SELECT menuIconMapping FROM MenuIconMapping menuIconMapping";
+ private static final String _SQL_SELECT_MENUICONMAPPING_WHERE = "SELECT menuIconMapping FROM MenuIconMapping menuIconMapping WHERE ";
+ private static final String _SQL_COUNT_MENUICONMAPPING = "SELECT COUNT(menuIconMapping) FROM MenuIconMapping menuIconMapping";
+ private static final String _SQL_COUNT_MENUICONMAPPING_WHERE = "SELECT COUNT(menuIconMapping) FROM MenuIconMapping menuIconMapping WHERE ";
+ private static final String _FINDER_COLUMN_APPROLEID_APPROLEID_2 = "menuIconMapping.appRoleId = ?";
+ private static final String _ORDER_BY_ENTITY_ALIAS = "menuIconMapping.";
+ private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MenuIconMapping exists with the primary key ";
+ private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MenuIconMapping 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(MenuIconMappingPersistenceImpl.class);
+ private static MenuIconMapping _nullMenuIconMapping = new MenuIconMappingImpl() {
+ @Override
+ public Object clone() {
+ return this;
+ }
+
+ @Override
+ public CacheModel<MenuIconMapping> toCacheModel() {
+ return _nullMenuIconMappingCacheModel;
+ }
+ };
+
+ private static CacheModel<MenuIconMapping> _nullMenuIconMappingCacheModel = new CacheModel<MenuIconMapping>() {
+ public MenuIconMapping toEntityModel() {
+ return _nullMenuIconMapping;
+ }
+ };
+}
\ No newline at end of file