Re: Validation and @PrePersist

2017-03-01 Thread Matt Watson
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.

EventManager example usages

2015-09-14 Thread Matt Watson
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

Re: Implementing and audit log using Cayenne; finding what was modified in an object

2015-08-07 Thread 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