on h2, don't use NCLOB in generated DDL

since we don't use NCHAR/NVARCHAR

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-06-29 09:01:59 +02:00 committed by Steve Ebersole
parent 755c93c9f1
commit 785dac135a
1 changed files with 7 additions and 0 deletions

View File

@ -83,6 +83,7 @@ import static org.hibernate.query.sqm.TemporalUnit.SECOND;
import static org.hibernate.type.SqlTypes.BIGINT; import static org.hibernate.type.SqlTypes.BIGINT;
import static org.hibernate.type.SqlTypes.BINARY; import static org.hibernate.type.SqlTypes.BINARY;
import static org.hibernate.type.SqlTypes.CHAR; import static org.hibernate.type.SqlTypes.CHAR;
import static org.hibernate.type.SqlTypes.CLOB;
import static org.hibernate.type.SqlTypes.DOUBLE; import static org.hibernate.type.SqlTypes.DOUBLE;
import static org.hibernate.type.SqlTypes.FLOAT; import static org.hibernate.type.SqlTypes.FLOAT;
import static org.hibernate.type.SqlTypes.GEOMETRY; import static org.hibernate.type.SqlTypes.GEOMETRY;
@ -92,6 +93,7 @@ import static org.hibernate.type.SqlTypes.LONG32NVARCHAR;
import static org.hibernate.type.SqlTypes.LONG32VARBINARY; import static org.hibernate.type.SqlTypes.LONG32VARBINARY;
import static org.hibernate.type.SqlTypes.LONG32VARCHAR; import static org.hibernate.type.SqlTypes.LONG32VARCHAR;
import static org.hibernate.type.SqlTypes.NCHAR; import static org.hibernate.type.SqlTypes.NCHAR;
import static org.hibernate.type.SqlTypes.NCLOB;
import static org.hibernate.type.SqlTypes.NVARCHAR; import static org.hibernate.type.SqlTypes.NVARCHAR;
import static org.hibernate.type.SqlTypes.OTHER; import static org.hibernate.type.SqlTypes.OTHER;
import static org.hibernate.type.SqlTypes.UUID; import static org.hibernate.type.SqlTypes.UUID;
@ -191,10 +193,15 @@ public class H2Dialect extends Dialect {
@Override @Override
protected String columnType(int sqlTypeCode) { protected String columnType(int sqlTypeCode) {
switch ( sqlTypeCode ) { switch ( sqlTypeCode ) {
// h2 recognizes NCHAR and NCLOB as aliases
// but, according to the docs, not NVARCHAR
// so just normalize all these types
case NCHAR: case NCHAR:
return columnType( CHAR ); return columnType( CHAR );
case NVARCHAR: case NVARCHAR:
return columnType( VARCHAR ); return columnType( VARCHAR );
case NCLOB:
return columnType( CLOB );
default: default:
return super.columnType( sqlTypeCode ); return super.columnType( sqlTypeCode );
} }