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(); }}; ??