• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 5006
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
 
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic