软锁只是一种特定的缓存值失效表述方式,在它获得新数据库值前阻止其他事务读写缓存。
A soft lock is just a special cache value invalidation representation that stops other transactions from reading or writing to the cache before it gets the new database value.
通过此策略,由于您未对数据保持读取锁,因此在执行更新操作时遇到失效数据异常的机率会增加。
With this strategy, because you are not holding read locks on data, the chance of getting stale data exceptions when you execute the update operations increases.
如果Hibernate不是独占数据库用户,乐观锁会失效,除非创建数据库触发器为其他应用程序对相同数据的变更增加版本字段值。
Optimistic locking will not work if Hibernate is not the sole database user, unless you create database triggers to increment the version column for the same data change by other applications.
应用推荐