I have a somewhat special structure that I am trying to cascade over. I have tried almost everything but I can't get it to work. The structure looks a little bit like this:
Code:
public class Container {
long id;
Set<AbstractParentClass> items;
}
public abstract class AbstractParentClass {
Container container;
long id;
}
public class Child1 extends AbstractParentClass {
String foo;
}
public class Child2 extends AbstractParentClass {
String bar;
}
I have a ContainerDAO and would like to be able to cascade and save the children when I save the Container. I write my mapping file something like this for the Container:
Code:
<set
name="items"
cascade="all"
lazy="false" >
<key column="itemsId" />
<one-to-many class="AbstractParentClass" />
</set>
But I always get an org.hibernate.TransientObjectException for the Child classes. Is there a solution except persisting the child objects before persisiting the Container?