My model:
public class Father {
Set<Son> sons = new HashSet<Son>();
String name = null;
Date lastSonModifyDate = null;
// ... other fields and setters/getters
}
public class Son {
Father father = null;
String name = null;
Date lastModifyDate = null;
// ... other fields and setters/getters
}
Use case:
- There is in DB a
Father
object with aSon
object associated (bidir). - Load from DB father.
- Update name field for father.
- Update name field for son.
- Persist father.
My interceptor first detects father updates (onFlushDirty). Then executes the onFlushDirty for the son. In this case, I update son.lastModifyDate and also father.lastSonModifyDate.
When execution ends, all updates are persisted except father.lastSonModifyDate. I think this is because father is in session and has been updated before son, so this entity overrides the changes done in onFlushDirty method for the son entity.
How could I achieve my mark (set father's lastSonModifyDate from son interceptor)?
Thanks.