• 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

same primary key as foreign key in two table[Hibernate Mapping]

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

schema

TABLE_A
=========
id_a[PK]
tx_a_desc

TABLE_B
=========
id_b[PK]
id_a[FK]
tx_b_desc

TABLE_C
=========
id_c
id_a[FK]
tx_c_desc

With id_c and id_a as composite primary key for TABLE_C

What should be the best way to map these?
It�s not normal but I can't change the schema.

I am trying something like this for now

A.java [@Table(name = "TABLE_A")]


B.java [@Table(name = "TABLE_B")]


C.java [@Table(name = "TABLE_C")]


CompositeId.java [@Embeddable]


It works but it's wrong and may break in certain cases.
Ideally nullable should be false in both the cases in A's mapping,
But when I try this I get Repeated column in mapping

Please help
 
It's weird that we cook bacon and bake cookies. Eat this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic