When I ran into this same scenario I realized that “validateForInsert” was the
hook I needed, instead of @PrePersist.
@Override
public void validateForInsert(ValidationResult validationResult) {
if (getReference() == null || getReference().isEmpty()) {
setReference(System.
void didUpdate() {
this.getSalesOrder().sync();
}
}
Was hoping to find something that I can execute after the commit of all objects
is done, but call sync on the SalesOrder once. Can the EventManager help with
this?
post-commit listeners?
Thanks,
Matt Watson
We do this by extending the CayenneDataObject class and introducing a HashMap
that tracks the original value of the properties that have changed.
Override the writeProperty/setToOneTarget (we only care about auditing
attributes and belongsTo relationships.
Then when it comes time to Insert/Updat