读书人

Hibernate中session.connection()的顶

发布时间: 2012-07-03 13:37:42 作者: rapoo

Hibernate中session.connection()的替代方法

Hibernate中session.connection()的替代方法
???? Hibernate3.3.2版本中getSession().connection()已被弃用,替代方法SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection()

来自类org.springframework.orm.hibernate3.SessionFactoryUtils

?

Transaction tx=session.beginTransaction();//定义一个匿名类,实现了Work接口Work work=new Work(){public void execute(Connection connection)throws SQLException{  //通过JDBC API执行用于批量更新的SQL语句      PreparedStatement stmt=connection       .prepareStatement("update CUSTOMERS set AGE=AGE+1 where AGE>0 ");       stmt.executeUpdate();   }}; 
?

?

读书人网 >其他数据库

热点推荐