Skip to content

Commit

Permalink
HHH-18582 Throw explicit error when trying to map nested arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
mbladel committed Sep 20, 2024
1 parent 97f9477 commit a1010b8
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.hibernate.HibernateException;
import org.hibernate.Internal;
import org.hibernate.MappingException;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
Expand Down Expand Up @@ -156,16 +157,24 @@ private <J> BasicType<J> resolvedType(JavaType<J> javaType, JdbcType jdbcType) {
}

private <E> BasicType<?> resolvedType(ArrayJdbcType arrayType, BasicPluralJavaType<E> castPluralJavaType) {
final BasicType<E> elementType = resolve( castPluralJavaType.getElementJavaType(), arrayType.getElementJdbcType() );
final BasicType<?> resolvedType = castPluralJavaType.resolveType(
typeConfiguration,
typeConfiguration.getCurrentBaseSqlTypeIndicators().getDialect(),
resolve( castPluralJavaType.getElementJavaType(), arrayType.getElementJdbcType() ),
elementType,
null,
typeConfiguration.getCurrentBaseSqlTypeIndicators()
);
if ( resolvedType instanceof BasicPluralType<?,?> ) {
register( resolvedType );
}
else if ( resolvedType == null ) {
final Class<?> elementJavaTypeClass = elementType.getJavaTypeDescriptor().getJavaTypeClass();
if ( elementJavaTypeClass != null && elementJavaTypeClass.isArray() && elementJavaTypeClass != byte[].class ) {
// No support for nested arrays, except for byte[][]
throw new MappingException( "Nested arrays (with the exception of byte[][]) are not supported" );
}
}
return resolvedType;
}

Expand Down

0 comments on commit a1010b8

Please sign in to comment.