HHH-15441 Improve error message if SqlTypes type code can't be interpreted

This commit is contained in:
Christian Beikov 2022-08-05 15:31:55 +02:00
parent a681c0e1d9
commit 95a300d7d9
1 changed files with 8 additions and 2 deletions

View File

@ -9,6 +9,7 @@ package org.hibernate.internal.util.config;
import java.sql.Types; import java.sql.Types;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.StringTokenizer; import java.util.StringTokenizer;
@ -600,12 +601,17 @@ public final class ConfigurationHelper {
return ( (Number) value ).intValue(); return ( (Number) value ).intValue();
} }
final String string = value.toString(); final String string = value.toString().toUpperCase( Locale.ROOT );
final Integer typeCode = JdbcTypeNameMapper.getTypeCode( string ); final Integer typeCode = JdbcTypeNameMapper.getTypeCode( string );
if ( typeCode != null ) { if ( typeCode != null ) {
return typeCode; return typeCode;
} }
try {
return Integer.parseInt( string ); return Integer.parseInt( string );
} }
catch (NumberFormatException ex) {
throw new IllegalArgumentException( String.format( "Couldn't interpret '%s' as JDBC type code or type code name", string ) );
}
}
} }
} }