?? messagehome.java
字號:
package cn.hxex.tools.hibernate.model;
// Generated 2006-2-20 21:19:35 by Hibernate Tools 3.1.0.beta4
import java.util.List;
import javax.naming.InitialContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Example;
/**
* Home object for domain model class Message.
* @see cn.hxex.tools.hibernate.model.Message
* @author Hibernate Tools
*/
public class MessageHome {
private static final Log log = LogFactory.getLog(MessageHome.class);
private final SessionFactory sessionFactory = getSessionFactory();
protected SessionFactory getSessionFactory() {
try {
return (SessionFactory) new InitialContext().lookup("SessionFactory");
}
catch (Exception e) {
log.error("Could not locate SessionFactory in JNDI", e);
throw new IllegalStateException("Could not locate SessionFactory in JNDI");
}
}
public void persist(Message transientInstance) {
log.debug("persisting Message instance");
try {
sessionFactory.getCurrentSession().persist(transientInstance);
log.debug("persist successful");
}
catch (RuntimeException re) {
log.error("persist failed", re);
throw re;
}
}
public void attachDirty(Message instance) {
log.debug("attaching dirty Message instance");
try {
sessionFactory.getCurrentSession().saveOrUpdate(instance);
log.debug("attach successful");
}
catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Message instance) {
log.debug("attaching clean Message instance");
try {
sessionFactory.getCurrentSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
}
catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void delete(Message persistentInstance) {
log.debug("deleting Message instance");
try {
sessionFactory.getCurrentSession().delete(persistentInstance);
log.debug("delete successful");
}
catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Message merge(Message detachedInstance) {
log.debug("merging Message instance");
try {
Message result = (Message) sessionFactory.getCurrentSession()
.merge(detachedInstance);
log.debug("merge successful");
return result;
}
catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public Message findById( java.lang.String id) {
log.debug("getting Message instance with id: " + id);
try {
Message instance = (Message) sessionFactory.getCurrentSession()
.get("cn.hxex.tools.hibernate.model.Message", id);
if (instance==null) {
log.debug("get successful, no instance found");
}
else {
log.debug("get successful, instance found");
}
return instance;
}
catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Message instance) {
log.debug("finding Message instance by example");
try {
List results = sessionFactory.getCurrentSession()
.createCriteria("cn.hxex.tools.hibernate.model.Message")
.add(Example.create(instance))
.list();
log.debug("find by example successful, result size: " + results.size());
return results;
}
catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -