Could someone help me with the use case when to use @Version and @Audited in Hibernate?
Could someone help me with the use case when to use @Version and @Audited
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
@Versionis 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
@Versionfield 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.
@Auditedis used to perform auditing functionality on entities part of Hibernate Envers