R – Does Hibernate 2nd-Level cache invalidate when running a JPQL update statement

hibernatesecond-level-cache

When you run a JPQL update or delete query, is Hibernate smart enough to invalidate the 2nd-level cache for the entity that is changed?

Contrived example:

You have the JPQL:

update Product p set p.status = 'S' where p.name like 'Monitor%'

If you currently have products in the 2nd-level cache when that statement is run, will Hibernate invalidate all products from the cache or does it do nothing to the cache and the products in the 2nd level cache are now invalid?

Just FYI… I'm using JBoss 5.1 with Hibernate and JBossCache

Best Answer

After running my own test and running across this bug it appears that it will invalidate the ENTIRE second-level cache, not just the second-level cache for any entities involved in the update.

Related Topic