2,使用乐观锁进行控制,大多数乐观锁基于数据版本(版本)记录机制,即向数据添加版本标识。In database version based solution, it is usually achieved by adding a version field to the database table.When the data is read out, the version number is read together, and then the version number is added when the update is updated.At this time, the version data of the submitted data is compared with the current version information corresponding to the database table. 如果提交的数据的版本号大于数据库表的当前版本号,它将被更新,否则将被认为是过时的。乐观的锁定机制避免数据库在长事务中被锁起来。没有数据库的数据锁定在用户A与B的操作,大大提高了大并发系统的整体性能。Hibernate乐观锁的实现建立在其数据访问引擎。应该指出的是,由于乐观锁机制是在我们的系统中实现,从外部系统操作用户更新不我们的系统控制,所以脏数据可以更新到数据库。