-->
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: Alternative to Session.replicate()?
PostPosted: Mon Jun 04, 2007 3:13 pm 
Newbie

Joined: Mon Jun 04, 2007 12:27 pm
Posts: 2
Dear Hibernate forum,

I'm implementing import/export functionality in our project that is using
Hibernate as a data persistence layer. I would like to import objects
previously exported to XML back to the database preserving their original ids.

Objects are deserialized from XML using XStream (http://xstream.codehaus.org)
with some customizations (deserialization also restores original id to the transient object).
After deserialization I would like to save the transient object to the database ideally
using something similar to Session.replicate() (ReplicationMode gives perfect sense
in this case and I would probably let the user choose which kind of import
is preferable).

The problem is that Session.replicate(object, replicationMode) requires
the object to be detached instance for some reason.

I was thinking about trying to "fake" Hibernate to accept transient
instances received from deserialization as detached instances in
replicate(), but this seems a bit unsafe (How exactly does Hibernate
distinguish between detached and transient instance?).

Another idea was to use 'assigned' ids instead of id-generator, but I would
consider this as a "last-resort" solution.

Do you have any suggestions how to accomplish such import that would preserve original ids?
Any comments would be highly appreciated.
Best Regards!

--
Pavol Juhos


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 11:36 pm 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
Have you tried session.persist()?

_________________
Don't forget to rate the reply if it helps..:)

Budyanto


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.