Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
walter wang
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic