Skip to content

Commit

Permalink
Reproducer for native build failing due to UUID[] not being registere…
Browse files Browse the repository at this point in the history
…d for reflection

This seems to only affect PostgreSQL, so I didn't add tests for other DBs.

(cherry picked from commit 70d7a6b)
  • Loading branch information
yrodiere authored and gsmet committed Aug 15, 2023
1 parent 3f84706 commit d75a07c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit d75a07c

Please sign in to comment.