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)
|