diff --git a/integration-tests/jpa-postgresql/src/main/java/io/quarkus/it/jpa/postgresql/JPAFunctionalityTestEndpoint.java b/integration-tests/jpa-postgresql/src/main/java/io/quarkus/it/jpa/postgresql/JPAFunctionalityTestEndpoint.java index 0bc9b7d02b6e7..ac23341e763f4 100644 --- a/integration-tests/jpa-postgresql/src/main/java/io/quarkus/it/jpa/postgresql/JPAFunctionalityTestEndpoint.java +++ b/integration-tests/jpa-postgresql/src/main/java/io/quarkus/it/jpa/postgresql/JPAFunctionalityTestEndpoint.java @@ -57,6 +57,8 @@ private static void doStuffWithHibernate(EntityManagerFactory entityManagerFacto deleteAllPerson(entityManagerFactory); + // Try an entity using a UUID + verifyUUIDEntity(entityManagerFactory); } private static void verifyJPANamedQuery(final EntityManagerFactory emf) { @@ -144,6 +146,27 @@ private static String randomName() { return UUID.randomUUID().toString(); } + private static void verifyUUIDEntity(final EntityManagerFactory emf) { + EntityManager em = emf.createEntityManager(); + EntityTransaction transaction = em.getTransaction(); + transaction.begin(); + MyUUIDEntity myEntity = new MyUUIDEntity(); + myEntity.setName("George"); + em.persist(myEntity); + transaction.commit(); + em.close(); + + em = emf.createEntityManager(); + transaction = em.getTransaction(); + transaction.begin(); + myEntity = em.find(MyUUIDEntity.class, myEntity.getId()); + if (myEntity == null || !"George".equals(myEntity.getName())) { + throw new RuntimeException("Incorrect loaded MyUUIDEntity " + myEntity); + } + transaction.commit(); + em.close(); + } + private void reportException(String errorMessage, final Exception e, final HttpServletResponse resp) throws IOException { final PrintWriter writer = resp.getWriter(); if (errorMessage != null) { diff --git a/integration-tests/jpa-postgresql/src/main/java/io/quarkus/it/jpa/postgresql/MyUUIDEntity.java b/integration-tests/jpa-postgresql/src/main/java/io/quarkus/it/jpa/postgresql/MyUUIDEntity.java new file mode 100644 index 0000000000000..23997f53e5f09 --- /dev/null +++ b/integration-tests/jpa-postgresql/src/main/java/io/quarkus/it/jpa/postgresql/MyUUIDEntity.java @@ -0,0 +1,41 @@ +package io.quarkus.it.jpa.postgresql; + +import java.util.UUID; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity(name = "uuidentity") +public class MyUUIDEntity { + + @Id + @GeneratedValue(strategy = GenerationType.UUID) + private UUID id; + private String name; + + public MyUUIDEntity() { + } + + public MyUUIDEntity(UUID id, String name) { + this.id = id; + this.name = name; + } + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +}