From f5062fca66f6b0399acca38d8983ed2603911be7 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Fri, 22 Nov 2024 21:52:44 +0100 Subject: [PATCH] HHH-14020 add getServiceRegistry() to TypeBootstrapContext --- .../hibernate/boot/internal/BootstrapContextImpl.java | 2 +- .../boot/internal/TypeBeanInstanceProducer.java | 10 +++++++++- .../org/hibernate/type/spi/TypeBootstrapContext.java | 4 +++- .../orm/test/boot/models/BootstrapContextTesting.java | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java index 6efbabb6b9..cfde4e259a 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java @@ -101,7 +101,7 @@ public class BootstrapContextImpl implements BootstrapContext { this.representationStrategySelector = ManagedTypeRepresentationResolverStandard.INSTANCE; this.typeConfiguration = new TypeConfiguration(); - this.beanInstanceProducer = new TypeBeanInstanceProducer( configService ); + this.beanInstanceProducer = new TypeBeanInstanceProducer( configService, serviceRegistry ); this.sqmFunctionRegistry = new SqmFunctionRegistry(); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/TypeBeanInstanceProducer.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/TypeBeanInstanceProducer.java index 5cc24d1468..2fd7fed6b3 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/TypeBeanInstanceProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/TypeBeanInstanceProducer.java @@ -10,6 +10,7 @@ import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.resource.beans.spi.BeanInstanceProducer; import org.hibernate.type.spi.TypeBootstrapContext; +import org.hibernate.service.ServiceRegistry; import java.lang.reflect.Constructor; import java.util.Map; @@ -22,9 +23,11 @@ import java.util.Map; @Internal public class TypeBeanInstanceProducer implements BeanInstanceProducer, TypeBootstrapContext { private final ConfigurationService configurationService; + private final ServiceRegistry serviceRegistry; - public TypeBeanInstanceProducer(ConfigurationService configurationService) { + public TypeBeanInstanceProducer(ConfigurationService configurationService, ServiceRegistry serviceRegistry) { this.configurationService = configurationService; + this.serviceRegistry = serviceRegistry; } @Override @@ -64,4 +67,9 @@ public class TypeBeanInstanceProducer implements BeanInstanceProducer, TypeBoots public Map getConfigurationSettings() { return configurationService.getSettings(); } + + @Override + public ServiceRegistry getServiceRegistry() { + return serviceRegistry; + } } diff --git a/hibernate-core/src/main/java/org/hibernate/type/spi/TypeBootstrapContext.java b/hibernate-core/src/main/java/org/hibernate/type/spi/TypeBootstrapContext.java index e62f28c5e9..b46f3963af 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/spi/TypeBootstrapContext.java +++ b/hibernate-core/src/main/java/org/hibernate/type/spi/TypeBootstrapContext.java @@ -4,6 +4,8 @@ */ package org.hibernate.type.spi; +import org.hibernate.service.ServiceRegistry; + import java.util.Map; /** @@ -18,6 +20,6 @@ import java.util.Map; * @since 5.4 */ public interface TypeBootstrapContext { - @SuppressWarnings("unused") Map getConfigurationSettings(); + ServiceRegistry getServiceRegistry(); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/BootstrapContextTesting.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/BootstrapContextTesting.java index 8a8e778aa9..fa5a9a1c67 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/BootstrapContextTesting.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/BootstrapContextTesting.java @@ -106,7 +106,7 @@ public class BootstrapContextTesting implements BootstrapContext { this.representationStrategySelector = ManagedTypeRepresentationResolverStandard.INSTANCE; this.typeConfiguration = new TypeConfiguration(); - this.beanInstanceProducer = new TypeBeanInstanceProducer( configService ); + this.beanInstanceProducer = new TypeBeanInstanceProducer( configService, serviceRegistry ); this.sqmFunctionRegistry = new SqmFunctionRegistry(); }