Skip to content

Commit

Permalink
Register Hibernate service providers for native run-time access
Browse files Browse the repository at this point in the history
Relates to quarkusio#41995
  • Loading branch information
zakkak committed Jan 16, 2025
1 parent 0a44026 commit 123acaa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<DotName> SERVICE_PROVIDERS = List.of(
// Accessed in org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder.<init>
createConstant("org.hibernate.query.criteria.spi.CriteriaBuilderExtension"),
// Accessed in io.quarkus.hibernate.orm.runtime.customized.QuarkusIntegratorServiceImpl.<init>
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.<init>
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.<init>
createConstant("org.hibernate.event.spi.EventEngineContributor"),
// Accessed in org.hibernate.service.internal.SessionFactoryServiceRegistryFactoryImpl.buildServiceRegistry
createConstant("org.hibernate.service.spi.SessionFactoryServiceContributor"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ServiceProviderBuildItem> services) {
for (DotName serviceProvider : ClassNames.SERVICE_PROVIDERS) {
services.produce(ServiceProviderBuildItem.allProvidersFromClassPath(serviceProvider.toString()));
}

return new NativeImageFeatureBuildItem(RegisterServicesForReflectionFeature.class);
}

Expand Down

0 comments on commit 123acaa

Please sign in to comment.