advancedBulk Updates & Batch Processing
Why does a bulk JPQL update leave an already-loaded entity in the persistence context stale?
A bulk update executes as one SQL statement directly against the database, entirely bypassing entity loading and the persistence context. Hibernate has no way to know the bulk update affected a row corresponding to an already-managed entity, so that entity's in-memory field values won't reflect the change unless you explicitly refresh or clear the persistence context afterward.
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.
Why does a bulk JPQL update leave an already-loaded entity in the persistence context stale?