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

How to apply OneToOne mapping annotaion in hibernate.

 
Guddu Ali
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
  • 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 ?
 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
  • 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.

 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic