*
The moose likes Object Relational Mapping and the fly likes how to interpret this relation(optional one to one) in Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "how to interpret this relation(optional one to one) in Hibernate" Watch "how to interpret this relation(optional one to one) in Hibernate" New topic
Author

how to interpret this relation(optional one to one) in Hibernate

walter wang
Ranch Hand

Joined: Jun 02, 2001
Posts: 150
Dear All,

I encounter a problem
as below

Table A which uses one composite key pair as primary key

and Table B which refers Table A 's primary key as it own Primary key

Every record in Table B should one record stored in Table A
but
every record in Table A has 0 or 1 record stored in Table B?

How do I interpret this relation into Hibernate Mapping?

one direction one to one ?
or a inheritance mapping?

Thanks in advance?


public class Walter { public boolean is_Working_Now (boolean is_boss_Coming) { return is_boss_Coming; }
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Yes, you can actually do either. But I think you will find that you will have one side defined as one-to-one and in the other direction it being one to many.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to interpret this relation(optional one to one) in Hibernate
 
Similar Threads
One table Sequeunce key mapping into another table
Hibernate many-to-one composite key as foreign key
about one to one
mapping for duplicate rows
Hibernate Mapping problem because no primary key in database