Hibernate - same result after update / select
hibernateSession.createQuery ("select foo where id = 1");
// This command returns the item with id 1.
// [BREAK POINT STOP] ==> I am going to MySQL and I delete this item manually.
// [BREAK POINT CONTINU]
hibernateSession.createQuery ("select foo where id = 1");
// This command returns item ID 1 too! :-(
This is the same with hibernateSession.flush () / hibernateSession.clean ()
I guess I am not using my hibernate cache ...
try it
Object o = hibernateSession.createQuery("select foo where id = 1").uniqueResult();
// [BREAK POINT STOP] ==> I go in MySQL and I delete this item manualy.
hibernateSession.evict(o);
hibernateSession.createQuery("select foo where id = 1");
If that works, then the problem is with the L1 cache. The L1 cache is ALWAYS there, associated with the given Session object and does not depend on the L2 cache, which is what all the hibernation cache documentation says. The purpose of the L1 cache is to satisfy the requirement that if you get the same database object twice in the same session, the two references will satisfy the requirement r1 == r2.
In principle, using hibernation when concurrent changes to the database are possible is not easy.
a source to share