hibernate工作原理(非底层原理)

来源:互联网 发布:通信网络系统组成 编辑:程序博客网 时间:2024/05/16 12:53


1.通过Configuration config = new Configuration().configure();//读取并解析hibernate.cfg.xml配置文件

 2.由hibernate.cfg.xml中的<mapping resource="com/xx/User.hbm.xml"/>读取并解析映射信息
 3.通过SessionFactory sf = config.buildSessionFactory();//创建SessionFactory
 4.Session session = sf.openSession();//打开Sesssion
 5.Transaction tx = session.beginTransaction();//创建并启动事务Transation
 6.persistent operate操作数据,持久化操作
 7.tx.commit();//提交事务
 8.关闭Session
 9.关闭SesstionFactory

原创粉丝点击