quarkusio/quarkus · error · RuntimeException
Persons should have been deleted
Error message
Persons should have been deleted
What it means
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.
Source
Thrown at integration-tests/hibernate-orm-cache/src/main/java/io/quarkus/it/hibernate/orm/cache/HibernateOrmCacheTestEndpoint.java:484
em.createNativeQuery("Delete from Country").executeUpdate();
em.createNativeQuery("Delete from Pokemon").executeUpdate();
em.createNativeQuery("Delete from Trainer").executeUpdate();
});
}
private void testDeleteViaQuery() {
QuarkusTransaction.requiringNew().run(() -> {
em.createNativeQuery("Delete from Person").executeUpdate();
});
clearStatistics();
QuarkusTransaction.requiringNew().run(() -> {
if (em.find(Person.class, 1L) != null
|| em.find(Person.class, 2L) != null
|| em.find(Person.class, 3L) != null
|| em.find(Person.class, 4L) != null) {
throw new RuntimeException("Persons should have been deleted");
}
});
assertRegionStats(new Counts(0, 0, 4, 0), Person.class.
getName());
}
private void testDeleteViaRemove() {
clearStatistics();
QuarkusTransaction.requiringNew().run(() -> {
em.remove(em.find(Pokemon.class, 3));
em.remove(em.find(Pokemon.class, 248));
em.remove(em.find(Pokemon.class, 242));
});
View on GitHub (pinned to e1c734241f)
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
Example fix
// before
QuarkusTransaction.requiringNew().run(() -> em.createQuery("DELETE FROM Person").executeUpdate());
// verification assumes commit
// after
QuarkusTransaction.requiringNew().run(() -> { em.createQuery("DELETE FROM Person").executeUpdate(); });
// ensure flush+commit completed, then verify with a fresh transaction and cleared cache statistics Defensive patterns
Strategy: validation
Validate before calling
Long remaining = em.createQuery("SELECT COUNT(p) FROM Person p", Long.class).getSingleResult();
if (remaining != 0) throw new IllegalStateException(remaining + " persons still present after bulk delete"); Try / catch
try {
testDeleteViaQuery();
} catch (RuntimeException e) {
if (e.getMessage().equals("Persons should have been deleted")) {
// verify delete transaction committed and cache region invalidated
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Incorrect number of results
- Pokemons should have been deleted
- Incorrect cp: " + igeldo.getCp()
- Incorrect cp: " + godzilla.getCp()
- Incorrect cp: " + blissey.getCp()
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/d6ed478fdd466bfa.
Report an issue: GitHub.