I have exactly the same problem.
I don't understand why it does't work because it's not very complicated.
Have you found any solutions to solve this problem ?
thanks a lot
sudhir wrote:
I have a mapping file parent.hbm.xml which contains
set of childs.
Parent.hbm.xml
-------------------
<set name="childSet" inverse="true" lazy="true" cascade="save-update" outer-join="true">
<key column="parent_id"/>
<one-to-many class="Child"/>
</set>
Child.hbm.xml
----------------
<many-to-one name="parent" column="parent_id" not-null="true"/>
In code:
--------
Parent p = new Parent();
//set other parent properties
HashSet s = new HashSet();
Child c = new Child();
//set other child properties
c.setParent(p);
s.add(c);
p.setChildSet(c);
Session session = getSessionFactory().openSession();
Transaction t = session.beginTransaction();
session.save(p);
t.commit();
session.close();
The above code is only creating parent entry in the db not child entry? why? Do I need to set any attributes in the mapping file in order to accomodate this?
I appreciate your help.