I am just wondering if within the listener I can get the previous state of the entity and compare it to the new state of the entity.
Kind of like how you can in a React framework.
Something like:
@Override
public void onBeforeUpdate(Entity existingState, Entity newState, EntityManager entityManager) {
if(previousState.someAttribute <> newState.someAttribute){
thenDoSomething()
}
I presume you would need to do some sort of native database query?
Or maybe would
Entity oldEntity = entityManager.find(Entity.class, newState.id)
load the old state of the entity from the database? Or would that just copy the current new state?
Or is there another solution?