0
votes

I have a oracle Store procedure where is two in parameter varchar2 type
one ref_cursor out parameter and one number out parameter how to call the procedure using hibernate without obtain JDBC connection from Session object.

1
there are plenty of ways available on google. did you faced any issue with searched result? - S4beR
ref cursor is a cute. - user2173738
my point was how do i get the resultset from ref_cursor , I am using hibernate 4 and its easy to get the jdbc connection(I have to write extra 3 lines ) But I think There is another way without using jdbc connection - NaN

1 Answers

0
votes

Hibernate is an Object-Relational mapping tool, designed to act as a bridge between the OO and Relational paradigms. It's not just a convenience wrapper around JDBC. As such, it's not designed to work with stored procedures.

You can do it, if you really must, using native queries.

Example:

Query query = session.createSQLQuery(
  "CALL GetStocks(:stockCode)")
  .addEntity(Stock.class)
  .setParameter("stockCode", "7277");

Borrowed from http://www.mkyong.com/hibernate/how-to-call-store-procedure-in-hibernate/

I would recommend instead using MyBatis - this is designed as a convenience wrapper around JDBC, and maps SQL result sets to your domain objects.

http://mybatis.github.io/mybatis-3/