-->
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.  [ 3 posts ] 
Author Message
 Post subject: Really using "assigned" ids
PostPosted: Sat Sep 25, 2004 6:55 pm 
Newbie

Joined: Thu Sep 09, 2004 5:09 am
Posts: 7
If I use "assigned" ids, saveOrUpdate, and cascaded collections appear to not function with unsaved objects that have their unique ids already assigned. In this sense "assigned" ids appear to be second class citizens.

I have an application where I need to be able to send my records from 1 database to another (a sort of home-brewed replication), keeping the same unique id. I basically open a hibernate session to the source database, and one to the destination database, and I use the same mapping, only the db connection differs. Then I basically query the objects I want from the source database, and then save them to the destination. If I use a generated id, like uuid.hex, that works for inserting the record in the source, but when i want to add an existing record from the src, to the dest, with the same id, using the same mapping, it won't work because the id is not null.

Now, if I change my ids to be assigned, this seems to work in some cases, if i avoid saveOrUpdate, and avoid putting these objects in collections that are cascaded from their owner. but i need these features.

I'm not complaining about the behaviour of "assigned" unique ids, although I think their status could be better documented in the manual. I'm really just looking for advice as to how to create a single mapping that allows the same objects to exist in 2 different databases, with an easy way to match up an object with its twin.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 27, 2004 9:47 pm 
Beginner
Beginner

Joined: Mon May 03, 2004 1:25 pm
Posts: 31
Have you set the "unsaved-value" on the id tag? It sounds like this might solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 4:01 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
hi
This is documented in the reference guide + Hibernate in Action. Plus your precise problem is in the FAQs.

Search the forum, for DB 2 DB migrations, I can remember some good discussions on that subject.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.