diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/basicproxy/BasicProxyTestEndpoint.java b/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/basicproxy/BasicProxyTestEndpoint.java deleted file mode 100644 index 4183abf7519111..00000000000000 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/basicproxy/BasicProxyTestEndpoint.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.quarkus.it.jpa.h2.basicproxy; - -import java.io.IOException; -import java.util.List; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.event.Observes; -import jakarta.inject.Inject; -import jakarta.persistence.EntityManager; -import jakarta.transaction.Transactional; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.core.MediaType; - -import io.quarkus.runtime.StartupEvent; - -@ApplicationScoped -@Path("/jpa-h2/testbasicproxy") -@Produces(MediaType.TEXT_PLAIN) -public class BasicProxyTestEndpoint { - - @Inject - EntityManager entityManager; - - @Transactional - public void setup(@Observes StartupEvent startupEvent) { - ConcreteEntity entity = new ConcreteEntity(); - entity.id = "1"; - entity.type = "Concrete"; - entityManager.persist(entity); - } - - @GET - public String test() throws IOException { - final List list = entityManager.createQuery("from ConcreteEntity").getResultList(); - if (list.size() != 1) { - throw new RuntimeException("Expected 1 result, got " + list.size()); - } - return "OK"; - } -} diff --git a/integration-tests/jpa-h2/src/main/resources/application.properties b/integration-tests/jpa-h2/src/main/resources/application.properties index 889612ceae6cd3..45d910294f7ed0 100644 --- a/integration-tests/jpa-h2/src/main/resources/application.properties +++ b/integration-tests/jpa-h2/src/main/resources/application.properties @@ -1,5 +1,4 @@ quarkus.datasource.jdbc.max-size=8 quarkus.hibernate-orm.database.generation=drop-and-create -dummy.transaction.timeout=30 transaction.timeout.1s=1 diff --git a/integration-tests/jpa-h2/src/test/java/io/quarkus/it/jpa/h2/JPAFunctionalityTest.java b/integration-tests/jpa-h2/src/test/java/io/quarkus/it/jpa/h2/JPAFunctionalityTest.java index 986926d4ae2a12..a13d79e2f7024d 100644 --- a/integration-tests/jpa-h2/src/test/java/io/quarkus/it/jpa/h2/JPAFunctionalityTest.java +++ b/integration-tests/jpa-h2/src/test/java/io/quarkus/it/jpa/h2/JPAFunctionalityTest.java @@ -20,14 +20,4 @@ public void testJPAFunctionalityFromServlet() throws Exception { RestAssured.when().get("/jpa-h2/testfunctionality").then().body(is("OK")); } - @Test - public void testHibernateEnhancedProxies() throws Exception { - RestAssured.when().get("/jpa-h2/testproxy").then().body(is("OK")); - } - - @Test - public void testHibernateEnhancedBasicProxies() throws Exception { - RestAssured.when().get("/jpa-h2/testbasicproxy").then().body(is("OK")); - } - } diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/generics/AbstractGenericMappedSuperType.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/generics/AbstractGenericMappedSuperType.java similarity index 86% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/generics/AbstractGenericMappedSuperType.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/generics/AbstractGenericMappedSuperType.java index d93b8d28d0a747..853f37d9f79464 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/generics/AbstractGenericMappedSuperType.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/generics/AbstractGenericMappedSuperType.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2.generics; +package io.quarkus.it.jpa.generics; import jakarta.persistence.Basic; import jakarta.persistence.Lob; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/generics/IntermediateAbstractMapped.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/generics/IntermediateAbstractMapped.java similarity index 96% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/generics/IntermediateAbstractMapped.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/generics/IntermediateAbstractMapped.java index fb1ca748d36714..4ccbe37ee7ad30 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/generics/IntermediateAbstractMapped.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/generics/IntermediateAbstractMapped.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2.generics; +package io.quarkus.it.jpa.generics; import java.io.Serializable; import java.util.Objects; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/generics/SnapshotEventEntry.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/generics/SnapshotEventEntry.java similarity index 95% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/generics/SnapshotEventEntry.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/generics/SnapshotEventEntry.java index f44a4f87dc7b26..a2ef3e11440f3d 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/generics/SnapshotEventEntry.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/generics/SnapshotEventEntry.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2.generics; +package io.quarkus.it.jpa.generics; import jakarta.persistence.Entity; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/basicproxy/AbstractEntity.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/AbstractEntity.java similarity index 95% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/basicproxy/AbstractEntity.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/AbstractEntity.java index eac2f692343739..7adac2ceb7381c 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/basicproxy/AbstractEntity.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/AbstractEntity.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2.basicproxy; +package io.quarkus.it.jpa.proxy; import java.io.Serializable; import java.util.Objects; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/Cat.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Cat.java similarity index 86% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/Cat.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Cat.java index b1ff52532b1e42..260bc11a73f208 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/Cat.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Cat.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2.proxy; +package io.quarkus.it.jpa.proxy; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/CompanyCustomer.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/CompanyCustomer.java similarity index 91% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/CompanyCustomer.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/CompanyCustomer.java index 7e03220c7a8e28..4bc86c874a9432 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/CompanyCustomer.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/CompanyCustomer.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2; +package io.quarkus.it.jpa.proxy; import jakarta.persistence.Entity; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/basicproxy/ConcreteEntity.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/ConcreteEntity.java similarity index 85% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/basicproxy/ConcreteEntity.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/ConcreteEntity.java index ba1b07d4bac837..48a58872a4903e 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/basicproxy/ConcreteEntity.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/ConcreteEntity.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2.basicproxy; +package io.quarkus.it.jpa.proxy; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/Customer.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Customer.java similarity index 87% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/Customer.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Customer.java index 960a417b6bff12..458973c6554f4b 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/Customer.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Customer.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2; +package io.quarkus.it.jpa.proxy; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/Dog.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Dog.java similarity index 94% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/Dog.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Dog.java index 6be1e4e5ac3308..30e16e8356b2a2 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/Dog.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Dog.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2.proxy; +package io.quarkus.it.jpa.proxy; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/DogProxy.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/DogProxy.java similarity index 77% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/DogProxy.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/DogProxy.java index 55bf0a66902f2a..d128fee16fe11c 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/DogProxy.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/DogProxy.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2.proxy; +package io.quarkus.it.jpa.proxy; public interface DogProxy { diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/IndividualCustomer.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/IndividualCustomer.java similarity index 80% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/IndividualCustomer.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/IndividualCustomer.java index e76267b2e731bb..48c5fc23166a1c 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/IndividualCustomer.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/IndividualCustomer.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2; +package io.quarkus.it.jpa.proxy; import jakarta.persistence.Entity; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/Pet.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Pet.java similarity index 95% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/Pet.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Pet.java index fad96348116ea3..8da2622a49b812 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/Pet.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Pet.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2.proxy; +package io.quarkus.it.jpa.proxy; import jakarta.persistence.DiscriminatorColumn; import jakarta.persistence.DiscriminatorValue; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/PetOwner.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/PetOwner.java similarity index 95% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/PetOwner.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/PetOwner.java index 93fe8efa7c6fb6..8c430db0c82bbd 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/PetOwner.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/PetOwner.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2.proxy; +package io.quarkus.it.jpa.proxy; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/PetProxy.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/PetProxy.java similarity index 60% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/PetProxy.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/PetProxy.java index 225f4b56a64ace..cac54dad6f5d55 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/PetProxy.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/PetProxy.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2.proxy; +package io.quarkus.it.jpa.proxy; public interface PetProxy { diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/Project.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Project.java similarity index 92% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/Project.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Project.java index b7ad744063c375..3e6f81258dc84e 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/Project.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/Project.java @@ -1,4 +1,4 @@ -package io.quarkus.it.jpa.h2; +package io.quarkus.it.jpa.proxy; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; diff --git a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/ProxyTestEndpoint.java b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/ProxyTestEndpoint.java similarity index 69% rename from integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/ProxyTestEndpoint.java rename to integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/ProxyTestEndpoint.java index 95f1ac34efefe5..ac02e4c20afdb6 100644 --- a/integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/proxy/ProxyTestEndpoint.java +++ b/integration-tests/jpa/src/main/java/io/quarkus/it/jpa/proxy/ProxyTestEndpoint.java @@ -1,22 +1,26 @@ -package io.quarkus.it.jpa.h2.proxy; +package io.quarkus.it.jpa.proxy; -import java.io.IOException; +import java.util.List; import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.event.Observes; import jakarta.inject.Inject; import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; import jakarta.transaction.Transactional; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; +import org.wildfly.common.Assert; + +import io.quarkus.narayana.jta.QuarkusTransaction; import io.quarkus.narayana.jta.runtime.TransactionConfiguration; import io.quarkus.runtime.StartupEvent; @ApplicationScoped -@Path("/jpa-h2/testproxy") +@Path("/jpa/proxy") @Produces(MediaType.TEXT_PLAIN) public class ProxyTestEndpoint { @@ -26,6 +30,11 @@ public class ProxyTestEndpoint { @Transactional @TransactionConfiguration(timeoutFromConfigProperty = "dummy.transaction.timeout") public void setup(@Observes StartupEvent startupEvent) { + ConcreteEntity entity = new ConcreteEntity(); + entity.id = "1"; + entity.type = "Concrete"; + entityManager.persist(entity); + Pet pet = new Pet(); pet.setId(1); pet.setName("Goose"); @@ -59,7 +68,17 @@ public void setup(@Observes StartupEvent startupEvent) { petOwner.setPet(pet); entityManager.persist(petOwner); + } + @GET + @Path("basic") + @Transactional + public String testBasic() { + final List list = entityManager.createQuery("from ConcreteEntity").getResultList(); + if (list.size() != 1) { + throw new RuntimeException("Expected 1 result, got " + list.size()); + } + return "OK"; } /** @@ -68,7 +87,9 @@ public void setup(@Observes StartupEvent startupEvent) { * We need to do our own proxy generation at build time, so this tests that the logic matches what hibernate expects */ @GET - public String test() throws IOException { + @Path("inheritance") + @Transactional + public String inheritance() { PetOwner owner = entityManager.find(PetOwner.class, 1); expectEquals("Stuart", owner.getName()); expectEquals("Generic pet noises", owner.getPet().makeNoise()); @@ -99,6 +120,27 @@ public String test() throws IOException { return "OK"; } + @GET + @Path("enhanced") + private void testEnhanced(EntityManagerFactory emf) { + //Define the test data: + CompanyCustomer company = new CompanyCustomer(); + company.companyname = "Quarked consulting, inc."; + Project project = new Project(); + project.name = "Hibernate RX"; + project.customer = company; + + //Store the test model: + QuarkusTransaction.requiringNew() + .run(() -> entityManager.persist(project)); + final Integer testId = project.id; + Assert.assertNotNull(testId); + + //Now try to load it, should trigger the use of enhanced proxies: + QuarkusTransaction.requiringNew() + .run(() -> entityManager.find(Project.class, testId)); + } + void expectEquals(Object expected, Object actual) { if (!expected.equals(actual)) { throw new RuntimeException("Expected " + expected + " but was " + actual); diff --git a/integration-tests/jpa/src/main/resources/application.properties b/integration-tests/jpa/src/main/resources/application.properties index d0642c9cb3b42d..ce0333451d50df 100644 --- a/integration-tests/jpa/src/main/resources/application.properties +++ b/integration-tests/jpa/src/main/resources/application.properties @@ -5,4 +5,6 @@ quarkus.hibernate-orm.database.generation=drop-and-create quarkus.hibernate-orm.metadata-builder-contributor=io.quarkus.it.jpa.defaultcatalogandschema.Schema1MetadataBuilderContributor -quarkus.hibernate-orm.multitenant=DISCRIMINATOR \ No newline at end of file +quarkus.hibernate-orm.multitenant=DISCRIMINATOR + +dummy.transaction.timeout=30 \ No newline at end of file diff --git a/integration-tests/jpa/src/test/java/io/quarkus/it/jpa/proxy/ProxyInGraalITCase.java b/integration-tests/jpa/src/test/java/io/quarkus/it/jpa/proxy/ProxyInGraalITCase.java new file mode 100644 index 00000000000000..3d067e929eeb05 --- /dev/null +++ b/integration-tests/jpa/src/test/java/io/quarkus/it/jpa/proxy/ProxyInGraalITCase.java @@ -0,0 +1,11 @@ +package io.quarkus.it.jpa.proxy; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +/** + * Test various JPA operations running in native mode + */ +@QuarkusIntegrationTest +public class ProxyInGraalITCase extends ProxyTest { + +} diff --git a/integration-tests/jpa/src/test/java/io/quarkus/it/jpa/proxy/ProxyTest.java b/integration-tests/jpa/src/test/java/io/quarkus/it/jpa/proxy/ProxyTest.java new file mode 100644 index 00000000000000..c5fbd3aeb63a3b --- /dev/null +++ b/integration-tests/jpa/src/test/java/io/quarkus/it/jpa/proxy/ProxyTest.java @@ -0,0 +1,28 @@ +package io.quarkus.it.jpa.proxy; + +import static org.hamcrest.Matchers.is; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; + +@QuarkusTest +public class ProxyTest { + + @Test + public void testBasicProxies() { + RestAssured.when().get("/jpa/proxy/basic").then().body(is("OK")); + } + + @Test + public void testProxyInheritance() { + RestAssured.when().get("/jpa/proxy/inheritance").then().body(is("OK")); + } + + @Test + public void testEnhancedProxies() { + RestAssured.when().get("/jpa/proxy/enhanced").then().body(is("OK")); + } + +}