-->
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: Pushing objects between databases
PostPosted: Wed Feb 02, 2005 7:17 pm 
Newbie

Joined: Wed Dec 08, 2004 7:07 pm
Posts: 2
Lets say i have obj1 with a child object obj2.
I also have hibernate running on one machine connected to a database, db1. I have another instance of hibernate running on another machine connected to a different database, db2.

If i serialize obj1 and sent to the second machine via a webservice, how do i get the second instance to persist the deserialized object properly?
The three situations are,
- both obj1, and obj2 haven't arrived at db2 before, we call save with the objects ids.
- both obj1 and obj2 have arrived before, we call update.
- obj1 is new, obj2 is not (or vis versa) and we have to somehow decide which objects to save and which ones to update.

Of course if we call update on a newly arrived object, hibernate will throw a StaleObject exception.
So how do we alter the behaviour to save 'stale' objects on db2?



Hibernate version:2


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 3:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
have you looked at saveOrUpdate ?

_________________
Max
Don't forget to rate


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.