Controlling when SQL UPDATE is executing on ehcache 'd classes

Posted by thomers on Stack Overflow See other posts from Stack Overflow or by thomers
Published on 2010-05-05T08:53:34Z Indexed on 2010/05/05 14:08 UTC
Read the original article Hit count: 201

Filed under:
|
|

We are using Hibernate and ehcache as 2nd level cache.

If I load an entity that is cached (e.g. cache-usage="read-write") and update it, it seems that this immediately results in an SQL UPDATE.

(How) Can I influence when this SQL UPDATE happens?

        hibSession = HibernateUtil.getReadWriteSession();
        tx = hibSession.beginTransaction();
        User u = (User) hibSession.load(User.class, user_id);
        u.modify();
        hibSession.update(u);
        tx.commit();

Edit: It seems that setting a CacheMode should have an effect, but each hibSession.update() results in an immediate SQL UPDATE, regardless which CacheMode I set.

© Stack Overflow or respective owner

Related posts about ehcache

Related posts about hibernate