简体   繁体   English

GenericHibernateDAO的方法findById中的“锁定”布尔值是什么意思?

[英]What does “lock” boolean mean in GenericHibernateDAO's method findById?

I am using hibernate. 我正在使用休眠模式。 When i have to find a specific entity, i want to use the findById(Long id, boolean lock) 当我必须找到特定实体时,我想使用findById(Long id,boolean lock)

method. 方法。 What value should i give to lock? 我应该给锁赋予什么价值?

The API for the method is here . 该方法的API在此处 You should put true if you want no chance of the value changing while you are getting it from the database. 如果您不希望在从数据库中获取值时就改变它的值,则应设置为true。

There are several overloaded findById. 有几个重载的findById。 You should choose one depending on the locking strategy you are using. 您应根据所使用的锁定策略选择一种。

I suggest read about optimist and pessimist locking. 我建议阅读有关乐观主义者和悲观主义者锁定的文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM