quarkusio/quarkus · error · RuntimeException
Incorrect number of results
Error message
Incorrect number of results
What it means
A RuntimeException thrown by the JPAFunctionalityTestEndpoint.base smoke test when a Criteria query over Person returns a list whose size is not exactly 3. It indicates the database state (seeded persons) or query mapping differs from what the test expects. It is application-level test validation, not an ORM failure.
Source
Thrown at integration-tests/jpa-postgresql-withxml/src/main/java/io/quarkus/it/jpa/postgresql/JPAFunctionalityTestEndpoint.java:81
//Store some well known Person instances we can then test on:
QuarkusTransaction.requiringNew().run(() -> {
persistNewPerson("Gizmo");
persistNewPerson("Quarkus");
persistNewPerson("Hibernate ORM");
});
//Load all persons and run some checks on the query results:
QuarkusTransaction.requiringNew().run(() -> {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Person> cq = cb.createQuery(Person.class);
Root<Person> from = cq.from(Person.class);
cq.select(from).orderBy(cb.asc(from.get("name")));
TypedQuery<Person> q = em.createQuery(cq);
List<Person> allpersons = q.getResultList();
if (allpersons.size() != 3) {
throw new RuntimeException("Incorrect number of results");
}
if (!allpersons.get(0).getName().equals("Gizmo")) {
throw new RuntimeException("Incorrect order of results");
}
StringBuilder sb = new StringBuilder("list of stored Person names:\n\t");
for (Person p : allpersons) {
p.describeFully(sb);
}
sb.append("\nList complete.\n");
System.out.print(sb);
});
//Try a JPA named query:
QuarkusTransaction.requiringNew().run(() -> {
TypedQuery<Person> typedQuery = em.createNamedQuery(
"get_person_by_name", Person.class);
typedQuery.setParameter("name", "Quarkus");
final Person singleResult = typedQuery.getSingleResult();View on GitHub (pinned to e1c734241f)
Solutions
- Reset the database before the test run (drop/recreate schema or use a clean test container)
- Remove leftover Person rows from prior failed runs
- Verify the test setup/seed code that inserts exactly 3 Person entities actually ran
Example fix
// before
List<Person> allpersons = q.getResultList();
if (allpersons.size() != 3) {
throw new RuntimeException("Incorrect number of results");
}
// after
em.createQuery("delete from Person").executeUpdate(); // reset state in test setup
List<Person> allpersons = q.getResultList();
assertEquals(3, allpersons.size()); Defensive patterns
Strategy: validation
Validate before calling
long count = em.createQuery("select count(p) from Person p", Long.class).getSingleResult();
boolean datasetReady = count == 3; Prevention
- Reset/clean the Person table in test setup before assertions
- Make each test transactional with rollback to avoid dirty state
- Assert seed data was created before running query assertions
When it happens
Trigger: Running GET on the test endpoint after the Person table contains fewer or more than the 3 expected rows (Gizmo, Quarkus, etc.) - e.g. leftover data from a previous run or a failed seed step.
Common situations: Dirty database between test runs, concurrent tests mutating Person rows, or a changed persistence.xml/orm.xml that altered which entities are persisted.
Related errors
- No entities with json were found
- Default mapper cannot process date/time properties. So we we
- flush failed for a different reason than expected.
- No entities with XML were found
- Our custom XML format mapper throws exceptions. So we were e
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/b4cab7aee07aec62.
Report an issue: GitHub.