Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Bi-directional mapping in Hibernate

 
Swerrgy Smith
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have read many documents to try to understand the nature of bi-directional mapping but I still do not get it.
All I understand is that it allows some kinds of "navigation" from one object to another object in 2 directions.

Can anyone explain this for me with a concrete example? Thank you very much.

Best.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35976
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the below code, we have a bi-directional mapping. The Parent entity has a reference to the Child entity. The Child entity has a reference to two Parent entities. Depending on the Hibernate settings, all this data may be loaded at once or it might be loaded later (lazy loading.) If this doesn't help, can you ask more specifically what you are wondering about?

 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!