I have developed a customer maintenance application. Users can alter the customer details via web interface. I want to handle the following scenario:
User 1
loads customer1
details.User 2
loads customer1
details.User 1
changes and saves customer1
's name
.User 2
only changes and saves customer1
's age.In the scenario above, finally database holds customer1
's old name and the new age because User 2
overwrites User 1
's update. I'm using Hibernate. I had heard that Hibernate Automatic Versioning supports this. If any one know how to handle this please advise me.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With