?? userdefinedtypefacade.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.Userdefinedtype;
/**
* Facade for entity Userdefinedtype.
*
* @see com.sinosoft.message.po.Userdefinedtype
* @author MyEclipse Persistence Tools
*/
@Stateless
public class UserdefinedtypeFacade implements UserdefinedtypeFacadeLocal,
UserdefinedtypeFacadeRemote {
// property constants
public static final String NAME = "name";
public static final String DEC = "dec";
@PersistenceContext
private EntityManager entityManager;
/**
* Perform an initial save of a previously unsaved Userdefinedtype entity.
* All subsequent persist actions of this entity should use the #update()
* method.
*
* @param entity
* Userdefinedtype entity to persist
* @throws RuntimeException
* when the operation fails
*/
public void save(Userdefinedtype entity) {
LogUtil.log("saving Userdefinedtype 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 Userdefinedtype entity.
*
* @param entity
* Userdefinedtype entity to delete
* @throws RuntimeException
* when the operation fails
*/
public void delete(Userdefinedtype entity) {
LogUtil.log("deleting Userdefinedtype instance", Level.INFO, null);
try {
entity = entityManager.getReference(Userdefinedtype.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 Userdefinedtype entity and return it or a copy
* of it to the sender. A copy of the Userdefinedtype entity parameter is
* returned when the JPA persistence mechanism has not previously been
* tracking the updated entity.
*
* @param entity
* Userdefinedtype entity to update
* @return Userdefinedtype the persisted Userdefinedtype entity instance,
* may not be the same
* @throws RuntimeException
* if the operation fails
*/
public Userdefinedtype update(Userdefinedtype entity) {
LogUtil.log("updating Userdefinedtype instance", Level.INFO, null);
try {
Userdefinedtype 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 Userdefinedtype findById(String id) {
LogUtil.log("finding Userdefinedtype instance with id: " + id,
Level.INFO, null);
try {
Userdefinedtype instance = entityManager.find(
Userdefinedtype.class, id);
return instance;
} catch (RuntimeException re) {
LogUtil.log("find failed", Level.SEVERE, re);
throw re;
}
}
/**
* Find all Userdefinedtype entities with a specific property value.
*
* @param propertyName
* the name of the Userdefinedtype 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<Userdefinedtype> found by query
*/
@SuppressWarnings("unchecked")
public List<Userdefinedtype> findByProperty(String propertyName,
final Object value, final int... rowStartIdxAndCount) {
LogUtil.log("finding Userdefinedtype instance with property: "
+ propertyName + ", value: " + value, Level.INFO, null);
try {
final String queryString = "select model from Userdefinedtype 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<Userdefinedtype> findByName(Object name,
int... rowStartIdxAndCount) {
return findByProperty(NAME, name, rowStartIdxAndCount);
}
public List<Userdefinedtype> findByDec(Object dec,
int... rowStartIdxAndCount) {
return findByProperty(DEC, dec, rowStartIdxAndCount);
}
/**
* Find all Userdefinedtype 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<Userdefinedtype> all Userdefinedtype entities
*/
@SuppressWarnings("unchecked")
public List<Userdefinedtype> findAll(final int... rowStartIdxAndCount) {
LogUtil.log("finding all Userdefinedtype instances", Level.INFO, null);
try {
final String queryString = "select model from Userdefinedtype 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 + -