Optimistic locking in JPA Hibernate with a best simple way
Step 1: Remember this annotation
Think of it, add it to the Model @Entity or @Table which you want to apply
So everything is done
Step 2: Get detail in plenty of optimistic locking
https://www.logicbig.com/tutorials/spring-framework/spring-data/optimistic-lock.html
https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/chapters/locking/Locking.html
http://docs.jboss.org/hibernate/orm/6.0/userguide/html_single/Hibernate_User_Guide.html#locking-optimistic
@Version @Column(name="OPTLOCK") private long version;
Think of it, add it to the Model @Entity or @Table which you want to apply
@Entity
public class Employee{
private @Id
@GeneratedValue
Long id;
private String name;
private String dept;
private int salary;
@Version
private long version;
.............
}
So everything is done
Step 2: Get detail in plenty of optimistic locking
https://www.logicbig.com/tutorials/spring-framework/spring-data/optimistic-lock.html
https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/chapters/locking/Locking.html
http://docs.jboss.org/hibernate/orm/6.0/userguide/html_single/Hibernate_User_Guide.html#locking-optimistic
Comments
Post a Comment