日期:2014-05-16  浏览次数:20432 次

Hibernate对数据库进行持久化操作:七步

?//1.读取配置文件
??? ???? Configuration conf = new Configuration().configure();
??? ???? //2.获得会话工厂
??? ???? SessionFactory? sessionfactory = conf.configure().buildSessionFactory();
??? ?????? //3.打开会话
??? ???? sessionfactory.openSession();
??? ?????? //4.开启事物
??? ???? Transaction? tx = session.beginTransaction();
??? ????? //5.进行持久化

//6.提交事务
??????? ????? tx.commit();
??????? ???? //7.关闭会话