Register / Login
this forum made possible by our volunteer staff, including ...
Roel De Nijs
Stephan van Hulst
Object Relational Mapping
how does cascade work under the covers for parent child enity relationship
posted 7 years ago
I have a parent child relationship
Parent Entity Child Entity, when I persist the child enity I wish to persist the parent.
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() this will then call a aspect which will populate the parentId
In my childEnity i have the following relation ship set up
@ManyToOne(cascade = CascadeType.ALL, targetEntity = ParentEntity.class)
private ParentEntity applicant;
As mentioned it does not work
calling childEntity.persist() then call the parentEntity.aj persist() method before it calls the childEntity.aj persist() method.
Or does calling childEntity.persist() only call childEntity.aj persist() and the parentEntity is persisted under the covers as part of the childEntity.persist() call.
If this is so then my aspect will never be called an I will need to rethink the logic.
Thanks for any help
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
Boost this thread!
Container trying to save CMR field
Hibernate entity referencing itself by foreign key
[Hibernate] Insert multiple record in one statement
cmr 1-many difficulty
CMR save problem