nicolasl
nicolasl

Reputation: 441

Hibernate Envers SQL auditing

I was wondering if anyone had succeeded in auditing a native query (SQL) with Hibernate Envers? I know this is probably just wrong, but it would spare me a lot of refactoring time.

Cheers

Nick

Upvotes: 3

Views: 2675

Answers (1)

VimalKumar
VimalKumar

Reputation: 1850

I just want to leave my thoughts here so others might benefit when they choose to Envers. We tried Hibernate envers in one our recent project and it did not work out. Below are the reason

  1. Hibernate Envers captures the Audit information only when the updates happen through Persistence Context.
  2. We did not like one audit table for each entity. It was too much schema pollution.
  3. We have lot of batch jobs and data synchronization scripts that updates data directly using sql queries. Any update that is happening outside the persistence context will not be captured in these Hibernate ENvers created Audit tables.

SO we went with Database trigger appraoach with just only one AUDIT table which will capture the table_name, column_name, primary_key, old_value and new_value. It worked for us.

Upvotes: 3

Related Questions