-->
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.  [ 1 post ] 
Author Message
 Post subject: About auto-generated keys and portability
PostPosted: Mon May 23, 2005 5:55 am 
Regular
Regular

Joined: Tue Oct 26, 2004 3:54 pm
Posts: 60
Hi,

this is just a "philosophical" question for the database gurus which inhabitate this forum.

Let's say I have an application which must be portable to different databases. My tables all have an auto-generated id as a primary key, and unique indexes on "business" keys. I found this practice as a suggested one often in Hibernate documentation.

Now, when I define a many-to-one it looks very simple and clever to use that primary key as the mapping key between parent and child tables.

But what happens if I must port the application to another database and I must export the already existing data ? The id fields are auto-generated and usually the database server doesn't like INSERTs which populate auto-generated keys. So I should let the DB regenerate the IDs. And the collections based on them would be all wrong then.

My solution is then to define <many-to-one> to map parent/child using the "business" keys (which can be multi-column). I don't really know if there's a better way to do this.

Any suggestions ?

Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.