As explained on Zulip, the issue in this situation is the use of getReference() versus find(). In order for Envers to perform proper diff analysis on entity state, the entity must be loaded fully into the PersistenceContext. When using getReference(), the entity’s full state isn’t loaded by ORM and therefore only the primary key fields are available. Envers also does not lazily load this state because this can create other cascading concerns during the listener invocation. So we ultimately rely on the user to guarantee the entity’s state is loaded so the right audit state gets persisted. You can workaround and avoid this by using EntityManager#find() rather than EntityManager#getReference(). |