diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java index 5a59216351..7994f22327 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java @@ -365,14 +365,8 @@ public class Binder { attributeSource.getNaturalIdMutability(), createMetaAttributeContext( attributeBindingContainer, attributeSource ), attributeSource.getGeneration() ); - final HibernateTypeDescriptor hibernateTypeDescriptor = attributeBinding.getHibernateTypeDescriptor(); typeHelper.bindSingularAttributeTypeInformation( attributeSource, attributeBinding ); - // TODO: Move heuristic type into typeHelper? - Type resolvedType = heuristicType( hibernateTypeDescriptor ); - bindHibernateResolvedType( attributeBinding.getHibernateTypeDescriptor(), resolvedType ); - typeHelper.bindJdbcDataType( resolvedType, relationalValueBindings ); - attributeBinding.getAttribute().resolveType( bindingContext().makeJavaType( hibernateTypeDescriptor.getJavaTypeName() ) ); return attributeBinding; } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java index f711392ee5..0d75b9f347 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java @@ -33,6 +33,7 @@ import org.hibernate.AssertionFailure; import org.hibernate.DuplicateMappingException; import org.hibernate.MappingException; import org.hibernate.SessionFactory; +import org.hibernate.annotations.common.util.StringHelper; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.cache.spi.access.AccessType; import org.hibernate.cfg.NamingStrategy; @@ -230,12 +231,12 @@ public class MetadataImpl implements MetadataImplementor, Serializable { if ( typeDefinition == null ) { throw new IllegalArgumentException( "Type definition is null" ); } - else if ( typeDefinition.getName() == null ) { - throw new IllegalArgumentException( "Type definition name is null: " + typeDefinition.getTypeImplementorClass().getName() ); - } // Need to register both by name and registration keys. - addTypeDefinition( typeDefinition.getName(), typeDefinition ); + if ( !StringHelper.isEmpty( typeDefinition.getName() ) ) { + addTypeDefinition( typeDefinition.getName(), typeDefinition ); + } + for ( String registrationKey : typeDefinition.getRegistrationKeys() ) { addTypeDefinition( registrationKey, typeDefinition ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/enumerated/EntityEnum.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/enumerated/EntityEnum.java index 5c5c869866..af3e6b8a28 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/enumerated/EntityEnum.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/enumerated/EntityEnum.java @@ -15,8 +15,7 @@ import org.hibernate.annotations.TypeDefs; */ @Entity @TypeDefs({ - @TypeDef(name = "LastNumber", - typeClass = LastNumberType.class, + @TypeDef(typeClass = LastNumberType.class, defaultForType = EntityEnum.LastNumber.class) }) public class EntityEnum {