FYI: the Hibernate in Action book has a good explanation about the inverse attribute.
just a piece: ... This code is fine, but in this situation, Hibernate detects two different changes to the in-memory persistent instances. From the point of view of the database, just one value must be updated to reflect these changes: the ITEM_ID column of the BID table. Hibernate doesn�t transparently detect the fact that the two changes refer to the same database column, since at this point we�ve done nothing to indicate that this is a bidirectional association. We need one more thing in our association mapping to tell Hibernate to treat this as a bidirectional association: The inverse attribute tells Hibernate that the collection is a mirror image of the many-to-one association on the other side: <class name="Item" table="ITEM"> ... <set name="bids" inverse="true"> <key column="ITEM_ID"/> <one-to-many class="Bid"/> </set> </class> Without the inverse attribute, Hibernate would try to execute two different SQL statements, both updating the same foreign key column, when we manipulate the association between the two instances. By specifying inverse="true", we explicitly tell Hibernate which end of the association it should synchronize with the database. In this example, we tell Hibernate that it should propagate changes made at the Bid end of the association to the database, ignoring changes made only to the bids collection. Thus if we only call item.getBids().add(bid), no changes will be made persistent. This is consistent with the behavior in Java without Hibernate: If an association is bidirectional, you have to create the link on two sides, not just one. ... Walter [EMAIL PROTECTED] writes: >The following comment has been added to this issue: > > Author: Matthias Bohlen > Created: Mi, 20 Okt 2004 7:51 PM > Body: >Walter, > >I did not activate the "inverse" flag because the Hibernate manual says >nothing about its meaning! (Incredible but true!). > >Quote from the Hibernate reference manual (PDF version): > > "inverse (optional - defaults to false) mark this collection as the > 'inverse' end of a bidirectional association." > >This is the definition of a term using itself, isn't it? > >So, I prefer not to do anything with 'inverse' until I know precisely >what it means. > >Cheers... >Matthias > >--------------------------------------------------------------------- >View this comment: > >http://team.andromda.org:8080/jira/browse/HIB-2?page=comments#action_10336 > >--------------------------------------------------------------------- >View the issue: > http://team.andromda.org:8080/jira/browse/HIB-2 > >Here is an overview of the issue: >--------------------------------------------------------------------- > Key: HIB-2 > Summary: inverse="true" > Type: Improvement > > Status: Open > Priority: Minor > > Original Estimate: Unknown > Time Spent: Unknown > Remaining: Unknown > > Project: Hibernate Cartridge > > Assignee: Matthias Bohlen > Reporter: Walter Itamar Mourão > > Created: Di, 10 Aug 2004 5:32 PM > Updated: Mi, 20 Okt 2004 7:51 PM > >Description: >The use of inverse="true" should be default or based on the model. Maybe >the association navegability or a tagged value. > > >--------------------------------------------------------------------- >JIRA INFORMATION: >This message is automatically generated by JIRA. > >If you think it was sent incorrectly contact one of the administrators: > http://team.andromda.org:8080/jira/secure/Administrators.jspa > >If you want more information on JIRA, or have a bug to report see: > http://www.atlassian.com/software/jira > > > >------------------------------------------------------- >This SF.net email is sponsored by: IT Product Guide on ITManagersJournal >Use IT products in your business? Tell us what you think of them. Give us >Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out >more >http://productguide.itmanagersjournal.com/guidepromo.tmpl >_______________________________________________ >Andromda-devel mailing list >[EMAIL PROTECTED] >https://lists.sourceforge.net/lists/listinfo/andromda-devel --------------------------------------------------------------------------- Walter Itamar Mour�o - Diretor de Tecnologia e Projetos - Arcadian S/A www.arcadian.com.br ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ Andromda-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/andromda-devel
