I have developed a customer maintenance application. Users can alter the customer details via web interface. I want to handle the following scenario:
Use
one solution, when second request tends to update details first check if it is updated after details loaded, if so then raise exception and allow user to change after loading details again, you can use modification time stamp to compare
You just need to add a field annotated with @Version
:
public class Customer {
@Id
private Long id;
@Version
private Long version;
// rest of the fields, etc.
}
Read this article for more information.