When to use @Version and @Audited in Hibernate?

@Version is used to implement Optimistic locking with Hibernate, which means that no two transactions override the data at the same time with a conflict.
If the data is read by two threads at the same time, and both try to update the same row with different values,
Hibernate uses the @Version field to check if the row is already updated.
Before committing, each transaction verifies that no other transaction has modified its data.
If modified, the last transaction encounters a “Working with stale data” error.

@Audited is used to perform auditing functionality on entities part of Hibernate Envers

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)