quarkusio/quarkus · error · AssertionError

No entities with json were found

Error message

No entities with json were found

What it means

Assertion in the jpa-postgresql json endpoint. After storing EntityWithJson rows and querying 'select e from EntityWithJson e', the result list was empty, meaning the entities were never persisted (or the insert failed silently / hit a different table/schema).

Source

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

        return "OK";
    }

    @GET
    @Path("json")
    public String json() {
        QuarkusTransaction.requiringNew().run(() -> {
            EntityWithJson entity = new EntityWithJson(
                    new EntityWithJson.ToBeSerializedWithDateTime(LocalDate.of(2023, 7, 28)),
                    new SomeEmbeddable(100, LocalDate.of(2023, 7, 29)));
            em.persist(entity);
        });

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

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

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

View on GitHub (pinned to e1c734241f)

Solutions

  1. Enable SQL logging to confirm the INSERT executed and committed
  2. Verify the EntityWithJson mapping uses @JdbcTypeCode(SqlTypes.JSON) (Hibernate 6) for the json field
  3. Ensure the persisting block runs in QuarkusTransaction.requiringNew() and completes without swallowing exceptions
  4. Confirm the entity maps to the expected table in the current schema

Example fix

// before
@Column(columnDefinition = "json")
private String json;
// after (Hibernate 6)
@JdbcTypeCode(SqlTypes.JSON)
@Column(columnDefinition = "json")
private Map<String, Object> json;
Defensive patterns

Strategy: validation

Validate before calling

long count = em.createQuery("select count(e) from EntityWithJson e", Long.class).getSingleResult();
if (count == 0) {
    throw new IllegalStateException("No EntityWithJson rows persisted; check INSERT/commit");
}

Try / catch

try {
    QuarkusTransaction.requiringNew().run(() -> em.persist(entity));
} catch (RuntimeException e) {
    throw new AssertionError("persisting EntityWithJson failed", e);
}

Prevention

When it happens

Trigger: Persisting EntityWithJson in one transaction then querying all of them in a new transaction and getting an empty list — persist rolled back, JSON mapping failed before insert, or the query targets a different persistence unit/schema.

Common situations: Hibernate JSON mapping (hibernate-types / @JdbcTypeCode(SqlTypes.JSON)) misconfigured for the dialect, test schema not created, or transaction not committed before the read.

Related errors


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