We are using JBossCache with Hibernate and we noticed a very unexpected and wrong cache behavior. This could also be a bug in Hibernate, but anyhow, the problem is very serious and I would very much appreciate any information.
The thing is that changed data remains in the second-level cache even if the changes are not successfully flushed into the database, or if the transaction has been explicitly rolled-back.
Here is one simple way to reproduce the problem:
SomeObject o = session.get(SomeObject.class, 1); o.setSomeProperty("a value too long for the DB field"); // to trigger exception session.flush();
You need to use JTA transactions. JBossCache's transactional support is based on JTA transactions; it has no knowledge of non-JTA Hibernate transactions.