From 72bf70f013d66a4ad924735ad7a4caf1024f5264 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 28 Apr 2020 15:43:33 +0100 Subject: [PATCH] Fix issue with Column size detection causing errors during schema generation --- .../java/org/hibernate/mapping/Column.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Column.java b/hibernate-core/src/main/java/org/hibernate/mapping/Column.java index c3bc9a2d73..ba80b9a70d 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Column.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Column.java @@ -242,21 +242,20 @@ public class Column implements Selectable, Serializable, Cloneable { if ( sqlType == null ) { Size size = new Size( getPrecision(), getScale(), getLength(), null ); Type type = getValue().getType(); - if ( size.getLength() == null - && size.getScale() == null && size.getPrecision() == null ) { + if ( size.getLength() == null && size.getScale() == null && size.getPrecision() == null ) { if ( type instanceof EntityType ) { - //ManyToOneType doesn't implement JdbcMapping - type = mapping.getIdentifierType( ( (EntityType) type ).getAssociatedEntityName() ); - if ( type instanceof ComponentType ) { - type = ( (ComponentType) type ).getSubtypes()[getTypeIndex()]; + while ( !( type instanceof JdbcMapping ) ) { + //ManyToOneType doesn't implement JdbcMapping + type = mapping.getIdentifierType( ( (EntityType) type ).getAssociatedEntityName() ); + if ( type instanceof ComponentType ) { + type = ( (ComponentType) type ).getSubtypes()[getTypeIndex()]; + } } } - if ( type instanceof JdbcMapping ) { - size = dialect.getDefaultSizeStrategy().resolveDefaultSize( - ((JdbcMapping) type).getSqlTypeDescriptor(), - ((JdbcMapping) type).getJavaTypeDescriptor() - ); - } + size = dialect.getDefaultSizeStrategy().resolveDefaultSize( + ( (JdbcMapping) type ).getSqlTypeDescriptor(), + ( (JdbcMapping) type ).getJavaTypeDescriptor() + ); } try {