diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ClassNames.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ClassNames.java index f7e6bd6d5f6205..aca0343ec32d95 100644 --- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ClassNames.java +++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ClassNames.java @@ -465,4 +465,22 @@ private static DotName createConstant(String fqcn) { "io.quarkus.hibernate.orm.deployment.HibernateUserTypeProcessor"); public static final DotName GRAAL_VM_FEATURES = createConstant("io.quarkus.hibernate.orm.deployment.GraalVMFeatures"); + + public static final List SERVICE_PROVIDERS = List.of( + // Accessed in org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder. + createConstant("org.hibernate.query.criteria.spi.CriteriaBuilderExtension"), + // Accessed in io.quarkus.hibernate.orm.runtime.customized.QuarkusIntegratorServiceImpl. + createConstant("org.hibernate.integrator.spi.Integrator"), + // Accessed in io.quarkus.hibernate.orm.runtime.customized.QuarkusStrategySelectorBuilder.buildSelector + createConstant("org.hibernate.boot.registry.selector.StrategyRegistrationProvider"), + // Accessed in io.quarkus.hibernate.orm.runtime.recording.RecordableBootstrap.applyServiceContributors + createConstant("org.hibernate.service.spi.ServiceContributor"), + // Accessed in org.hibernate.internal.FastSessionServices. + createConstant("org.hibernate.event.spi.EventManager"), + // Accessed in org.hibernate.query.internal.QueryEngineImpl.sortedFunctionContributors + createConstant("org.hibernate.boot.model.FunctionContributor"), + // Accessed in org.hibernate.event.spi.EventEngine. + createConstant("org.hibernate.event.spi.EventEngineContributor"), + // Accessed in org.hibernate.service.internal.SessionFactoryServiceRegistryFactoryImpl.buildServiceRegistry + createConstant("org.hibernate.service.spi.SessionFactoryServiceContributor")); } diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java index 2c518fbd575d58..1ecb454e5f2cbf 100644 --- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java +++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java @@ -104,6 +104,7 @@ import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; import io.quarkus.deployment.index.IndexingUtil; import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; import io.quarkus.deployment.recording.RecorderContext; @@ -163,7 +164,11 @@ public final class HibernateOrmProcessor { private static final String INTEGRATOR_SERVICE_FILE = "META-INF/services/org.hibernate.integrator.spi.Integrator"; @BuildStep - NativeImageFeatureBuildItem registerServicesForReflection() { + NativeImageFeatureBuildItem registerServicesForReflection(BuildProducer services) { + for (DotName serviceProvider : ClassNames.SERVICE_PROVIDERS) { + services.produce(ServiceProviderBuildItem.allProvidersFromClassPath(serviceProvider.toString())); + } + return new NativeImageFeatureBuildItem(RegisterServicesForReflectionFeature.class); }