Relationship between two tables will happen with foreignkey / joins /jointables.
Hibernate Supports Uni-directional, not bi-direction like
ejb 2.1 cmp (Drawback of ejb 2.1),
means
For ex:
we have two tables
1) goods – (Parent )
2) goods_record – (Child, foreign-key - goodsid)
Relationship between goods to goods_record is the one to many.
Relationship between goods_record to goods is the many to one.
Relationship of goods to goods_record Not Equals(!=) Relationship of goods_record to goods
Foreign-key goodsid maintain relationship between goods to goods_record
Same Foreign-key goodsid maintain relationship between goods_record to goods.
Relationship of Goods to Goods_Record:
Here Relationship owner is Goods, this relationshipowner will take care of parent and child relationship with updation of foreign-key, because foreign-key maintain relationship both of them.
Relationship Goods_Record to Goods
Here Relationship owner is Goods_Record, this relationshipowner will take care of parent and child relationship with updation of foreign-key, because foreign-key maintain relationship both of them.
In Bi-direction means we have 2 uni-directions like
1)Goods to Goods_Record
2) Goods_Record to Goods
In this scenario foreign-key will by updated by twice, which is not necessary because one uni-direction is enough maintain relationship between two tables.
To avoid the foreign-key updation twice, hibernate introduces “inverse=true”, it will maintain the relationship means nothing like uni-directional, so that we are avoided updation foreign-key twice.
Hope it will clarify all your doubts.
For source code with explanation, please contact me:
ramesh.niwas@gmail.com