0

I am using nhibernate envers for auditing. creating a corrosponding audit table for each table in database.

Envers needs two fields mandatory: one version and another timestamp.

but version field is also needed in main table for optimistic concurrency.

lets say: TableA { id , version , name } then as per envers the audit table with have: { id, version, name, revision, revisionType }

the fields in audit table: version and revision would be exactly same, both contains the version of an entry.

If i remove the version field from main table, then optimistic concurrency will not work with nhibernate and for envers it is mandatory to specify a revision field.

how can i deal with this situation?

Roger
  • 1,944
  • 1
  • 11
  • 17

1 Answers1

2

The Envers version and the Optimistic Concurrency version fields are different things. You should probably rename one or the other, if these are the default names.

adamw
  • 8,038
  • 4
  • 28
  • 32
  • understand, but its kind of not a good thing to have 2 fields containing exactly the same information :(. hence trying to look at a solution using which i can avoid it.... –  Mar 16 '13 at 16:15
  • Well, the information is different. The optimistic locking version should be present only in the "live" (current) entities. It doesn't make sense to audit it. On the other hand, the Envers version is present only in audited entities. – adamw Mar 16 '13 at 17:27