Search code examples
hibernatejava-8audithibernate-envers

How to save Logged User in Hibernate Envers audit table?


I just imported hibernate-envers 5.0.7 Final to my project dependencies. And everything is working fine with the "AUDITED" part. But I'd like to save the session's Logged User to the audit table as well (So it's possible to know which user changed what). Is there a way to implement that?

Currently i'm only using the annotation @Audited in my Entity class. So the audit table and the REVINFO table are working fine. But how would I "add" data to be audited, that's not mapped to the entity?


Solution

  • If the data is important for audit you need to add it to entities, with a updateUser et updateDate properties.