CallableStatement callstate;
ResultSet rs;
List<Account> list = new ArrayList<Account>();
try {
callstate = factory.getCurrentSession().connection().prepareCall(
"call p_zhou.quer_aaccount(?,?)");
callstate.setString(1, "2");
callstate.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR);
callstate.execute();
rs = (ResultSet) callstate.getObject(2);
int i = rs.getMetaData().getColumnCount();// 得到列数
while (rs.next()) {
Account account = new Account();
account.setName(rs.getString(1));
account.setPassword(rs.getString(2));
list.add(account);
}这是目前采用的方法 jdbc方式的,但是由Session获得Connection是过期的!目前知道还有种配置文件的方式,但不知道该如何写,我的存储过程传入一个参数返回一个游标!create or replace package body p_zhou is  -- Private type declarations
  -- Private constant declarations
  -- Private variable declarations
  -- Function and procedure implementations
  procedure quer_aaccount(zpassword varchar2, Zresult out zjcursor) as
  begin
    open Zresult for
      select t.* from account t where t.password = zpassword;
  exception
    when others then
      p_Myerr.Handle(sqlcode, sqlerrm);
  end;end p_zhou;

解决方案 »

  1.   

    你可以Session session =HibernateSessionFactory.getSession();   
    SQLQuery query = session.createSQLQuery("{Call p_zhou.quer_aaccount(?,?)}");  
      

  2.   

    或者session.doWork(new Work() {

    @Override
    public void execute(Connection connection) throws SQLException {
    connection.prepareCall("");
    }
    });
      

  3.   

    我已经用配置文件的方式实现了,借鉴的http://www.blogjava.net/amigoxie/archive/2007/08/15/136828.html。
    但是感觉不全面,想找个全面的hibernate调用各种情况的存储过程的总结!可没发现!