Business logic afterUpdate

Hi.

When I change a property of an object and save it, I need to know the value of the property before it was saved, and the value of the property after it has been saved. I have overriden afterUpdate of the object in business logic, but the property shows the same value in the both part objects, the part and the part in the result map. Both show the new saved result of the property. Is it supposed to work like this, and is there another way to know what have changed in afterUpdate?

@Async
@Override
public void afterUpdate(RunnerContext context, Part part, ExecutionResult<Part> result) throws Exception {
}

Hi Ludwig,

Where do you “change a property of an object and save it”? On the client side? Before the request reaches your business logic?

Regards,
Mark

Yeah I should have been more clear. That is exactly what I do.

And the column property that I change is a 1:N relation property. I need to know if the update added or removed a pointer, or if it was another property that changed. Currently if I add a relation on the client side and save, in afterUpdate, the length of the array containing the relations is always the same in the two objects that I retrieve in afterUpdate.

Do you switched autoload in the column to on?

Yeah autoload is on. The autoloaded object is accessible as it should from the Part object.

I just tested with the simple text property. It is the same with that property. If I change the text and call save, both the objects in afterUpdate shows the updated property.

I guess I understood your Problem now.

How about invoking a custom service?

Client sends updated object to custom service.
Service loads the actual object via persistence.
You can then distinguish what Kind of Operation (insert/update) will happen.
Save the newvalue, report to client whatever you like.

Yeah that could work thanks. I was just hoping the the afterUpdate metod would provide the object before the update and the object after the update, but I see now that this is not the case.

I’ll propose this as improvement.

Mark, is it possible to bring this as a feature onto roadmap?

(object before + object after update inside the AfterUpdateEvent)