-->
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: Data write after rollback
PostPosted: Tue Oct 29, 2013 3:59 am 
Newbie

Joined: Tue Oct 29, 2013 3:40 am
Posts: 1
Dear all,

i'm curious whether i have a major missunderstanding...

I built a following sequence:

0) read several POJOs
1) get an particular POJO from database by criteria.list() command, for any reason an exception occurs here (Grammar, primitive null value, or .......) in a relation of the POJO, so the POJO itself is returned but relations might be emtpy/partially existing!
2) perform a rollback, as i would like to make sure the exceptions have no data structure consequences
3) now do somethings else with writing POJO with safeOrUpdate
4) perform a commit

What i see and i can perfectly reproduce is that the object from step 1) with the Exception is safed in the Error state within 4) even though i did a rollback in step 2) and i did NOT perform an safe or safe like (merge) command on the POJO, so relations/collections might be for example entirely wiped out. From the documentation my understanding was that after any RuntimeException a rollback should be executed, i didn't read or missed that a clean and/or a entire new hibernate session object is needed for proceeding.

I can also reproduce that if i put a session.clean() between 2) and 3) the commit does NOT safe the POJO from step 2), the clean however has other consequences .... for the read POJOs of step 0) which i would like to have for the next steps of proper error display/handling...

So: Why is rollback not sufficient and i need clean() additionally?
Related question: Is there a way to have parts of a hibernate Session guaranteed to be read only, even if Exceptions occur?

Please let me know when you need more details of the sequence, the code sequence i relativly straight forward.

I'm sure that i got something wrong, but i just don't see it.
Any hint very appreciated, thanks!

Gulpi (=Martin Adler)


Top
 Profile  
 
 Post subject: Re: Data write after rollback
PostPosted: Tue Oct 29, 2013 8:25 am 
Senior
Senior

Joined: Tue Oct 28, 2008 10:39 am
Posts: 196
Never ever use a session that had an exception. Close it, get a new one!


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.