Hibernate Automatic Versioning

前端 未结 2 1732
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 06:15

I have developed a customer maintenance application. Users can alter the customer details via web interface. I want to handle the following scenario:

  1. Use
相关标签:
2条回答
  • 2021-01-05 07:00

    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

    0 讨论(0)
  • 2021-01-05 07:17

    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.

    0 讨论(0)
提交回复
热议问题