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 ef0bca4a2..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,10 +35,8 @@ 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 +configurations.all { + resolutionStrategy.preferProjectModules() } graalvmNative { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a65d60905..bce5cfb46 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -52,7 +52,6 @@ managed-h2 = "2.1.214" # Other sfm-reflect = "8.2.3" -graal-svm = "22.3.1" # Testing @@ -138,7 +137,6 @@ jakarta-transaction-api = { module = "jakarta.transaction:jakarta.transaction-ap # Others sfm-reflect = { module = "org.simpleflatmapper:sfm-reflect", version.ref = "sfm-reflect" } -graal-svm = { module = "org.graalvm.nativeimage:svm", version.ref = "graal-svm" } # Testcontainers diff --git a/hibernate-jpa-spring/build.gradle b/hibernate-jpa-spring/build.gradle index 51f539273..50db5de9a 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-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 { /** 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-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/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/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/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 index d70976cb3..c95e99bf5 100644 --- 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 @@ -1,16 +1,116 @@ [ - { - "name": "org.hibernate.internal.log.ConnectionPoolingLogger_$logger", - "condition": { - "typeReachable": "org.hibernate.internal.log.ConnectionPoolingLogger" - }, - "methods": [ - { - "name": "", - "parameterTypes": [ - "org.jboss.logging.Logger" + { + "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-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/build.gradle b/jdbc/build.gradle index ee49a2a2f..5e5e4d6a7 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(mnSpring.spring.jdbc) 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 deleted file mode 100644 index e0e481e23..000000000 --- a/jdbc/src/main/resources/META-INF/native-image/io.micronaut.sql/micronaut-jdbc/resource-config.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "bundles": [], - "resources": { - "includes": [ - { - "condition": { - "typeReachable": "org.mariadb.jdbc.util.VersionFactory" - }, - "pattern": "\\Qmariadb.properties\\E" - } - ] - } -} diff --git a/jooq/build.gradle b/jooq/build.gradle index 7cf35b29b..fb5e798ed 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) 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/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" + } + } +] diff --git a/settings.gradle b/settings.gradle index 6ea12b41b..ba84a4b3f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -47,6 +47,7 @@ include 'jdbi' include 'tests:common' include 'tests:common-reactive' +include 'tests:common-sync' include 'tests:common-tests' include 'tests:hibernate6:hibernate6-sync-common' @@ -58,13 +59,10 @@ 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-oracle' -//include 'tests:hibernate6:hibernate6-reactive-postgres' +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:jooq-tests:jooq-jdbc-postgres' include 'tests:jooq-tests:jooq-r2dbc-postgres' -include 'tests:common-entity' - 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. 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-entity/build.gradle b/tests/common-entity/build.gradle deleted file mode 100644 index 1d0c34309..000000000 --- a/tests/common-entity/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -plugins { - id 'io.micronaut.build.internal.test-library' -} - -dependencies { - api(mnSerde.micronaut.serde.api) -} diff --git a/tests/common-reactive/build.gradle b/tests/common-reactive/build.gradle index 008505122..f1d67a015 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.micronautTests.micronautCommonEntity) + api(projects.micronautTests.micronautCommon) api(mnData.micronaut.data.tx) implementation(mnSerde.micronaut.serde.jackson) diff --git a/tests/common-reactive/src/main/java/example/Application.java b/tests/common-reactive/src/main/java/example/Application.java deleted file mode 100644 index fe509231a..000000000 --- a/tests/common-reactive/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-reactive/src/main/resources/application.yml b/tests/common-reactive/src/main/resources/application.yml deleted file mode 100644 index 2dfa1a024..000000000 --- a/tests/common-reactive/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-reactive/src/main/resources/logback.xml b/tests/common-reactive/src/main/resources/logback.xml deleted file mode 100644 index 110cefe7a..000000000 --- a/tests/common-reactive/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n - - - - - - - - diff --git a/tests/common-sync/build.gradle b/tests/common-sync/build.gradle new file mode 100644 index 000000000..59e1d42c6 --- /dev/null +++ b/tests/common-sync/build.gradle @@ -0,0 +1,15 @@ +plugins { + id 'io.micronaut.build.internal.test-library' +} + +dependencies { + implementation mn.micronaut.http + implementation mn.micronaut.runtime + api(projects.micronautTests.micronautCommon) + api(mnData.micronaut.data.tx) + + implementation(mnSerde.micronaut.serde.jackson) + testImplementation(mnSerde.micronaut.serde.jackson) + + runtimeOnly(mn.snakeyaml) +} 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 94% rename from tests/common/src/main/java/example/sync/PetController.java rename to tests/common-sync/src/main/java/example/sync/PetController.java index b7fca142a..64ba4b5cd 100644 --- a/tests/common/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-tests/build.gradle b/tests/common-tests/build.gradle index 3033e7854..42c2e8dab 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.micronautTests.micronautCommonEntity) + api(projects.micronautTests.micronautCommon) api libs.micronaut.testresources.client } 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/common/build.gradle b/tests/common/build.gradle index 155e3cc81..5a2b4a33e 100644 --- a/tests/common/build.gradle +++ b/tests/common/build.gradle @@ -3,13 +3,12 @@ plugins { } dependencies { - implementation mn.micronaut.http - implementation mn.micronaut.runtime - api(projects.micronautTests.micronautCommonEntity) - api(mnData.micronaut.data.tx) - - implementation(mnSerde.micronaut.serde.jackson) - testImplementation(mnSerde.micronaut.serde.jackson) - + 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/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/hibernate6/hibernate6-h2/build.gradle b/tests/hibernate6/hibernate6-h2/build.gradle index 801121337..f77efccf5 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 97e891130..20b564b68 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-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/build.gradle b/tests/hibernate6/hibernate6-mssql/build.gradle index 22e7cf4aa..fd216d8aa 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-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/build.gradle b/tests/hibernate6/hibernate6-mysql/build.gradle index 3a8fe0cb1..01f2b6859 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-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/build.gradle b/tests/hibernate6/hibernate6-oracle/build.gradle index 5ffbe000f..2b6ec2aa1 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-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 { } diff --git a/tests/hibernate6/hibernate6-postgres/build.gradle b/tests/hibernate6/hibernate6-postgres/build.gradle index a6e39aef8..204c31cac 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-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 59f1df167..d8c3fe44c 100644 --- a/tests/hibernate6/hibernate6-reactive-mssql/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-mssql/build.gradle @@ -14,14 +14,11 @@ 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) } } graalvmNative { - // TODO: Enable native tests in separate PR - testSupport = false binaries.all { buildArgs.addAll("-H:+AddAllCharsets") } diff --git a/tests/hibernate6/hibernate6-reactive-mysql/build.gradle b/tests/hibernate6/hibernate6-reactive-mysql/build.gradle index 18c69e248..be147bd03 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 -} diff --git a/tests/hibernate6/hibernate6-reactive-oracle/build.gradle b/tests/hibernate6/hibernate6-reactive-oracle/build.gradle index 3b9a8643e..15fca8a2e 100644 --- a/tests/hibernate6/hibernate6-reactive-oracle/build.gradle +++ b/tests/hibernate6/hibernate6-reactive-oracle/build.gradle @@ -11,12 +11,6 @@ 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) } } - -graalvmNative { - // TODO: Enable native tests in separate PR - testSupport = false -} diff --git a/tests/hibernate6/hibernate6-reactive-postgres/build.gradle b/tests/hibernate6/hibernate6-reactive-postgres/build.gradle index 7336b848a..7de076ec0 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) } } diff --git a/tests/hibernate6/hibernate6-sync-common/build.gradle b/tests/hibernate6/hibernate6-sync-common/build.gradle index b4af377ab..8b6e9aac0 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.micronautTests.micronautCommon + implementation projects.micronautTests.micronautCommonSync implementation projects.micronautHibernateJpa runtimeOnly projects.micronautJdbcHikari 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 diff --git a/tests/jooq-tests/jooq-jdbc-postgres/build.gradle b/tests/jooq-tests/jooq-jdbc-postgres/build.gradle index a7c82a59b..e3617f1a3 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.micronautJooq implementation mnData.micronaut.data.tx - implementation projects.micronautTests.micronautCommon + implementation projects.micronautTests.micronautCommonSync annotationProcessor mnData.micronaut.data.processor