⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userdefinedstrategyfacade.java

📁 协同办公
💻 JAVA
字号:
package com.sinosoft.message.ejb;

import java.util.List;
import java.util.logging.Level;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import com.sinosoft.message.po.Userdefinedstrategy;

/**
 * Facade for entity Userdefinedstrategy.
 * 
 * @see com.sinosoft.message.po.Userdefinedstrategy
 * @author MyEclipse Persistence Tools
 */
@Stateless
public class UserdefinedstrategyFacade implements
		UserdefinedstrategyFacadeLocal, UserdefinedstrategyFacadeRemote {
	// property constants
	public static final String STRATEGY_NAME = "strategyName";
	public static final String STRATEGY_DEC = "strategyDec";
	public static final String CREATOR = "creator";
	public static final String MESSAGETYPEID = "messagetypeid";
	public static final String ALLOW = "allow";
	public static final String FUNMODELID = "funmodelid";

	@PersistenceContext
	private EntityManager entityManager;

	/**
	 * Perform an initial save of a previously unsaved Userdefinedstrategy
	 * entity. All subsequent persist actions of this entity should use the
	 * #update() method.
	 * 
	 * @param entity
	 *            Userdefinedstrategy entity to persist
	 * @throws RuntimeException
	 *             when the operation fails
	 */
	public void save(Userdefinedstrategy entity) {
		LogUtil.log("saving Userdefinedstrategy instance", Level.INFO, null);
		try {
			entityManager.persist(entity);
			LogUtil.log("save successful", Level.INFO, null);
		} catch (RuntimeException re) {
			LogUtil.log("save failed", Level.SEVERE, re);
			throw re;
		}
	}

	/**
	 * Delete a persistent Userdefinedstrategy entity.
	 * 
	 * @param entity
	 *            Userdefinedstrategy entity to delete
	 * @throws RuntimeException
	 *             when the operation fails
	 */
	public void delete(Userdefinedstrategy entity) {
		LogUtil.log("deleting Userdefinedstrategy instance", Level.INFO, null);
		try {
			entity = entityManager.getReference(Userdefinedstrategy.class,
					entity.getId());
			entityManager.remove(entity);
			LogUtil.log("delete successful", Level.INFO, null);
		} catch (RuntimeException re) {
			LogUtil.log("delete failed", Level.SEVERE, re);
			throw re;
		}
	}

	/**
	 * Persist a previously saved Userdefinedstrategy entity and return it or a
	 * copy of it to the sender. A copy of the Userdefinedstrategy entity
	 * parameter is returned when the JPA persistence mechanism has not
	 * previously been tracking the updated entity.
	 * 
	 * @param entity
	 *            Userdefinedstrategy entity to update
	 * @return Userdefinedstrategy the persisted Userdefinedstrategy entity
	 *         instance, may not be the same
	 * @throws RuntimeException
	 *             if the operation fails
	 */
	public Userdefinedstrategy update(Userdefinedstrategy entity) {
		LogUtil.log("updating Userdefinedstrategy instance", Level.INFO, null);
		try {
			Userdefinedstrategy result = entityManager.merge(entity);
			LogUtil.log("update successful", Level.INFO, null);
			return result;
		} catch (RuntimeException re) {
			LogUtil.log("update failed", Level.SEVERE, re);
			throw re;
		}
	}

	public Userdefinedstrategy findById(String id) {
		LogUtil.log("finding Userdefinedstrategy instance with id: " + id,
				Level.INFO, null);
		try {
			Userdefinedstrategy instance = entityManager.find(
					Userdefinedstrategy.class, id);
			return instance;
		} catch (RuntimeException re) {
			LogUtil.log("find failed", Level.SEVERE, re);
			throw re;
		}
	}

	/**
	 * Find all Userdefinedstrategy entities with a specific property value.
	 * 
	 * @param propertyName
	 *            the name of the Userdefinedstrategy property to query
	 * @param value
	 *            the property value to match
	 * @param rowStartIdxAndCount
	 *            Optional int varargs. rowStartIdxAndCount[0] specifies the the
	 *            row index in the query result-set to begin collecting the
	 *            results. rowStartIdxAndCount[1] specifies the the maximum
	 *            number of results to return.
	 * @return List<Userdefinedstrategy> found by query
	 */
	@SuppressWarnings("unchecked")
	public List<Userdefinedstrategy> findByProperty(String propertyName,
			final Object value, final int... rowStartIdxAndCount) {
		LogUtil.log("finding Userdefinedstrategy instance with property: "
				+ propertyName + ", value: " + value, Level.INFO, null);
		try {
			final String queryString = "select model from Userdefinedstrategy model where model."
					+ propertyName + "= :propertyValue";
			Query query = entityManager.createQuery(queryString);
			query.setParameter("propertyValue", value);
			if (rowStartIdxAndCount != null && rowStartIdxAndCount.length > 0) {
				int rowStartIdx = Math.max(0, rowStartIdxAndCount[0]);
				if (rowStartIdx > 0) {
					query.setFirstResult(rowStartIdx);
				}

				if (rowStartIdxAndCount.length > 1) {
					int rowCount = Math.max(0, rowStartIdxAndCount[1]);
					if (rowCount > 0) {
						query.setMaxResults(rowCount);
					}
				}
			}
			return query.getResultList();
		} catch (RuntimeException re) {
			LogUtil.log("find by property name failed", Level.SEVERE, re);
			throw re;
		}
	}

	public List<Userdefinedstrategy> findByStrategyName(Object strategyName,
			int... rowStartIdxAndCount) {
		return findByProperty(STRATEGY_NAME, strategyName, rowStartIdxAndCount);
	}

	public List<Userdefinedstrategy> findByStrategyDec(Object strategyDec,
			int... rowStartIdxAndCount) {
		return findByProperty(STRATEGY_DEC, strategyDec, rowStartIdxAndCount);
	}

	public List<Userdefinedstrategy> findByCreator(Object creator,
			int... rowStartIdxAndCount) {
		return findByProperty(CREATOR, creator, rowStartIdxAndCount);
	}

	public List<Userdefinedstrategy> findByMessagetypeid(Object messagetypeid,
			int... rowStartIdxAndCount) {
		return findByProperty(MESSAGETYPEID, messagetypeid, rowStartIdxAndCount);
	}

	public List<Userdefinedstrategy> findByAllow(Object allow,
			int... rowStartIdxAndCount) {
		return findByProperty(ALLOW, allow, rowStartIdxAndCount);
	}

	public List<Userdefinedstrategy> findByFunmodelid(Object funmodelid,
			int... rowStartIdxAndCount) {
		return findByProperty(FUNMODELID, funmodelid, rowStartIdxAndCount);
	}

	/**
	 * Find all Userdefinedstrategy entities.
	 * 
	 * @param rowStartIdxAndCount
	 *            Optional int varargs. rowStartIdxAndCount[0] specifies the the
	 *            row index in the query result-set to begin collecting the
	 *            results. rowStartIdxAndCount[1] specifies the the maximum
	 *            count of results to return.
	 * @return List<Userdefinedstrategy> all Userdefinedstrategy entities
	 */
	@SuppressWarnings("unchecked")
	public List<Userdefinedstrategy> findAll(final int... rowStartIdxAndCount) {
		LogUtil.log("finding all Userdefinedstrategy instances", Level.INFO,
				null);
		try {
			final String queryString = "select model from Userdefinedstrategy model";
			Query query = entityManager.createQuery(queryString);
			if (rowStartIdxAndCount != null && rowStartIdxAndCount.length > 0) {
				int rowStartIdx = Math.max(0, rowStartIdxAndCount[0]);
				if (rowStartIdx > 0) {
					query.setFirstResult(rowStartIdx);
				}

				if (rowStartIdxAndCount.length > 1) {
					int rowCount = Math.max(0, rowStartIdxAndCount[1]);
					if (rowCount > 0) {
						query.setMaxResults(rowCount);
					}
				}
			}
			return query.getResultList();
		} catch (RuntimeException re) {
			LogUtil.log("find all failed", Level.SEVERE, re);
			throw re;
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -