This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate 1-0,1 relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate 1-0,1 relationship" Watch "Hibernate 1-0,1 relationship" New topic
Author

Hibernate 1-0,1 relationship

Samuel Cox
Ranch Hand

Joined: Nov 16, 2004
Posts: 96

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.
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

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.


If you are not laughing at yourself, then you just didn't get the joke.
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

you can refer to this article.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate 1-0,1 relationship