-->
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.  [ 5 posts ] 
Author Message
 Post subject: Rollback a Session.flush() ?
PostPosted: Fri Mar 25, 2005 8:02 pm 
Regular
Regular

Joined: Tue Jan 11, 2005 8:55 pm
Posts: 53
Hi,

I am using Hibernate v2.1.7 with Weblogic. I am using Weblogic's JTA, and at the end of each session(or EJB call) - I call session.flush() to synchronize the session with the database. However, what if an error occurs halfway through the synchronization - how can I rollback "flushing" the session, or the transaction? I am not using the Transaction API because I'm using Weblogic.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 26, 2005 3:29 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 5:34 pm
Posts: 35
When you have error, throw the exception to you layer where you have done the flush and catch that exception.

so you can avoid doing flush there in case of exception.

Srigold


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 26, 2005 5:05 pm 
Regular
Regular

Joined: Tue Jan 11, 2005 8:55 pm
Posts: 53
srigold wrote:
When you have error, throw the exception to you layer where you have done the flush and catch that exception.

so you can avoid doing flush there in case of exception.

Srigold


That is what I am doing, but for some reason, some inserts were still occuring into the database. I'll test again, I think I was doing something else wrong.

Thanks though for the verification!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 26, 2005 6:15 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 5:34 pm
Posts: 35
And one more thing, you are not using your flush statements anywhere right ?
Remove all the flush statement and check.
If everything is all right at the end of your transactional block, it will make necessary changes and rollback if in case of exception.

Just give a try for this one.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 26, 2005 7:17 pm 
Regular
Regular

Joined: Tue Jan 11, 2005 8:55 pm
Posts: 53
srigold wrote:
And one more thing, you are not using your flush statements anywhere right ?
Remove all the flush statement and check.
If everything is all right at the end of your transactional block, it will make necessary changes and rollback if in case of exception.

Just give a try for this one.


What od you mean? When I am done with all the necessary changes, I call session.flush() to "commit" to the database. I read in the documentation that calling flush() is necessary in an EJB container (b/c I am not using the transaction api).


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