Hello all, I ve recently started working on Hibernate. I have queries related to persisting collections and their associations.
My application has two POJOs FacilityBean and FloorBean mapping to entities Facility and Floor. FacilityBean has a set of floors as I want the set of floors associated with the facility to be retrieved along with it. And Floor has a Facility object as every floor belongs to a facility (there are no foreign keys involved).
I can persist the collection only when i am inserting both the entities together after setting the set of floors. I want to insert a new floor alone and also update the association table facility_floor like insert new floor object and the FM_FACILITY_ID and the FL_FLOOR_ID fields gets updated in the association table facility_floor.
Can anyone please help me to know how I can do this. I believe that hibernate will insert data into the association join table only when new entries of the entities like facility and floor are inserted together. Is there a way where I can insert floor object with existing facility and persist this as floors are added later to a facility. Please help. Thanks in advance, Viola
[ September 18, 2008: Message edited by: viola rotrigues ] [ September 18, 2008: Message edited by: viola rotrigues ]
Sneha N Rao
Greenhorn
Joined: Sep 18, 2008
Posts: 4
posted
0
hi friends, I found out how to do it now. This association is nothing but a parent and child association. And child and parent are both associated hence there is no change in the POJOs. Slight changes in the mapping xml.