• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Hibernate Surrogate key??

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Good night. Drive safely. Here's a tiny ad for the road:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic