quarkusio/quarkus · error · RuntimeException

Incorrect loaded MyUUIDEntity " + myEntity

Error message

Incorrect loaded MyUUIDEntity " + myEntity

What it means

Assertion in the jpa-postgresql uuid endpoint. After persisting a MyUUIDEntity (ID generated as UUID) in one transaction and re-loading it with em.find in a new transaction, the entity was either null or its name was not 'George', meaning UUID-id persistence/lookup round-trip failed.

Source

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

    private static String randomName() {
        return UUID.randomUUID().toString();
    }

    @GET
    @Path("uuid")
    public String uuid() {
        var id = QuarkusTransaction.requiringNew().call(() -> {
            MyUUIDEntity myEntity = new MyUUIDEntity();
            myEntity.setName("George");
            em.persist(myEntity);
            return myEntity.getId();
        });

        QuarkusTransaction.requiringNew().run(() -> {
            var myEntity = em.find(MyUUIDEntity.class, id);
            if (myEntity == null || !"George".equals(myEntity.getName())) {
                throw new RuntimeException("Incorrect loaded MyUUIDEntity " + myEntity);
            }
        });
        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)

View on GitHub (pinned to e1c734241f)

Solutions

  1. Check MyUUIDEntity is annotated with @UuidGenerator (or equivalent) on the id and the column type is uuid
  2. Confirm the persisting transaction committed before the find (QuarkusTransaction.requiringNew)
  3. Enable SQL logging to see the INSERT and SELECT statements
  4. Verify the name field is not marked transient/ignorable

Example fix

// before
@Entity
public class MyUUIDEntity {
    @Id @GeneratedValue
    private UUID id;
}
// after
@Entity
public class MyUUIDEntity {
    @Id @UuidGenerator
    private UUID id;
}
Defensive patterns

Strategy: validation

Validate before calling

// before relying on UUID round-trip, verify the row exists
Long exists = (Long) em.createQuery("select count(e) from MyUUIDEntity e where e.id = :id")
        .setParameter("id", id).getSingleResult();
if (exists != 1) {
    throw new IllegalStateException("MyUUIDEntity " + id + " was not persisted");
}

Try / catch

try {
    MyUUIDEntity e = em.find(MyUUIDEntity.class, id);
    if (e == null) throw new AssertionError("Entity not found: " + id);
} catch (RuntimeException ex) {
    throw new AssertionError("UUID entity lookup failed", ex);
}

Prevention

When it happens

Trigger: em.find(MyUUIDEntity.class, id) in a fresh transaction returning null (row not committed, wrong UUID generation strategy) or a row whose name column wasn't persisted correctly.

Common situations: UUID generator misconfiguration (@UuidGenerator vs @GeneratedValue mismatch), transaction isolation/commit issues, or dialect problems with uuid column types in PostgreSQL.

Related errors


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