开发者

Versioning in Hibernate's optimistic locking

开发者 https://www.devze.com 2023-02-12 15:55 出处:网络
I\'m new to Hibernate, and i\'m trying to understand @Version annotation. In all examples I\'ve seen it looks like 开发者_开发技巧I should provide special column in each table of my database. Am I rig

I'm new to Hibernate, and i'm trying to understand @Version annotation. In all examples I've seen it looks like 开发者_开发技巧I should provide special column in each table of my database. Am I right? I understand what optimistic lock means, but can I make only hibernate responsible for versioning and do not change database?


You should add a column to a table , if you want to use optimistic locking.. Well, it is not necessary to add a version column to all tables for optimistic locking, if Child entity is accessed and modified by means of Parent entity , then you dont have to put a version column to the table of Child entity..

Optimistic locking is powerful feature of O-R engines, it did not cause any performance loss or deadlock like database pessimistic locking, therefore it should be preferred ..

0

精彩评论

暂无评论...
验证码 换一张
取 消