• 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

One-to-One Relationship Mapping

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic