2 回答
TA贡献1850条经验 获得超11个赞
好像还是没办法。但是,这是通过从 Hibernate 获取连接EntityManager然后使用CallableStatement.
// Session = org.hibernate.Session
// entityManager = javax.persistence.EntityManager
Session session = entityManager.unwrap(Session.class);
session.doWork(new Work() {
@Override
public void execute(Connection con) throws SQLException {
// do something useful
try (CallableStatement cs = con.prepareCall("{CALL TEST_PACKAGE.GETCURSORS(?,?,?)}")) {
cs.setInt(1, 1);
cs.registerOutParameter(2, OracleTypes.CURSOR);
cs.registerOutParameter(3, OracleTypes.CURSOR);
cs.execute();
ResultSet rs = (ResultSet) cs.getObject(2);
ResultSet rs1 = (ResultSet) cs.getObject(3);
while (rs.next()) {
int a = rs.getInt(1);
System.out.println(a);
}
while (rs1.next()) {
int b = rs1.getInt(1);
System.out.println(b);
}
}
}
});
添加回答
举报