Stale data found in Infinispan cache following Hibernate JPAQL UPDATE or DELETE in JBoss EAP

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.2
    • 7.3
  • Hibernate 5.3
  • Infinispan
    • 9.3
    • 9.4

Issue

  • A JPAQL operation is used to modify data in the database (e.g. entityManager.createQuery("update Employee e set e.title = 'Senior Engineer'").executeUpdate();)
  • The Infinispan cache region seems to be immediately purged
  • Any subsequent load of the relevant entities (from another thread) loads data into the cache which will be stale as soon as the database commit for the updating thread completes.
  • No invalidation of the cache region occurs following the database commit.
    • This is a change in behavior compared to EAP 7.1 / Hibernate 5.1 / Infinispan 8.2

Resolution

This issue will be addressed in a future release1.

As a workaround, a JPA update/delete may be performed using explicit entity update/merge operations rather than JPAQL.

Root Cause

This is a known defect (This content is not included.HHH-14232).

Diagnostic Steps

Enable TRACE for org.hibernate and org.infinispan

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.