A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Object Relational Mapping
Hibernate : Bidirectional Association
Joined: Feb 27, 2006
Jun 21, 2008 10:38:00
Assume one to many relationship exists between Item and Bid and is bidirectional. As we need to access them in either way,to save an item, we need to write :
Set bidset = new
item.setBids(bidset);// Line 2
suppose i only comment line 1 and then save item :
a)it's inserting into ITEM table
b) It's inserting into BID table but the FK (ITEM_ID) is setting as null...
So this means i won;t be able to retrieve bids from this item.. ?
suppose i only comment line 2 and then save bid :
a) insert into bid
b) insert into item
c) update bid to set FK (ITEM_ID) properly
Moreover i don't understand that why in case 2) it executed the update (c)
while in case 1) it doesn't ?
Have you checked out
subject: Hibernate : Bidirectional Association
inverse attribute - too confusing !!!
Inverse Attribute : Serious Problem
Item - Bid example not working
Cascade-save HELP !!!!
Too many queries , JDBC vs Hibernate
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015