I am new to Hibernate and I am reading the Hibernate in Action book. I am unable to understand Associations. We make an association bidirectional by setting inverse=true in the mapping file. The book example says there is a bidirectional relationship between Item and Bid. But in the table relationship diagram there is a primary key BID_ID in the BID table and a foreign key ITEM_ID which shows the association between Bid and item. The other association (ie the other way round ) between Item and BId, there is no foreign key in ITEM table. So just saying inverse=true, would that make it a bidirectional association . Don't we have to have a foreign key in the ITem table ?
If anyone could please explain me this or redirect me to an URL etc which could explain associations.
The bi-directional association you specify with Hibernate only exists in the Java application, not in the database. In other words, the inverse="true" you type into your configuration file means that 1) Hibernate fetches the "parent" object and the "child" object(s), 2) Hibernate says "hey, parent, here's your children", and then 3) Hibernate says "hey, children, here's your parent"
Even though the foreign key technically points from one table to another, and not the other way around, semantically that foreign key is a two-way relationship. Hibernate doesn't restrict itself on the technical but instead (and rightly so) handles things on the semantic level.