开发者

LockMode.READ in Hibernate

开发者 https://www.devze.com 2023-03-04 22:54 出处:网络
I\'m new to Hibernate and trying to understand more about the LockModes. I found below text in book \"Java Persistence with Hibernate\":

I'm new to Hibernate and trying to understand more about the LockModes.

I found below text in book "Java Persistence with Hibernate":

LockMode.READ—Bypass all caches, and perform a version check to verify that the object in memory is the same version that currently exists in the database.

Does that mean, calling session.lock(myObject, LockMode.READ), will refresh myObject state from Database? From "version check" I understand that Hibernate will check the version of myObject with Database, and if there is a difference it will synchronize instance of myObject with that of data开发者_运维技巧base.

I should also mention that after synchronizing the myObject instance with database, Hibernate will attach the myObject instance with persistence context (or session).

Isn't that correct?

0

精彩评论

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

关注公众号