diff --git a/orm/hibernate-orm-6/pom.xml b/orm/hibernate-orm-6/pom.xml index 0dc6b7b0..382ca6c7 100644 --- a/orm/hibernate-orm-6/pom.xml +++ b/orm/hibernate-orm-6/pom.xml @@ -79,7 +79,7 @@ maven-compiler-plugin 3.13.0 - 11 + 16 diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/Item.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/Item.java new file mode 100644 index 00000000..5f43744b --- /dev/null +++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/Item.java @@ -0,0 +1,15 @@ +package org.hibernate.bugs; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; + +@Entity +public class Item { + + @Id + private long id; + + public Item(long id) { + this.id = id; + } +} \ No newline at end of file diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java index 3734df49..3fe70d51 100644 --- a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java +++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java @@ -1,12 +1,12 @@ package org.hibernate.bugs; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.Persistence; +import jakarta.persistence.TypedQuery; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * This template demonstrates how to develop a test case for Hibernate ORM, using the Java Persistence API. @@ -28,10 +28,23 @@ void destroy() { // Entities are auto-discovered, so just add them anywhere on class-path // Add your tests, using standard JUnit. @Test - void hhh123Test() throws Exception { + void hhh18668Test() throws Exception { EntityManager entityManager = entityManagerFactory.createEntityManager(); entityManager.getTransaction().begin(); - // Do stuff... + + Item entity = new Item(1); + entityManager.persist(entity); + + TypedQuery query = entityManager.createQuery(""" + SELECT new org.hibernate.bugs.Summary( + :id + ) + FROM Item i + """, Summary.class); + query.setParameter("id", 1); + Summary singleResult = query.getSingleResult(); + System.out.println(singleResult); + entityManager.getTransaction().commit(); entityManager.close(); } diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeORMUnitTestCase.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeORMUnitTestCase.java deleted file mode 100644 index f96bffd4..00000000 --- a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeORMUnitTestCase.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2014 JBoss Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.hibernate.bugs; - -import org.hibernate.cfg.AvailableSettings; - -import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced; -import org.hibernate.testing.orm.junit.DomainModel; -import org.hibernate.testing.orm.junit.ServiceRegistry; -import org.hibernate.testing.orm.junit.SessionFactory; -import org.hibernate.testing.orm.junit.SessionFactoryScope; -import org.hibernate.testing.orm.junit.Setting; -import org.junit.jupiter.api.Test; - -/** - * This template demonstrates how to develop a test case for Hibernate ORM, using its built-in unit test framework. - *

- * What's even better? Fork hibernate-orm itself, add your test case directly to a module's unit tests, then - * submit it as a PR! - */ -@DomainModel( - annotatedClasses = { - // Add your entities here, e.g.: - // Foo.class, - // Bar.class - } -) -@ServiceRegistry( - // Add in any settings that are specific to your test. See resources/hibernate.properties for the defaults. - settings = { - // For your own convenience to see generated queries: - @Setting(name = AvailableSettings.SHOW_SQL, value = "true"), - @Setting(name = AvailableSettings.FORMAT_SQL, value = "true"), - // @Setting( name = AvailableSettings.GENERATE_STATISTICS, value = "true" ), - - // Other settings that will make your test case run under similar configuration that Quarkus is using by default: - @Setting(name = AvailableSettings.PREFERRED_POOLED_OPTIMIZER, value = "pooled-lo"), - @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "16"), - @Setting(name = AvailableSettings.BATCH_FETCH_STYLE, value = "PADDED"), - @Setting(name = AvailableSettings.QUERY_PLAN_CACHE_MAX_SIZE, value = "2048"), - @Setting(name = AvailableSettings.DEFAULT_NULL_ORDERING, value = "none"), - @Setting(name = AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, value = "true"), - @Setting(name = AvailableSettings.SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY, value = "none"), - - // Add your own settings that are a part of your quarkus configuration: - // @Setting( name = AvailableSettings.SOME_CONFIGURATION_PROPERTY, value = "SOME_VALUE" ), - } -) -@SessionFactory -@BytecodeEnhanced -class QuarkusLikeORMUnitTestCase { - - // Add your tests, using standard JUnit. - @Test - void hhh123Test(SessionFactoryScope scope) throws Exception { - scope.inTransaction( session -> { - // Do stuff... - } ); - } -} diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/Summary.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/Summary.java new file mode 100644 index 00000000..41c45da1 --- /dev/null +++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/Summary.java @@ -0,0 +1,6 @@ +package org.hibernate.bugs; + +public record Summary( + long id +) { +} \ No newline at end of file