How to call an Oracle function from Hibernate with a return parameter?

后端 未结 5 1618
你的背包
你的背包 2020-11-29 05:47

My question is very much like Getting the return value of a PL/SQL function via Hibernate

I have a function which does some modifications internally and it returns a

5条回答
  •  迷失自我
    2020-11-29 06:16

    Yes, you do need to use an out parameter. If you use the doWork() method, you'd do something like this:

    session.doWork(new Work() {
       public void execute(Connection conn) {
          CallableStatement stmt = conn.prepareCall("? = call (?)");
          stmt.registerOutParameter(1, OracleTypes.INTEGER);
          stmt.setInt(2, );
          stmt.execute();
          Integer outputValue = stmt.getInt(1);
          // And then you'd do something with this outputValue
       }
    });
    

提交回复
热议问题