That's the optimistic locking feature which can be used to prevent inappropriate usage of concurrent updates over an entity in the database. Simply you can use this @Version annotation to annotate a property of a primary entity.

Now, the version property manages a version value for the given entity in the database. It gets assigned a new value at each commit (to the database). In a concurrent scenario, let's say that the attributes in the same entity gets concurrently modified. Then, the first commit will be successful, because the version value in the entity instance, and which was in the database are identical to each other. This value will be changed once it is committed. After that, the second concurrent modification will not be allowed to commit - because the version value which IS in the database is different than the value in the entity instance itself. On that case OptimisticLockException will be thrown when you attempt to commit (or flush) the entity instance which has an incorrect version value. If there is an active transaction, that will be (marked) rolled-back so that it prevents the concurrent problem.