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

📄 applicationinfofacade.java

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

import java.util.List;
import java.util.Set;
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.Applicationinfo;

/**
 * Facade for entity Applicationinfo.
 * 
 * @see com.sinosoft.message.po.Applicationinfo
 * @author MyEclipse Persistence Tools
 */
@Stateless
public class ApplicationinfoFacade implements ApplicationinfoFacadeLocal,
		ApplicationinfoFacadeRemote {
	// property constants
	public static final String APPLICATION_NAME = "applicationName";
	public static final String URL = "url";
	public static final String CREATEOR = "createor";
	public static final String CREATE_TIME = "createTime";
	public static final String LAST_CREATOR = "lastCreator";
	public static final String LAST_MODIFY = "lastModify";

	@PersistenceContext
	private EntityManager entityManager;

	/**
	 * Perform an initial save of a previously unsaved Applicationinfo entity.
	 * All subsequent persist actions of this entity should use the #update()
	 * method.
	 * 
	 * @param entity
	 *            Applicationinfo entity to persist
	 * @throws RuntimeException
	 *             when the operation fails
	 */
	public void save(Applicationinfo entity) {
		LogUtil.log("saving Applicationinfo 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 Applicationinfo entity.
	 * 
	 * @param entity
	 *            Applicationinfo entity to delete
	 * @throws RuntimeException
	 *             when the operation fails
	 */
	public void delete(Applicationinfo entity) {
		LogUtil.log("deleting Applicationinfo instance", Level.INFO, null);
		try {
			entity = entityManager.getReference(Applicationinfo.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 Applicationinfo entity and return it or a copy
	 * of it to the sender. A copy of the Applicationinfo entity parameter is
	 * returned when the JPA persistence mechanism has not previously been
	 * tracking the updated entity.
	 * 
	 * @param entity
	 *            Applicationinfo entity to update
	 * @return Applicationinfo the persisted Applicationinfo entity instance,
	 *         may not be the same
	 * @throws RuntimeException
	 *             if the operation fails
	 */
	public Applicationinfo update(Applicationinfo entity) {
		LogUtil.log("updating Applicationinfo instance", Level.INFO, null);
		try {
			Applicationinfo 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 Applicationinfo findById(String id) {
		LogUtil.log("finding Applicationinfo instance with id: " + id,
				Level.INFO, null);
		try {
			Applicationinfo instance = entityManager.find(
					Applicationinfo.class, id);
			return instance;
		} catch (RuntimeException re) {
			LogUtil.log("find failed", Level.SEVERE, re);
			throw re;
		}
	}

	/**
	 * Find all Applicationinfo entities with a specific property value.
	 * 
	 * @param propertyName
	 *            the name of the Applicationinfo 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<Applicationinfo> found by query
	 */
	@SuppressWarnings("unchecked")
	public List<Applicationinfo> findByProperty(String propertyName,
			final Object value, final int... rowStartIdxAndCount) {
		LogUtil.log("finding Applicationinfo instance with property: "
				+ propertyName + ", value: " + value, Level.INFO, null);
		try {
			final String queryString = "select model from Applicationinfo 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<Applicationinfo> findByApplicationName(Object applicationName,
			int... rowStartIdxAndCount) {
		return findByProperty(APPLICATION_NAME, applicationName,
				rowStartIdxAndCount);
	}

	public List<Applicationinfo> findByUrl(Object url,
			int... rowStartIdxAndCount) {
		return findByProperty(URL, url, rowStartIdxAndCount);
	}

	public List<Applicationinfo> findByCreateor(Object createor,
			int... rowStartIdxAndCount) {
		return findByProperty(CREATEOR, createor, rowStartIdxAndCount);
	}

	public List<Applicationinfo> findByCreateTime(Object createTime,
			int... rowStartIdxAndCount) {
		return findByProperty(CREATE_TIME, createTime, rowStartIdxAndCount);
	}

	public List<Applicationinfo> findByLastCreator(Object lastCreator,
			int... rowStartIdxAndCount) {
		return findByProperty(LAST_CREATOR, lastCreator, rowStartIdxAndCount);
	}

	public List<Applicationinfo> findByLastModify(Object lastModify,
			int... rowStartIdxAndCount) {
		return findByProperty(LAST_MODIFY, lastModify, rowStartIdxAndCount);
	}

	/**
	 * Find all Applicationinfo 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<Applicationinfo> all Applicationinfo entities
	 */
	@SuppressWarnings("unchecked")
	public List<Applicationinfo> findAll(final int... rowStartIdxAndCount) {
		LogUtil.log("finding all Applicationinfo instances", Level.INFO, null);
		try {
			final String queryString = "select model from Applicationinfo 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 + -