-->
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.  [ 4 posts ] 
Author Message
 Post subject: How can I get the information on stored procedure?
PostPosted: Mon May 24, 2004 6:21 am 
Newbie

Joined: Mon May 24, 2004 6:06 am
Posts: 2
Hi all,

I have a question about using the hibernate object and stored procedure working together.

I have an object save session.save(order), then read the information from the stored procedure. I found that the "session.save(order)" is not really saved into the database until the "Transaction.commit();"

How can I solve this? Why I need to do this because, if the stored procedure validation fail, the "order" object will not be saved.

Code:
====
Session sess = new Session();
Order obj = new Order();
obj.setOrderNo("XXX");
sess.save(obj);

Connection conn = sess.connection();
query = "oracle_stored_procedure(?,?)";
CallableStatement callStmt = conn.prepareCall(query);
....
callStmt.execute();
....

if oracle_stored_procedure is return valid then
Transaction.commit();
else
Transaction.rollback();
end if;

oracle_stored_procedure:
=================
....
select * from order_table where order_no = "XXX";
...do something checking.....


Due to the sess.save(obj) is not really saved into the database, the "oracle_stored_procedure" cannot select the order. Always "rollback".

How can I solve this?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 6:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
do a session.flush() before the sp.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 9:46 am 
Newbie

Joined: Mon May 24, 2004 6:06 am
Posts: 2
I tried this sess.flush() but still not success.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 24, 2004 11:50 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
1- enable show sql on hibernate.cfg.xml
2- as Mickael said, debug with session.flush, you may see what sql is executed
3- if you see nothing, that may mean that hibernate considers no change have been made on persistent objects
4- depending you id generator, session.save(obj) + session.flush may at least hit the db to get sequence next value (if you are using sequence of course)

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.