{"record":{"id":"d6ed478fdd466bfa","repo":"quarkusio/quarkus","slug":"persons-should-have-been-deleted","errorCode":null,"errorMessage":"Persons should have been deleted","messagePattern":"Persons should have been deleted","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"integration-tests/hibernate-orm-cache/src/main/java/io/quarkus/it/hibernate/orm/cache/HibernateOrmCacheTestEndpoint.java","lineNumber":484,"sourceCode":"            em.createNativeQuery(\"Delete from Country\").executeUpdate();\n            em.createNativeQuery(\"Delete from Pokemon\").executeUpdate();\n            em.createNativeQuery(\"Delete from Trainer\").executeUpdate();\n        });\n    }\n\n    private void testDeleteViaQuery() {\n        QuarkusTransaction.requiringNew().run(() -> {\n            em.createNativeQuery(\"Delete from Person\").executeUpdate();\n        });\n\n        clearStatistics();\n\n        QuarkusTransaction.requiringNew().run(() -> {\n            if (em.find(Person.class, 1L) != null\n                    || em.find(Person.class, 2L) != null\n                    || em.find(Person.class, 3L) != null\n                    || em.find(Person.class, 4L) != null) {\n                throw new RuntimeException(\"Persons should have been deleted\");\n            }\n\n        });\n\n        assertRegionStats(new Counts(0, 0, 4, 0), Person.class.\n\n                getName());\n    }\n\n    private void testDeleteViaRemove() {\n        clearStatistics();\n\n        QuarkusTransaction.requiringNew().run(() -> {\n            em.remove(em.find(Pokemon.class, 3));\n            em.remove(em.find(Pokemon.class, 248));\n            em.remove(em.find(Pokemon.class, 242));\n        });\n","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/hibernate-orm-cache/src/main/java/io/quarkus/it/hibernate/orm/cache/HibernateOrmCacheTestEndpoint.java#L466-L502","documentation":"RuntimeException thrown by testDeleteViaQuery when, after executing a bulk delete query, at least one of Person IDs 1-4 is still loadable via em.find(). The test asserts that delete-by-query removed the rows and that the second-level cache correctly invalidated/evicted the Person entries.","triggerScenarios":"A JPQL bulk delete (DELETE FROM Person) ran but rows remain: the delete did not match the rows, was rolled back, or em.find resurrects entities from a not-yet-invalidated second-level cache region within the verification transaction.","commonSituations":"Bulk delete executed in a transaction that failed to commit; cache invalidation misconfigured so stale Person entities are still cached; delete query filter (WHERE clause) does not match seeded rows; running against a DB where another writer recreated the rows.","solutions":["Verify the delete query transaction commits before the verification transaction starts (QuarkusTransaction.requiringNew boundaries)","Check that the second-level cache region for Person is invalidated after bulk delete (Hibernate invalidates regions on bulk operations only when configured)","Run the delete query without restrictive WHERE clauses so all seeded Persons are removed","Confirm no other transaction/process re-inserts Person rows between delete and verification"],"exampleFix":"// before\nQuarkusTransaction.requiringNew().run(() -> em.createQuery(\"DELETE FROM Person\").executeUpdate());\n// verification assumes commit\n// after\nQuarkusTransaction.requiringNew().run(() -> { em.createQuery(\"DELETE FROM Person\").executeUpdate(); });\n// ensure flush+commit completed, then verify with a fresh transaction and cleared cache statistics","handlingStrategy":"validation","validationCode":"Long remaining = em.createQuery(\"SELECT COUNT(p) FROM Person p\", Long.class).getSingleResult();\nif (remaining != 0) throw new IllegalStateException(remaining + \" persons still present after bulk delete\");","typeGuard":null,"tryCatchPattern":"try {\n    testDeleteViaQuery();\n} catch (RuntimeException e) {\n    if (e.getMessage().equals(\"Persons should have been deleted\")) {\n        // verify delete transaction committed and cache region invalidated\n    }\n}","preventionTips":["Commit the bulk-delete transaction before verifying with a new transaction","Confirm bulk operations invalidate affected cache regions","Avoid WHERE clauses that can silently match zero rows"],"tags":["hibernate-orm","cache","bulk-delete","integration-test"],"backgroundTag":"delete-did-not-persist","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}