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

Hibernate Bi-directional associations: Many-Many mapping, inverse-true

 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I am a newbie to Hibernate, reading the "Hiberbate Quickly" by Patrick Peak, Nick Heudecker. In chapter 5 Collection and Custom Types, Bidirectional relations page 145, the author says "Changes made to the inverse end of association will not be persisted".

Can some please help in better understanding the above statement?
[ November 13, 2006: Message edited by: Santosh Ramachandrula ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well inverse just makes the bi-directional part happen so Hibernate knows that the two sides map the same relationship. It comes down to the cascade option to determine how relationships are persisted or not.

Mark
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark thanks for your response. So far what I have understood through some discussion is that::
In a many to many bi-directional mapping we would want to keep one of the mapping as inverse="true" so that only one table inserts the rows into JOIN TABLE thus avoiding attempting duplicate insertions in the JOIN TBALE and hence "Changes made to the inverse end of association will not be persisted"

Hope my explanation was clear enough
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic