Hi,
hibernateSession.createQuery("select foo where id = 1");
// This command return the Item with id 1.
// [BREAK POINT STOP] ==> I go in MySQL and I delete this item manualy.
// [BREAK POINT CONTINU]
hibernateSession.createQuery("select foo where id = 1");
// This command return the Item with id 1 too ! :-(
It's the same with hibernateSession.flush()/hibernateSession.clean()
I think I don't well use my hibernate cache...
views:
395answers:
3
+1
A:
Definitely a caching issue. Are you using the same session? Try closing the session and getting a new one from the factory.
Mike Pone
2009-05-20 15:41:41
+1
A:
Try this
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 you're problem is with the L1 cache. The L1 cache is ALWAYS there, is associated with a given Session object and is independent of the L2 cache which is what all the hibernate cache documentation talks about. 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 r1 == r2.
Basically, using hibernate when there can be concurrent modifications to the DB is not straightforward.
Jherico
2009-05-20 17:20:21