日期:2014-05-18  浏览次数:20653 次

Hibernate 能不能执行存储过程哟?
Hibernate   能不能执行存储过程哟?高手请说一下呀!

------解决方案--------------------
当然可以,只是要绕过hibernate 调用jdbc API,当然事务还是由hibernate业管理:
假如我们创建了以下存储过程:
create or replace procedure batchUpdateCustomer(p_age in number) as
begin
update CUSTOMERS set AGE=AGE+1 where AGE> p_age;
end;


存储过程中有一个参数p_age,代表客户的年龄,应用程序可按照以下方式调用存储过程:
代码内容
tx = session.beginTransaction();
Connection con=session.connection();
String procedure = "{call batchUpdateCustomer(?) } ";
CallableStatement cstmt = con.prepareCall(procedure);
cstmt.setInt(1,0); //把年龄参数设为0
cstmt.executeUpdate();
tx.commit();

------解决方案--------------------
http://www.net0791.com/article/73868.htm

我从这里拷贝过来的
------解决方案--------------------
学习了!
------解决方案--------------------
对,可以,调用 call 就可以了
------解决方案--------------------
up
------解决方案--------------------
学习一下....