Hibernate beginTransaction方法:开启一个事务

  • 内容
  • 评论
  • 相关

beginTransaction 方法用于开启一个事务并返回一个 Transaction 对象。

语法:

beginTransaction()

返回值:一个 Transaction 对象。

示例

开启一个事务,并抛出异常信息,关键代码如下:

Transaction tx = null;  //定义事务对象
try{
  tx = session.beginTransaction();  //开启事务
}catch(HibernateException e){
  e.printStackTrace();
}

本文标题:Hibernate beginTransaction方法:开启一个事务

本文地址:http://www.hosteonscn.com/6486.html

评论

0条评论

发表评论

邮箱地址不会被公开。 必填项已用*标注