Hibernate LockModes/LockOptions

前端 未结 2 1499
北恋
北恋 2021-02-02 03:48

I am going through Hibernate Documentation an came across the LockModes. Are these same as Isolation levels that we use for database? How are they diff

2条回答
  •  别那么骄傲
    2021-02-02 04:12

    UPGRADE means that you want to modify the loaded object and you don't want any other process to change it while you're in the process.

    It's an odd combination to use load with UPGRADE, because load is generally used just to have reference to the object to be able to use it while modifying some other object. e.g.

    DomesticCat kitten = (DomesticCat)session.get(DomesticCat.class, 2L); kitten.setParent(d1);

    That is why if you use a load, Hibernate will only load it if you start referencing properties.

提交回复
热议问题