Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One-to-One Relationship Mapping

 
Bal Krishna Gupta
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have two tables having one-to-one relationship where child table has the primary key of parent table as foreign key.
I used <one-to-one> tag in parent table and <many-to-one> in child table but it is searching the child record.

Can anyone help me out??
 
Matt Gaunt
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bal,

This sounds a little odd. If you have a <many-to-one> relationship within the child table, this would indicate that the parent table could have many children, and thus the relationship between the parent and the child should then be <one-to-many>.

Might be best if you could show us your mapping files. Or if you are not using mapping files, show us the two classes with the associated annotations.

Regards

Matt Gaunt
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed, the two sides of your mapping do not jive. If one side is one-to-one, the other side should be one-to-one. Alternatively, if one side is one-to-many, the other side should be many-to-one.

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic