Find dirty fields of an embedded object in an entity


Hibernate provides us two alternative paths to detect the changed/dirty fields of an entity, either before or after its update, via an interceptor or a listener.

I followed the second approach by implementing the PostUpdateEventListener and getting entity’s dirty properties (as indexes) by overriding void onPostUpdate(final PostUpdateEvent event). After combining them with the property names of the entity I ended up with the dirty property names of the entity.

The problem arises when the entity has dirty @Embedded properties, aka embeddable objects. The invocation of event.getDirtyProperties() returns only the index denoting the embeddable object of the entity (i.e. ProjectInformation projectInformation).

It seems that there is no way of getting the exact property (the dirty one) of the embeddable (i.e. String projectName).

Can you please help?

Thank you in advance!