From 5c692a1d27a0898bb5c7c42f94c70ebffb55c91f Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Mon, 27 Feb 2023 08:29:04 +0100 Subject: [PATCH 01/19] Renamed `tests.common` to `tests.common-sync` --- settings.gradle | 5 ++--- tests/{common => common-sync}/build.gradle | 0 .../src/main/java/example/Application.java | 0 .../src/main/java/example/sync/DestroyController.java | 0 .../src/main/java/example/sync/IOwnerRepository.java | 0 .../src/main/java/example/sync/IPetRepository.java | 0 .../src/main/java/example/sync/InitController.java | 0 .../src/main/java/example/sync/Mapper.java | 0 .../src/main/java/example/sync/OwnerController.java | 0 .../src/main/java/example/sync/PetController.java | 0 .../src/main/resources/application.yml | 0 tests/{common => common-sync}/src/main/resources/logback.xml | 0 tests/hibernate5/hibernate5-sync-common/build.gradle | 2 +- tests/hibernate6/hibernate6-sync-common/build.gradle | 2 +- tests/jooq-tests/jooq-jdbc-postgres/build.gradle | 2 +- 15 files changed, 5 insertions(+), 6 deletions(-) rename tests/{common => common-sync}/build.gradle (100%) rename tests/{common => common-sync}/src/main/java/example/Application.java (100%) rename tests/{common => common-sync}/src/main/java/example/sync/DestroyController.java (100%) rename tests/{common => common-sync}/src/main/java/example/sync/IOwnerRepository.java (100%) rename tests/{common => common-sync}/src/main/java/example/sync/IPetRepository.java (100%) rename tests/{common => common-sync}/src/main/java/example/sync/InitController.java (100%) rename tests/{common => common-sync}/src/main/java/example/sync/Mapper.java (100%) rename tests/{common => common-sync}/src/main/java/example/sync/OwnerController.java (100%) rename tests/{common => common-sync}/src/main/java/example/sync/PetController.java (100%) rename tests/{common => common-sync}/src/main/resources/application.yml (100%) rename tests/{common => common-sync}/src/main/resources/logback.xml (100%) diff --git a/settings.gradle b/settings.gradle index 38cadc5bf..4a3c9503e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -44,8 +44,9 @@ include 'vertx-mysql-client' include 'vertx-pg-client' include 'jdbi' -include 'tests:common' +include 'tests:common-entity' include 'tests:common-reactive' +include 'tests:common-sync' include 'tests:common-tests' include 'tests:hibernate5:hibernate5-sync-common' @@ -72,5 +73,3 @@ include 'tests:hibernate6:hibernate6-postgres' include 'tests:jooq-tests:jooq-jdbc-postgres' include 'tests:jooq-tests:jooq-r2dbc-postgres' -include 'tests:common-entity' - diff --git a/tests/common/build.gradle b/tests/common-sync/build.gradle similarity index 100% rename from tests/common/build.gradle rename to tests/common-sync/build.gradle diff --git a/tests/common/src/main/java/example/Application.java b/tests/common-sync/src/main/java/example/Application.java similarity index 100% rename from tests/common/src/main/java/example/Application.java rename to tests/common-sync/src/main/java/example/Application.java diff --git a/tests/common/src/main/java/example/sync/DestroyController.java b/tests/common-sync/src/main/java/example/sync/DestroyController.java similarity index 100% rename from tests/common/src/main/java/example/sync/DestroyController.java rename to tests/common-sync/src/main/java/example/sync/DestroyController.java diff --git a/tests/common/src/main/java/example/sync/IOwnerRepository.java b/tests/common-sync/src/main/java/example/sync/IOwnerRepository.java similarity index 100% rename from tests/common/src/main/java/example/sync/IOwnerRepository.java rename to tests/common-sync/src/main/java/example/sync/IOwnerRepository.java diff --git a/tests/common/src/main/java/example/sync/IPetRepository.java b/tests/common-sync/src/main/java/example/sync/IPetRepository.java similarity index 100% rename from tests/common/src/main/java/example/sync/IPetRepository.java rename to tests/common-sync/src/main/java/example/sync/IPetRepository.java diff --git a/tests/common/src/main/java/example/sync/InitController.java b/tests/common-sync/src/main/java/example/sync/InitController.java similarity index 100% rename from tests/common/src/main/java/example/sync/InitController.java rename to tests/common-sync/src/main/java/example/sync/InitController.java diff --git a/tests/common/src/main/java/example/sync/Mapper.java b/tests/common-sync/src/main/java/example/sync/Mapper.java similarity index 100% rename from tests/common/src/main/java/example/sync/Mapper.java rename to tests/common-sync/src/main/java/example/sync/Mapper.java diff --git a/tests/common/src/main/java/example/sync/OwnerController.java b/tests/common-sync/src/main/java/example/sync/OwnerController.java similarity index 100% rename from tests/common/src/main/java/example/sync/OwnerController.java rename to tests/common-sync/src/main/java/example/sync/OwnerController.java diff --git a/tests/common/src/main/java/example/sync/PetController.java b/tests/common-sync/src/main/java/example/sync/PetController.java similarity index 100% rename from tests/common/src/main/java/example/sync/PetController.java rename to tests/common-sync/src/main/java/example/sync/PetController.java diff --git a/tests/common/src/main/resources/application.yml b/tests/common-sync/src/main/resources/application.yml similarity index 100% rename from tests/common/src/main/resources/application.yml rename to tests/common-sync/src/main/resources/application.yml diff --git a/tests/common/src/main/resources/logback.xml b/tests/common-sync/src/main/resources/logback.xml similarity index 100% rename from tests/common/src/main/resources/logback.xml rename to tests/common-sync/src/main/resources/logback.xml diff --git a/tests/hibernate5/hibernate5-sync-common/build.gradle b/tests/hibernate5/hibernate5-sync-common/build.gradle index d88741518..cf2c9b5b0 100644 --- a/tests/hibernate5/hibernate5-sync-common/build.gradle +++ b/tests/hibernate5/hibernate5-sync-common/build.gradle @@ -3,7 +3,7 @@ plugins { } dependencies { - implementation projects.tests.common + implementation projects.tests.commonSync implementation projects.hibernateJpa runtimeOnly projects.jdbcHikari diff --git a/tests/hibernate6/hibernate6-sync-common/build.gradle b/tests/hibernate6/hibernate6-sync-common/build.gradle index 0c1cc3ff0..6e9226c31 100644 --- a/tests/hibernate6/hibernate6-sync-common/build.gradle +++ b/tests/hibernate6/hibernate6-sync-common/build.gradle @@ -3,7 +3,7 @@ plugins { } dependencies { - implementation projects.tests.common + implementation projects.tests.commonSync implementation projects.hibernate6Jpa runtimeOnly projects.jdbcHikari diff --git a/tests/jooq-tests/jooq-jdbc-postgres/build.gradle b/tests/jooq-tests/jooq-jdbc-postgres/build.gradle index 31adb6d73..b37635145 100644 --- a/tests/jooq-tests/jooq-jdbc-postgres/build.gradle +++ b/tests/jooq-tests/jooq-jdbc-postgres/build.gradle @@ -5,7 +5,7 @@ plugins { dependencies { implementation projects.jooq implementation mnData.micronaut.data.tx - implementation projects.tests.common + implementation projects.tests.commonSync annotationProcessor mnData.micronaut.data.processor From b48a96bffd0ac52cc7841f7536af8aee32c26c7e Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Mon, 27 Feb 2023 08:48:54 +0100 Subject: [PATCH 02/19] Renamed `tests.common-entity` to `tests.common` --- settings.gradle | 2 +- .../postgres/build.gradle | 8 ------ tests/common-reactive/build.gradle | 2 +- tests/common-sync/build.gradle | 2 +- .../src/main/java/example/Application.java | 25 ------------------- .../main/java/example/sync/PetController.java | 3 --- .../src/main/resources/application.yml | 6 ----- .../src/main/resources/logback.xml | 14 ----------- tests/common-tests/build.gradle | 2 +- tests/{common-entity => common}/build.gradle | 0 .../src/main/java/example/Application.java | 0 .../src/main/java/example/domain/IOwner.java | 0 .../src/main/java/example/domain/IPet.java | 0 .../src/main/java/example/dto/OwnerDto.java | 0 .../src/main/java/example/dto/PetDto.java | 0 .../src/main/resources/application.yml | 0 .../src/main/resources/logback.xml | 0 17 files changed, 4 insertions(+), 60 deletions(-) delete mode 100644 test-graalvm-hibernate-jpa/postgres/build.gradle delete mode 100644 tests/common-sync/src/main/java/example/Application.java delete mode 100644 tests/common-sync/src/main/resources/application.yml delete mode 100644 tests/common-sync/src/main/resources/logback.xml rename tests/{common-entity => common}/build.gradle (100%) rename tests/{common-reactive => common}/src/main/java/example/Application.java (100%) rename tests/{common-entity => common}/src/main/java/example/domain/IOwner.java (100%) rename tests/{common-entity => common}/src/main/java/example/domain/IPet.java (100%) rename tests/{common-entity => common}/src/main/java/example/dto/OwnerDto.java (100%) rename tests/{common-entity => common}/src/main/java/example/dto/PetDto.java (100%) rename tests/{common-reactive => common}/src/main/resources/application.yml (100%) rename tests/{common-reactive => common}/src/main/resources/logback.xml (100%) diff --git a/settings.gradle b/settings.gradle index 4a3c9503e..a6ff4afcb 100644 --- a/settings.gradle +++ b/settings.gradle @@ -44,7 +44,7 @@ include 'vertx-mysql-client' include 'vertx-pg-client' include 'jdbi' -include 'tests:common-entity' +include 'tests:common' include 'tests:common-reactive' include 'tests:common-sync' include 'tests:common-tests' diff --git a/test-graalvm-hibernate-jpa/postgres/build.gradle b/test-graalvm-hibernate-jpa/postgres/build.gradle deleted file mode 100644 index 7b3f14d75..000000000 --- a/test-graalvm-hibernate-jpa/postgres/build.gradle +++ /dev/null @@ -1,8 +0,0 @@ -plugins { - id 'io.micronaut.build.internal.test-application' -} - -dependencies { - runtimeOnly(libs.managed.postgresql) - testImplementation(libs.testcontainers.postgresql) -} diff --git a/tests/common-reactive/build.gradle b/tests/common-reactive/build.gradle index 45f9e8c40..96a5c23b4 100644 --- a/tests/common-reactive/build.gradle +++ b/tests/common-reactive/build.gradle @@ -6,7 +6,7 @@ dependencies { implementation mnReactor.micronaut.reactor implementation mn.micronaut.http implementation mn.micronaut.runtime - api(projects.tests.commonEntity) + api(projects.tests.common) api(mnData.micronaut.data.tx) implementation(mnSerde.micronaut.serde.jackson) diff --git a/tests/common-sync/build.gradle b/tests/common-sync/build.gradle index 3d13ac1e9..26960242c 100644 --- a/tests/common-sync/build.gradle +++ b/tests/common-sync/build.gradle @@ -5,7 +5,7 @@ plugins { dependencies { implementation mn.micronaut.http implementation mn.micronaut.runtime - api(projects.tests.commonEntity) + api(projects.tests.common) api(mnData.micronaut.data.tx) implementation(mnSerde.micronaut.serde.jackson) diff --git a/tests/common-sync/src/main/java/example/Application.java b/tests/common-sync/src/main/java/example/Application.java deleted file mode 100644 index fe509231a..000000000 --- a/tests/common-sync/src/main/java/example/Application.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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 example; - -import io.micronaut.runtime.Micronaut; - -public class Application { - - public static void main(String[] args) { - Micronaut.run(Application.class); - } -} diff --git a/tests/common-sync/src/main/java/example/sync/PetController.java b/tests/common-sync/src/main/java/example/sync/PetController.java index b7fca142a..64ba4b5cd 100644 --- a/tests/common-sync/src/main/java/example/sync/PetController.java +++ b/tests/common-sync/src/main/java/example/sync/PetController.java @@ -22,9 +22,6 @@ import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; - -import static java.util.stream.Collectors.toList; @Controller("/pets") class PetController { diff --git a/tests/common-sync/src/main/resources/application.yml b/tests/common-sync/src/main/resources/application.yml deleted file mode 100644 index 2dfa1a024..000000000 --- a/tests/common-sync/src/main/resources/application.yml +++ /dev/null @@ -1,6 +0,0 @@ -micronaut: - application: - name: graalvm-hibernate-jpa - http: - client: - read-timeout: 60s diff --git a/tests/common-sync/src/main/resources/logback.xml b/tests/common-sync/src/main/resources/logback.xml deleted file mode 100644 index 59b0f6903..000000000 --- a/tests/common-sync/src/main/resources/logback.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - true - - %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n - - - - - - - - diff --git a/tests/common-tests/build.gradle b/tests/common-tests/build.gradle index 4e2814a09..01569b407 100644 --- a/tests/common-tests/build.gradle +++ b/tests/common-tests/build.gradle @@ -6,6 +6,6 @@ dependencies { api mn.micronaut.http.client api mnTest.micronaut.test.junit5 api mnReactor.micronaut.reactor - api projects.tests.commonEntity + api projects.tests.common api libs.micronaut.testresources.client } diff --git a/tests/common-entity/build.gradle b/tests/common/build.gradle similarity index 100% rename from tests/common-entity/build.gradle rename to tests/common/build.gradle diff --git a/tests/common-reactive/src/main/java/example/Application.java b/tests/common/src/main/java/example/Application.java similarity index 100% rename from tests/common-reactive/src/main/java/example/Application.java rename to tests/common/src/main/java/example/Application.java diff --git a/tests/common-entity/src/main/java/example/domain/IOwner.java b/tests/common/src/main/java/example/domain/IOwner.java similarity index 100% rename from tests/common-entity/src/main/java/example/domain/IOwner.java rename to tests/common/src/main/java/example/domain/IOwner.java diff --git a/tests/common-entity/src/main/java/example/domain/IPet.java b/tests/common/src/main/java/example/domain/IPet.java similarity index 100% rename from tests/common-entity/src/main/java/example/domain/IPet.java rename to tests/common/src/main/java/example/domain/IPet.java diff --git a/tests/common-entity/src/main/java/example/dto/OwnerDto.java b/tests/common/src/main/java/example/dto/OwnerDto.java similarity index 100% rename from tests/common-entity/src/main/java/example/dto/OwnerDto.java rename to tests/common/src/main/java/example/dto/OwnerDto.java diff --git a/tests/common-entity/src/main/java/example/dto/PetDto.java b/tests/common/src/main/java/example/dto/PetDto.java similarity index 100% rename from tests/common-entity/src/main/java/example/dto/PetDto.java rename to tests/common/src/main/java/example/dto/PetDto.java diff --git a/tests/common-reactive/src/main/resources/application.yml b/tests/common/src/main/resources/application.yml similarity index 100% rename from tests/common-reactive/src/main/resources/application.yml rename to tests/common/src/main/resources/application.yml diff --git a/tests/common-reactive/src/main/resources/logback.xml b/tests/common/src/main/resources/logback.xml similarity index 100% rename from tests/common-reactive/src/main/resources/logback.xml rename to tests/common/src/main/resources/logback.xml From ae3705cac50b290778d062ad19ac2d432e9c7042 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Tue, 28 Feb 2023 17:59:23 +0100 Subject: [PATCH 03/19] Metadata migration --- .../micronaut-jdbc-hikari/reflect-config.json | 23 -- .../micronaut-jdbc-ucp/reflect-config.json | 9 - .../jdbc/nativeimage/JdbcFeature.java | 201 ------------------ .../micronaut-jdbc/dynamic-proxy-config.json | 4 - .../micronaut-jdbc/native-image.properties | 3 +- .../micronaut-jdbc/reflect-config.json | 28 --- .../micronaut-jdbc/resource-config.json | 19 +- 7 files changed, 9 insertions(+), 278 deletions(-) delete mode 100644 jdbc-hikari/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc-hikari/reflect-config.json delete mode 100644 jdbc-ucp/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc-ucp/reflect-config.json delete mode 100644 jdbc/src/main/java/io/micronaut/jdbc/nativeimage/JdbcFeature.java delete mode 100644 jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/dynamic-proxy-config.json delete mode 100644 jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/reflect-config.json diff --git a/jdbc-hikari/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc-hikari/reflect-config.json b/jdbc-hikari/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc-hikari/reflect-config.json deleted file mode 100644 index c20252d79..000000000 --- a/jdbc-hikari/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc-hikari/reflect-config.json +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "name":"com.zaxxer.hikari.HikariConfig", - "allDeclaredFields":true, - "allDeclaredMethods": true - }, - { - "name":"java.sql.Statement[]", - "allDeclaredConstructors":true - }, - { - "name" : "com.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry[]", - "allDeclaredFields" : true, - "allPublicMethods" : true, - "allDeclaredConstructors" : true - }, - { - "name" : "java.util.concurrent.CopyOnWriteArrayList", - "fields" : [ - { "name" : "lock", "allowWrite" : true } - ] - } -] \ No newline at end of file diff --git a/jdbc-ucp/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc-ucp/reflect-config.json b/jdbc-ucp/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc-ucp/reflect-config.json deleted file mode 100644 index 111e0ad23..000000000 --- a/jdbc-ucp/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc-ucp/reflect-config.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - { - "name":"oracle.jdbc.driver.OracleDriver", - "allDeclaredFields":true, - "allDeclaredMethods": true, - "allPublicMethods" : true, - "allDeclaredConstructors":true - } -] \ No newline at end of file diff --git a/jdbc/src/main/java/io/micronaut/jdbc/nativeimage/JdbcFeature.java b/jdbc/src/main/java/io/micronaut/jdbc/nativeimage/JdbcFeature.java deleted file mode 100644 index c55c2b5fe..000000000 --- a/jdbc/src/main/java/io/micronaut/jdbc/nativeimage/JdbcFeature.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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 io.micronaut.jdbc.nativeimage; - -import java.util.Arrays; -import java.util.Collections; - -import org.graalvm.nativeimage.hosted.Feature; - -import com.oracle.svm.core.annotate.AutomaticFeature; - -import io.micronaut.core.annotation.Internal; -import io.micronaut.core.graal.AutomaticFeatureUtils; -import static io.micronaut.core.graal.AutomaticFeatureUtils.addResourceBundles; -import static io.micronaut.core.graal.AutomaticFeatureUtils.addResourcePatterns; -import static io.micronaut.core.graal.AutomaticFeatureUtils.initializeAtBuildTime; -import static io.micronaut.core.graal.AutomaticFeatureUtils.initializeAtRunTime; -import static io.micronaut.core.graal.AutomaticFeatureUtils.registerAllForRuntimeReflection; -import static io.micronaut.core.graal.AutomaticFeatureUtils.registerClassForRuntimeReflection; -import static io.micronaut.core.graal.AutomaticFeatureUtils.registerClassForRuntimeReflectionAndReflectiveInstantiation; -import static io.micronaut.core.graal.AutomaticFeatureUtils.registerFieldsAndMethodsWithReflectiveAccess; -import static io.micronaut.core.graal.AutomaticFeatureUtils.registerFieldsForRuntimeReflection; -import static io.micronaut.core.graal.AutomaticFeatureUtils.registerMethodsForRuntimeReflection; - -/** - * A JDBC feature that configures JDBC drivers correctly for native image. - * - * @author graemerocher - * @author Iván López - * @since 2.2.1 - */ -@AutomaticFeature -@Internal -final class JdbcFeature implements Feature { - - private static final String H2_DRIVER = "org.h2.Driver"; - private static final String POSTGRESQL_DRIVER = "org.postgresql.Driver"; - private static final String SQL_SERVER_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; - private static final String MYSQL_DRIVER = "com.mysql.cj.jdbc.Driver"; - - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - handleH2(access); - - handlePostgres(access); - - handleSqlServer(access); - - handleMySql(access); - } - - private void handleH2(BeforeAnalysisAccess access) { - Class h2Driver = access.findClassByName(H2_DRIVER); - if (h2Driver != null) { - registerFieldsAndMethodsWithReflectiveAccess(access, "org.h2.mvstore.db.MVTableEngine"); - - registerClassForRuntimeReflection(access, H2_DRIVER); - initializeAtBuildTime(access, H2_DRIVER); - - Collections.singletonList("org.h2.engine.Constants") - .forEach(s -> { - registerClassForRuntimeReflection(access, s); - registerMethodsForRuntimeReflection(access, s); - registerFieldsForRuntimeReflection(access, s); - }); - - // required for file-based H2 databases - Arrays.asList( - "org.h2.store.fs.FilePathDisk", - "org.h2.store.fs.FilePathMem", - "org.h2.store.fs.FilePathMemLZF", - "org.h2.store.fs.FilePathNioMem", - "org.h2.store.fs.FilePathNioMemLZF", - "org.h2.store.fs.FilePathSplit", - "org.h2.store.fs.FilePathNio", - "org.h2.store.fs.FilePathNioMapped", - "org.h2.store.fs.FilePathAsync", - "org.h2.store.fs.FilePathZip", - "org.h2.store.fs.FilePathRetryOnInterrupt" - ).forEach(c -> registerClassForRuntimeReflectionAndReflectiveInstantiation(access, c)); - - addResourcePatterns( - "META-INF/services/java.sql.Driver", - "org/h2/util/data.zip" - ); - - initializeAtBuildTime(access, "java.sql.DriverManager"); - } - } - - private void handlePostgres(BeforeAnalysisAccess access) { - Class postgresDriver = access.findClassByName(POSTGRESQL_DRIVER); - if (postgresDriver != null) { - registerClassForRuntimeReflection(access, POSTGRESQL_DRIVER); - - initializeAtBuildTime(access, - POSTGRESQL_DRIVER, - "org.postgresql.util.SharedTimer" - ); - - registerAllForRuntimeReflection(access, "org.postgresql.PGProperty"); - - addResourcePatterns("META-INF/services/java.sql.Driver"); - - initializeAtBuildTime(access, "java.sql.DriverManager"); - } - } - - private void handleSqlServer(BeforeAnalysisAccess access) { - Class sqlServerDriver = access.findClassByName(SQL_SERVER_DRIVER); - if (sqlServerDriver != null) { - registerFieldsAndMethodsWithReflectiveAccess(access, SQL_SERVER_DRIVER); - - initializeAtBuildTime(access, - SQL_SERVER_DRIVER, - "com.microsoft.sqlserver.jdbc.Util", - "com.microsoft.sqlserver.jdbc.SQLServerException", - "com.microsoft.sqlserver.jdbc.SQLServerDriverStringProperty" - ); - - addResourcePatterns( - "META-INF/services/java.sql.Driver", - "javax.crypto.Cipher.class" - ); - addResourceBundles("com.microsoft.sqlserver.jdbc.SQLServerResource"); - - initializeAtBuildTime(access, "java.sql.DriverManager"); - } - } - - private void handleMySql(BeforeAnalysisAccess access) { - Class mysqlDriver = access.findClassByName(MYSQL_DRIVER); - if (mysqlDriver != null) { - Arrays.asList( - "com.mysql.cj.exceptions.AssertionFailedException", - "com.mysql.cj.exceptions.CJCommunicationsException", - "com.mysql.cj.exceptions.CJConnectionFeatureNotAvailableException", - "com.mysql.cj.exceptions.CJException", - "com.mysql.cj.exceptions.CJOperationNotSupportedException", - "com.mysql.cj.exceptions.CJPacketTooBigException", - "com.mysql.cj.exceptions.CJTimeoutException", - "com.mysql.cj.exceptions.ClosedOnExpiredPasswordException", - "com.mysql.cj.exceptions.ConnectionIsClosedException", - "com.mysql.cj.exceptions.DataConversionException", - "com.mysql.cj.exceptions.DataReadException", - "com.mysql.cj.exceptions.DataTruncationException", - "com.mysql.cj.exceptions.FeatureNotAvailableException", - "com.mysql.cj.exceptions.InvalidConnectionAttributeException", - "com.mysql.cj.exceptions.MysqlErrorNumbers", - "com.mysql.cj.exceptions.NumberOutOfRange", - "com.mysql.cj.exceptions.OperationCancelledException", - "com.mysql.cj.exceptions.PasswordExpiredException", - "com.mysql.cj.exceptions.PropertyNotModifiableException", - "com.mysql.cj.exceptions.RSAException", - "com.mysql.cj.exceptions.SSLParamsException", - "com.mysql.cj.exceptions.StatementIsClosedException", - "com.mysql.cj.exceptions.UnableToConnectException", - "com.mysql.cj.exceptions.UnsupportedConnectionStringException", - "com.mysql.cj.exceptions.WrongArgumentException" - ).forEach(name -> { - AutomaticFeatureUtils.registerClassForRuntimeReflection(access, name); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection(access, name); - }); - registerFieldsAndMethodsWithReflectiveAccess(access, MYSQL_DRIVER); - - registerAllForRuntimeReflection(access, "com.mysql.cj.log.StandardLogger"); - registerAllForRuntimeReflection(access, "com.mysql.cj.conf.url.SingleConnectionUrl"); - // Required for X protocol - registerAllForRuntimeReflection(access, "com.mysql.cj.conf.url.XDevApiConnectionUrl"); - registerAllForRuntimeReflection(access, "com.mysql.cj.protocol.x.SyncFlushDeflaterOutputStream"); - registerAllForRuntimeReflection(access, "java.util.zip.InflaterInputStream"); - - registerFieldsAndMethodsWithReflectiveAccess(access, "com.mysql.cj.protocol.StandardSocketFactory"); - registerFieldsAndMethodsWithReflectiveAccess(access, "com.mysql.cj.jdbc.AbandonedConnectionCleanupThread"); - - addResourcePatterns( - "META-INF/services/java.sql.Driver", - "com/mysql/cj/TlsSettings.properties", - "com/mysql/cj/LocalizedErrorMessages.properties", - "com/mysql/cj/util/TimeZoneMapping.properties" - ); - addResourceBundles("com.mysql.cj.LocalizedErrorMessages"); - - initializeAtRunTime(access, "java.sql.DriverManager"); - } - } - -} diff --git a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/dynamic-proxy-config.json b/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/dynamic-proxy-config.json deleted file mode 100644 index e5d4e6c14..000000000 --- a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/dynamic-proxy-config.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - ["java.sql.Statement"], - ["java.sql.PreparedStatement"] -] diff --git a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/native-image.properties b/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/native-image.properties index 346682360..9e53853c8 100644 --- a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/native-image.properties +++ b/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/native-image.properties @@ -14,5 +14,4 @@ # limitations under the License. # -Args = -H:DynamicProxyConfigurationResources=${.}/dynamic-proxy-config.json \ - --add-modules=java.sql.rowset +Args = --add-modules=java.sql.rowset diff --git a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/reflect-config.json b/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/reflect-config.json deleted file mode 100644 index df2611e63..000000000 --- a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/reflect-config.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "condition": { - "typeReachable": "org.mariadb.jdbc.Configuration" - }, - "name": "org.mariadb.jdbc.Configuration", - "allDeclaredFields": true - }, - { - "condition": { - "typeReachable": "org.mariadb.jdbc.Configuration" - }, - "name": "org.mariadb.jdbc.Configuration$Builder", - "allDeclaredFields": true - }, - { - "condition": { - "typeReachable": "org.mariadb.jdbc.plugin.authentication.standard.NativePasswordPlugin" - }, - "name": "sun.security.provider.SHA", - "methods": [ - { - "name": "", - "parameterTypes": [] - } - ] - } -] diff --git a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json b/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json index e0e481e23..0dc99e44d 100644 --- a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json +++ b/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json @@ -1,13 +1,10 @@ { - "bundles": [], - "resources": { - "includes": [ - { - "condition": { - "typeReachable": "org.mariadb.jdbc.util.VersionFactory" - }, - "pattern": "\\Qmariadb.properties\\E" - } - ] - } + "bundles": [ + { + "condition": { + "typeReachable": "com.microsoft.sqlserver.jdbc.SQLServerResource" + }, + "name": "com.microsoft.sqlserver.jdbc.SQLServerResource" + } + ] } From 8a104b8c59840b0d459abc8ae57c468aba464265 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Thu, 9 Mar 2023 10:39:27 +0100 Subject: [PATCH 04/19] Metadata migration --- ...aut.build.internal.test-application.gradle | 6 - .../hibernate/jpa/graal/HibernateFeature.java | 120 ------ .../jpa/graal/HibernateSubstitutions.java | 379 ------------------ .../hibernate/jpa/graal/package-info.java | 22 - .../jpa/graal/HibernateFeature.java | 120 ------ .../jpa/graal/HibernateSubstitutions.java | 223 ----------- .../hibernate6/jpa/graal/package-info.java | 22 - .../micronaut-jdbc/resource-config.json | 2 +- 8 files changed, 1 insertion(+), 893 deletions(-) delete mode 100644 hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateFeature.java delete mode 100644 hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateSubstitutions.java delete mode 100644 hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/package-info.java delete mode 100644 hibernate6-jpa/src/main/java/io/micronaut/configuration/hibernate6/jpa/graal/HibernateFeature.java delete mode 100644 hibernate6-jpa/src/main/java/io/micronaut/configuration/hibernate6/jpa/graal/HibernateSubstitutions.java delete mode 100644 hibernate6-jpa/src/main/java/io/micronaut/configuration/hibernate6/jpa/graal/package-info.java diff --git a/buildSrc/src/main/groovy/io.micronaut.build.internal.test-application.gradle b/buildSrc/src/main/groovy/io.micronaut.build.internal.test-application.gradle index 250702aa0..b66b6d694 100644 --- a/buildSrc/src/main/groovy/io.micronaut.build.internal.test-application.gradle +++ b/buildSrc/src/main/groovy/io.micronaut.build.internal.test-application.gradle @@ -35,12 +35,6 @@ tasks.named("check") { task -> } } -// TODO: Remove when micronaut-gradle-plugin gets upgraded to 4.0.0 version -project.afterEvaluate { - // Disabled since native tests are executed by 'nativeTest' task from Native Build Tools plugin - nativeCompile.enabled = false -} - graalvmNative { toolchainDetection = false binaries { diff --git a/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateFeature.java b/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateFeature.java deleted file mode 100644 index 578229ba5..000000000 --- a/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateFeature.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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 io.micronaut.configuration.hibernate.jpa.graal; - -import com.oracle.svm.core.annotate.AutomaticFeature; -import io.micronaut.core.annotation.Internal; -import io.micronaut.core.graal.AutomaticFeatureUtils; -import org.graalvm.nativeimage.hosted.Feature; -import org.hibernate.dialect.*; - -/** - * Feature for automatically configuring the dialect for the active driver with GraalVM. - * - * @author graemerocher - * @author Iván López - * @since 2.2.1 - */ -@AutomaticFeature -@Internal -final class HibernateFeature implements Feature { - - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - registerIfPresent(access, "org.h2.Driver", - H2Dialect.class - ); - - Class[] postgresDialects = {PostgreSQL9Dialect.class, - PostgreSQL10Dialect.class, - PostgreSQL91Dialect.class, - PostgreSQL92Dialect.class, - PostgreSQL93Dialect.class, - PostgreSQL94Dialect.class, - PostgreSQL95Dialect.class, - PostgreSQL81Dialect.class, - PostgreSQL82Dialect.class}; - - registerIfPresent(access, "org.postgresql.Driver", postgresDialects); - registerIfPresent(access, "io.vertx.pgclient.spi.PgDriver", postgresDialects); - - Class[] mariaDialects = {MariaDBDialect.class, - MariaDB10Dialect.class, - MariaDB102Dialect.class, - MariaDB103Dialect.class, - MariaDB53Dialect.class}; - - registerIfPresent(access, "org.mariadb.jdbc.Driver", mariaDialects); - registerIfPresent(access, "io.vertx.mysqlclient.spi.MySQLDriver", mariaDialects); - - Class[] oracleDialects = {Oracle8iDialect.class, - Oracle9iDialect.class, - Oracle10gDialect.class, - Oracle12cDialect.class}; - - registerIfPresent(access, "oracle.jdbc.OracleDriver", oracleDialects); - registerIfPresent(access, "io.vertx.oracleclient.spi.OracleDriver", oracleDialects); - - Class[] sqlServerDialects = {SQLServerDialect.class, - SQLServer2005Dialect.class, - SQLServer2008Dialect.class, - SQLServer2012Dialect.class}; - - registerIfPresent(access, "com.microsoft.sqlserver.jdbc.SQLServerDriver", sqlServerDialects); - registerIfPresent(access, "io.vertx.mssqlclient.spi.MSSQLDriver", sqlServerDialects); - - Class[] mysqlDialects = {MySQL5Dialect.class, - MySQL55Dialect.class, - MySQL57Dialect.class, - MySQL8Dialect.class}; - - registerIfPresent(access, "com.mysql.cj.jdbc.Driver", mysqlDialects); - registerIfPresent(access, "io.vertx.mysqlclient.spi.MySQLDriver", mysqlDialects); - - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.entity.JoinedSubclassEntityPersister"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.entity.SingleTableEntityPersister"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.entity.UnionSubclassEntityPersister"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.collection.OneToManyPersister"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.collection.BasicCollectionPersister"); - - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.sql.ordering.antlr.NodeSupport"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.sql.ordering.antlr.SortKey"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.sql.ordering.antlr.OrderingSpecification"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.sql.ordering.antlr.SortSpecification"); - AutomaticFeatureUtils.registerClassForRuntimeReflectionAndReflectiveInstantiation( - access, "org.hibernate.sql.ordering.antlr.OrderByFragment"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection(access, "antlr.CommonToken"); - } - - private void registerIfPresent(BeforeAnalysisAccess access, String name, Class... dialects) { - Class driver = access.findClassByName(name); - boolean present = driver != null; - if (present) { - for (Class dialect : dialects) { - AutomaticFeatureUtils.registerClassForRuntimeReflectionAndReflectiveInstantiation(access, dialect.getName()); - } - } - } -} diff --git a/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateSubstitutions.java b/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateSubstitutions.java deleted file mode 100644 index 4b035f740..000000000 --- a/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateSubstitutions.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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 io.micronaut.configuration.hibernate.jpa.graal; - -/* - * Internal class that provides substitutions for Hibernate on GraalVM substrate. - * - * @author graemerocher - * @since 1.2.0 - */ - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import io.micronaut.configuration.hibernate.jpa.proxy.IntrospectedHibernateBytecodeProvider; -import io.micronaut.core.annotation.TypeHint; -import io.micronaut.core.annotation.TypeHint.AccessType; -import io.micronaut.jdbc.spring.HibernatePresenceCondition; -import org.hibernate.boot.archive.spi.InputStreamAccess; -import org.hibernate.boot.jaxb.internal.MappingBinder; -import org.hibernate.boot.jaxb.spi.Binding; -import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl; -import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; -import org.hibernate.bytecode.spi.BytecodeProvider; -import org.hibernate.event.spi.EventType; -import org.hibernate.hql.internal.ast.HqlToken; -import org.hibernate.hql.internal.ast.tree.AggregateNode; -import org.hibernate.hql.internal.ast.tree.AssignmentSpecification; -import org.hibernate.hql.internal.ast.tree.BetweenOperatorNode; -import org.hibernate.hql.internal.ast.tree.BinaryArithmeticOperatorNode; -import org.hibernate.hql.internal.ast.tree.BinaryLogicOperatorNode; -import org.hibernate.hql.internal.ast.tree.BooleanLiteralNode; -import org.hibernate.hql.internal.ast.tree.CastFunctionNode; -import org.hibernate.hql.internal.ast.tree.CollectionFunction; -import org.hibernate.hql.internal.ast.tree.ComponentJoin; -import org.hibernate.hql.internal.ast.tree.ConstructorNode; -import org.hibernate.hql.internal.ast.tree.CountNode; -import org.hibernate.hql.internal.ast.tree.DeleteStatement; -import org.hibernate.hql.internal.ast.tree.DotNode; -import org.hibernate.hql.internal.ast.tree.EntityJoinFromElement; -import org.hibernate.hql.internal.ast.tree.FromClause; -import org.hibernate.hql.internal.ast.tree.FromElement; -import org.hibernate.hql.internal.ast.tree.FromElementFactory; -import org.hibernate.hql.internal.ast.tree.FromReferenceNode; -import org.hibernate.hql.internal.ast.tree.HqlSqlWalkerNode; -import org.hibernate.hql.internal.ast.tree.IdentNode; -import org.hibernate.hql.internal.ast.tree.ImpliedFromElement; -import org.hibernate.hql.internal.ast.tree.InLogicOperatorNode; -import org.hibernate.hql.internal.ast.tree.IndexNode; -import org.hibernate.hql.internal.ast.tree.InsertStatement; -import org.hibernate.hql.internal.ast.tree.IntoClause; -import org.hibernate.hql.internal.ast.tree.IsNotNullLogicOperatorNode; -import org.hibernate.hql.internal.ast.tree.IsNullLogicOperatorNode; -import org.hibernate.hql.internal.ast.tree.JavaConstantNode; -import org.hibernate.hql.internal.ast.tree.LiteralNode; -import org.hibernate.hql.internal.ast.tree.MapEntryNode; -import org.hibernate.hql.internal.ast.tree.MapKeyEntityFromElement; -import org.hibernate.hql.internal.ast.tree.MapKeyNode; -import org.hibernate.hql.internal.ast.tree.MapValueNode; -import org.hibernate.hql.internal.ast.tree.MethodNode; -import org.hibernate.hql.internal.ast.tree.Node; -import org.hibernate.hql.internal.ast.tree.NullNode; -import org.hibernate.hql.internal.ast.tree.OrderByClause; -import org.hibernate.hql.internal.ast.tree.ParameterNode; -import org.hibernate.hql.internal.ast.tree.QueryNode; -import org.hibernate.hql.internal.ast.tree.ResultVariableRefNode; -import org.hibernate.hql.internal.ast.tree.SearchedCaseNode; -import org.hibernate.hql.internal.ast.tree.SelectClause; -import org.hibernate.hql.internal.ast.tree.SelectExpressionImpl; -import org.hibernate.hql.internal.ast.tree.SelectExpressionList; -import org.hibernate.hql.internal.ast.tree.SimpleCaseNode; -import org.hibernate.hql.internal.ast.tree.SqlFragment; -import org.hibernate.hql.internal.ast.tree.SqlNode; -import org.hibernate.hql.internal.ast.tree.UnaryArithmeticNode; -import org.hibernate.hql.internal.ast.tree.UnaryLogicOperatorNode; -import org.hibernate.hql.internal.ast.tree.UpdateStatement; -import org.hibernate.id.Assigned; -import org.hibernate.id.ForeignGenerator; -import org.hibernate.id.GUIDGenerator; -import org.hibernate.id.IdentityGenerator; -import org.hibernate.id.IncrementGenerator; -import org.hibernate.id.SelectGenerator; -import org.hibernate.id.UUIDGenerator; -import org.hibernate.id.UUIDHexGenerator; -import org.hibernate.id.enhanced.HiLoOptimizer; -import org.hibernate.id.enhanced.LegacyHiLoAlgorithmOptimizer; -import org.hibernate.id.enhanced.NoopOptimizer; -import org.hibernate.id.enhanced.PooledLoOptimizer; -import org.hibernate.id.enhanced.PooledLoThreadLocalOptimizer; -import org.hibernate.id.enhanced.PooledOptimizer; -import org.hibernate.id.enhanced.SequenceStyleGenerator; -import org.hibernate.id.enhanced.TableGenerator; -import org.hibernate.jmx.spi.JmxService; -import org.hibernate.persister.collection.BasicCollectionPersister; -import org.hibernate.persister.collection.OneToManyPersister; -import org.hibernate.persister.entity.SingleTableEntityPersister; -import org.hibernate.service.Service; -import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.spi.Manageable; -import org.hibernate.service.spi.Stoppable; -import org.hibernate.tuple.component.PojoComponentTuplizer; -import org.hibernate.tuple.entity.EntityMetamodel; -import org.hibernate.tuple.entity.PojoEntityTuplizer; -import org.hibernate.type.EnumType; - -import javax.management.ObjectName; -import javax.xml.stream.XMLResolver; -import javax.xml.stream.XMLStreamException; -import java.io.File; -import java.io.InputStream; -import java.net.URL; -import java.util.Map; -import java.util.Properties; - -// Additional classes -@TypeHint( - typeNames = { - "org.hibernate.internal.CoreMessageLogger_$logger", - "org.hibernate.internal.EntityManagerMessageLogger_$logger", - "org.hibernate.annotations.common.util.impl.Log_$logger", - "com.sun.xml.internal.stream.events.XMLEventFactoryImpl", - "org.hibernate.bytecode.enhance.spi.interceptor.BytecodeInterceptorLogging_$logger", - "org.hibernate.envers.internal.EnversMessageLogger_$logger", - } -) -final class Loggers { -} - -// For HQL and other Hibernate internal classes -@TypeHint(value = { - // Hibernate - HibernatePresenceCondition.class, - SingleTableEntityPersister.class, - EntityMetamodel.class, - PojoComponentTuplizer.class, - PojoEntityTuplizer.class, - BasicCollectionPersister.class, - HqlToken.class, - OneToManyPersister.class, - // Hibernate AST - AggregateNode.class, - AssignmentSpecification.class, - BetweenOperatorNode.class, - BinaryArithmeticOperatorNode.class, - BinaryLogicOperatorNode.class, - BooleanLiteralNode.class, - CastFunctionNode.class, - CollectionFunction.class, - ComponentJoin.class, - ConstructorNode.class, - CountNode.class, - DeleteStatement.class, - DotNode.class, - EntityJoinFromElement.class, - FromClause.class, - FromElement.class, - FromElementFactory.class, - FromReferenceNode.class, - HqlSqlWalkerNode.class, - IdentNode.class, - ImpliedFromElement.class, - IndexNode.class, - InLogicOperatorNode.class, - InsertStatement.class, - IntoClause.class, - IsNotNullLogicOperatorNode.class, - IsNullLogicOperatorNode.class, - JavaConstantNode.class, - LiteralNode.class, - MapEntryNode.class, - MapKeyEntityFromElement.class, - MapKeyNode.class, - MapValueNode.class, - MethodNode.class, - Node.class, - NullNode.class, - OrderByClause.class, - ParameterNode.class, - QueryNode.class, - ResultVariableRefNode.class, - SearchedCaseNode.class, - SelectClause.class, - SelectExpressionImpl.class, - SelectExpressionList.class, - SimpleCaseNode.class, - SqlFragment.class, - SqlNode.class, - UnaryArithmeticNode.class, - UnaryLogicOperatorNode.class, - UpdateStatement.class, - // Others - ImplicitNamingStrategyJpaCompliantImpl.class -}, typeNames = { - "org.hibernate.event.spi.AutoFlushEventListener[]", - "org.hibernate.event.spi.ClearEventListener[]", - "org.hibernate.event.spi.DeleteEventListener[]", - "org.hibernate.event.spi.DirtyCheckEventListener[]", - "org.hibernate.event.spi.EvictEventListener[]", - "org.hibernate.event.spi.FlushEntityEventListener[]", - "org.hibernate.event.spi.FlushEventListener[]", - "org.hibernate.event.spi.InitializeCollectionEventListener[]", - "org.hibernate.event.spi.LockEventListener[]", - "org.hibernate.event.spi.MergeEventListener[]", - "org.hibernate.event.spi.PersistEventListener[]", - "org.hibernate.event.spi.PostActionEventListener[]", - "org.hibernate.event.spi.PostCollectionRecreateEventListener[]", - "org.hibernate.event.spi.PostCollectionRemoveEventListener[]", - "org.hibernate.event.spi.PostCollectionUpdateEventListener[]", - "org.hibernate.event.spi.PostCommitDeleteEventListener[]", - "org.hibernate.event.spi.PostCommitInsertEventListener[]", - "org.hibernate.event.spi.PostCommitUpdateEventListener[]", - "org.hibernate.event.spi.PostDeleteEventListener[]", - "org.hibernate.event.spi.PostInsertEventListener[]", - "org.hibernate.event.spi.PostLoadEventListener[]", - "org.hibernate.event.spi.PostUpdateEventListener[]", - "org.hibernate.event.spi.PreCollectionRecreateEventListener[]", - "org.hibernate.event.spi.PreCollectionRemoveEventListener[]", - "org.hibernate.event.spi.PreCollectionUpdateEventListener[]", - "org.hibernate.event.spi.PreDeleteEventListener[]", - "org.hibernate.event.spi.PreInsertEventListener[]", - "org.hibernate.event.spi.PreLoadEventListener[]", - "org.hibernate.event.spi.PreUpdateEventListener[]", - "org.hibernate.event.spi.RefreshEventListener[]", - "org.hibernate.event.spi.ReplicateEventListener[]", - "org.hibernate.event.spi.ResolveNaturalIdEventListener[]", - "org.hibernate.event.spi.SaveOrUpdateEventListener[]", - "org.hibernate.event.spi.LoadEventListener[]", - // Hibernate Envers - "org.dom4j.DocumentFactory", - "org.hibernate.envers.DefaultRevisionEntity", - "org.hibernate.envers.boot.internal.LegacyModifiedColumnNamingStrategy", - "org.hibernate.envers.configuration.internal.ClassesAuditingData", - "org.hibernate.envers.configuration.internal.RevisionInfoConfiguration", - "org.hibernate.envers.internal.EnversMessageLogger", - "org.hibernate.envers.strategy.DefaultAuditStrategy", - "org.hibernate.envers.strategy.internal.DefaultAuditStrategy", - "java.util.ServiceLoader$Provider" -}, - accessType = {TypeHint.AccessType.ALL_PUBLIC}) -final class Hql { -} - -@TypeHint(typeNames = "org.hibernate.cfg.beanvalidation.TypeSafeActivator", accessType = {TypeHint.AccessType.ALL_PUBLIC}) -final class Cfg { -} - -// ID Generators -@TypeHint({ - UUIDGenerator.class, - GUIDGenerator.class, - UUIDHexGenerator.class, - Assigned.class, - IdentityGenerator.class, - SelectGenerator.class, - SequenceStyleGenerator.class, - IncrementGenerator.class, - ForeignGenerator.class, - TableGenerator.class -}) -final class IdGenerators { -} - -// ID Optimizers -@TypeHint({ - NoopOptimizer.class, - HiLoOptimizer.class, - LegacyHiLoAlgorithmOptimizer.class, - PooledOptimizer.class, - PooledLoOptimizer.class, - PooledLoThreadLocalOptimizer.class -}) -final class IdOptimizers { -} - -// Disable Runtime Byte Code Enhancement -@TargetClass(className = "org.hibernate.cfg.Environment") -@TypeHint( - value = {EventType.class, EnumType.class}, - accessType = {AccessType.ALL_DECLARED_FIELDS, AccessType.ALL_DECLARED_METHODS, AccessType.ALL_DECLARED_CONSTRUCTORS} -) -final class EnvironmentSubs { - @Substitute - public static BytecodeProvider buildBytecodeProvider(Properties properties) { - return new IntrospectedHibernateBytecodeProvider(); - } -} - -// Disable JMX support -@TargetClass(className = "org.hibernate.jmx.internal.JmxServiceImpl") -@Substitute -final class NoopJmxService implements JmxService, Stoppable { - - @Substitute - public NoopJmxService(Map configValues) { - } - - @Override - public void stop() { - - } - - @Override - public void registerService(Manageable service, Class serviceRole) { - - } - - @Override - public void registerMBean(ObjectName objectName, Object mBean) { - - } -} - -// Disable XML support -@TargetClass(className = "org.hibernate.boot.spi.XmlMappingBinderAccess") -@Substitute -final class NoopXmlMappingBinderAccess { - - @Substitute - public NoopXmlMappingBinderAccess(ServiceRegistry serviceRegistry) { - } - - @Substitute - public MappingBinder getMappingBinder() { - return null; - } - - @Substitute - public Binding bind(String resource) { - return null; - } - - @Substitute - public Binding bind(File file) { - return null; - } - - @Substitute - public Binding bind(InputStreamAccess xmlInputStreamAccess) { - return null; - } - - @Substitute - public Binding bind(InputStream xmlInputStream) { - return null; - } - - @Substitute - public Binding bind(URL url) { - return null; - } -} - -// Disable Schema Resolution -@TargetClass(className = "org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver") -@Substitute -final class NoopSchemaResolver implements XMLResolver { - @Substitute - public NoopSchemaResolver(ClassLoaderService classLoaderService) { - } - - @Override - @Substitute - public Object resolveEntity(String publicID, String systemID, String baseURI, String namespace) - throws XMLStreamException { - return null; - } -} diff --git a/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/package-info.java b/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/package-info.java deleted file mode 100644 index e2d036054..000000000 --- a/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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. - */ -/** - * This package contains GraalVM Substrate specific classes. - * - * @author graemerocher - * @since 1.0 - */ -package io.micronaut.configuration.hibernate.jpa.graal; diff --git a/hibernate6-jpa/src/main/java/io/micronaut/configuration/hibernate6/jpa/graal/HibernateFeature.java b/hibernate6-jpa/src/main/java/io/micronaut/configuration/hibernate6/jpa/graal/HibernateFeature.java deleted file mode 100644 index 5728f9979..000000000 --- a/hibernate6-jpa/src/main/java/io/micronaut/configuration/hibernate6/jpa/graal/HibernateFeature.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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 io.micronaut.configuration.hibernate6.jpa.graal; - -import com.oracle.svm.core.annotate.AutomaticFeature; -import io.micronaut.core.annotation.Internal; -import io.micronaut.core.graal.AutomaticFeatureUtils; -import org.graalvm.nativeimage.hosted.Feature; -import org.hibernate.dialect.*; - -/** - * Feature for automatically configuring the dialect for the active driver with GraalVM. - * - * @author graemerocher - * @author Iván López - * @since 2.2.1 - */ -@AutomaticFeature -@Internal -final class HibernateFeature implements Feature { - - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - registerIfPresent(access, "org.h2.Driver", - H2Dialect.class - ); - - Class[] postgresDialects = {PostgreSQL9Dialect.class, - PostgreSQLDialect.class, - PostgreSQL91Dialect.class, - PostgreSQL92Dialect.class, - PostgreSQL93Dialect.class, - PostgreSQL94Dialect.class, - PostgreSQL95Dialect.class, - PostgreSQL81Dialect.class, - PostgreSQL82Dialect.class}; - - registerIfPresent(access, "org.postgresql.Driver", postgresDialects); - registerIfPresent(access, "io.vertx.pgclient.spi.PgDriver", postgresDialects); - - Class[] mariaDialects = {MariaDBDialect.class, - MariaDB10Dialect.class, - MariaDB102Dialect.class, - MariaDB103Dialect.class, - MariaDB53Dialect.class}; - - registerIfPresent(access, "org.mariadb.jdbc.Driver", mariaDialects); - registerIfPresent(access, "io.vertx.mysqlclient.spi.MySQLDriver", mariaDialects); - - Class[] oracleDialects = {Oracle8iDialect.class, - Oracle9iDialect.class, - Oracle10gDialect.class, - Oracle12cDialect.class}; - - registerIfPresent(access, "oracle.jdbc.OracleDriver", oracleDialects); - registerIfPresent(access, "io.vertx.oracleclient.spi.OracleDriver", oracleDialects); - - Class[] sqlServerDialects = {SQLServerDialect.class, - SQLServer2005Dialect.class, - SQLServer2008Dialect.class, - SQLServer2012Dialect.class}; - - registerIfPresent(access, "com.microsoft.sqlserver.jdbc.SQLServerDriver", sqlServerDialects); - registerIfPresent(access, "io.vertx.mssqlclient.spi.MSSQLDriver", sqlServerDialects); - - Class[] mysqlDialects = {MySQL5Dialect.class, - MySQL55Dialect.class, - MySQL57Dialect.class, - MySQL8Dialect.class}; - - registerIfPresent(access, "com.mysql.cj.jdbc.Driver", mysqlDialects); - registerIfPresent(access, "io.vertx.mysqlclient.spi.MySQLDriver", mysqlDialects); - - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.entity.JoinedSubclassEntityPersister"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.entity.SingleTableEntityPersister"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.entity.UnionSubclassEntityPersister"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.collection.OneToManyPersister"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.collection.BasicCollectionPersister"); - - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.sql.ordering.antlr.NodeSupport"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.sql.ordering.antlr.SortKey"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.sql.ordering.antlr.OrderingSpecification"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.sql.ordering.antlr.SortSpecification"); - AutomaticFeatureUtils.registerClassForRuntimeReflectionAndReflectiveInstantiation( - access, "org.hibernate.sql.ordering.antlr.OrderByFragment"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection(access, "antlr.CommonToken"); - } - - private void registerIfPresent(BeforeAnalysisAccess access, String name, Class... dialects) { - Class driver = access.findClassByName(name); - boolean present = driver != null; - if (present) { - for (Class dialect : dialects) { - AutomaticFeatureUtils.registerClassForRuntimeReflectionAndReflectiveInstantiation(access, dialect.getName()); - } - } - } -} diff --git a/hibernate6-jpa/src/main/java/io/micronaut/configuration/hibernate6/jpa/graal/HibernateSubstitutions.java b/hibernate6-jpa/src/main/java/io/micronaut/configuration/hibernate6/jpa/graal/HibernateSubstitutions.java deleted file mode 100644 index f4affa91f..000000000 --- a/hibernate6-jpa/src/main/java/io/micronaut/configuration/hibernate6/jpa/graal/HibernateSubstitutions.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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 io.micronaut.configuration.hibernate6.jpa.graal; - -/* - * Internal class that provides substitutions for Hibernate on GraalVM substrate. - * - * @author graemerocher - * @since 1.2.0 - */ - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import io.micronaut.core.annotation.TypeHint; -import io.micronaut.core.annotation.TypeHint.AccessType; -import io.micronaut.jdbc.spring.HibernatePresenceCondition; -import org.hibernate.boot.ResourceStreamLocator; -import org.hibernate.boot.archive.spi.InputStreamAccess; -import org.hibernate.boot.jaxb.internal.MappingBinder; -import org.hibernate.boot.jaxb.spi.Binding; -import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl; -import org.hibernate.id.Assigned; -import org.hibernate.id.ForeignGenerator; -import org.hibernate.id.GUIDGenerator; -import org.hibernate.id.IdentityGenerator; -import org.hibernate.id.IncrementGenerator; -import org.hibernate.id.SelectGenerator; -import org.hibernate.id.UUIDGenerator; -import org.hibernate.id.UUIDHexGenerator; -import org.hibernate.id.enhanced.HiLoOptimizer; -import org.hibernate.id.enhanced.LegacyHiLoAlgorithmOptimizer; -import org.hibernate.id.enhanced.NoopOptimizer; -import org.hibernate.id.enhanced.PooledLoOptimizer; -import org.hibernate.id.enhanced.PooledLoThreadLocalOptimizer; -import org.hibernate.id.enhanced.PooledOptimizer; -import org.hibernate.id.enhanced.SequenceStyleGenerator; -import org.hibernate.id.enhanced.TableGenerator; -import org.hibernate.persister.collection.BasicCollectionPersister; -import org.hibernate.persister.collection.OneToManyPersister; -import org.hibernate.persister.entity.SingleTableEntityPersister; -import org.hibernate.service.ServiceRegistry; -import org.hibernate.tuple.entity.EntityMetamodel; - -import javax.xml.stream.XMLResolver; -import javax.xml.stream.XMLStreamException; -import java.io.File; -import java.io.InputStream; -import java.net.URL; - -// Additional classes -@TypeHint( - typeNames = { - "org.hibernate.internal.CoreMessageLogger_$logger", - "org.hibernate.internal.EntityManagerMessageLogger_$logger", - "org.hibernate.annotations.common.util.impl.Log_$logger", - "com.sun.xml.internal.stream.events.XMLEventFactoryImpl", - "org.hibernate.bytecode.enhance.spi.interceptor.BytecodeInterceptorLogging_$logger", - "org.hibernate.envers.internal.EnversMessageLogger_$logger", - } -) -final class Loggers { -} - -// For HQL and other Hibernate internal classes -@TypeHint(value = { - // Hibernate - HibernatePresenceCondition.class, - SingleTableEntityPersister.class, - EntityMetamodel.class, - BasicCollectionPersister.class, - OneToManyPersister.class, - // Others - ImplicitNamingStrategyJpaCompliantImpl.class -}, typeNames = { - "org.hibernate.event.spi.AutoFlushEventListener[]", - "org.hibernate.event.spi.ClearEventListener[]", - "org.hibernate.event.spi.DeleteEventListener[]", - "org.hibernate.event.spi.DirtyCheckEventListener[]", - "org.hibernate.event.spi.EvictEventListener[]", - "org.hibernate.event.spi.FlushEntityEventListener[]", - "org.hibernate.event.spi.FlushEventListener[]", - "org.hibernate.event.spi.InitializeCollectionEventListener[]", - "org.hibernate.event.spi.LockEventListener[]", - "org.hibernate.event.spi.MergeEventListener[]", - "org.hibernate.event.spi.PersistEventListener[]", - "org.hibernate.event.spi.PostActionEventListener[]", - "org.hibernate.event.spi.PostCollectionRecreateEventListener[]", - "org.hibernate.event.spi.PostCollectionRemoveEventListener[]", - "org.hibernate.event.spi.PostCollectionUpdateEventListener[]", - "org.hibernate.event.spi.PostCommitDeleteEventListener[]", - "org.hibernate.event.spi.PostCommitInsertEventListener[]", - "org.hibernate.event.spi.PostCommitUpdateEventListener[]", - "org.hibernate.event.spi.PostDeleteEventListener[]", - "org.hibernate.event.spi.PostInsertEventListener[]", - "org.hibernate.event.spi.PostLoadEventListener[]", - "org.hibernate.event.spi.PostUpdateEventListener[]", - "org.hibernate.event.spi.PreCollectionRecreateEventListener[]", - "org.hibernate.event.spi.PreCollectionRemoveEventListener[]", - "org.hibernate.event.spi.PreCollectionUpdateEventListener[]", - "org.hibernate.event.spi.PreDeleteEventListener[]", - "org.hibernate.event.spi.PreInsertEventListener[]", - "org.hibernate.event.spi.PreLoadEventListener[]", - "org.hibernate.event.spi.PreUpdateEventListener[]", - "org.hibernate.event.spi.RefreshEventListener[]", - "org.hibernate.event.spi.ReplicateEventListener[]", - "org.hibernate.event.spi.ResolveNaturalIdEventListener[]", - "org.hibernate.event.spi.SaveOrUpdateEventListener[]", - "org.hibernate.event.spi.LoadEventListener[]", - // Hibernate Envers - "org.dom4j.DocumentFactory", - "org.hibernate.envers.DefaultRevisionEntity", - "org.hibernate.envers.boot.internal.LegacyModifiedColumnNamingStrategy", - "org.hibernate.envers.configuration.internal.ClassesAuditingData", - "org.hibernate.envers.configuration.internal.RevisionInfoConfiguration", - "org.hibernate.envers.internal.EnversMessageLogger", - "org.hibernate.envers.strategy.DefaultAuditStrategy", - "org.hibernate.envers.strategy.internal.DefaultAuditStrategy", - "java.util.ServiceLoader$Provider" -}, - accessType = {AccessType.ALL_PUBLIC}) -final class Hql { -} - -@TypeHint(typeNames = "org.hibernate.cfg.beanvalidation.TypeSafeActivator", accessType = {AccessType.ALL_PUBLIC}) -final class Cfg { -} - -// ID Generators -@TypeHint({ - UUIDGenerator.class, - GUIDGenerator.class, - UUIDHexGenerator.class, - Assigned.class, - IdentityGenerator.class, - SelectGenerator.class, - SequenceStyleGenerator.class, - IncrementGenerator.class, - ForeignGenerator.class, - TableGenerator.class -}) -final class IdGenerators { -} - -// ID Optimizers -@TypeHint({ - NoopOptimizer.class, - HiLoOptimizer.class, - LegacyHiLoAlgorithmOptimizer.class, - PooledOptimizer.class, - PooledLoOptimizer.class, - PooledLoThreadLocalOptimizer.class -}) -final class IdOptimizers { -} - -// Disable XML support -@TargetClass(className = "org.hibernate.boot.spi.XmlMappingBinderAccess") -@Substitute -final class NoopXmlMappingBinderAccess { - - @Substitute - public NoopXmlMappingBinderAccess(ServiceRegistry serviceRegistry) { - } - - @Substitute - public MappingBinder getMappingBinder() { - return null; - } - - @Substitute - public Binding bind(String resource) { - return null; - } - - @Substitute - public Binding bind(File file) { - return null; - } - - @Substitute - public Binding bind(InputStreamAccess xmlInputStreamAccess) { - return null; - } - - @Substitute - public Binding bind(InputStream xmlInputStream) { - return null; - } - - @Substitute - public Binding bind(URL url) { - return null; - } -} - -// Disable Schema Resolution -@TargetClass(className = "org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver") -@Substitute -final class NoopSchemaResolver implements XMLResolver { - @Substitute - public NoopSchemaResolver(ResourceStreamLocator resourceStreamLocator) { - } - - @Override - @Substitute - public Object resolveEntity(String publicID, String systemID, String baseURI, String namespace) - throws XMLStreamException { - return null; - } -} diff --git a/hibernate6-jpa/src/main/java/io/micronaut/configuration/hibernate6/jpa/graal/package-info.java b/hibernate6-jpa/src/main/java/io/micronaut/configuration/hibernate6/jpa/graal/package-info.java deleted file mode 100644 index 6ad8de53f..000000000 --- a/hibernate6-jpa/src/main/java/io/micronaut/configuration/hibernate6/jpa/graal/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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. - */ -/** - * This package contains GraalVM Substrate specific classes. - * - * @author graemerocher - * @since 1.0 - */ -package io.micronaut.configuration.hibernate6.jpa.graal; diff --git a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json b/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json index 0dc99e44d..0623e7ecd 100644 --- a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json +++ b/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json @@ -2,7 +2,7 @@ "bundles": [ { "condition": { - "typeReachable": "com.microsoft.sqlserver.jdbc.SQLServerResource" + "typeReachable": "com.microsoft.sqlserver.jdbc.SQLServerDriver" }, "name": "com.microsoft.sqlserver.jdbc.SQLServerResource" } From f21092b6f90d13802ca277658e2e4ab53ffb17e7 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Wed, 22 Mar 2023 09:04:02 +0100 Subject: [PATCH 05/19] Fixed dependency --- tests/common-sync/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/common-sync/build.gradle b/tests/common-sync/build.gradle index 26960242c..59e1d42c6 100644 --- a/tests/common-sync/build.gradle +++ b/tests/common-sync/build.gradle @@ -5,7 +5,7 @@ plugins { dependencies { implementation mn.micronaut.http implementation mn.micronaut.runtime - api(projects.tests.common) + api(projects.micronautTests.micronautCommon) api(mnData.micronaut.data.tx) implementation(mnSerde.micronaut.serde.jackson) From 5e3d88481aa078b7c639dc98bd0d27779dd17043 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Thu, 23 Mar 2023 07:50:30 +0100 Subject: [PATCH 06/19] Enabled hib6 native tests --- .../hibernate/jpa/graal/HibernateFeature.java | 103 -------- .../jpa/graal/HibernateSubstitutions.java | 241 ------------------ tests/hibernate6/hibernate6-h2/build.gradle | 5 - .../hibernate6-mariadb/build.gradle | 5 - .../hibernate6/hibernate6-mssql/build.gradle | 2 - .../hibernate6/hibernate6-mysql/build.gradle | 5 - .../hibernate6/hibernate6-oracle/build.gradle | 5 - .../hibernate6-postgres/build.gradle | 5 - .../java/example/hibernate6/sync/Owner.java | 2 + .../src/main/resources/application.yml | 1 + 10 files changed, 3 insertions(+), 371 deletions(-) delete mode 100644 hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateFeature.java delete mode 100644 hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateSubstitutions.java diff --git a/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateFeature.java b/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateFeature.java deleted file mode 100644 index 2682c11a6..000000000 --- a/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateFeature.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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 io.micronaut.configuration.hibernate.jpa.graal; - -import com.oracle.svm.core.annotate.AutomaticFeature; -import io.micronaut.core.annotation.Internal; -import io.micronaut.core.graal.AutomaticFeatureUtils; -import org.graalvm.nativeimage.hosted.Feature; -import org.hibernate.dialect.*; - -/** - * Feature for automatically configuring the dialect for the active driver with GraalVM. - * - * @author graemerocher - * @author Iván López - * @since 2.2.1 - */ -@AutomaticFeature -@Internal -final class HibernateFeature implements Feature { - - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - registerIfPresent(access, "org.h2.Driver", - H2Dialect.class - ); - - Class[] postgresDialects = {PostgreSQLDialect.class}; - - registerIfPresent(access, "org.postgresql.Driver", postgresDialects); - registerIfPresent(access, "io.vertx.pgclient.spi.PgDriver", postgresDialects); - - Class[] mariaDialects = {MariaDBDialect.class, - MariaDB103Dialect.class}; - - registerIfPresent(access, "org.mariadb.jdbc.Driver", mariaDialects); - registerIfPresent(access, "io.vertx.mysqlclient.spi.MySQLDriver", mariaDialects); - - Class[] oracleDialects = {Oracle12cDialect.class}; - - registerIfPresent(access, "oracle.jdbc.OracleDriver", oracleDialects); - registerIfPresent(access, "io.vertx.oracleclient.spi.OracleDriver", oracleDialects); - - Class[] sqlServerDialects = {SQLServerDialect.class, - SQLServer2008Dialect.class, - SQLServer2012Dialect.class}; - - registerIfPresent(access, "com.microsoft.sqlserver.jdbc.SQLServerDriver", sqlServerDialects); - registerIfPresent(access, "io.vertx.mssqlclient.spi.MSSQLDriver", sqlServerDialects); - - Class[] mysqlDialects = {MySQL57Dialect.class, - MySQL8Dialect.class}; - - registerIfPresent(access, "com.mysql.cj.jdbc.Driver", mysqlDialects); - registerIfPresent(access, "io.vertx.mysqlclient.spi.MySQLDriver", mysqlDialects); - - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.entity.JoinedSubclassEntityPersister"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.entity.SingleTableEntityPersister"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.entity.UnionSubclassEntityPersister"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.collection.OneToManyPersister"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.persister.collection.BasicCollectionPersister"); - - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.sql.ordering.antlr.NodeSupport"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.sql.ordering.antlr.SortKey"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.sql.ordering.antlr.OrderingSpecification"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection( - access, "org.hibernate.sql.ordering.antlr.SortSpecification"); - AutomaticFeatureUtils.registerClassForRuntimeReflectionAndReflectiveInstantiation( - access, "org.hibernate.sql.ordering.antlr.OrderByFragment"); - AutomaticFeatureUtils.registerConstructorsForRuntimeReflection(access, "antlr.CommonToken"); - } - - private void registerIfPresent(BeforeAnalysisAccess access, String name, Class... dialects) { - Class driver = access.findClassByName(name); - boolean present = driver != null; - if (present) { - for (Class dialect : dialects) { - AutomaticFeatureUtils.registerClassForRuntimeReflectionAndReflectiveInstantiation(access, dialect.getName()); - } - } - } -} diff --git a/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateSubstitutions.java b/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateSubstitutions.java deleted file mode 100644 index 4ef3f2315..000000000 --- a/hibernate-jpa/src/main/java/io/micronaut/configuration/hibernate/jpa/graal/HibernateSubstitutions.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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 io.micronaut.configuration.hibernate.jpa.graal; - -/* - * Internal class that provides substitutions for Hibernate on GraalVM substrate. - * - * @author graemerocher - * @since 1.2.0 - */ - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import io.micronaut.configuration.hibernate.jpa.proxy.IntrospectedHibernateBytecodeProvider; -import io.micronaut.core.annotation.TypeHint; -import io.micronaut.core.annotation.TypeHint.AccessType; -import io.micronaut.jdbc.spring.HibernatePresenceCondition; -import org.hibernate.boot.ResourceStreamLocator; -import org.hibernate.boot.archive.spi.InputStreamAccess; -import org.hibernate.boot.jaxb.internal.MappingBinder; -import org.hibernate.boot.jaxb.spi.Binding; -import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl; -import org.hibernate.bytecode.spi.BytecodeProvider; -import org.hibernate.event.spi.EventType; -import org.hibernate.id.Assigned; -import org.hibernate.id.ForeignGenerator; -import org.hibernate.id.GUIDGenerator; -import org.hibernate.id.IdentityGenerator; -import org.hibernate.id.IncrementGenerator; -import org.hibernate.id.SelectGenerator; -import org.hibernate.id.UUIDGenerator; -import org.hibernate.id.UUIDHexGenerator; -import org.hibernate.id.enhanced.HiLoOptimizer; -import org.hibernate.id.enhanced.LegacyHiLoAlgorithmOptimizer; -import org.hibernate.id.enhanced.NoopOptimizer; -import org.hibernate.id.enhanced.PooledLoOptimizer; -import org.hibernate.id.enhanced.PooledLoThreadLocalOptimizer; -import org.hibernate.id.enhanced.PooledOptimizer; -import org.hibernate.id.enhanced.SequenceStyleGenerator; -import org.hibernate.id.enhanced.TableGenerator; -import org.hibernate.persister.collection.BasicCollectionPersister; -import org.hibernate.persister.collection.OneToManyPersister; -import org.hibernate.persister.entity.SingleTableEntityPersister; -import org.hibernate.service.ServiceRegistry; -import org.hibernate.tuple.entity.EntityMetamodel; -import org.hibernate.type.EnumType; - -import javax.xml.stream.XMLResolver; -import javax.xml.stream.XMLStreamException; -import java.io.File; -import java.io.InputStream; -import java.net.URL; -import java.util.Properties; - -// Additional classes -@TypeHint( - typeNames = { - "org.hibernate.internal.CoreMessageLogger_$logger", - "org.hibernate.internal.EntityManagerMessageLogger_$logger", - "org.hibernate.annotations.common.util.impl.Log_$logger", - "com.sun.xml.internal.stream.events.XMLEventFactoryImpl", - "org.hibernate.bytecode.enhance.spi.interceptor.BytecodeInterceptorLogging_$logger", - "org.hibernate.envers.internal.EnversMessageLogger_$logger", - } -) -final class Loggers { -} - -// For HQL and other Hibernate internal classes -@TypeHint(value = { - // Hibernate - HibernatePresenceCondition.class, - SingleTableEntityPersister.class, - EntityMetamodel.class, - BasicCollectionPersister.class, - OneToManyPersister.class, - // Others - ImplicitNamingStrategyJpaCompliantImpl.class -}, typeNames = { - "org.hibernate.event.spi.AutoFlushEventListener[]", - "org.hibernate.event.spi.ClearEventListener[]", - "org.hibernate.event.spi.DeleteEventListener[]", - "org.hibernate.event.spi.DirtyCheckEventListener[]", - "org.hibernate.event.spi.EvictEventListener[]", - "org.hibernate.event.spi.FlushEntityEventListener[]", - "org.hibernate.event.spi.FlushEventListener[]", - "org.hibernate.event.spi.InitializeCollectionEventListener[]", - "org.hibernate.event.spi.LockEventListener[]", - "org.hibernate.event.spi.MergeEventListener[]", - "org.hibernate.event.spi.PersistEventListener[]", - "org.hibernate.event.spi.PostActionEventListener[]", - "org.hibernate.event.spi.PostCollectionRecreateEventListener[]", - "org.hibernate.event.spi.PostCollectionRemoveEventListener[]", - "org.hibernate.event.spi.PostCollectionUpdateEventListener[]", - "org.hibernate.event.spi.PostCommitDeleteEventListener[]", - "org.hibernate.event.spi.PostCommitInsertEventListener[]", - "org.hibernate.event.spi.PostCommitUpdateEventListener[]", - "org.hibernate.event.spi.PostDeleteEventListener[]", - "org.hibernate.event.spi.PostInsertEventListener[]", - "org.hibernate.event.spi.PostLoadEventListener[]", - "org.hibernate.event.spi.PostUpdateEventListener[]", - "org.hibernate.event.spi.PreCollectionRecreateEventListener[]", - "org.hibernate.event.spi.PreCollectionRemoveEventListener[]", - "org.hibernate.event.spi.PreCollectionUpdateEventListener[]", - "org.hibernate.event.spi.PreDeleteEventListener[]", - "org.hibernate.event.spi.PreInsertEventListener[]", - "org.hibernate.event.spi.PreLoadEventListener[]", - "org.hibernate.event.spi.PreUpdateEventListener[]", - "org.hibernate.event.spi.RefreshEventListener[]", - "org.hibernate.event.spi.ReplicateEventListener[]", - "org.hibernate.event.spi.ResolveNaturalIdEventListener[]", - "org.hibernate.event.spi.SaveOrUpdateEventListener[]", - "org.hibernate.event.spi.LoadEventListener[]", - // Hibernate Envers - "org.dom4j.DocumentFactory", - "org.hibernate.envers.DefaultRevisionEntity", - "org.hibernate.envers.boot.internal.LegacyModifiedColumnNamingStrategy", - "org.hibernate.envers.configuration.internal.ClassesAuditingData", - "org.hibernate.envers.configuration.internal.RevisionInfoConfiguration", - "org.hibernate.envers.internal.EnversMessageLogger", - "org.hibernate.envers.strategy.DefaultAuditStrategy", - "org.hibernate.envers.strategy.internal.DefaultAuditStrategy", - "java.util.ServiceLoader$Provider" -}, - accessType = {AccessType.ALL_PUBLIC}) -final class Hql { -} - -@TypeHint(typeNames = "org.hibernate.cfg.beanvalidation.TypeSafeActivator", accessType = {AccessType.ALL_PUBLIC}) -final class Cfg { -} - -// Disable Runtime Byte Code Enhancement -@TargetClass(className = "org.hibernate.cfg.Environment") -@TypeHint( - value = {EventType.class, EnumType.class}, - accessType = {AccessType.ALL_DECLARED_FIELDS, AccessType.ALL_DECLARED_METHODS, AccessType.ALL_DECLARED_CONSTRUCTORS} -) -final class EnvironmentSubs { - @Substitute - public static BytecodeProvider buildBytecodeProvider(Properties properties) { - return new IntrospectedHibernateBytecodeProvider(); - } -} - -// ID Generators -@TypeHint({ - UUIDGenerator.class, - GUIDGenerator.class, - UUIDHexGenerator.class, - Assigned.class, - IdentityGenerator.class, - SelectGenerator.class, - SequenceStyleGenerator.class, - IncrementGenerator.class, - ForeignGenerator.class, - TableGenerator.class -}) -final class IdGenerators { -} - -// ID Optimizers -@TypeHint({ - NoopOptimizer.class, - HiLoOptimizer.class, - LegacyHiLoAlgorithmOptimizer.class, - PooledOptimizer.class, - PooledLoOptimizer.class, - PooledLoThreadLocalOptimizer.class -}) -final class IdOptimizers { -} - -// Disable XML support -@TargetClass(className = "org.hibernate.boot.spi.XmlMappingBinderAccess") -@Substitute -final class NoopXmlMappingBinderAccess { - - @Substitute - public NoopXmlMappingBinderAccess(ServiceRegistry serviceRegistry) { - } - - @Substitute - public MappingBinder getMappingBinder() { - return null; - } - - @Substitute - public Binding bind(String resource) { - return null; - } - - @Substitute - public Binding bind(File file) { - return null; - } - - @Substitute - public Binding bind(InputStreamAccess xmlInputStreamAccess) { - return null; - } - - @Substitute - public Binding bind(InputStream xmlInputStream) { - return null; - } - - @Substitute - public Binding bind(URL url) { - return null; - } -} - -// Disable Schema Resolution -@TargetClass(className = "org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver") -@Substitute -final class NoopSchemaResolver implements XMLResolver { - @Substitute - public NoopSchemaResolver(ResourceStreamLocator resourceStreamLocator) { - } - - @Override - @Substitute - public Object resolveEntity(String publicID, String systemID, String baseURI, String namespace) - throws XMLStreamException { - return null; - } -} diff --git a/tests/hibernate6/hibernate6-h2/build.gradle b/tests/hibernate6/hibernate6-h2/build.gradle index 3fd593fca..99bba48ce 100644 --- a/tests/hibernate6/hibernate6-h2/build.gradle +++ b/tests/hibernate6/hibernate6-h2/build.gradle @@ -12,8 +12,3 @@ dependencies { configurations { all*.exclude module: "javassist" } - -// TODO: Enable native tests once jakarta.validation gets replaced with jakarta.validation which is required for hibernate6 -graalvmNative { - testSupport = false -} diff --git a/tests/hibernate6/hibernate6-mariadb/build.gradle b/tests/hibernate6/hibernate6-mariadb/build.gradle index 83a71c124..d3b2d3b64 100644 --- a/tests/hibernate6/hibernate6-mariadb/build.gradle +++ b/tests/hibernate6/hibernate6-mariadb/build.gradle @@ -18,8 +18,3 @@ micronaut { additionalModules.add(JDBC_MARIADB) } } - -// TODO: Enable native tests once jakarta.validation gets replaced with jakarta.validation which is required for hibernate6 -graalvmNative { - testSupport = false -} diff --git a/tests/hibernate6/hibernate6-mssql/build.gradle b/tests/hibernate6/hibernate6-mssql/build.gradle index b6e93c3dc..53f98fcce 100644 --- a/tests/hibernate6/hibernate6-mssql/build.gradle +++ b/tests/hibernate6/hibernate6-mssql/build.gradle @@ -20,8 +20,6 @@ micronaut { } graalvmNative { - // TODO: Enable native tests once jakarta.validation gets replaced with jakarta.validation which is required for hibernate6 - testSupport = false binaries { all { buildArgs.add("-H:+AddAllCharsets") diff --git a/tests/hibernate6/hibernate6-mysql/build.gradle b/tests/hibernate6/hibernate6-mysql/build.gradle index b04a93a30..da926dfda 100644 --- a/tests/hibernate6/hibernate6-mysql/build.gradle +++ b/tests/hibernate6/hibernate6-mysql/build.gradle @@ -18,8 +18,3 @@ micronaut { additionalModules.add(JDBC_MYSQL) } } - -// TODO: Enable native tests once jakarta.validation gets replaced with jakarta.validation which is required for hibernate6 -graalvmNative { - testSupport = false -} diff --git a/tests/hibernate6/hibernate6-oracle/build.gradle b/tests/hibernate6/hibernate6-oracle/build.gradle index f28af6325..798d12123 100644 --- a/tests/hibernate6/hibernate6-oracle/build.gradle +++ b/tests/hibernate6/hibernate6-oracle/build.gradle @@ -18,8 +18,3 @@ micronaut { additionalModules.add(JDBC_ORACLE_XE) } } - -// TODO: Enable native tests once jakarta.validation gets replaced with jakarta.validation which is required for hibernate6 -graalvmNative { - testSupport = false -} diff --git a/tests/hibernate6/hibernate6-postgres/build.gradle b/tests/hibernate6/hibernate6-postgres/build.gradle index f91d6d506..1502763d9 100644 --- a/tests/hibernate6/hibernate6-postgres/build.gradle +++ b/tests/hibernate6/hibernate6-postgres/build.gradle @@ -18,8 +18,3 @@ micronaut { additionalModules.add(JDBC_POSTGRESQL) } } - -// TODO: Enable native tests once jakarta.validation gets replaced with jakarta.validation which is required for hibernate6 -graalvmNative { - testSupport = false -} diff --git a/tests/hibernate6/hibernate6-sync-common/src/main/java/example/hibernate6/sync/Owner.java b/tests/hibernate6/hibernate6-sync-common/src/main/java/example/hibernate6/sync/Owner.java index f8ae8d31d..602d363cc 100644 --- a/tests/hibernate6/hibernate6-sync-common/src/main/java/example/hibernate6/sync/Owner.java +++ b/tests/hibernate6/hibernate6-sync-common/src/main/java/example/hibernate6/sync/Owner.java @@ -16,6 +16,7 @@ package example.hibernate6.sync; import example.domain.IOwner; +import io.micronaut.configuration.hibernate.jpa.proxy.GenerateProxy; import io.micronaut.serde.annotation.Serdeable; import jakarta.persistence.Entity; @@ -24,6 +25,7 @@ @Entity @Serdeable +@GenerateProxy public class Owner implements IOwner { @Id diff --git a/tests/hibernate6/hibernate6-sync-common/src/main/resources/application.yml b/tests/hibernate6/hibernate6-sync-common/src/main/resources/application.yml index 4c4ceed04..829ecb078 100644 --- a/tests/hibernate6/hibernate6-sync-common/src/main/resources/application.yml +++ b/tests/hibernate6/hibernate6-sync-common/src/main/resources/application.yml @@ -11,3 +11,4 @@ jpa: hbm2ddl: auto: update show_sql: true + compileTimeHibernateProxies: true From 0192120eb37743df195e1ae248782925b10acb43 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Thu, 23 Mar 2023 14:52:50 +0100 Subject: [PATCH 07/19] Additional hib6 metadata --- .../hibernate-jpa-graal/reflect-config.json | 181 ++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 hibernate-jpa/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json diff --git a/hibernate-jpa/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json b/hibernate-jpa/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json new file mode 100644 index 000000000..13f092ef7 --- /dev/null +++ b/hibernate-jpa/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json @@ -0,0 +1,181 @@ +[ + { + "name": "[Lorg.hibernate.query.hql.spi.DotIdentifierConsumer;", + "condition": { + "typeReachable": "org.hibernate.internal.util.collections.StandardStack" + } + }, + { + "name": "[Lorg.hibernate.query.hql.spi.SqmCreationProcessingState;", + "condition": { + "typeReachable": "org.hibernate.query.hql.internal.SemanticQueryBuilder" + } + }, + { + "name": "[Lorg.hibernate.query.sqm.spi.ParameterDeclarationContext;", + "condition": { + "typeReachable": "org.hibernate.query.hql.internal.SemanticQueryBuilder" + } + }, + { + "name": "[Lorg.hibernate.query.sqm.sql.FromClauseIndex;", + "condition": { + "typeReachable": "org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter" + } + }, + { + "name": "[Lorg.hibernate.sql.ast.Clause;", + "condition": { + "typeReachable": "org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter" + } + }, + { + "name": "[Lorg.hibernate.sql.ast.Clause;", + "condition": { + "typeReachable": "org.hibernate.sql.ast.spi.AbstractSqlAstTranslator" + } + }, + { + "name": "[Lorg.hibernate.sql.ast.spi.SqlAstProcessingState;", + "condition": { + "typeReachable": "org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter" + } + }, + { + "name": "[Lorg.hibernate.sql.ast.tree.Statement;", + "condition": { + "typeReachable": "org.hibernate.sql.ast.spi.AbstractSqlAstTranslator" + } + }, + { + "name": "[Lorg.hibernate.sql.ast.tree.select.QueryPart;", + "condition": { + "typeReachable": "org.hibernate.sql.ast.spi.AbstractSqlAstTranslator" + } + }, + { + "name": "[Lorg.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState;", + "condition": { + "typeReachable": "org.hibernate.sql.results.spi.LoadContexts" + } + }, + { + "name": "org.hibernate.boot.beanvalidation.TypeSafeActivator", + "condition": { + "typeReachable": "org.hibernate.boot.beanvalidation.BeanValidationIntegrator" + }, + "methods": [ + { + "name": "activate", + "parameterTypes": [ + "org.hibernate.boot.beanvalidation.ActivationContext" + ] + } + ] + }, + { + "name": "org.hibernate.boot.model.relational.ColumnOrderingStrategyStandard", + "condition": { + "typeReachable": "org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl$2" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + } + ] + }, + { + "name": "org.hibernate.engine.jdbc.batch.JdbcBatchLogging_$logger", + "condition": { + "typeReachable": "org.hibernate.engine.jdbc.batch.JdbcBatchLogging" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + "org.jboss.logging.Logger" + ] + } + ] + }, + { + "name": "org.hibernate.dialect.OracleArrayJdbcType", + "condition": { + "typeReachable": "org.hibernate.dialect.OracleJdbcHelper" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + } + ] + }, + { + "name": "org.hibernate.dialect.OracleStructJdbcType", + "condition": { + "typeReachable": "org.hibernate.dialect.OracleJdbcHelper" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + } + ] + }, + { + "name": "org.hibernate.dialect.PostgreSQLInetJdbcType", + "condition": { + "typeReachable": "org.hibernate.dialect.PgJdbcHelper" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + } + ] + }, + { + "name": "org.hibernate.dialect.PostgreSQLIntervalSecondJdbcType", + "condition": { + "typeReachable": "org.hibernate.dialect.PgJdbcHelper" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + } + ] + }, + { + "name": "org.hibernate.dialect.PostgreSQLJsonPGObjectJsonbType", + "condition": { + "typeReachable": "org.hibernate.dialect.PgJdbcHelper" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + } + ] + }, + { + "name": "org.hibernate.dialect.PostgreSQLStructPGObjectJdbcType", + "condition": { + "typeReachable": "org.hibernate.dialect.PgJdbcHelper" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + ] + } + ] + } +] From 375469523ba6d775ee082da4ce681f8ce38f5aa9 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Thu, 23 Mar 2023 15:48:19 +0100 Subject: [PATCH 08/19] Enabled reactive tests --- settings.gradle | 6 +++--- tests/common/build.gradle | 1 + tests/hibernate6/hibernate6-reactive-mssql/build.gradle | 3 +-- tests/hibernate6/hibernate6-reactive-oracle/build.gradle | 3 +-- tests/hibernate6/hibernate6-reactive-postgres/build.gradle | 3 +-- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/settings.gradle b/settings.gradle index 705182cc0..61fc1b050 100644 --- a/settings.gradle +++ b/settings.gradle @@ -60,10 +60,10 @@ include 'tests:hibernate6:hibernate6-postgres' include 'tests:hibernate6:hibernate6-reactive-common' // TODO: Add these modules when testresources add back support for hibernate reactive -//include 'tests:hibernate6:hibernate6-reactive-mssql' +include 'tests:hibernate6:hibernate6-reactive-mssql' //include 'tests:hibernate6:hibernate6-reactive-mysql' -//include 'tests:hibernate6:hibernate6-reactive-oracle' -//include 'tests:hibernate6:hibernate6-reactive-postgres' +include 'tests:hibernate6:hibernate6-reactive-oracle' +include 'tests:hibernate6:hibernate6-reactive-postgres' include 'tests:jooq-tests:jooq-jdbc-postgres' include 'tests:jooq-tests:jooq-r2dbc-postgres' diff --git a/tests/common/build.gradle b/tests/common/build.gradle index 1d0c34309..dac1b5f50 100644 --- a/tests/common/build.gradle +++ b/tests/common/build.gradle @@ -4,4 +4,5 @@ plugins { dependencies { api(mnSerde.micronaut.serde.api) + runtimeOnly(mn.snakeyaml) } diff --git a/tests/hibernate6/hibernate6-reactive-mssql/build.gradle b/tests/hibernate6/hibernate6-reactive-mssql/build.gradle index 0dee07ca8..c437c0c10 100644 --- a/tests/hibernate6/hibernate6-reactive-mssql/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-mssql/build.gradle @@ -14,8 +14,7 @@ dependencies { micronaut { testResources { - // TODO: This is temporary removed from testresources, add once we have sql and data modules fixed - // additionalModules.add(HIBERNATE_REACTIVE_MSSQL) + additionalModules.add(HIBERNATE_REACTIVE_MSSQL) } } diff --git a/tests/hibernate6/hibernate6-reactive-oracle/build.gradle b/tests/hibernate6/hibernate6-reactive-oracle/build.gradle index c94d15cab..624d6aa45 100644 --- a/tests/hibernate6/hibernate6-reactive-oracle/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-oracle/build.gradle @@ -11,8 +11,7 @@ dependencies { micronaut { testResources { - // TODO: This is temporary removed from testresources, add once we have sql and data modules fixed - // additionalModules.add(HIBERNATE_REACTIVE_ORACLE_XE) + additionalModules.add(HIBERNATE_REACTIVE_ORACLE_XE) } } diff --git a/tests/hibernate6/hibernate6-reactive-postgres/build.gradle b/tests/hibernate6/hibernate6-reactive-postgres/build.gradle index 4ef4bef9e..5c6761600 100644 --- a/tests/hibernate6/hibernate6-reactive-postgres/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-postgres/build.gradle @@ -12,8 +12,7 @@ dependencies { micronaut { testResources { - // TODO: This is temporary removed from testresources, add once we have sql and data modules fixed - // additionalModules.add(HIBERNATE_REACTIVE_POSTGRESQL) + additionalModules.add(HIBERNATE_REACTIVE_POSTGRESQL) } } From ef4a91209f42f7743d58d0b7f0c5da329d4b6c21 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Thu, 23 Mar 2023 16:52:36 +0100 Subject: [PATCH 09/19] Enabled native reactive tests --- .../src/main/resources/application.yml | 1 + tests/hibernate6/hibernate6-reactive-mssql/build.gradle | 2 -- tests/hibernate6/hibernate6-reactive-oracle/build.gradle | 5 ----- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/hibernate6/hibernate6-reactive-common/src/main/resources/application.yml b/tests/hibernate6/hibernate6-reactive-common/src/main/resources/application.yml index b1d298ec3..cd7d8015c 100644 --- a/tests/hibernate6/hibernate6-reactive-common/src/main/resources/application.yml +++ b/tests/hibernate6/hibernate6-reactive-common/src/main/resources/application.yml @@ -14,3 +14,4 @@ jpa: hbm2ddl: auto: update show_sql: true + compileTimeHibernateProxies: true diff --git a/tests/hibernate6/hibernate6-reactive-mssql/build.gradle b/tests/hibernate6/hibernate6-reactive-mssql/build.gradle index c437c0c10..bb9956d47 100644 --- a/tests/hibernate6/hibernate6-reactive-mssql/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-mssql/build.gradle @@ -19,8 +19,6 @@ micronaut { } graalvmNative { - // TODO: Enable native tests in separate PR - testSupport = false binaries.all { buildArgs.addAll("-H:+AddAllCharsets") } diff --git a/tests/hibernate6/hibernate6-reactive-oracle/build.gradle b/tests/hibernate6/hibernate6-reactive-oracle/build.gradle index 624d6aa45..b5625210d 100644 --- a/tests/hibernate6/hibernate6-reactive-oracle/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-oracle/build.gradle @@ -14,8 +14,3 @@ micronaut { additionalModules.add(HIBERNATE_REACTIVE_ORACLE_XE) } } - -graalvmNative { - // TODO: Enable native tests in separate PR - testSupport = false -} From ac924e50fc23356ebdc472912e3a7707a433db77 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Thu, 23 Mar 2023 17:24:07 +0100 Subject: [PATCH 10/19] Removed unnecessary metadata --- .../hibernate-jpa-graal/reflect-config.json | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 hibernate-reactive/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json diff --git a/hibernate-reactive/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json b/hibernate-reactive/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json deleted file mode 100644 index d70976cb3..000000000 --- a/hibernate-reactive/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json +++ /dev/null @@ -1,16 +0,0 @@ -[ - { - "name": "org.hibernate.internal.log.ConnectionPoolingLogger_$logger", - "condition": { - "typeReachable": "org.hibernate.internal.log.ConnectionPoolingLogger" - }, - "methods": [ - { - "name": "", - "parameterTypes": [ - "org.jboss.logging.Logger" - ] - } - ] - } -] From 09a539ee137b65e183aa74d41552edcc7c539548 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Fri, 24 Mar 2023 17:29:50 +0100 Subject: [PATCH 11/19] Hibernate Reactive metadata --- .../conf/ReactiveRegistryCreator.java | 13 -- .../hibernate-jpa-graal/reflect-config.json | 116 ++++++++++++++++++ .../hibernate-jpa-graal/resource-config.json | 12 ++ .../micronaut-jdbc/resource-config.json | 10 -- 4 files changed, 128 insertions(+), 23 deletions(-) create mode 100644 hibernate-reactive/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json create mode 100644 hibernate-reactive/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/resource-config.json delete mode 100644 jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json diff --git a/hibernate-reactive/src/main/java/io/micronaut/configuration/hibernate/reactive/conf/ReactiveRegistryCreator.java b/hibernate-reactive/src/main/java/io/micronaut/configuration/hibernate/reactive/conf/ReactiveRegistryCreator.java index 6770c42a1..b4ccae43f 100644 --- a/hibernate-reactive/src/main/java/io/micronaut/configuration/hibernate/reactive/conf/ReactiveRegistryCreator.java +++ b/hibernate-reactive/src/main/java/io/micronaut/configuration/hibernate/reactive/conf/ReactiveRegistryCreator.java @@ -22,25 +22,12 @@ import io.micronaut.context.annotation.Prototype; import io.micronaut.context.annotation.Requires; import io.micronaut.core.annotation.Nullable; -import io.micronaut.core.annotation.TypeHint; import org.hibernate.boot.registry.BootstrapServiceRegistry; import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.integrator.spi.Integrator; -import org.hibernate.reactive.persister.entity.impl.ReactiveSingleTableEntityPersister; import org.hibernate.reactive.provider.ReactiveServiceRegistryBuilder; -import java.util.ServiceLoader; - -@TypeHint(value = ServiceLoader.Provider.class, accessType = {TypeHint.AccessType.ALL_PUBLIC}) -final class Provider { -} - -@TypeHint({ - org.hibernate.reactive.logging.impl.Log_$logger.class, - ReactiveServiceRegistryBuilder.class, - ReactiveSingleTableEntityPersister.class -}) @Requires(classes = ReactiveServiceRegistryBuilder.class) @Prototype final class ReactiveRegistryCreator implements StandardServiceRegistryBuilderCreator { diff --git a/hibernate-reactive/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json b/hibernate-reactive/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json new file mode 100644 index 000000000..c95e99bf5 --- /dev/null +++ b/hibernate-reactive/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json @@ -0,0 +1,116 @@ +[ + { + "name": "org.hibernate.reactive.context.impl.VertxContext", + "queryAllPublicMethods": true, + "condition": { + "typeReachable": "org.hibernate.reactive.stage.impl.StageSessionFactoryImpl" + } + }, + { + "name": "org.hibernate.reactive.logging.impl.Log_$logger", + "condition": { + "typeReachable": "org.hibernate.reactive.logging.impl.LoggerFactory" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + "org.jboss.logging.Logger" + ] + } + ] + }, + { + "name": "org.hibernate.reactive.provider.ReactiveServiceRegistryBuilder", + "condition": { + "typeReachable": "org.hibernate.reactive.session.impl.ReactiveSessionFactoryImpl" + } + }, + { + "name": "org.hibernate.reactive.persister.entity.impl.ReactiveSingleTableEntityPersister", + "condition": { + "typeReachable": "org.hibernate.reactive.session.impl.ReactiveSessionFactoryImpl" + }, + "methods": [ + { + "name": "", + "parameterTypes": [ + "org.hibernate.mapping.PersistentClass", + "org.hibernate.cache.spi.access.EntityDataAccess", + "org.hibernate.cache.spi.access.NaturalIdDataAccess", + "org.hibernate.metamodel.spi.RuntimeModelCreationContext" + ] + } + ] + }, + { + "name": "org.hibernate.reactive.pool.impl.DefaultSqlClientPool", + "queryAllPublicMethods": true, + "condition": { + "typeReachable": "org.hibernate.reactive.provider.service.ReactiveImprovedExtractionContextImpl" + } + }, + { + "name": "org.hibernate.reactive.pool.impl.DefaultSqlClientPoolConfiguration", + "queryAllPublicMethods": true, + "condition": { + "typeReachable": "org.hibernate.reactive.pool.impl.DefaultSqlClientPool" + } + }, + { + "name": "org.hibernate.reactive.provider.service.NoJdbcConnectionProvider", + "queryAllPublicMethods": true, + "condition": { + "typeReachable": "org.hibernate.reactive.provider.service.NoJdbcEnvironmentInitiator" + } + }, + { + "name": "org.hibernate.reactive.provider.service.ReactiveMarkerServiceSingleton", + "queryAllPublicMethods": true, + "condition": { + "typeReachable": "org.hibernate.reactive.provider.impl.ReactiveModeCheck" + } + }, + { + "name": "org.hibernate.reactive.provider.service.ReactivePersisterClassResolver", + "queryAllPublicMethods": true, + "condition": { + "typeReachable": "org.hibernate.reactive.session.impl.ReactiveSessionFactoryImpl" + } + }, + { + "name": "org.hibernate.reactive.provider.service.ReactiveSchemaManagementTool", + "queryAllPublicMethods": true, + "condition": { + "typeReachable": "org.hibernate.reactive.session.impl.ReactiveSessionFactoryImpl" + } + }, + { + "name": "org.hibernate.reactive.provider.service.ReactiveValuesMappingProducerProvider", + "queryAllPublicMethods": true, + "condition": { + "typeReachable": "org.hibernate.reactive.session.impl.ReactiveSessionFactoryImpl" + } + }, + { + "name": "org.hibernate.reactive.provider.service.ReactiveWrappingDialectFactory", + "queryAllPublicMethods": true, + "condition": { + "typeReachable": "org.hibernate.reactive.provider.service.NoJdbcEnvironmentInitiator" + } + }, + { + "name": "org.hibernate.reactive.query.sqm.spi.ReactiveNativeQueryInterpreter", + "queryAllPublicMethods": true, + "condition": { + "typeReachable": "org.hibernate.reactive.session.impl.ReactiveSessionFactoryImpl" + } + }, + { + "name": "org.hibernate.reactive.vertx.impl.DefaultVertxInstance", + "queryAllPublicMethods": true, + "condition": { + "typeReachable": "org.hibernate.reactive.pool.impl.DefaultSqlClientPool" + } + } +] diff --git a/hibernate-reactive/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/resource-config.json b/hibernate-reactive/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/resource-config.json new file mode 100644 index 000000000..595cc31d3 --- /dev/null +++ b/hibernate-reactive/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/resource-config.json @@ -0,0 +1,12 @@ +{ + "resources": { + "includes": [ + { + "pattern": "\\QMETA-INF/services/org.hibernate.service.spi.SessionFactoryServiceContributor\\E", + "condition": { + "typeReachable": "org.hibernate.reactive.session.impl.ReactiveSessionFactoryImpl" + } + } + ] + } +} diff --git a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json b/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json deleted file mode 100644 index 0623e7ecd..000000000 --- a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bundles": [ - { - "condition": { - "typeReachable": "com.microsoft.sqlserver.jdbc.SQLServerDriver" - }, - "name": "com.microsoft.sqlserver.jdbc.SQLServerResource" - } - ] -} From fdec777937efbeace317ebaa609535b85295b86c Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Tue, 28 Mar 2023 16:03:44 +0200 Subject: [PATCH 12/19] Moved JOOQ metadata to the metadata shared repository --- .../jooq/graal/DefaultDataTypeReflection.java | 85 ------------------- .../DefaultReflectionServiceSubstitute.java | 37 -------- .../jooq/graal/ProxyMapperSubstitute.java | 33 ------- .../jooq/graal/SimpleFlatMapperAvailable.java | 39 --------- .../jooq/graal/package-info.java | 22 ----- .../guide/hibernate/hibernate-proxies.adoc | 2 - src/main/docs/guide/jooq/jooq-graalvm.adoc | 4 +- 7 files changed, 1 insertion(+), 221 deletions(-) delete mode 100644 jooq/src/main/java/io/micronaut/configuration/jooq/graal/DefaultDataTypeReflection.java delete mode 100644 jooq/src/main/java/io/micronaut/configuration/jooq/graal/DefaultReflectionServiceSubstitute.java delete mode 100644 jooq/src/main/java/io/micronaut/configuration/jooq/graal/ProxyMapperSubstitute.java delete mode 100644 jooq/src/main/java/io/micronaut/configuration/jooq/graal/SimpleFlatMapperAvailable.java delete mode 100644 jooq/src/main/java/io/micronaut/configuration/jooq/graal/package-info.java diff --git a/jooq/src/main/java/io/micronaut/configuration/jooq/graal/DefaultDataTypeReflection.java b/jooq/src/main/java/io/micronaut/configuration/jooq/graal/DefaultDataTypeReflection.java deleted file mode 100644 index 89cf49f6f..000000000 --- a/jooq/src/main/java/io/micronaut/configuration/jooq/graal/DefaultDataTypeReflection.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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 io.micronaut.configuration.jooq.graal; - -import io.micronaut.core.annotation.TypeHint; -import io.micronaut.core.annotation.TypeHint.AccessType; - -@TypeHint( - typeNames = { - "java.time.LocalDate[]", - "java.time.LocalDateTime[]", - "java.time.LocalTime[]", - "java.time.ZonedDateTime[]", - "java.time.OffsetDateTime[]", - "java.time.OffsetTime[]", - "java.time.Instant[]", - "java.sql.Timestamp[]", - "java.sql.Date[]", - "java.sql.Time[]", - "java.math.BigInteger[]", - "java.math.BigDecimal[]", - "org.jooq.types.UNumber[]", - "org.jooq.types.UByte[]", - "org.jooq.types.UInteger[]", - "org.jooq.types.ULong[]", - "org.jooq.types.Unsigned[]", - "org.jooq.types.UShort[]", - "java.lang.Byte[]", - "java.lang.Integer[]", - "java.lang.Long[]", - "java.lang.Float[]", - "java.lang.Double[]", - "java.lang.String[]", - "org.jooq.types.YearToMonth[]", - "org.jooq.types.YearToSecond[]", - "org.jooq.types.DayToSecond[]", - "org.jooq.RowId[]", - "org.jooq.Result[]", - "org.jooq.Record[]", - "org.jooq.JSON[]", - "org.jooq.JSONB[]", - "org.jooq.XML[]", - "org.jooq.Geography[]", - "org.jooq.Geometry[]", - "java.util.UUID[]", - "byte[]", - "org.jooq.impl.SQLDataType", - "org.jooq.util.cubrid.CUBRIDDataType", - "org.jooq.util.derby.DerbyDataType", - "org.jooq.util.firebird.FirebirdDataType", - "org.jooq.util.h2.H2DataType", - "org.jooq.util.hsqldb.HSQLDBDataType", - "org.jooq.util.ignite.IgniteDataType", - "org.jooq.util.mariadb.MariaDBDataType", - "org.jooq.util.mysql.MySQLDataType", - "org.jooq.util.postgres.PostgresDataType", - "org.jooq.util.sqlite.SQLiteDataType", - "org.jooq.util.oracle.OracleDataType", - "org.jooq.util.sqlserver.SQLServerDataType", - "org.jooq.impl.DefaultBinding$Mdsys", - "org.jooq.impl.DefaultBinding$SdoElemInfoArray", - "org.jooq.impl.DefaultBinding$SdoOrdinateArray", - "org.jooq.impl.DefaultBinding$SdoGeometry", - "org.jooq.impl.DefaultBinding$SdoGeometryRecord", - "org.jooq.impl.DefaultBinding$SdoPointType", - "org.jooq.impl.DefaultBinding$SdoPointTypeRecord", - }, - accessType = AccessType.ALL_PUBLIC_CONSTRUCTORS -) -final class DefaultDataTypeReflection { - -} diff --git a/jooq/src/main/java/io/micronaut/configuration/jooq/graal/DefaultReflectionServiceSubstitute.java b/jooq/src/main/java/io/micronaut/configuration/jooq/graal/DefaultReflectionServiceSubstitute.java deleted file mode 100644 index 0effcd588..000000000 --- a/jooq/src/main/java/io/micronaut/configuration/jooq/graal/DefaultReflectionServiceSubstitute.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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 io.micronaut.configuration.jooq.graal; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import org.simpleflatmapper.reflect.asm.AsmFactory; - -/** - * Disable not supported ASM bytecode manipulation in GraalVM native image runtime. - * - * @author Lukas Moravec - * @since 2.3.5 - */ -@TargetClass( - className = "org.simpleflatmapper.reflect.DefaultReflectionService", - onlyWith = SimpleFlatMapperAvailable.class -) -final class DefaultReflectionServiceSubstitute { - @Substitute - public AsmFactory getAsmFactory(ClassLoader classLoader) { - return null; - } -} diff --git a/jooq/src/main/java/io/micronaut/configuration/jooq/graal/ProxyMapperSubstitute.java b/jooq/src/main/java/io/micronaut/configuration/jooq/graal/ProxyMapperSubstitute.java deleted file mode 100644 index 85690dccc..000000000 --- a/jooq/src/main/java/io/micronaut/configuration/jooq/graal/ProxyMapperSubstitute.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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 io.micronaut.configuration.jooq.graal; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -/** - * Disable not supported ProxyMapper in GraalVM native image runtime. - * - * @author Lukas Moravec - * @since 2.2.5 - */ -@TargetClass(className = "org.jooq.impl.DefaultRecordMapper", innerClass = "ProxyMapper") -final class ProxyMapperSubstitute { - @Substitute - private Object proxy() { - throw new UnsupportedOperationException("Not supported in GraalVM native image."); - } -} diff --git a/jooq/src/main/java/io/micronaut/configuration/jooq/graal/SimpleFlatMapperAvailable.java b/jooq/src/main/java/io/micronaut/configuration/jooq/graal/SimpleFlatMapperAvailable.java deleted file mode 100644 index 5cf16fa8e..000000000 --- a/jooq/src/main/java/io/micronaut/configuration/jooq/graal/SimpleFlatMapperAvailable.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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 io.micronaut.configuration.jooq.graal; - -import io.micronaut.core.annotation.Internal; - -import java.util.function.BooleanSupplier; - -/** - * Companion class for DefaultReflectionServiceSubstitute. - * - * @author Lukas Moravec - * @since 2.3.5 - */ -@Internal -public class SimpleFlatMapperAvailable implements BooleanSupplier { - @Override - public boolean getAsBoolean() { - try { - Class.forName("org.simpleflatmapper.reflect.DefaultReflectionService"); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } -} diff --git a/jooq/src/main/java/io/micronaut/configuration/jooq/graal/package-info.java b/jooq/src/main/java/io/micronaut/configuration/jooq/graal/package-info.java deleted file mode 100644 index b1700cde3..000000000 --- a/jooq/src/main/java/io/micronaut/configuration/jooq/graal/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2017-2020 original authors - * - * 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 - * - * https://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. - */ -/** - * This package contains GraalVM Substrate specific classes. - * - * @author Lukas Moravec - * @since 2.2.5 - */ -package io.micronaut.configuration.jooq.graal; diff --git a/src/main/docs/guide/hibernate/hibernate-proxies.adoc b/src/main/docs/guide/hibernate/hibernate-proxies.adoc index 2075f14c2..33f12aa71 100644 --- a/src/main/docs/guide/hibernate/hibernate-proxies.adoc +++ b/src/main/docs/guide/hibernate/hibernate-proxies.adoc @@ -13,8 +13,6 @@ jpa: compile-time-hibernate-proxies: true ---- -[NOTE]Compile-time proxies are not supported for Hibernate6. - Compile-time proxies require for an entity which needs to have a proxy to be annotated with `@GenerateProxy`: For example: diff --git a/src/main/docs/guide/jooq/jooq-graalvm.adoc b/src/main/docs/guide/jooq/jooq-graalvm.adoc index 2f8b46ea8..6eb8256d3 100644 --- a/src/main/docs/guide/jooq/jooq-graalvm.adoc +++ b/src/main/docs/guide/jooq/jooq-graalvm.adoc @@ -1,6 +1,4 @@ -Micronaut by default deactivates mapping to proxies with `ProxyMapper` to enable native image generation. -It also provides reflection configuration for basic type mappings but it is necessary to declare the `Record` classes -for reflection. +To use JOOQ in a native image it is necessary to declare the `Record` classes for reflection. The easiest way to do it is configure jOOQ to annotate the generated classes with the JPA annotations enabling the option `jpaAnnotations`. This way Micronaut will be able to detect them and automatically generate the reflection configuration that GraalVM needs. From e1b07c83357b0a846338b73d90b8887bd88d6c34 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Tue, 28 Mar 2023 16:17:58 +0200 Subject: [PATCH 13/19] Enabled tests for hibernate6 reactive mysql --- settings.gradle | 3 +-- tests/hibernate6/hibernate6-reactive-mysql/build.gradle | 8 +------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/settings.gradle b/settings.gradle index 61fc1b050..ba84a4b3f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -59,9 +59,8 @@ include 'tests:hibernate6:hibernate6-oracle' include 'tests:hibernate6:hibernate6-postgres' include 'tests:hibernate6:hibernate6-reactive-common' -// TODO: Add these modules when testresources add back support for hibernate reactive include 'tests:hibernate6:hibernate6-reactive-mssql' -//include 'tests:hibernate6:hibernate6-reactive-mysql' +include 'tests:hibernate6:hibernate6-reactive-mysql' include 'tests:hibernate6:hibernate6-reactive-oracle' include 'tests:hibernate6:hibernate6-reactive-postgres' diff --git a/tests/hibernate6/hibernate6-reactive-mysql/build.gradle b/tests/hibernate6/hibernate6-reactive-mysql/build.gradle index 2887a96ce..3aa183abc 100644 --- a/tests/hibernate6/hibernate6-reactive-mysql/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-mysql/build.gradle @@ -15,12 +15,6 @@ dependencies { micronaut { testResources { - // TODO: This is temporary removed from testresources, add once we have sql and data modules fixed - // additionalModules.add(HIBERNATE_REACTIVE_MYSQL) + additionalModules.add(HIBERNATE_REACTIVE_MYSQL) } } - -graalvmNative { - // TODO: Enable native tests in separate PR - testSupport = false -} From c33e8a20fba60ea5b2b8ce3ab402b030cd90d5a6 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Wed, 29 Mar 2023 08:48:51 +0200 Subject: [PATCH 14/19] Removed graal-svm dependency --- gradle/libs.versions.toml | 2 -- hibernate-jpa-spring/build.gradle | 1 - hibernate-jpa/build.gradle | 1 - hibernate-reactive/build.gradle | 1 - jdbc/build.gradle | 1 - jooq/build.gradle | 1 - 6 files changed, 7 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b1c7c470d..6aa976675 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -55,7 +55,6 @@ jaxb-api = "2.3.1" sfm-reflect = "8.2.3" spring = "5.3.25" caffeine = "3.1.4" -graal-svm = "22.3.1" logback = "1.4.5" # Testing @@ -150,7 +149,6 @@ jakarta-transaction-api = { module = "jakarta.transaction:jakarta.transaction-ap jaxb-api = { module = "javax.xml.bind:jaxb-api", version.ref = "jaxb-api" } sfm-reflect = { module = "org.simpleflatmapper:sfm-reflect", version.ref = "sfm-reflect" } caffeine = { module = "com.github.ben-manes.caffeine:caffeine", version.ref = "caffeine" } -graal-svm = { module = "org.graalvm.nativeimage:svm", version.ref = "graal-svm" } logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } # Testcontainers diff --git a/hibernate-jpa-spring/build.gradle b/hibernate-jpa-spring/build.gradle index 42834c630..148fe06ae 100644 --- a/hibernate-jpa-spring/build.gradle +++ b/hibernate-jpa-spring/build.gradle @@ -5,7 +5,6 @@ plugins { dependencies { annotationProcessor(mn.micronaut.graal) - compileOnly(libs.graal.svm) api(libs.managed.hibernate.core) { exclude group:'org.javassist', module:'javassist' } diff --git a/hibernate-jpa/build.gradle b/hibernate-jpa/build.gradle index 9e6cdaddc..fd933d6c0 100644 --- a/hibernate-jpa/build.gradle +++ b/hibernate-jpa/build.gradle @@ -21,7 +21,6 @@ dependencies { api projects.micronautJdbc api(mn.micronaut.runtime) - compileOnly(libs.graal.svm) compileOnly(libs.managed.hibernate.micrometer) compileOnly(libs.managed.hibernate.jcache) compileOnly(mn.micronaut.management) diff --git a/hibernate-reactive/build.gradle b/hibernate-reactive/build.gradle index 942bb99d3..015d5cc30 100644 --- a/hibernate-reactive/build.gradle +++ b/hibernate-reactive/build.gradle @@ -18,7 +18,6 @@ dependencies { api libs.managed.hibernate.reactive.core api mn.micronaut.runtime - compileOnly libs.graal.svm compileOnly libs.managed.vertx.sql.client testAnnotationProcessor mn.micronaut.inject.java diff --git a/jdbc/build.gradle b/jdbc/build.gradle index 71cb58d72..aaed4dc99 100644 --- a/jdbc/build.gradle +++ b/jdbc/build.gradle @@ -7,7 +7,6 @@ dependencies { api(mn.micronaut.inject) - compileOnly(libs.graal.svm) compileOnly(mnSpring.micronaut.spring) compileOnly(libs.spring.jdbc) diff --git a/jooq/build.gradle b/jooq/build.gradle index d62305c63..2927918b6 100644 --- a/jooq/build.gradle +++ b/jooq/build.gradle @@ -19,7 +19,6 @@ dependencies { // needed because otherwise IntelliJ integration broken compileOnly(mn.micronaut.inject.java) - compileOnly(libs.graal.svm) testCompileOnly(mn.micronaut.inject.java) // needed for native image (adding @Entity annotation to UpdatableRecords for reflection registration) From f285c3b4799e5d0fa1a373aae8b45f4449d76dfb Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Thu, 30 Mar 2023 11:23:58 +0200 Subject: [PATCH 15/19] Removed TypeHint annotation --- .../jpa/spring/HibernateTransactionManagerFactory.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/hibernate-jpa-spring/src/main/java/io/micronaut/configuration/hibernate/jpa/spring/HibernateTransactionManagerFactory.java b/hibernate-jpa-spring/src/main/java/io/micronaut/configuration/hibernate/jpa/spring/HibernateTransactionManagerFactory.java index 2d20a7b36..2de0d301e 100644 --- a/hibernate-jpa-spring/src/main/java/io/micronaut/configuration/hibernate/jpa/spring/HibernateTransactionManagerFactory.java +++ b/hibernate-jpa-spring/src/main/java/io/micronaut/configuration/hibernate/jpa/spring/HibernateTransactionManagerFactory.java @@ -16,11 +16,9 @@ package io.micronaut.configuration.hibernate.jpa.spring; import io.micronaut.context.annotation.*; -import io.micronaut.core.annotation.TypeHint; import io.micronaut.jdbc.spring.DataSourceTransactionManagerFactory; import org.hibernate.SessionFactory; import org.springframework.orm.hibernate5.HibernateTransactionManager; -import org.springframework.orm.hibernate5.SpringSessionContext; import javax.sql.DataSource; @@ -33,7 +31,6 @@ @Factory @Requires(classes = HibernateTransactionManager.class) @Replaces(factory = DataSourceTransactionManagerFactory.class) -@TypeHint({SpringSessionContext.class, HibernateTransactionManager.class}) public class HibernateTransactionManagerFactory { /** From 19a1bb3f7493b7a634757b4c01bda702d6793b24 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Wed, 5 Apr 2023 10:21:13 +0200 Subject: [PATCH 16/19] Added metadata repository and modified tests --- .../hibernate-jpa-graal/reflect-config.json | 181 ------------------ tests/common/build.gradle | 6 + .../example/hibernate6/sync/MariaDBApp.java | 2 +- .../example/hibernate6/sync/MSSQLApp.java | 2 +- .../example/hibernate6/sync/MySQLApp.java | 2 +- .../example/hibernate6/sync/OracleDBApp.java | 2 +- 6 files changed, 10 insertions(+), 185 deletions(-) delete mode 100644 hibernate-jpa/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json diff --git a/hibernate-jpa/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json b/hibernate-jpa/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json deleted file mode 100644 index 13f092ef7..000000000 --- a/hibernate-jpa/src/main/resources/META-INF/native-image/io.micronaut.sql/hibernate-jpa-graal/reflect-config.json +++ /dev/null @@ -1,181 +0,0 @@ -[ - { - "name": "[Lorg.hibernate.query.hql.spi.DotIdentifierConsumer;", - "condition": { - "typeReachable": "org.hibernate.internal.util.collections.StandardStack" - } - }, - { - "name": "[Lorg.hibernate.query.hql.spi.SqmCreationProcessingState;", - "condition": { - "typeReachable": "org.hibernate.query.hql.internal.SemanticQueryBuilder" - } - }, - { - "name": "[Lorg.hibernate.query.sqm.spi.ParameterDeclarationContext;", - "condition": { - "typeReachable": "org.hibernate.query.hql.internal.SemanticQueryBuilder" - } - }, - { - "name": "[Lorg.hibernate.query.sqm.sql.FromClauseIndex;", - "condition": { - "typeReachable": "org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter" - } - }, - { - "name": "[Lorg.hibernate.sql.ast.Clause;", - "condition": { - "typeReachable": "org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter" - } - }, - { - "name": "[Lorg.hibernate.sql.ast.Clause;", - "condition": { - "typeReachable": "org.hibernate.sql.ast.spi.AbstractSqlAstTranslator" - } - }, - { - "name": "[Lorg.hibernate.sql.ast.spi.SqlAstProcessingState;", - "condition": { - "typeReachable": "org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter" - } - }, - { - "name": "[Lorg.hibernate.sql.ast.tree.Statement;", - "condition": { - "typeReachable": "org.hibernate.sql.ast.spi.AbstractSqlAstTranslator" - } - }, - { - "name": "[Lorg.hibernate.sql.ast.tree.select.QueryPart;", - "condition": { - "typeReachable": "org.hibernate.sql.ast.spi.AbstractSqlAstTranslator" - } - }, - { - "name": "[Lorg.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState;", - "condition": { - "typeReachable": "org.hibernate.sql.results.spi.LoadContexts" - } - }, - { - "name": "org.hibernate.boot.beanvalidation.TypeSafeActivator", - "condition": { - "typeReachable": "org.hibernate.boot.beanvalidation.BeanValidationIntegrator" - }, - "methods": [ - { - "name": "activate", - "parameterTypes": [ - "org.hibernate.boot.beanvalidation.ActivationContext" - ] - } - ] - }, - { - "name": "org.hibernate.boot.model.relational.ColumnOrderingStrategyStandard", - "condition": { - "typeReachable": "org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl$2" - }, - "methods": [ - { - "name": "", - "parameterTypes": [ - ] - } - ] - }, - { - "name": "org.hibernate.engine.jdbc.batch.JdbcBatchLogging_$logger", - "condition": { - "typeReachable": "org.hibernate.engine.jdbc.batch.JdbcBatchLogging" - }, - "methods": [ - { - "name": "", - "parameterTypes": [ - "org.jboss.logging.Logger" - ] - } - ] - }, - { - "name": "org.hibernate.dialect.OracleArrayJdbcType", - "condition": { - "typeReachable": "org.hibernate.dialect.OracleJdbcHelper" - }, - "methods": [ - { - "name": "", - "parameterTypes": [ - ] - } - ] - }, - { - "name": "org.hibernate.dialect.OracleStructJdbcType", - "condition": { - "typeReachable": "org.hibernate.dialect.OracleJdbcHelper" - }, - "methods": [ - { - "name": "", - "parameterTypes": [ - ] - } - ] - }, - { - "name": "org.hibernate.dialect.PostgreSQLInetJdbcType", - "condition": { - "typeReachable": "org.hibernate.dialect.PgJdbcHelper" - }, - "methods": [ - { - "name": "", - "parameterTypes": [ - ] - } - ] - }, - { - "name": "org.hibernate.dialect.PostgreSQLIntervalSecondJdbcType", - "condition": { - "typeReachable": "org.hibernate.dialect.PgJdbcHelper" - }, - "methods": [ - { - "name": "", - "parameterTypes": [ - ] - } - ] - }, - { - "name": "org.hibernate.dialect.PostgreSQLJsonPGObjectJsonbType", - "condition": { - "typeReachable": "org.hibernate.dialect.PgJdbcHelper" - }, - "methods": [ - { - "name": "", - "parameterTypes": [ - ] - } - ] - }, - { - "name": "org.hibernate.dialect.PostgreSQLStructPGObjectJdbcType", - "condition": { - "typeReachable": "org.hibernate.dialect.PgJdbcHelper" - }, - "methods": [ - { - "name": "", - "parameterTypes": [ - ] - } - ] - } -] diff --git a/tests/common/build.gradle b/tests/common/build.gradle index dac1b5f50..5a2b4a33e 100644 --- a/tests/common/build.gradle +++ b/tests/common/build.gradle @@ -6,3 +6,9 @@ dependencies { api(mnSerde.micronaut.serde.api) runtimeOnly(mn.snakeyaml) } + +graalvmNative { + metadataRepository { + uri("https://github.com/oracle/graalvm-reachability-metadata/releases/download/0.2.7/graalvm-reachability-metadata-0.2.7.zip") + } +} diff --git a/tests/hibernate6/hibernate6-mariadb/src/test/java/example/hibernate6/sync/MariaDBApp.java b/tests/hibernate6/hibernate6-mariadb/src/test/java/example/hibernate6/sync/MariaDBApp.java index 3576fcf35..d0f1f9545 100644 --- a/tests/hibernate6/hibernate6-mariadb/src/test/java/example/hibernate6/sync/MariaDBApp.java +++ b/tests/hibernate6/hibernate6-mariadb/src/test/java/example/hibernate6/sync/MariaDBApp.java @@ -21,7 +21,7 @@ @MicronautTest @Property(name = "datasources.default.db-type", value = "mariadb") -@Property(name = "jpa.default.properties.hibernate.dialect", value = "org.hibernate.dialect.MariaDB103Dialect") +@Property(name = "jpa.default.properties.hibernate.dialect", value = "org.hibernate.dialect.MariaDBDialect") @Property(name = "test-resources.containers.mariadb.image-name", value = "mariadb:10.9.3") public class MariaDBApp extends AbstractApp { } diff --git a/tests/hibernate6/hibernate6-mssql/src/test/java/example/hibernate6/sync/MSSQLApp.java b/tests/hibernate6/hibernate6-mssql/src/test/java/example/hibernate6/sync/MSSQLApp.java index 9cc71267a..884146f15 100644 --- a/tests/hibernate6/hibernate6-mssql/src/test/java/example/hibernate6/sync/MSSQLApp.java +++ b/tests/hibernate6/hibernate6-mssql/src/test/java/example/hibernate6/sync/MSSQLApp.java @@ -21,6 +21,6 @@ @MicronautTest @Property(name = "datasources.default.db-type", value = "mssql") -@Property(name = "jpa.default.properties.hibernate.dialect", value = "org.hibernate.dialect.SQLServer2012Dialect") +@Property(name = "jpa.default.properties.hibernate.dialect", value = "org.hibernate.dialect.SQLServerDialect") public class MSSQLApp extends AbstractApp { } diff --git a/tests/hibernate6/hibernate6-mysql/src/test/java/example/hibernate6/sync/MySQLApp.java b/tests/hibernate6/hibernate6-mysql/src/test/java/example/hibernate6/sync/MySQLApp.java index 666dab62e..9f0004fc1 100644 --- a/tests/hibernate6/hibernate6-mysql/src/test/java/example/hibernate6/sync/MySQLApp.java +++ b/tests/hibernate6/hibernate6-mysql/src/test/java/example/hibernate6/sync/MySQLApp.java @@ -21,7 +21,7 @@ @MicronautTest @Property(name = "datasources.default.db-type", value = "mysql") -@Property(name = "jpa.default.properties.hibernate.dialect", value = "org.hibernate.dialect.MySQL8Dialect") +@Property(name = "jpa.default.properties.hibernate.dialect", value = "org.hibernate.dialect.MySQLDialect") @Property(name = "test-resources.containers.mysql.image-name", value = "mysql:8.0.30") public class MySQLApp extends AbstractApp { } diff --git a/tests/hibernate6/hibernate6-oracle/src/test/java/example/hibernate6/sync/OracleDBApp.java b/tests/hibernate6/hibernate6-oracle/src/test/java/example/hibernate6/sync/OracleDBApp.java index c7acd1139..467044d53 100644 --- a/tests/hibernate6/hibernate6-oracle/src/test/java/example/hibernate6/sync/OracleDBApp.java +++ b/tests/hibernate6/hibernate6-oracle/src/test/java/example/hibernate6/sync/OracleDBApp.java @@ -21,7 +21,7 @@ @MicronautTest @Property(name = "datasources.default.db-type", value = "oracle") -@Property(name = "jpa.default.properties.hibernate.dialect", value = "org.hibernate.dialect.Oracle12cDialect") +@Property(name = "jpa.default.properties.hibernate.dialect", value = "org.hibernate.dialect.OracleDialect") @Property(name = "test-resources.containers.oracle.image-name", value = "gvenzl/oracle-xe:slim") public class OracleDBApp extends AbstractApp { } From d707e89c6a13e340450ea2b1192b6005fcb262b4 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Wed, 5 Apr 2023 12:09:50 +0200 Subject: [PATCH 17/19] Disabled reactive native tests and modified AbstractApp --- .../main/java/example/sync/AbstractApp.java | 47 ++++++++----------- .../hibernate6-reactive-mssql/build.gradle | 5 ++ .../hibernate6-reactive-mysql/build.gradle | 5 ++ .../hibernate6-reactive-oracle/build.gradle | 5 ++ 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/tests/common-tests/src/main/java/example/sync/AbstractApp.java b/tests/common-tests/src/main/java/example/sync/AbstractApp.java index ff56bfb2c..bb6674bc2 100644 --- a/tests/common-tests/src/main/java/example/sync/AbstractApp.java +++ b/tests/common-tests/src/main/java/example/sync/AbstractApp.java @@ -28,8 +28,10 @@ import io.micronaut.testresources.client.TestResourcesClient; import io.micronaut.testresources.client.TestResourcesClientFactory; import jakarta.inject.Inject; -import org.junit.jupiter.api.*; -import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import reactor.core.publisher.Flux; import java.util.HashMap; @@ -38,7 +40,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -@TestMethodOrder(OrderAnnotation.class) @TestInstance(TestInstance.Lifecycle.PER_CLASS) public abstract class AbstractApp implements TestPropertyProvider { @@ -56,25 +57,29 @@ public Map getProperties() { return properties; } + @BeforeAll + public void init() { + HttpResponse response = client.toBlocking().exchange(HttpRequest.GET("/init")); + assertEquals(HttpStatus.OK, response.getStatus()); + } + @AfterAll public void cleanup() { try { - TestResourcesClient testResourcesClient = TestResourcesClientFactory.extractFrom(context); - testResourcesClient.closeScope(getClass().getName()); - } catch (Exception e) { - // ignore + HttpResponse response = client.toBlocking().exchange(HttpRequest.GET("/destroy")); + assertEquals(HttpStatus.OK, response.getStatus()); + } finally { + // always close scope + try { + TestResourcesClient testResourcesClient = TestResourcesClientFactory.extractFrom(context); + testResourcesClient.closeScope(getClass().getName()); + } catch (Exception e) { + // ignore + } } } @Test - @Order(1) - void shouldInit() { - HttpResponse response = client.toBlocking().exchange(HttpRequest.GET("/init")); - assertEquals(HttpStatus.OK, response.getStatus()); - } - - @Test - @Order(2) void shouldFetchOwners() { List results = client.toBlocking().retrieve(HttpRequest.GET("/owners"), Argument.listOf(OwnerDto.class)); assertEquals(2, results.size()); @@ -83,14 +88,12 @@ void shouldFetchOwners() { } @Test - @Order(3) void shouldFetchOwnerByName() { Map result = client.toBlocking().retrieve(HttpRequest.GET("/owners/Fred"), Map.class); assertEquals("Fred", result.get("name")); } @Test - @Order(4) void shouldFetchPets() { List results = client.toBlocking().retrieve(HttpRequest.GET("/pets"), Argument.listOf(PetDto.class)); assertEquals(3, results.size()); @@ -103,7 +106,6 @@ void shouldFetchPets() { } @Test - @Order(5) void shouldFetchPetByName() { Map result = client.toBlocking().retrieve(HttpRequest.GET("/pets/Dino"), Map.class); assertEquals("Dino", result.get("name")); @@ -111,7 +113,6 @@ void shouldFetchPetByName() { } @Test - @Order(6) void shouldFetchPetsParallel() { List> resultsList = Flux.range(1, 1000) .flatMap(it -> client.retrieve(HttpRequest.GET("/pets"), Argument.listOf(PetDto.class))) @@ -130,7 +131,6 @@ void shouldFetchPetsParallel() { } @Test - @Order(7) void shouldFetchPetByNameParallel() { List resultsList = Flux.range(1, 1000) .flatMap(it -> client.retrieve(HttpRequest.GET("/pets/Dino"), Map.class)) @@ -139,11 +139,4 @@ void shouldFetchPetByNameParallel() { resultsList.forEach(it -> assertEquals("Dino", it.get("name"))); } - - @Test - @Order(8) - void shouldDestroy() { - HttpResponse response = client.toBlocking().exchange(HttpRequest.GET("/destroy")); - assertEquals(HttpStatus.OK, response.getStatus()); - } } diff --git a/tests/hibernate6/hibernate6-reactive-mssql/build.gradle b/tests/hibernate6/hibernate6-reactive-mssql/build.gradle index d8c3fe44c..461388800 100644 --- a/tests/hibernate6/hibernate6-reactive-mssql/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-mssql/build.gradle @@ -23,3 +23,8 @@ graalvmNative { buildArgs.addAll("-H:+AddAllCharsets") } } + +// TODO: Enable when the `Registering type as reachable after analysis` issue gets fixed +graalvmNative { + testSupport = false +} diff --git a/tests/hibernate6/hibernate6-reactive-mysql/build.gradle b/tests/hibernate6/hibernate6-reactive-mysql/build.gradle index be147bd03..de4618c9e 100644 --- a/tests/hibernate6/hibernate6-reactive-mysql/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-mysql/build.gradle @@ -18,3 +18,8 @@ micronaut { additionalModules.add(HIBERNATE_REACTIVE_MYSQL) } } + +// TODO: Enable when the `Registering type as reachable after analysis` issue gets fixed +graalvmNative { + testSupport = false +} diff --git a/tests/hibernate6/hibernate6-reactive-oracle/build.gradle b/tests/hibernate6/hibernate6-reactive-oracle/build.gradle index 15fca8a2e..febe97a9d 100644 --- a/tests/hibernate6/hibernate6-reactive-oracle/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-oracle/build.gradle @@ -14,3 +14,8 @@ micronaut { additionalModules.add(HIBERNATE_REACTIVE_ORACLE_XE) } } + +// TODO: Enable when the `Registering type as reachable after analysis` issue gets fixed +graalvmNative { + testSupport = false +} From 24052590edb8b6db39f2e5d4c9c901199cce38cd Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Wed, 5 Apr 2023 17:02:59 +0200 Subject: [PATCH 18/19] Enabled reactive native tests and fixed micronaut dependency issue in tests --- .../io.micronaut.build.internal.test-application.gradle | 4 ++++ tests/hibernate6/hibernate6-reactive-mssql/build.gradle | 5 ----- tests/hibernate6/hibernate6-reactive-mysql/build.gradle | 5 ----- tests/hibernate6/hibernate6-reactive-oracle/build.gradle | 5 ----- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/buildSrc/src/main/groovy/io.micronaut.build.internal.test-application.gradle b/buildSrc/src/main/groovy/io.micronaut.build.internal.test-application.gradle index bbfe9dce8..8eb5c85cc 100644 --- a/buildSrc/src/main/groovy/io.micronaut.build.internal.test-application.gradle +++ b/buildSrc/src/main/groovy/io.micronaut.build.internal.test-application.gradle @@ -35,6 +35,10 @@ tasks.named("check") { task -> } } +configurations.all { + resolutionStrategy.preferProjectModules() +} + graalvmNative { toolchainDetection = false binaries { diff --git a/tests/hibernate6/hibernate6-reactive-mssql/build.gradle b/tests/hibernate6/hibernate6-reactive-mssql/build.gradle index 461388800..d8c3fe44c 100644 --- a/tests/hibernate6/hibernate6-reactive-mssql/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-mssql/build.gradle @@ -23,8 +23,3 @@ graalvmNative { buildArgs.addAll("-H:+AddAllCharsets") } } - -// TODO: Enable when the `Registering type as reachable after analysis` issue gets fixed -graalvmNative { - testSupport = false -} diff --git a/tests/hibernate6/hibernate6-reactive-mysql/build.gradle b/tests/hibernate6/hibernate6-reactive-mysql/build.gradle index de4618c9e..be147bd03 100644 --- a/tests/hibernate6/hibernate6-reactive-mysql/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-mysql/build.gradle @@ -18,8 +18,3 @@ micronaut { additionalModules.add(HIBERNATE_REACTIVE_MYSQL) } } - -// TODO: Enable when the `Registering type as reachable after analysis` issue gets fixed -graalvmNative { - testSupport = false -} diff --git a/tests/hibernate6/hibernate6-reactive-oracle/build.gradle b/tests/hibernate6/hibernate6-reactive-oracle/build.gradle index febe97a9d..15fca8a2e 100644 --- a/tests/hibernate6/hibernate6-reactive-oracle/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-oracle/build.gradle @@ -14,8 +14,3 @@ micronaut { additionalModules.add(HIBERNATE_REACTIVE_ORACLE_XE) } } - -// TODO: Enable when the `Registering type as reachable after analysis` issue gets fixed -graalvmNative { - testSupport = false -} From 2394aa904edbd0a2da9468a89486fa2bb6237c28 Mon Sep 17 00:00:00 2001 From: Milenko Supic Date: Wed, 5 Apr 2023 18:12:10 +0200 Subject: [PATCH 19/19] Additional metadata needed because of jooq upgrade (from 3.17.7 to 3.18.2) --- .../io.micronaut.sql/jooq-graal/reflect-config.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 jooq/src/main/resources/META-INF/native-image/io.micronaut.sql/jooq-graal/reflect-config.json diff --git a/jooq/src/main/resources/META-INF/native-image/io.micronaut.sql/jooq-graal/reflect-config.json b/jooq/src/main/resources/META-INF/native-image/io.micronaut.sql/jooq-graal/reflect-config.json new file mode 100644 index 000000000..b050e97dc --- /dev/null +++ b/jooq/src/main/resources/META-INF/native-image/io.micronaut.sql/jooq-graal/reflect-config.json @@ -0,0 +1,8 @@ +[ + { + "name": "[Ljava.time.Year;", + "condition": { + "typeReachable": "org.jooq.impl.SQLDataType" + } + } +]