HHH-15746 Register the StandardIdentifierGeneratorFactory as a default Service

This commit is contained in:
Davide D'Alto 2022-11-22 14:17:31 +00:00 committed by Sanne Grinovero
parent 7081d31647
commit dd36425b31
4 changed files with 33 additions and 3 deletions

View File

@ -63,7 +63,6 @@ import org.hibernate.engine.config.spi.StandardConverters;
import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.log.DeprecationLogger;
@ -567,7 +566,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
public MetadataBuildingOptionsImpl(StandardServiceRegistry serviceRegistry) {
this.serviceRegistry = serviceRegistry;
this.identifierGeneratorFactory = new StandardIdentifierGeneratorFactory( serviceRegistry );
this.identifierGeneratorFactory = serviceRegistry.getService( IdentifierGeneratorFactory.class );
final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );

View File

@ -11,6 +11,7 @@ import java.util.Properties;
import org.hibernate.dialect.Dialect;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.factory.spi.GeneratorDefinitionResolver;
import org.hibernate.service.Service;
import org.hibernate.type.Type;
import org.hibernate.type.descriptor.java.JavaType;
@ -21,7 +22,7 @@ import jakarta.persistence.GenerationType;
*
* @author Steve Ebersole
*/
public interface IdentifierGeneratorFactory {
public interface IdentifierGeneratorFactory extends Service {
/**
* Get the dialect.
* @deprecated should be removed

View File

@ -0,0 +1,27 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.id.factory.internal;
import java.util.Map;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.service.spi.ServiceRegistryImplementor;
public class StandardIdentifierGeneratorFactoryInitiator implements StandardServiceInitiator<IdentifierGeneratorFactory> {
public static final StandardIdentifierGeneratorFactoryInitiator INSTANCE = new StandardIdentifierGeneratorFactoryInitiator();
@Override
public Class<IdentifierGeneratorFactory> getServiceInitiated() {
return IdentifierGeneratorFactory.class;
}
@Override
public IdentifierGeneratorFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
return new StandardIdentifierGeneratorFactory( registry );
}
}

View File

@ -29,6 +29,7 @@ import org.hibernate.engine.jndi.internal.JndiServiceInitiator;
import org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator;
import org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformResolverInitiator;
import org.hibernate.event.internal.EntityCopyObserverFactoryInitiator;
import org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactoryInitiator;
import org.hibernate.persister.internal.PersisterClassResolverInitiator;
import org.hibernate.persister.internal.PersisterFactoryInitiator;
import org.hibernate.property.access.internal.PropertyAccessStrategyResolverInitiator;
@ -54,6 +55,8 @@ public final class StandardServiceInitiators {
serviceInitiators.add( DefaultSessionFactoryBuilderInitiator.INSTANCE );
serviceInitiators.add( StandardIdentifierGeneratorFactoryInitiator.INSTANCE );
serviceInitiators.add( BytecodeProviderInitiator.INSTANCE );
serviceInitiators.add( ProxyFactoryFactoryInitiator.INSTANCE );