Hibernate first level cache - does it Sync?

后端 未结 3 769
广开言路
广开言路 2021-01-05 19:53

I am aware of the fact that Session is first level

3条回答
  •  庸人自扰
    2021-01-05 20:45

    The first-level (session level) cache ensures that the state of the persistent instances loaded by one transaction is isolated from the changes made by other transactions.

    So the changes made by s2 in a different transaction(T2) is not visible when you call s1.get(User.class, 1) in the first transaction, because this time Hibernate will fetch the User from the session level cache s1.

提交回复
热议问题