首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

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

2012-07-03 
Hibernate中session.connection()的替代方法Hibernate中session.connection()的替代方法???? Hibernate3.3

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

?

热点排行