quarkusio/quarkus · error · AssertionError

No entities with XML were found

Error message

No entities with XML were found

What it means

An AssertionError from hibernateXml when an HQL query 'select e from EntityWithXml e' returns no rows. The test expects at least one entity with an XML-mapped attribute to exist (written earlier in the test), so an empty result means the write step failed silently or was rolled back.

Source

Thrown at integration-tests/jpa-postgresql-withxml/src/main/java/io/quarkus/it/jpa/postgresql/JPAFunctionalityTestEndpoint.java:209

            //ignore this one
        }
    }

    @GET
    @Path("hibernate-xml")
    public String hibernateXml() {
        QuarkusTransaction.requiringNew().run(() -> {
            EntityWithXml entity = new EntityWithXml(
                    new EntityWithXml.ToBeSerializedWithDateTime(LocalDate.of(2023, 7, 28)));
            em.persist(entity);
        });

        QuarkusTransaction.requiringNew().run(() -> {
            List<EntityWithXml> entities = em
                    .createQuery("select e from EntityWithXml e", EntityWithXml.class)
                    .getResultList();
            if (entities.isEmpty()) {
                throw new AssertionError("No entities with XML were found");
            }
        });

        QuarkusTransaction.requiringNew().run(() -> {
            em.createQuery("delete from EntityWithXml").executeUpdate();
        });

        Exception exception = null;
        try {
            QuarkusTransaction.requiringNew().run(() -> {
                EntityWithXmlOtherPU otherPU = new EntityWithXmlOtherPU(
                        new EntityWithXmlOtherPU.ToBeSerializedWithDateTime(LocalDate.of(2023, 7, 28)));
                otherEm.persist(otherPU);
            });
        } catch (Exception e) {
            exception = e;
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Verify the earlier persist/flush of EntityWithXml succeeded (check for swallowed exceptions)
  2. Run the test against a clean database to rule out prior cleanup deleting rows
  3. Check whether the custom XML mapper caused a rollback before the select executes

Example fix

// before
List<EntityWithXml> entities = em.createQuery("select e from EntityWithXml e", EntityWithXml.class).getResultList();
if (entities.isEmpty()) { throw new AssertionError("No entities with XML were found"); }
// after
long count = (Long) em.createQuery("select count(e) from EntityWithXml e").getSingleResult();
assertTrue(count > 0, "EntityWithXml rows missing; seed step result=" + count);
Defensive patterns

Strategy: validation

Validate before calling

long count = em.createQuery("select count(e) from EntityWithXml e", Long.class).getSingleResult();
if (count == 0) { throw new AssertionError("Seed data missing before hibernateXml assertions"); }

Prevention

When it happens

Trigger: createQuery("select e from EntityWithXml e").getResultList() is empty inside a new transaction - earlier persist(s) of EntityWithXml did not commit, or the table was already cleaned.

Common situations: Custom XML FormatMapper throwing during flush (causing rollback of the seed data), test ordering issues, or leftover cleanup ('delete from EntityWithXml') from a previous run.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/3fd06d3883f6e877. Report an issue: GitHub.