From 0c4d19a2b782440bcdcbc104d0a668ffceb72b73 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Tue, 5 Aug 2025 18:11:02 +0200 Subject: [PATCH 1/4] Fix issue with hibernate-gradle-plugin testing and explicit test JDK --- .../orm/toolchains/JavaModulePlugin.java | 5 +-- .../hibernate-gradle-plugin.gradle | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/toolchains/JavaModulePlugin.java b/local-build-plugins/src/main/java/org/hibernate/orm/toolchains/JavaModulePlugin.java index ed7885deda4d..a343182cdb9e 100644 --- a/local-build-plugins/src/main/java/org/hibernate/orm/toolchains/JavaModulePlugin.java +++ b/local-build-plugins/src/main/java/org/hibernate/orm/toolchains/JavaModulePlugin.java @@ -99,8 +99,9 @@ public void execute(JavaCompile compileTask) { @Override public void execute(Task task) { project.getLogger().lifecycle( - "Compiling with '{}'", - compileTask.getJavaCompiler().get().getMetadata().getInstallationPath() + "Compiling with '{}' to release '{}'", + compileTask.getJavaCompiler().get().getMetadata().getInstallationPath(), + compileTask.getOptions().getRelease().get() ); } } diff --git a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle index 90aab011352b..4c893be0e882 100644 --- a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle +++ b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle @@ -3,6 +3,7 @@ * Copyright Red Hat Inc. and Hibernate Authors */ import org.apache.tools.ant.filters.ReplaceTokens +import org.gradle.api.internal.provider.DefaultProvider plugins { id 'java-gradle-plugin' @@ -119,6 +120,37 @@ if ( !jdkVersions.explicit ) { else { logger.warn( "[WARN] Toolchains are not yet supported for Groovy compilation." + " Using the JDK that runs Gradle for Groovy compilation." ) + if ( jdkVersions.test.explicit && jdkVersions.test.launcher.asInt() > jdkVersions.min.asInt() ) { + // Configure the gradle plugin to also compile test to at most the orm.jdk.min version, + // because the test will have to be able to run with a JVM of version orm.jdk.min + tasks.named( "compileTestJava", JavaCompile ).configure { + options.release = Math.min( jdkVersions.test.compiler.asInt(), jdkVersions.min.asInt() ) + } + // Must configure the test launcher to a version <= orm.jdk.max, because the tests invoke gradle, + // which inherently can only run with a JDK up to orm.jdk.max. + // Since we only support running Gradle with JDKs in the range of orm.jdk.min up to orm.jdk.max, + // we use a test java launcher for the latest available/configured JDK version + tasks.named( "test", Test ).configure { + def launcher = javaToolchains.launcherFor { + languageVersion = jdkVersions.min + } + for ( int version = jdkVersions.min.asInt() + 1; version <= jdkVersions.max.asInt(); version++ ) { + launcher = new DefaultProvider(() -> { + try { + return javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of( version ) + }.get() + } + catch (GradleException ex) { + // JavaToolchainQueryService unfortunately throws an exception if a version is not found, + // so we have to catch the exception and return null here to allow a fallback + return null + } + }).orElse( launcher ) + } + javaLauncher = launcher + } + } } tasks.publish.enabled !ormBuildDetails.hibernateVersion.isSnapshot From 88c82626488c8ded6826dfbdabd3a391e84410c2 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Tue, 5 Aug 2025 18:11:23 +0200 Subject: [PATCH 2/4] Skip some vector tests on Oracle due to a bug in version 23.9 --- .../test/java/org/hibernate/vector/OracleByteVectorTest.java | 2 ++ .../test/java/org/hibernate/vector/OracleDoubleVectorTest.java | 2 ++ .../test/java/org/hibernate/vector/OracleFloatVectorTest.java | 2 ++ .../test/java/org/hibernate/vector/OracleGenericVectorTest.java | 2 ++ 4 files changed, 8 insertions(+) diff --git a/hibernate-vector/src/test/java/org/hibernate/vector/OracleByteVectorTest.java b/hibernate-vector/src/test/java/org/hibernate/vector/OracleByteVectorTest.java index 762dbfacf119..bfbf2cc28d34 100644 --- a/hibernate-vector/src/test/java/org/hibernate/vector/OracleByteVectorTest.java +++ b/hibernate-vector/src/test/java/org/hibernate/vector/OracleByteVectorTest.java @@ -9,6 +9,7 @@ import org.hibernate.annotations.Array; import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.dialect.OracleDialect; +import org.hibernate.testing.orm.junit.SkipForDialect; import org.hibernate.type.SqlTypes; import org.hibernate.testing.orm.junit.DomainModel; @@ -168,6 +169,7 @@ public void testVectorDims(SessionFactoryScope scope) { } @Test + @SkipForDialect(dialectClass = OracleDialect.class, reason = "Oracle 23.9 bug") public void testVectorNorm(SessionFactoryScope scope) { scope.inTransaction( em -> { //tag::vector-norm-example[] diff --git a/hibernate-vector/src/test/java/org/hibernate/vector/OracleDoubleVectorTest.java b/hibernate-vector/src/test/java/org/hibernate/vector/OracleDoubleVectorTest.java index 7fe80b5b493e..49add683b4d4 100644 --- a/hibernate-vector/src/test/java/org/hibernate/vector/OracleDoubleVectorTest.java +++ b/hibernate-vector/src/test/java/org/hibernate/vector/OracleDoubleVectorTest.java @@ -9,6 +9,7 @@ import org.hibernate.annotations.Array; import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.dialect.OracleDialect; +import org.hibernate.testing.orm.junit.SkipForDialect; import org.hibernate.type.SqlTypes; import org.hibernate.testing.orm.junit.DomainModel; @@ -167,6 +168,7 @@ public void testVectorDims(SessionFactoryScope scope) { } @Test + @SkipForDialect(dialectClass = OracleDialect.class, reason = "Oracle 23.9 bug") public void testVectorNorm(SessionFactoryScope scope) { scope.inTransaction( em -> { //tag::vector-norm-example[] diff --git a/hibernate-vector/src/test/java/org/hibernate/vector/OracleFloatVectorTest.java b/hibernate-vector/src/test/java/org/hibernate/vector/OracleFloatVectorTest.java index 6961cfd466e9..da83e8bf7ef6 100644 --- a/hibernate-vector/src/test/java/org/hibernate/vector/OracleFloatVectorTest.java +++ b/hibernate-vector/src/test/java/org/hibernate/vector/OracleFloatVectorTest.java @@ -9,6 +9,7 @@ import org.hibernate.annotations.Array; import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.dialect.OracleDialect; +import org.hibernate.testing.orm.junit.SkipForDialect; import org.hibernate.type.SqlTypes; import org.hibernate.testing.orm.junit.DomainModel; @@ -186,6 +187,7 @@ public void testVectorDims(SessionFactoryScope scope) { } @Test + @SkipForDialect(dialectClass = OracleDialect.class, reason = "Oracle 23.9 bug") public void testVectorNorm(SessionFactoryScope scope) { scope.inTransaction( em -> { //tag::vector-norm-example[] diff --git a/hibernate-vector/src/test/java/org/hibernate/vector/OracleGenericVectorTest.java b/hibernate-vector/src/test/java/org/hibernate/vector/OracleGenericVectorTest.java index 308734dad5ef..d199b91f594b 100644 --- a/hibernate-vector/src/test/java/org/hibernate/vector/OracleGenericVectorTest.java +++ b/hibernate-vector/src/test/java/org/hibernate/vector/OracleGenericVectorTest.java @@ -9,6 +9,7 @@ import org.hibernate.annotations.Array; import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.dialect.OracleDialect; +import org.hibernate.testing.orm.junit.SkipForDialect; import org.hibernate.type.SqlTypes; import org.hibernate.testing.orm.junit.DomainModel; @@ -187,6 +188,7 @@ public void testVectorDims(SessionFactoryScope scope) { } @Test + @SkipForDialect(dialectClass = OracleDialect.class, reason = "Oracle 23.9 bug") public void testVectorNorm(SessionFactoryScope scope) { scope.inTransaction( em -> { //tag::vector-norm-example[] From f0afdfec897f2c6effb65b404d365bf40a37a3d2 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Tue, 5 Aug 2025 18:18:56 +0200 Subject: [PATCH 3/4] Skip some listagg tests on MySQL 8.0+ due to a MySQL regression --- .../test/query/criteria/CriteriaOrderedSetAggregateTest.java | 5 +++-- .../orm/test/query/hql/OrderedSetAggregateTest.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/criteria/CriteriaOrderedSetAggregateTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/criteria/CriteriaOrderedSetAggregateTest.java index a90a3264d565..6fcdf7825a8f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/criteria/CriteriaOrderedSetAggregateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/criteria/CriteriaOrderedSetAggregateTest.java @@ -200,13 +200,14 @@ public void testListaggWithFilterAndWindow(SessionFactoryScope scope) { } /* - * Skipped for MySQL 9.2: The test fails due to a regression in MySQL 9.2, which no longer supports NULLS FIRST/LAST in ORDER BY within LISTAGG as expected. + * Skipped for MySQL 8.0: The test fails due to a regression in MySQL 8.0.x, which no longer supports NULLS FIRST/LAST in ORDER BY within LISTAGG as expected. * See https://bugs.mysql.com/bug.php?id=117765 for more details. * This is a MySQL issue, not a problem in the dialect implementation. */ @Test @RequiresDialectFeature(feature = DialectFeatureChecks.SupportsStringAggregation.class) - @SkipForDialect(dialectClass = MySQLDialect.class, majorVersion = 9, minorVersion = 2, reason = "https://bugs.mysql.com/bug.php?id=117765") + @SkipForDialect(dialectClass = MySQLDialect.class, majorVersion = 8, reason = "https://bugs.mysql.com/bug.php?id=117765") + @SkipForDialect(dialectClass = MySQLDialect.class, majorVersion = 9, reason = "https://bugs.mysql.com/bug.php?id=117765") public void testListaggWithNullsClause(SessionFactoryScope scope) { scope.inTransaction( session -> { HibernateCriteriaBuilder cb = session.getCriteriaBuilder(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/OrderedSetAggregateTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/OrderedSetAggregateTest.java index 9c700b9ec8cb..42faeadd4f95 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/OrderedSetAggregateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/OrderedSetAggregateTest.java @@ -136,14 +136,15 @@ public void testListaggWithFilter(SessionFactoryScope scope) { } /* - * Skipped for MySQL 9.2: The test fails due to a regression in MySQL 9.2, which no longer supports NULLS FIRST/LAST in ORDER BY within LISTAGG as expected. + * Skipped for MySQL 8.0: The test fails due to a regression in MySQL 8.0.x, which no longer supports NULLS FIRST/LAST in ORDER BY within LISTAGG as expected. * See https://bugs.mysql.com/bug.php?id=117765 for more details. * This is a MySQL issue, not a problem in the dialect implementation. */ @Test @JiraKey( value = "HHH-15360") @RequiresDialectFeature(feature = DialectFeatureChecks.SupportsStringAggregation.class) - @SkipForDialect(dialectClass = MySQLDialect.class, majorVersion = 9, minorVersion = 2, reason = "https://bugs.mysql.com/bug.php?id=117765") + @SkipForDialect(dialectClass = MySQLDialect.class, majorVersion = 8, reason = "https://bugs.mysql.com/bug.php?id=117765") + @SkipForDialect(dialectClass = MySQLDialect.class, majorVersion = 9, reason = "https://bugs.mysql.com/bug.php?id=117765") public void testListaggWithNullsClause(SessionFactoryScope scope) { scope.inTransaction( session -> { From 32b0ed1ee47b003d85d38ee93677145b996f13ce Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Tue, 5 Aug 2025 18:25:26 +0200 Subject: [PATCH 4/4] Drop JDK 23 testing --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4646297df0c0..e4d60d35846e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -46,7 +46,6 @@ stage('Configure') { // We want to enable preview features when testing newer builds of OpenJDK: // even if we don't use these features, just enabling them can cause side effects // and it's useful to test that. - new BuildEnvironment( testJdkVersion: '23', testJdkLauncherArgs: '--enable-preview', additionalOptions: '-PskipJacoco=true' ), new BuildEnvironment( testJdkVersion: '24', testJdkLauncherArgs: '--enable-preview', additionalOptions: '-PskipJacoco=true' ), new BuildEnvironment( testJdkVersion: '25', testJdkLauncherArgs: '--enable-preview', additionalOptions: '-PskipJacoco=true' ), // The following JDKs aren't supported by Hibernate ORM out-of-the box yet: