Why does my JQL query return a different result than the equivalent CriteriaBuilder query?

前端 未结 1 1545
清酒与你
清酒与你 2021-01-28 18:14

I\'m using Dropwizard Hibernate and am having issues with my tests. I\'ve simplified this example as much as possible. I create a Foo, update it, and then try to fe

1条回答
  •  遥遥无期
    2021-01-28 18:36

    The Foo instance is still in the L1 cache i.e. the current session which is not touched by the update statement. Since Hibernate/JPA has to retain identity for entity objects of a session, it can't clear the session due to the update statement. Usually, one has to clear the session or refresh instances after an update statement to reflect the current state again.

    Try doing sessionFactory.getCurrentSession().clear(); instead at the start of your read transaction

    0 讨论(0)
提交回复
热议问题