diff --git a/orm/hibernate-orm-6/pom.xml b/orm/hibernate-orm-6/pom.xml index fe7d189c..1493ff83 100644 --- a/orm/hibernate-orm-6/pom.xml +++ b/orm/hibernate-orm-6/pom.xml @@ -8,7 +8,8 @@ Hibernate ORM 6 Test Case Template - 2.3.232 + 1.16.3 + 42.7.4 5.11.0 6.6.0.Final 3.26.3 @@ -30,6 +31,13 @@ pom import + + org.testcontainers + testcontainers-bom + 1.20.1 + pom + import + @@ -43,10 +51,17 @@ hibernate-testing + + + org.postgresql + postgresql + ${version.pgjdbc} + test + - com.h2database - h2 - ${version.com.h2database} + org.testcontainers + postgresql + test org.junit.jupiter diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ORMUnitTestCase.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ORMUnitTestCase.java index eefb7df4..efecb322 100644 --- a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ORMUnitTestCase.java +++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/ORMUnitTestCase.java @@ -15,8 +15,12 @@ */ package org.hibernate.bugs; -import org.hibernate.cfg.AvailableSettings; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; +import org.hibernate.bugs.model.Currency; +import org.hibernate.cfg.AvailableSettings; import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; @@ -35,36 +39,28 @@ */ @DomainModel( annotatedClasses = { - // Add your entities here. - // Foo.class, - // Bar.class - }, - // If you use *.hbm.xml mappings, instead of annotations, add the mappings here. - xmlMappings = { - // "org/hibernate/test/Foo.hbm.xml", - // "org/hibernate/test/Bar.hbm.xml" + Currency.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" ), - - // Add your own settings that are a part of your quarkus configuration: - // @Setting( name = AvailableSettings.SOME_CONFIGURATION_PROPERTY, value = "SOME_VALUE" ), } ) -@SessionFactory +@SessionFactory(exportSchema = false) class ORMUnitTestCase { - // Add your tests, using standard JUnit 5. @Test - void hhh123Test(SessionFactoryScope scope) throws Exception { + void hhh18618Test(SessionFactoryScope scope) throws Exception { scope.inTransaction( session -> { - // Do stuff... + List numbers = List.of(840, 978); + List currencies = session.createQuery( + "FROM Currency " + + "WHERE array_contains(:numbers, number)", + Currency.class) + .setParameter("numbers", numbers.toArray(Integer[]::new)) + .getResultList(); + assertEquals(2, currencies.size()); } ); } } diff --git a/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/model/Currency.java b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/model/Currency.java new file mode 100644 index 00000000..7facf910 --- /dev/null +++ b/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/model/Currency.java @@ -0,0 +1,22 @@ +package org.hibernate.bugs.model; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; + +@Entity +public class Currency { + + @Id + @Column(name = "num", nullable = false, updatable = false) + private Integer number; + + public Integer getNumber() { + return number; + } + + public void setNumber(Integer number) { + this.number = number; + } + +} diff --git a/orm/hibernate-orm-6/src/test/resources/hibernate.properties b/orm/hibernate-orm-6/src/test/resources/hibernate.properties index 9c894d7b..d1b5e759 100644 --- a/orm/hibernate-orm-6/src/test/resources/hibernate.properties +++ b/orm/hibernate-orm-6/src/test/resources/hibernate.properties @@ -5,12 +5,12 @@ # See the lgpl.txt file in the root directory or . # -hibernate.dialect org.hibernate.dialect.H2Dialect -hibernate.connection.driver_class org.h2.Driver +hibernate.dialect org.hibernate.dialect.PostgreSQLDialect +hibernate.connection.driver_class org.testcontainers.jdbc.ContainerDatabaseDriver #hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE -hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1 -hibernate.connection.username sa -hibernate.connection.password +hibernate.connection.url jdbc:tc:postgresql:9.6.8:///databasename?TC_INITSCRIPT=file:src/test/resources/postgres_array.sql +hibernate.connection.username test +hibernate.connection.password test hibernate.connection.pool_size 5 diff --git a/orm/hibernate-orm-6/src/test/resources/postgres_array.sql b/orm/hibernate-orm-6/src/test/resources/postgres_array.sql new file mode 100644 index 00000000..10faed13 --- /dev/null +++ b/orm/hibernate-orm-6/src/test/resources/postgres_array.sql @@ -0,0 +1,11 @@ +CREATE TABLE currency ( + num NUMERIC(3) NOT NULL, + CONSTRAINT pk_currency PRIMARY KEY(num) +); + +INSERT INTO currency(num) + VALUES (392), + (756), + (826), + (840), + (978);