This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes handling object restore on rollback Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "handling object restore on rollback" Watch "handling object restore on rollback" New topic
Author

handling object restore on rollback

fred funston
Greenhorn

Joined: Feb 21, 2004
Posts: 1
When you delete a user, for example, a large number of
objects that refer to the user will need to be updated also.
This all happens in a transaction. The objects will
get updated in memory before the database transaction
is committed.
How do you handle "restoring" the in memory objects when a
rollback in the database occurs?
The transaction context does not include objects so there
is no equivalent way of undoing all the changes that have
been made to objects.
The realistic solutions i can think of:
* restart the system so it reloads from the database
* don't use OO over relational
* map tables and objects 1-1, which defeats the purpose
Is there a better way?
Erik Bengtson
Ranch Hand

Joined: Dec 06, 2003
Posts: 90
a JDO implementation will restore your persistent objects on a simple configuration:
tx.setRestoreValues(true);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: handling object restore on rollback