When I do this:
Code:
...
Set<Child> mySet = new HashSet<Child>();
mySet.add(lots of stuff);
parent.setChildSet(mySet);
aSession.save(parent);
I get the error org.hibernate.TransientObjectException:.
I want to save Parent AND the child set when I call .save();, and set parent_fk in each child to equals the parent PK.
Code:
public class Parent
{
private Set<Child> childSet = new HashSeT<Child>();
public getChildSet()
{
return childSet;
}
}
Code:
public class Child
{
private Long parent_fk;
//Knows snothing of parent.
}
Code:
Parent Mapping
<set name="childSet">
<key column="parent_FK" />
<one-to-many class="Parent" />
</set>
Code:
Child Mapping
<property name="parent_FK" not-null="true" insert="true" type="java.lang.Long">
<column name="PARENT_FK"/>
</property>