I have a parent child relationship
Parent Entity Child Entity, when I persist the child enity I wish to persist the parent.
childEntity.persist()
The parent enity id is autogenerated when persisted.
As you can guess when I call childEntity.persist() I get the id must be set for the parentEntity, before the childEnity can be persisted.
when I call childEnity.persist() I want hibernate to carry out the following actions:
parentEnity.persist() childEntity.persist()
In my childEnity i have the following relation ship set up
@NotNull @ManyToOne(cascade = CascadeType.ALL, targetEntity = ParentEntity.class) @JoinColumn(name="child_parent_id", referencedColumnName="parent_id") private ParentEntity applicant;
As mentioned it does not work, do I need to set anything else. To get cascade to work , an just want to check you can cascade from child to parent, as well as parent down to child
Cheers
|