Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Surrogate key??

 
Mohan Natarajan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 languge 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.
 
Loren Rosen
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you should use a Map, e.g. something like this in the hbm file for A:

<map name="B">
<key column="B_id" />
<index column="language" type="string" />
<one-to-many class="B"/>
</map>
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohan,

Welcome to JavaRanch.

Unfortunately your registered name does not meet our naming requirements.

Please go into your profile and change your name to include first and last name.

Thanks a lot

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic