-->
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.  [ 1 post ] 
Author Message
 Post subject: Recovering from transaction rollback
PostPosted: Sun Oct 05, 2008 4:43 pm 
Newbie

Joined: Sun Oct 05, 2008 4:32 pm
Posts: 3
Hi,
I'd like to discuss how to recover state of objects (especially id) when transaction fails.
I'll describe situation: I have simple one to many mappings (person-address) in which I want to add new address. I load person (from database) with e.g. two addresses, I add new address to set of addresses of person and then I'm trying to save person (through cascading it save also newly created address). But because of let's say not null database column (street of address) the transaction fails. Then the state is following: I have person with some addresses and one of the address is not stored in database (but this address has id already assigned because of hibernate).
Then, on client I'm, not able to find out which address is the one which was newly created - because all addresses has id now.
Of course I could keep memory pointer to newly created address but situation can be worse when I e.g. need to send person and addresses through Spring's httpinvoker (and then after transaction fails I need to find which address was newly created) to server or when I need to save larger object graph with many associations. Does some general solution exists? Some description how to work with hibernate in such cases. Or some recommendation?
I'm considering following solutions: Set id back to null for newly created objects through hibernate interceptor. But I hope there is some build in automatic solution.


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

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.