hibernate中调用存储过程
来源:互联网 发布:网络机房消防 编辑:程序博客网 时间:2024/05/14 06:56
如果底层数据库(如Oracle)支持存储过程,也可以通过存储过程来执行批量更新。存储过程直接在数据库中运行,速度更加快。在Oracle数据库中可以定义一个名为batchUpdateStudent()的存储过程,代码如下:
create or replace procedure batchUpdateStudent(p_age in number) as
begin
update STUDENT set AGE=AGE+1 where AGE>p_age;
end;
以上存储过程有一个参数p_age,代表学生的年龄,应用程序可按照以下方式调用存储过程:
tx = session.beginTransaction();
Connection con=session.connection();
String procedure = "{call batchUpdateStudent(?) }";
CallableStatement cstmt = con.prepareCall(procedure);
cstmt.setInt(1,0); //把年龄参数设为0
cstmt.executeUpdate();
tx.commit();
在以上代码中,我用的是Hibernate的 Transaction接口来声明事务,而不是采用JDBC API来声明事务。
转自http://hi.baidu.com/liuxb/blog/item/2ded4954bd14cc54574e0052.html
- hibernate中调用存储过程hibernate中调用存储过程
- hibernate 中调用存储过程
- hibernate中调用存储过程
- hibernate中调用存储过程
- hibernate中调用存储过程
- hibernate中调用存储过程
- hibernate中调用存储过程
- hibernate调用mysql中存储过程
- java--hibernate中调用存储过程
- hibernate调用存储过程
- Hibernate调用存储过程
- hibernate调用存储过程
- hibernate 调用存储过程
- hibernate调用存储过程
- Hibernate调用存储过程
- Hibernate调用存储过程
- Hibernate --调用存储过程
- hibernate调用存储过程
- 实习了,不得不放弃asp,学java!公司里要用jsp开发项目!
- IP数据报格式
- MSN不能正常登录的解决办法
- 很久没有更新博客了,准备继续~~~
- 100多种清除木马方法
- hibernate中调用存储过程
- TCP报文格式
- iframe根据内容自动伸缩
- ARP协议
- 公钥私钥 和 SSL
- ICMP 格式
- C++类对象的复制-拷贝构造函数
- 万恶的食堂
- C++类对象的拷贝构造函数