-->
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: Copying from one database to another
PostPosted: Wed Feb 21, 2007 9:24 am 
Beginner
Beginner

Joined: Mon Dec 08, 2003 8:09 am
Posts: 25
Hi there,
I've not been able to find anything on this, so I thought it might be an idea to ask for help on a strategy on the Hibernate forums.

The problem we have is a relatively simple one at first glance: we need to take an object which exists in one database and copy it to another database whilst retaining the all fields within the object, including the id.

So, in one database we would have the object being initially persisted, and soon after a process connects to the this database, and obtains a copy of the object - which it then has to persist in another database. How do we go about telling Hibernate that in one instance we need it to assign an id, whilst in another we need it to preseve the id in memory? [Assuming the same mapping for both instances]

Jon


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 10:42 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
try session.replicate

from the apis
Quote:

Persist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped with cascade="replicate".

Parameters:
object - a detached instance of a persistent class


_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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.