• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

One to one mapping issue

 
Greenhorn
Posts: 5
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I need help on hibernate mapping.
I have a table “A” having primary key “A_ID”. And this “A_ID” primary column of table “A” is foreign key as well as primary key both in table ”B” .
That is “A_ID” is primary as well as foreign key (referencing table ”A”) in table “B” .

And “A_ID” in table “A” is created using a sequence “UNIQUE_ID_SEQUENCE”.

So my doubt is while making A.hbm.xml , I will be mapping primary key column “A_ID” of table “A” something like this


A.hbm.xml:
Correct me if I am wrong anywhere …
<id name="aid" type=”int” column="A_ID" >
<generator class="sequence">
<param name="sequence">UNIQUE_ID_SEQUENCE</param>
</generator>
</id>

B.hbm.xml


How will I be mapping primary key here ? Same as above ?

And moreover as A_ID is foreign key as well primary key in table “B” then should I provide foreign key mapping in B.hbm.xml also (provided the same column “A_ID is mapped as primary key also in B.hbm.xml”) ?
And what about using sequence inB.hbm.xml ?

Thanks & Regards
Vaibhav Bhardwaj
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic