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
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