Hibernate编写通用数据库操作代码演示

发表于:2008-05-12来源:作者:点击数: 标签:数据库代码演示Hibernatehibernate
关键字:

insert方法
public void insert(Object o){
    Session session = HibernateSessionFactory.currentSession();
    Transaction t = session.beginTransaction();
    session.save(o);
    t.commit();
    HibernateSessionFactory.clossSession();
}

delete方法
public void delete(Object o,Serializable id){
    Session session = HibernateSessionFactory.currentSession():
    Transaction t = session.beginTransaction();
    Object o = session.get(o.class,id);
    if(o!=null){
        session.delete(o);

原文转自:http://www.ltesting.net