• 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

How to apply OneToOne mapping annotaion in hibernate.

 
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I always confuse in mapping ie Using of @OneToOne , @PrimaryKeyJoinColumn , @JoinColumn. On which side of entity class these annotations are used. And how to mark the entity class as Parent and Child class ?
 
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Here is one-to-one:



That's all there is to it. If you inverse the relation, it will inverse the owner of the relationship and the table the foreign column will be in.

 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Guddu Ali wrote:I always confuse in mapping ie Using of @OneToOne , @PrimaryKeyJoinColumn , @JoinColumn. On which side of entity class these annotations are used. And how to mark the entity class as Parent and Child class ?


Then you should definitely bookmark the Java Persistence WikiBook. It's an awesome resource with tons of code examples (using both XML and annotations). Here you'll find the OneToOne relationship.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic