Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions hibernate-core/src/main/java/org/hibernate/type/TypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.tuple.component.ComponentMetamodel;
import org.hibernate.type.spi.TypeBootstrapContext;
import org.hibernate.type.spi.TypeConfiguration;
Expand Down Expand Up @@ -94,15 +95,24 @@ public Type type(Class<Type> typeClass, Properties parameters) {
try {
final Type type;

final Constructor<Type> bootstrapContextAwareTypeConstructor = ReflectHelper.getConstructor(
Constructor<Type> contextAwareTypeConstructor = ReflectHelper.getConstructor(
typeClass,
TypeBootstrapContext.class
ServiceRegistry.class
);
if ( bootstrapContextAwareTypeConstructor != null ) {
type = bootstrapContextAwareTypeConstructor.newInstance( this );
if ( contextAwareTypeConstructor != null ) {
type = contextAwareTypeConstructor.newInstance( this.typeConfiguration.getServiceRegistry() );
}
else {
type = typeClass.newInstance();
contextAwareTypeConstructor = ReflectHelper.getConstructor(
typeClass,
TypeBootstrapContext.class
);
if ( contextAwareTypeConstructor != null ) {
type = contextAwareTypeConstructor.newInstance( this );
}
else {
type = typeClass.newInstance();
}
}

injectParameters( type, parameters );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import java.util.Map;

import org.hibernate.dialect.Dialect;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.DiscriminatorType;
import org.hibernate.type.descriptor.sql.VarcharTypeDescriptor;
import org.hibernate.type.spi.TypeBootstrapContext;

/**
* @author Vlad Mihalcea
Expand All @@ -23,9 +24,10 @@ public ArrayType() {
super( VarcharTypeDescriptor.INSTANCE, ArrayTypeDescriptor.INSTANCE );
}

public ArrayType(TypeBootstrapContext typeBootstrapContext) {
public ArrayType(ServiceRegistry serviceRegistry) {
super( VarcharTypeDescriptor.INSTANCE, ArrayTypeDescriptor.INSTANCE );
this.settings = typeBootstrapContext.getConfigurationSettings();
ConfigurationService configurationService = serviceRegistry.getService( ConfigurationService.class );
this.settings = configurationService.getSettings();
}

@Override
Expand Down