0
我想在休眠中調用存儲函數,但我得到無效的sql異常。在Oracle在休眠調用存儲函數
Java代碼---
public Integer callSqlBlock(){
Integer outputValue =1;
Session session = getHibernateTemplate().getSessionFactory().getCurrentSession();
session.doWork(new Work() {
@Override
public void execute(Connection conn)
throws SQLException {
CallableStatement stmt = conn.prepareCall("? = call test(?)");
stmt.registerOutParameter(1, Types.INTEGER);
stmt.setString(2, "callIndex");
stmt.execute();
Integer output = stmt.getInt(1);
test(output);
}
});
Connection oracleConnection = getJavaSqlConnectionFromHibernateSession(session);
// CallableStatement statement = oracleConnection.prepareCall(sql)
return outputValue;
}
測試存儲功能---
create or replace
function test(str in varchar2) return number
as
begin
if str = 'test' then
return 1;
end if;
return 0;
end;
請讓我知道我錯了
感謝鮑勃,它爲我工作。 – Abhi