-->
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: Surrogate key?
PostPosted: Mon Jun 28, 2004 1:39 am 
Newbie

Joined: Mon Jun 28, 2004 1:33 am
Posts: 1
I have table A with Code and other fields and table B with Code, description and language. I want to associate these two table to show the Code and other fields from table A with description in user langugae from table B to the user.
Now, the primary key in table B is composite, but not all the fields of B is availble in A (language is missing). What do I do?
If I try to create a surrogate key in table B (using an identifier) then the primary key won't be composite, but I cannot use the same identifier in table A. Because if I put the identifier say 123 for combination "1, Some_Desc, EN" in the table A, then the data becomes language specific whereas I should store the data non-language specific to be able to display in user languge!!!
I am stuck with this, please help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2004 8:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Well there are two approaches I have used to handle this in Hibernate 2.1.x:
1) Use a custom UserType to manage the association. The UserType can be aware of the current language/locale and select the appropriate row. Here the FK between the two would just need to be the CODE.
2) Map this using a <map/>. Again the FK between the two would be the CODE; the map would be keyed by language/locale and its value would be the appropriate description for that language/locale key.


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.