• 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

Hibernate 1-0,1 relationship

 
Ranch Hand
Posts: 96
Scala VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

My team and I have been struggling with situations where a member object of a class might be null.

For instance:


Class B might never get populated. Our DB designer says A is the parent of B so B should have a foreign key reference to A. We can't seem to map this using one-to-one. We have tried many-to-one from A to B with unique="true" doesn't work if we have As without Bs (NULL violates uniqueness constraint). The only thing that I can see is the one-to-one using a primary key association, which would make the primary key in B match that of A. However, my DB guy really wants the foreign key relationship to be visible.

Any help is appreciated.
 
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for parent-child relationships between tables hibernate typically has a <subclass> XML mapping element. That again drills down to two conditions.
Whether the parent child relationships are in a single table(something like manager-employee, Cat-kittens) or two different tables (Car - benz, human - Samuel Cox).
you can map both of these relationships using hibernate.
 
Arun Kumarr
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can refer to this article.
 
On top of spaghetti all covered in cheese, there was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic