?? messageresourcefacade.java
字號(hào):
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.Messageresource;
/**
* Facade for entity Messageresource.
*
* @see com.sinosoft.message.po.Messageresource
* @author MyEclipse Persistence Tools
*/
@Stateless
public class MessageresourceFacade implements MessageresourceFacadeLocal,
MessageresourceFacadeRemote {
// property constants
public static final String CREATE_DATE = "createDate";
public static final String SENDER = "sender";
public static final String RECEIVER = "receiver";
public static final String SEND_DEL_FLAG = "sendDelFlag";
public static final String RECEVIVE_DEL_FLAG = "receviveDelFlag";
public static final String STATUS = "status";
public static final String SENDER_NAME = "senderName";
public static final String RECEVIER_NAME = "recevierName";
public static final String SEND_TYPE = "sendType";
public static final String RECEVIE_TYPE = "recevieType";
@PersistenceContext
private EntityManager entityManager;
/**
* Perform an initial save of a previously unsaved Messageresource entity.
* All subsequent persist actions of this entity should use the #update()
* method.
*
* @param entity
* Messageresource entity to persist
* @throws RuntimeException
* when the operation fails
*/
public void save(Messageresource entity) {
LogUtil.log("saving Messageresource 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 Messageresource entity.
*
* @param entity
* Messageresource entity to delete
* @throws RuntimeException
* when the operation fails
*/
public void delete(Messageresource entity) {
LogUtil.log("deleting Messageresource instance", Level.INFO, null);
try {
entity = entityManager.getReference(Messageresource.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 Messageresource entity and return it or a copy
* of it to the sender. A copy of the Messageresource entity parameter is
* returned when the JPA persistence mechanism has not previously been
* tracking the updated entity.
*
* @param entity
* Messageresource entity to update
* @return Messageresource the persisted Messageresource entity instance,
* may not be the same
* @throws RuntimeException
* if the operation fails
*/
public Messageresource update(Messageresource entity) {
LogUtil.log("updating Messageresource instance", Level.INFO, null);
try {
Messageresource 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 Messageresource findById(String id) {
LogUtil.log("finding Messageresource instance with id: " + id,
Level.INFO, null);
try {
Messageresource instance = entityManager.find(
Messageresource.class, id);
return instance;
} catch (RuntimeException re) {
LogUtil.log("find failed", Level.SEVERE, re);
throw re;
}
}
/**
* Find all Messageresource entities with a specific property value.
*
* @param propertyName
* the name of the Messageresource 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<Messageresource> found by query
*/
@SuppressWarnings("unchecked")
public List<Messageresource> findByProperty(String propertyName,
final Object value, final int... rowStartIdxAndCount) {
LogUtil.log("finding Messageresource instance with property: "
+ propertyName + ", value: " + value, Level.INFO, null);
try {
final String queryString = "select model from Messageresource 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<Messageresource> findByCreateDate(Object createDate,
int... rowStartIdxAndCount) {
return findByProperty(CREATE_DATE, createDate, rowStartIdxAndCount);
}
public List<Messageresource> findBySender(Object sender,
int... rowStartIdxAndCount) {
return findByProperty(SENDER, sender, rowStartIdxAndCount);
}
public List<Messageresource> findByReceiver(Object receiver,
int... rowStartIdxAndCount) {
return findByProperty(RECEIVER, receiver, rowStartIdxAndCount);
}
public List<Messageresource> findBySendDelFlag(Object sendDelFlag,
int... rowStartIdxAndCount) {
return findByProperty(SEND_DEL_FLAG, sendDelFlag, rowStartIdxAndCount);
}
public List<Messageresource> findByReceviveDelFlag(Object receviveDelFlag,
int... rowStartIdxAndCount) {
return findByProperty(RECEVIVE_DEL_FLAG, receviveDelFlag,
rowStartIdxAndCount);
}
public List<Messageresource> findByStatus(Object status,
int... rowStartIdxAndCount) {
return findByProperty(STATUS, status, rowStartIdxAndCount);
}
public List<Messageresource> findBySenderName(Object senderName,
int... rowStartIdxAndCount) {
return findByProperty(SENDER_NAME, senderName, rowStartIdxAndCount);
}
public List<Messageresource> findByRecevierName(Object recevierName,
int... rowStartIdxAndCount) {
return findByProperty(RECEVIER_NAME, recevierName, rowStartIdxAndCount);
}
public List<Messageresource> findBySendType(Object sendType,
int... rowStartIdxAndCount) {
return findByProperty(SEND_TYPE, sendType, rowStartIdxAndCount);
}
public List<Messageresource> findByRecevieType(Object recevieType,
int... rowStartIdxAndCount) {
return findByProperty(RECEVIE_TYPE, recevieType, rowStartIdxAndCount);
}
/**
* Find all Messageresource 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<Messageresource> all Messageresource entities
*/
@SuppressWarnings("unchecked")
public List<Messageresource> findAll(final int... rowStartIdxAndCount) {
LogUtil.log("finding all Messageresource instances", Level.INFO, null);
try {
final String queryString = "select model from Messageresource 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;
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -