My model:
Code:
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:
1. There is in DB a Father object with a Son object associated (bidir).
2. Load father from DB.
3. Update name field for father.
4. Update name field for son.
5. 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.