-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate with Stored Procedure
PostPosted: Tue Dec 13, 2005 1:10 am 
Newbie

Joined: Tue Dec 13, 2005 12:59 am
Posts: 1
Need help with Stored Procedures with Hibernate.
have a insert stored procedure that I would like to call from hibernate.
I am getting all sorts of problems but am not able to get it to work.
the details of the my implementation is given below. Can someone pl guide me with this issue.

[b]Hibernate version: 3.0.5

[b]Mapping documents:


STORED PROCEDURE::
Stored Procedue has 5 input paramters, it inserts these
paramenters into a database table (book)

Here is the part of the Stored Procedure. I dont need to get any output
back.

PROCEDURE GET_BOOK_KEY
(
c_code IN country.code%TYPE,
s_id IN book.system%TYPE,
v_id IN book.vendor%TYPE,
b_id IN book.book%TYPE,
g_id IN book.generation%TYPE
)



XML Document:
<sql-query name="get_book_Key_SP" callable="true">
{ call get_book_key(?,?,?,?,?)}
</sql-query>





Code between sessionFactory.openSession() and session.close():
3. Java code


// get the session from the factory
session = HibernateSessionFactory.currentSession();

//start a transaction before doing something from the database
tx = session.beginTransaction();

Query listQuery = session.getNamedQuery("get_book_Key_SP");
listQuery.setString(0,country);
listQuery.setInteger(1,system);
listQuery.setInteger(2,vendor);
listQuery.setInteger(3,book);
listQuery.setInteger(4,generation);

// r = listQuery.executeUpdate();
This line gives an execption that cant run executeUpdate on SQL



Name and version of the database you are using: Oracle 9i


I tried lot of variations and I wasnt successful..

My hibernate version is 3.0.5 and Oracle 9i.

can some one pl tell me how to execute his stored procedure with hibernate.
Have a deadline in a day any help would be greatly appreciated..


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 13, 2005 12:02 pm 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
Check p156 of H3 Reference [must return resultset from Oracle]. You do the insert/update work within the SP and then return any resultset. Rather than using .executeUpdate(), just use .list() or .uniqueResult(). While I haven't done this on Oracle, I've done this several times on DB2-400.

Curtis...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.