-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: inverse="true" allowed on both ends?
PostPosted: Wed Oct 19, 2005 5:25 pm 
Newbie

Joined: Wed Oct 19, 2005 5:16 pm
Posts: 2
Hibernate version: 3.0.5

Looking at the Hibernate 3 DTD here it appears that the many-to-one end of a bidirectional relationship does not support the inverse flag. This would seem to indicate that I can only set that flag on the collection side. Please clarify or point me to a clarification, a search on the forums and wiki did not turn up anything enlightening. All the example usage I have located has inverse on the collection side, but none mention that it may only be on that side.

While it's no longer strictly needed, finding this information would have helped me quite a bit several hours ago ;)

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 7:08 pm 
Beginner
Beginner

Joined: Tue Nov 25, 2003 3:33 pm
Posts: 35
inverse="true" means updates are done on the other side of the relationship.

If you have many-to-one association it means that the entity declaring the association say A has a reference to exactly one instance of the entity on the other side say B. While B has many instances of A refering to it. So it would not know what instance of A to update (especially if Many-To-One is unidirectional, which most of them are; think of Address (Many) - To - Country (One)).

In terms of DB tables it also makes no sense to have inverse attribute on many-to-one. If you have table A it will need b_id as FK to the PK of table B. So when you update/save an instance of A, you will not find a better way to update the b_id as to just update it on A's side.

HTH,
Alex.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 9:56 am 
Newbie

Joined: Wed Oct 19, 2005 5:16 pm
Posts: 2
Thanks for explaining that. In terms of inverse="true" on the many-to-one side I could imagine a system smart enough to know that in bidirectional relation A <>--<*B B1, B2, and B4 all need updating. I think I was also mixing up inverse and cascade, in terms of what does what when.

Anyway, thanks for the reply.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.