HHH-15464 Allow JdbcType to expose the type code to use for DDL

This commit is contained in:
Christian Beikov 2022-08-25 17:08:17 +02:00
parent a094d4c5d5
commit 4901d2bb61
51 changed files with 396 additions and 109 deletions

View File

@ -12,6 +12,7 @@ import java.util.function.Consumer;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.dialect.DatabaseVersion; import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.JdbcMappingContainer;
import org.hibernate.query.sqm.ComparisonOperator; import org.hibernate.query.sqm.ComparisonOperator;
import org.hibernate.query.sqm.FetchClauseType; import org.hibernate.query.sqm.FetchClauseType;
import org.hibernate.sql.ast.SqlAstNodeRenderingMode; import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
@ -40,6 +41,7 @@ import org.hibernate.sql.ast.tree.select.QuerySpec;
import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.sql.ast.tree.update.UpdateStatement; import org.hibernate.sql.ast.tree.update.UpdateStatement;
import org.hibernate.sql.exec.spi.JdbcOperation; import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.type.SqlTypes;
/** /**
* A SQL AST translator for DB2. * A SQL AST translator for DB2.
@ -376,10 +378,79 @@ public class DB2LegacySqlAstTranslator<T extends JdbcOperation> extends Abstract
renderComparisonStandard( lhs, operator, rhs ); renderComparisonStandard( lhs, operator, rhs );
} }
else { else {
final JdbcMappingContainer lhsExpressionType = lhs.getExpressionType();
if ( lhsExpressionType != null
&& lhsExpressionType.getJdbcMappings().get( 0 ).getJdbcType().getDdlTypeCode() == SqlTypes.SQLXML ) {
// In SQL Server, XMLTYPE is not "comparable", so we have to cast the two parts to varchar for this purpose
switch ( operator ) {
case DISTINCT_FROM:
appendSql( "decode(" );
appendSql( "xmlserialize(" );
lhs.accept( this );
appendSql( " as varchar(32672))" );
appendSql( ',' );
appendSql( "xmlserialize(" );
rhs.accept( this );
appendSql( " as varchar(32672))" );
appendSql( ",0,1)=1" );
return;
case NOT_DISTINCT_FROM:
appendSql( "decode(" );
appendSql( "xmlserialize(" );
lhs.accept( this );
appendSql( " as varchar(32672))" );
appendSql( ',' );
appendSql( "xmlserialize(" );
rhs.accept( this );
appendSql( " as varchar(32672))" );
appendSql( ",0,1)=0" );
return;
case EQUAL:
case NOT_EQUAL:
appendSql( "xmlserialize(" );
lhs.accept( this );
appendSql( " as varchar(32672))" );
appendSql( operator.sqlText() );
appendSql( "xmlserialize(" );
rhs.accept( this );
appendSql( " as varchar(32672))" );
return;
default:
// Fall through
break;
}
}
renderComparisonEmulateDecode( lhs, operator, rhs ); renderComparisonEmulateDecode( lhs, operator, rhs );
} }
} }
@Override
protected void renderComparisonStandard(Expression lhs, ComparisonOperator operator, Expression rhs) {
final JdbcMappingContainer lhsExpressionType = lhs.getExpressionType();
if ( lhsExpressionType != null
&& lhsExpressionType.getJdbcMappings().get( 0 ).getJdbcType().getDdlTypeCode() == SqlTypes.SQLXML ) {
// In SQL Server, XMLTYPE is not "comparable", so we have to cast the two parts to varchar for this purpose
switch ( operator ) {
case EQUAL:
case NOT_DISTINCT_FROM:
case NOT_EQUAL:
case DISTINCT_FROM:
appendSql( "xmlserialize(" );
lhs.accept( this );
appendSql( " as varchar(32672))" );
appendSql( operator.sqlText() );
appendSql( "xmlserialize(" );
rhs.accept( this );
appendSql( " as varchar(32672))" );
return;
default:
// Fall through
break;
}
}
super.renderComparisonStandard( lhs, operator, rhs );
}
@Override @Override
protected void renderSelectExpression(Expression expression) { protected void renderSelectExpression(Expression expression) {
renderSelectExpressionWithCastedOrInlinedPlainParameters( expression ); renderSelectExpressionWithCastedOrInlinedPlainParameters( expression );

View File

@ -176,49 +176,42 @@ public class DerbyLegacyDialect extends Dialect {
super.registerColumnTypes( typeContributions, serviceRegistry ); super.registerColumnTypes( typeContributions, serviceRegistry );
final DdlTypeRegistry ddlTypeRegistry = typeContributions.getTypeConfiguration().getDdlTypeRegistry(); final DdlTypeRegistry ddlTypeRegistry = typeContributions.getTypeConfiguration().getDdlTypeRegistry();
//long varchar is the right type to use for lengths between 32_672 and 32_700 int varcharDdlTypeCapacity = 32_672;
int maxLongVarcharLength = 32_700;
ddlTypeRegistry.addDescriptor( ddlTypeRegistry.addDescriptor(
CapacityDependentDdlType.builder( VARBINARY, columnType( BLOB ), columnType( VARBINARY ), this ) CapacityDependentDdlType.builder( VARBINARY, columnType( LONG32VARBINARY ), columnType( VARBINARY ), this )
.withTypeCapacity( getMaxVarbinaryLength(), columnType( VARBINARY ) ) .withTypeCapacity( varcharDdlTypeCapacity, columnType( VARBINARY ) )
.withTypeCapacity( maxLongVarcharLength, columnType( LONG32VARBINARY ) )
.build() .build()
); );
ddlTypeRegistry.addDescriptor( ddlTypeRegistry.addDescriptor(
CapacityDependentDdlType.builder( VARCHAR, columnType( CLOB ), columnType( VARCHAR ), this ) CapacityDependentDdlType.builder( VARCHAR, columnType( LONG32VARCHAR ), columnType( VARCHAR ), this )
.withTypeCapacity( getMaxVarcharLength(), columnType( VARCHAR ) ) .withTypeCapacity( varcharDdlTypeCapacity, columnType( VARCHAR ) )
.withTypeCapacity( maxLongVarcharLength, columnType( LONG32VARCHAR ) )
.build() .build()
); );
ddlTypeRegistry.addDescriptor( ddlTypeRegistry.addDescriptor(
CapacityDependentDdlType.builder( NVARCHAR, columnType( CLOB ), columnType( NVARCHAR ), this ) CapacityDependentDdlType.builder( NVARCHAR, columnType( LONG32VARCHAR ), columnType( NVARCHAR ), this )
.withTypeCapacity( getMaxVarcharLength(), columnType( NVARCHAR ) ) .withTypeCapacity( varcharDdlTypeCapacity, columnType( NVARCHAR ) )
.withTypeCapacity( maxLongVarcharLength, columnType( LONG32VARCHAR ) )
.build() .build()
); );
ddlTypeRegistry.addDescriptor( ddlTypeRegistry.addDescriptor(
CapacityDependentDdlType.builder( BINARY, columnType( BLOB ), columnType( VARBINARY ), this ) CapacityDependentDdlType.builder( BINARY, columnType( LONG32VARBINARY ), columnType( VARBINARY ), this )
.withTypeCapacity( 254, "char($l) for bit data" ) .withTypeCapacity( 254, "char($l) for bit data" )
.withTypeCapacity( getMaxVarbinaryLength(), columnType( VARBINARY ) ) .withTypeCapacity( varcharDdlTypeCapacity, columnType( VARBINARY ) )
.withTypeCapacity( maxLongVarcharLength, columnType( LONG32VARBINARY ) )
.build() .build()
); );
// This is the maximum size for the CHAR datatype on Derby // This is the maximum size for the CHAR datatype on Derby
ddlTypeRegistry.addDescriptor( ddlTypeRegistry.addDescriptor(
CapacityDependentDdlType.builder( CHAR, columnType( CLOB ), columnType( CHAR ), this ) CapacityDependentDdlType.builder( CHAR, columnType( LONG32VARCHAR ), columnType( CHAR ), this )
.withTypeCapacity( 254, columnType( CHAR ) ) .withTypeCapacity( 254, columnType( CHAR ) )
.withTypeCapacity( getMaxVarcharLength(), columnType( VARCHAR ) ) .withTypeCapacity( getMaxVarcharLength(), columnType( VARCHAR ) )
.withTypeCapacity( maxLongVarcharLength, columnType( LONG32VARCHAR ) )
.build() .build()
); );
ddlTypeRegistry.addDescriptor( ddlTypeRegistry.addDescriptor(
CapacityDependentDdlType.builder( NCHAR, columnType( CLOB ), columnType( NCHAR ), this ) CapacityDependentDdlType.builder( NCHAR, columnType( LONG32NVARCHAR ), columnType( NCHAR ), this )
.withTypeCapacity( 254, columnType( NCHAR ) ) .withTypeCapacity( 254, columnType( NCHAR ) )
.withTypeCapacity( getMaxVarcharLength(), columnType( NVARCHAR ) ) .withTypeCapacity( getMaxVarcharLength(), columnType( NVARCHAR ) )
.withTypeCapacity( maxLongVarcharLength, columnType( LONG32NVARCHAR ) )
.build() .build()
); );
} }
@ -228,6 +221,11 @@ public class DerbyLegacyDialect extends Dialect {
return 32_672; return 32_672;
} }
@Override
public int getMaxVarcharCapacity() {
return 32_700;
}
@Override @Override
public int getDefaultDecimalPrecision() { public int getDefaultDecimalPrecision() {
//this is the maximum allowed in Derby //this is the maximum allowed in Derby

View File

@ -11,7 +11,6 @@ import java.sql.DatabaseMetaData;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import java.util.Arrays;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.PessimisticLockException; import org.hibernate.PessimisticLockException;
@ -245,6 +244,12 @@ public class MySQLLegacyDialect extends Dialect {
} }
} }
@Override
public boolean useMaterializedLobWhenCapacityExceeded() {
// MySQL has no real concept of LOBs, so we can just use longtext/longblob with the materialized JDBC APIs
return false;
}
@Override @Override
protected String castType(int sqlTypeCode) { protected String castType(int sqlTypeCode) {
switch ( sqlTypeCode ) { switch ( sqlTypeCode ) {
@ -337,7 +342,7 @@ public class MySQLLegacyDialect extends Dialect {
) )
.withTypeCapacity( getMaxVarbinaryLength(), "varbinary($l)" ) .withTypeCapacity( getMaxVarbinaryLength(), "varbinary($l)" )
.withTypeCapacity( maxMediumLobLen, "mediumblob" ); .withTypeCapacity( maxMediumLobLen, "mediumblob" );
if ( getMaxVarcharLength() < maxLobLen ) { if ( getMaxVarbinaryLength() < maxLobLen ) {
varbinaryBuilder.withTypeCapacity( maxLobLen, "blob" ); varbinaryBuilder.withTypeCapacity( maxLobLen, "blob" );
} }
ddlTypeRegistry.addDescriptor( varbinaryBuilder.build() ); ddlTypeRegistry.addDescriptor( varbinaryBuilder.build() );

View File

@ -380,7 +380,7 @@ public class OracleLegacySqlAstTranslator<T extends JdbcOperation> extends Abstr
renderComparisonEmulateDecode( lhs, operator, rhs ); renderComparisonEmulateDecode( lhs, operator, rhs );
return; return;
} }
switch ( lhsExpressionType.getJdbcMappings().get( 0 ).getJdbcType().getJdbcTypeCode() ) { switch ( lhsExpressionType.getJdbcMappings().get( 0 ).getJdbcType().getDdlTypeCode() ) {
case SqlTypes.SQLXML: case SqlTypes.SQLXML:
// In Oracle, XMLTYPE is not "comparable", so we have to use the xmldiff function for this purpose // In Oracle, XMLTYPE is not "comparable", so we have to use the xmldiff function for this purpose
switch ( operator ) { switch ( operator ) {
@ -402,8 +402,11 @@ public class OracleLegacySqlAstTranslator<T extends JdbcOperation> extends Abstr
rhs.accept( this ); rhs.accept( this );
appendSql( "),'/*[local-name()=''xdiff'']/*')" ); appendSql( "),'/*[local-name()=''xdiff'']/*')" );
break; break;
case SqlTypes.CLOB:
case SqlTypes.NCLOB:
case SqlTypes.BLOB: case SqlTypes.BLOB:
// In Oracle, BLOB types are not "comparable", so we have to use the dbms_lob.compare function for this purpose // In Oracle, BLOB, CLOB and NCLOB types are not "comparable",
// so we have to use the dbms_lob.compare function for this purpose
switch ( operator ) { switch ( operator ) {
case EQUAL: case EQUAL:
appendSql( "0=" ); appendSql( "0=" );

View File

@ -278,6 +278,12 @@ public class PostgreSQLLegacyDialect extends Dialect {
return 10_485_760; return 10_485_760;
} }
@Override
public int getMaxVarcharCapacity() {
// 1GB according to PostgreSQL docs
return 1_073_741_824;
}
@Override @Override
public int getMaxVarbinaryLength() { public int getMaxVarbinaryLength() {
//postgres has no varbinary-like type //postgres has no varbinary-like type
@ -1018,6 +1024,13 @@ public class PostgreSQLLegacyDialect extends Dialect {
return false; return false;
} }
@Override
public boolean supportsMaterializedLobAccess() {
// Prefer using text and bytea over oid (LOB), because oid is very restricted.
// If someone really wants a type bigger than 1GB, they should ask for it by using @Lob explicitly
return false;
}
@Override @Override
public boolean supportsTemporalLiteralOffset() { public boolean supportsTemporalLiteralOffset() {
return true; return true;

View File

@ -8,6 +8,7 @@ package org.hibernate.community.dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.JdbcMappingContainer; import org.hibernate.metamodel.mapping.JdbcMappingContainer;
import org.hibernate.query.sqm.ComparisonOperator;
import org.hibernate.query.sqm.FetchClauseType; import org.hibernate.query.sqm.FetchClauseType;
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator; import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
import org.hibernate.sql.ast.tree.Statement; import org.hibernate.sql.ast.tree.Statement;
@ -25,6 +26,7 @@ import org.hibernate.sql.ast.tree.select.QueryPart;
import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.select.QuerySpec;
import org.hibernate.sql.exec.spi.JdbcOperation; import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.sql.model.internal.TableInsertStandard; import org.hibernate.sql.model.internal.TableInsertStandard;
import org.hibernate.type.SqlTypes;
/** /**
* A SQL AST translator for PostgreSQL. * A SQL AST translator for PostgreSQL.
@ -48,6 +50,33 @@ public class PostgreSQLLegacySqlAstTranslator<T extends JdbcOperation> extends A
expression.accept( this ); expression.accept( this );
} }
@Override
protected void renderComparison(Expression lhs, ComparisonOperator operator, Expression rhs) {
final JdbcMappingContainer lhsExpressionType = lhs.getExpressionType();
if ( lhsExpressionType != null
&& lhsExpressionType.getJdbcMappings().get( 0 ).getJdbcType().getDdlTypeCode() == SqlTypes.SQLXML ) {
// In PostgreSQL, XMLTYPE is not "comparable", so we have to cast the two parts to varchar for this purpose
switch ( operator ) {
case EQUAL:
case NOT_DISTINCT_FROM:
case NOT_EQUAL:
case DISTINCT_FROM:
appendSql( "cast(" );
lhs.accept( this );
appendSql( " as text)" );
appendSql( operator.sqlText() );
appendSql( "cast(" );
rhs.accept( this );
appendSql( " as text)" );
return;
default:
// Fall through
break;
}
}
renderComparisonStandard( lhs, operator, rhs );
}
@Override @Override
public void visitBooleanExpressionPredicate(BooleanExpressionPredicate booleanExpressionPredicate) { public void visitBooleanExpressionPredicate(BooleanExpressionPredicate booleanExpressionPredicate) {
final boolean isNegated = booleanExpressionPredicate.isNegated(); final boolean isNegated = booleanExpressionPredicate.isNegated();

View File

@ -11,6 +11,7 @@ import java.util.List;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.dialect.DatabaseVersion; import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.metamodel.mapping.JdbcMappingContainer;
import org.hibernate.query.sqm.FetchClauseType; import org.hibernate.query.sqm.FetchClauseType;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.query.sqm.ComparisonOperator; import org.hibernate.query.sqm.ComparisonOperator;
@ -37,6 +38,7 @@ import org.hibernate.sql.ast.tree.select.QuerySpec;
import org.hibernate.sql.ast.tree.select.SelectClause; import org.hibernate.sql.ast.tree.select.SelectClause;
import org.hibernate.sql.ast.tree.select.SortSpecification; import org.hibernate.sql.ast.tree.select.SortSpecification;
import org.hibernate.sql.exec.spi.JdbcOperation; import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.type.SqlTypes;
/** /**
* A SQL AST translator for SQL Server. * A SQL AST translator for SQL Server.
@ -394,6 +396,28 @@ public class SQLServerLegacySqlAstTranslator<T extends JdbcOperation> extends Ab
@Override @Override
protected void renderComparison(Expression lhs, ComparisonOperator operator, Expression rhs) { protected void renderComparison(Expression lhs, ComparisonOperator operator, Expression rhs) {
final JdbcMappingContainer lhsExpressionType = lhs.getExpressionType();
if ( lhsExpressionType != null
&& lhsExpressionType.getJdbcMappings().get( 0 ).getJdbcType().getDdlTypeCode() == SqlTypes.SQLXML ) {
// In SQL Server, XMLTYPE is not "comparable", so we have to cast the two parts to varchar for this purpose
switch ( operator ) {
case EQUAL:
case NOT_DISTINCT_FROM:
case NOT_EQUAL:
case DISTINCT_FROM:
appendSql( "cast(" );
lhs.accept( this );
appendSql( " as nvarchar(max))" );
appendSql( operator.sqlText() );
appendSql( "cast(" );
rhs.accept( this );
appendSql( " as nvarchar(max))" );
return;
default:
// Fall through
break;
}
}
renderComparisonEmulateIntersect( lhs, operator, rhs ); renderComparisonEmulateIntersect( lhs, operator, rhs );
} }

View File

@ -48,7 +48,7 @@ public @interface JdbcTypeRegistration {
* The type-code under which to register this descriptor. Can either add a new descriptor * The type-code under which to register this descriptor. Can either add a new descriptor
* or override an existing one. * or override an existing one.
* *
* By default we will use {@link JdbcType#getJdbcTypeCode} * By default we will use {@link JdbcType#getDefaultSqlTypeCode()}
*/ */
int registrationCode() default Integer.MIN_VALUE; int registrationCode() default Integer.MIN_VALUE;
} }

View File

@ -626,7 +626,7 @@ public final class AnnotationBinder {
final Class<? extends JdbcType> jdbcTypeClass = annotation.value(); final Class<? extends JdbcType> jdbcTypeClass = annotation.value();
final JdbcType jdbcType = managedBeanRegistry.getBean( jdbcTypeClass ).getBeanInstance(); final JdbcType jdbcType = managedBeanRegistry.getBean( jdbcTypeClass ).getBeanInstance();
final int typeCode = annotation.registrationCode() == Integer.MIN_VALUE final int typeCode = annotation.registrationCode() == Integer.MIN_VALUE
? jdbcType.getJdbcTypeCode() ? jdbcType.getDefaultSqlTypeCode()
: annotation.registrationCode(); : annotation.registrationCode();
context.getMetadataCollector().addJdbcTypeRegistration( typeCode, jdbcType ); context.getMetadataCollector().addJdbcTypeRegistration( typeCode, jdbcType );
} }

View File

@ -96,7 +96,7 @@ public class VersionResolution<E> implements BasicValue.Resolution<E> {
final BasicType<?> basicType = typeConfiguration.getBasicTypeRegistry().resolve( jtd, recommendedJdbcType ); final BasicType<?> basicType = typeConfiguration.getBasicTypeRegistry().resolve( jtd, recommendedJdbcType );
final BasicType legacyType = typeConfiguration.getBasicTypeRegistry().getRegisteredType( jtd.getJavaType() ); final BasicType legacyType = typeConfiguration.getBasicTypeRegistry().getRegisteredType( jtd.getJavaType() );
assert legacyType.getJdbcType().getJdbcTypeCode() == recommendedJdbcType.getJdbcTypeCode(); assert legacyType.getJdbcType().getDefaultSqlTypeCode() == recommendedJdbcType.getDefaultSqlTypeCode();
return new VersionResolution<>( jtd, recommendedJdbcType, basicType, legacyType ); return new VersionResolution<>( jtd, recommendedJdbcType, basicType, legacyType );
} }

View File

@ -1911,7 +1911,7 @@ public class ModelBinder {
.getBasicTypeRegistry() .getBasicTypeRegistry()
.getRegisteredType( value.getTypeName() ); .getRegisteredType( value.getTypeName() );
if ( basicType instanceof AbstractSingleColumnStandardBasicType ) { if ( basicType instanceof AbstractSingleColumnStandardBasicType ) {
if ( isLob( basicType.getJdbcType().getJdbcTypeCode(), null ) ) { if ( isLob( basicType.getJdbcType().getDdlTypeCode(), null ) ) {
value.makeLob(); value.makeLob();
} }
} }

View File

@ -11,6 +11,7 @@ import java.util.function.Consumer;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.JdbcMappingContainer;
import org.hibernate.query.sqm.ComparisonOperator; import org.hibernate.query.sqm.ComparisonOperator;
import org.hibernate.query.sqm.FetchClauseType; import org.hibernate.query.sqm.FetchClauseType;
import org.hibernate.sql.ast.SqlAstNodeRenderingMode; import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
@ -40,6 +41,7 @@ import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.sql.ast.tree.update.UpdateStatement; import org.hibernate.sql.ast.tree.update.UpdateStatement;
import org.hibernate.sql.exec.spi.JdbcOperation; import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.sql.model.internal.TableInsertStandard; import org.hibernate.sql.model.internal.TableInsertStandard;
import org.hibernate.type.SqlTypes;
import static org.hibernate.internal.util.collections.CollectionHelper.isEmpty; import static org.hibernate.internal.util.collections.CollectionHelper.isEmpty;
import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpty; import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpty;
@ -400,10 +402,79 @@ public class DB2SqlAstTranslator<T extends JdbcOperation> extends AbstractSqlAst
renderComparisonStandard( lhs, operator, rhs ); renderComparisonStandard( lhs, operator, rhs );
} }
else { else {
final JdbcMappingContainer lhsExpressionType = lhs.getExpressionType();
if ( lhsExpressionType != null
&& lhsExpressionType.getJdbcMappings().get( 0 ).getJdbcType().getDdlTypeCode() == SqlTypes.SQLXML ) {
// In SQL Server, XMLTYPE is not "comparable", so we have to cast the two parts to varchar for this purpose
switch ( operator ) {
case DISTINCT_FROM:
appendSql( "decode(" );
appendSql( "xmlserialize(" );
lhs.accept( this );
appendSql( " as varchar(32672))" );
appendSql( ',' );
appendSql( "xmlserialize(" );
rhs.accept( this );
appendSql( " as varchar(32672))" );
appendSql( ",0,1)=1" );
return;
case NOT_DISTINCT_FROM:
appendSql( "decode(" );
appendSql( "xmlserialize(" );
lhs.accept( this );
appendSql( " as varchar(32672))" );
appendSql( ',' );
appendSql( "xmlserialize(" );
rhs.accept( this );
appendSql( " as varchar(32672))" );
appendSql( ",0,1)=0" );
return;
case EQUAL:
case NOT_EQUAL:
appendSql( "xmlserialize(" );
lhs.accept( this );
appendSql( " as varchar(32672))" );
appendSql( operator.sqlText() );
appendSql( "xmlserialize(" );
rhs.accept( this );
appendSql( " as varchar(32672))" );
return;
default:
// Fall through
break;
}
}
renderComparisonEmulateDecode( lhs, operator, rhs ); renderComparisonEmulateDecode( lhs, operator, rhs );
} }
} }
@Override
protected void renderComparisonStandard(Expression lhs, ComparisonOperator operator, Expression rhs) {
final JdbcMappingContainer lhsExpressionType = lhs.getExpressionType();
if ( lhsExpressionType != null
&& lhsExpressionType.getJdbcMappings().get( 0 ).getJdbcType().getDdlTypeCode() == SqlTypes.SQLXML ) {
// In SQL Server, XMLTYPE is not "comparable", so we have to cast the two parts to varchar for this purpose
switch ( operator ) {
case EQUAL:
case NOT_DISTINCT_FROM:
case NOT_EQUAL:
case DISTINCT_FROM:
appendSql( "xmlserialize(" );
lhs.accept( this );
appendSql( " as varchar(32672))" );
appendSql( operator.sqlText() );
appendSql( "xmlserialize(" );
rhs.accept( this );
appendSql( " as varchar(32672))" );
return;
default:
// Fall through
break;
}
}
super.renderComparisonStandard( lhs, operator, rhs );
}
@Override @Override
protected void renderSelectExpression(Expression expression) { protected void renderSelectExpression(Expression expression) {
renderSelectExpressionWithCastedOrInlinedPlainParameters( expression ); renderSelectExpressionWithCastedOrInlinedPlainParameters( expression );

View File

@ -4279,13 +4279,13 @@ public abstract class Dialect implements ConversionContext {
Integer scale, Integer scale,
Long length) { Long length) {
final Size size = new Size(); final Size size = new Size();
int jdbcTypeCode = jdbcType.getDefaultSqlTypeCode(); final int ddlTypeCode = jdbcType.getDdlTypeCode();
// Set the explicit length to null if we encounter the JPA default 255 // Set the explicit length to null if we encounter the JPA default 255
if ( length != null && length == Size.DEFAULT_LENGTH ) { if ( length != null && length == Size.DEFAULT_LENGTH ) {
length = null; length = null;
} }
switch ( jdbcTypeCode ) { switch ( ddlTypeCode ) {
case SqlTypes.BIT: case SqlTypes.BIT:
case SqlTypes.CHAR: case SqlTypes.CHAR:
case SqlTypes.NCHAR: case SqlTypes.NCHAR:

View File

@ -123,7 +123,7 @@ public class MySQLDialect extends Dialect {
Integer precision, Integer precision,
Integer scale, Integer scale,
Long length) { Long length) {
switch ( jdbcType.getDefaultSqlTypeCode() ) { switch ( jdbcType.getDdlTypeCode() ) {
case Types.BIT: case Types.BIT:
// MySQL allows BIT with a length up to 64 (less the default length 255) // MySQL allows BIT with a length up to 64 (less the default length 255)
if ( length != null ) { if ( length != null ) {
@ -310,9 +310,9 @@ public class MySQLDialect extends Dialect {
"char", "char",
this this
) )
.withTypeCapacity( getVarcharDdlTypeCapacity(), "varchar($l)" ) .withTypeCapacity( getMaxVarcharLength(), "varchar($l)" )
.withTypeCapacity( maxMediumLobLen, "mediumtext" ); .withTypeCapacity( maxMediumLobLen, "mediumtext" );
if ( getVarcharDdlTypeCapacity() < maxLobLen ) { if ( getMaxVarcharLength() < maxLobLen ) {
varcharBuilder.withTypeCapacity( maxLobLen, "text" ); varcharBuilder.withTypeCapacity( maxLobLen, "text" );
} }
ddlTypeRegistry.addDescriptor( varcharBuilder.build() ); ddlTypeRegistry.addDescriptor( varcharBuilder.build() );
@ -323,9 +323,9 @@ public class MySQLDialect extends Dialect {
"char", "char",
this this
) )
.withTypeCapacity( getVarcharDdlTypeCapacity(), "varchar($l)" ) .withTypeCapacity( getMaxVarcharLength(), "varchar($l)" )
.withTypeCapacity( maxMediumLobLen, "mediumtext" ); .withTypeCapacity( maxMediumLobLen, "mediumtext" );
if ( getVarcharDdlTypeCapacity() < maxLobLen ) { if ( getMaxVarcharLength() < maxLobLen ) {
nvarcharBuilder.withTypeCapacity( maxLobLen, "text" ); nvarcharBuilder.withTypeCapacity( maxLobLen, "text" );
} }
ddlTypeRegistry.addDescriptor( nvarcharBuilder.build() ); ddlTypeRegistry.addDescriptor( nvarcharBuilder.build() );
@ -336,9 +336,9 @@ public class MySQLDialect extends Dialect {
"binary", "binary",
this this
) )
.withTypeCapacity( getVarbinaryDdlTypeCapacity(), "varbinary($l)" ) .withTypeCapacity( getMaxVarbinaryLength(), "varbinary($l)" )
.withTypeCapacity( maxMediumLobLen, "mediumblob" ); .withTypeCapacity( maxMediumLobLen, "mediumblob" );
if ( getVarbinaryDdlTypeCapacity() < maxLobLen ) { if ( getMaxVarbinaryLength() < maxLobLen ) {
varbinaryBuilder.withTypeCapacity( maxLobLen, "blob" ); varbinaryBuilder.withTypeCapacity( maxLobLen, "blob" );
} }
ddlTypeRegistry.addDescriptor( varbinaryBuilder.build() ); ddlTypeRegistry.addDescriptor( varbinaryBuilder.build() );
@ -431,11 +431,13 @@ public class MySQLDialect extends Dialect {
} }
} }
public int getVarcharDdlTypeCapacity() { @Override
public int getMaxVarcharLength() {
return maxVarcharLength; return maxVarcharLength;
} }
public int getVarbinaryDdlTypeCapacity() { @Override
public int getMaxVarbinaryLength() {
return maxVarbinaryLength; return maxVarbinaryLength;
} }

View File

@ -96,7 +96,7 @@ public class OracleArrayJdbcType extends ArrayJdbcType {
if ( typeName == null || typeName.isBlank() ) { if ( typeName == null || typeName.isBlank() ) {
typeName = dialect.getArrayTypeName( typeName = dialect.getArrayTypeName(
typeConfiguration.getDdlTypeRegistry().getTypeName( typeConfiguration.getDdlTypeRegistry().getTypeName(
elementType.getDefaultSqlTypeCode(), elementType.getDdlTypeCode(),
dialect dialect
) )
); );

View File

@ -379,7 +379,7 @@ public class OracleSqlAstTranslator<T extends JdbcOperation> extends AbstractSql
renderComparisonEmulateDecode( lhs, operator, rhs ); renderComparisonEmulateDecode( lhs, operator, rhs );
return; return;
} }
switch ( lhsExpressionType.getJdbcMappings().get( 0 ).getJdbcType().getJdbcTypeCode() ) { switch ( lhsExpressionType.getJdbcMappings().get( 0 ).getJdbcType().getDdlTypeCode() ) {
case SqlTypes.SQLXML: case SqlTypes.SQLXML:
// In Oracle, XMLTYPE is not "comparable", so we have to use the xmldiff function for this purpose // In Oracle, XMLTYPE is not "comparable", so we have to use the xmldiff function for this purpose
switch ( operator ) { switch ( operator ) {
@ -401,8 +401,11 @@ public class OracleSqlAstTranslator<T extends JdbcOperation> extends AbstractSql
rhs.accept( this ); rhs.accept( this );
appendSql( "),'/*[local-name()=''xdiff'']/*')" ); appendSql( "),'/*[local-name()=''xdiff'']/*')" );
break; break;
case SqlTypes.CLOB:
case SqlTypes.NCLOB:
case SqlTypes.BLOB: case SqlTypes.BLOB:
// In Oracle, BLOB types are not "comparable", so we have to use the dbms_lob.compare function for this purpose // In Oracle, BLOB, CLOB and NCLOB types are not "comparable",
// so we have to use the dbms_lob.compare function for this purpose
switch ( operator ) { switch ( operator ) {
case EQUAL: case EQUAL:
appendSql( "0=" ); appendSql( "0=" );

View File

@ -7,9 +7,9 @@
package org.hibernate.dialect; package org.hibernate.dialect;
import org.hibernate.metamodel.mapping.JdbcMappingContainer; import org.hibernate.metamodel.mapping.JdbcMappingContainer;
import org.hibernate.query.sqm.ComparisonOperator;
import org.hibernate.query.sqm.FetchClauseType; import org.hibernate.query.sqm.FetchClauseType;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.query.sqm.FetchClauseType;
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator; import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
import org.hibernate.sql.ast.tree.Statement; import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.cte.CteMaterialization; import org.hibernate.sql.ast.tree.cte.CteMaterialization;
@ -26,6 +26,7 @@ import org.hibernate.sql.ast.tree.select.QueryPart;
import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.select.QuerySpec;
import org.hibernate.sql.exec.spi.JdbcOperation; import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.sql.model.internal.TableInsertStandard; import org.hibernate.sql.model.internal.TableInsertStandard;
import org.hibernate.type.SqlTypes;
/** /**
* A SQL AST translator for PostgreSQL. * A SQL AST translator for PostgreSQL.
@ -50,6 +51,33 @@ public class PostgreSQLSqlAstTranslator<T extends JdbcOperation> extends Abstrac
expression.accept( this ); expression.accept( this );
} }
@Override
protected void renderComparison(Expression lhs, ComparisonOperator operator, Expression rhs) {
final JdbcMappingContainer lhsExpressionType = lhs.getExpressionType();
if ( lhsExpressionType != null
&& lhsExpressionType.getJdbcMappings().get( 0 ).getJdbcType().getDdlTypeCode() == SqlTypes.SQLXML ) {
// In PostgreSQL, XMLTYPE is not "comparable", so we have to cast the two parts to varchar for this purpose
switch ( operator ) {
case EQUAL:
case NOT_DISTINCT_FROM:
case NOT_EQUAL:
case DISTINCT_FROM:
appendSql( "cast(" );
lhs.accept( this );
appendSql( " as text)" );
appendSql( operator.sqlText() );
appendSql( "cast(" );
rhs.accept( this );
appendSql( " as text)" );
return;
default:
// Fall through
break;
}
}
renderComparisonStandard( lhs, operator, rhs );
}
@Override @Override
public void visitBooleanExpressionPredicate(BooleanExpressionPredicate booleanExpressionPredicate) { public void visitBooleanExpressionPredicate(BooleanExpressionPredicate booleanExpressionPredicate) {
final boolean isNegated = booleanExpressionPredicate.isNegated(); final boolean isNegated = booleanExpressionPredicate.isNegated();

View File

@ -11,6 +11,7 @@ import java.util.List;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.JdbcMappingContainer;
import org.hibernate.query.sqm.ComparisonOperator; import org.hibernate.query.sqm.ComparisonOperator;
import org.hibernate.query.sqm.FetchClauseType; import org.hibernate.query.sqm.FetchClauseType;
import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.Clause;
@ -35,6 +36,7 @@ import org.hibernate.sql.ast.tree.select.QuerySpec;
import org.hibernate.sql.ast.tree.select.SelectClause; import org.hibernate.sql.ast.tree.select.SelectClause;
import org.hibernate.sql.ast.tree.select.SortSpecification; import org.hibernate.sql.ast.tree.select.SortSpecification;
import org.hibernate.sql.exec.spi.JdbcOperation; import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.type.SqlTypes;
/** /**
* A SQL AST translator for SQL Server. * A SQL AST translator for SQL Server.
@ -369,6 +371,28 @@ public class SQLServerSqlAstTranslator<T extends JdbcOperation> extends Abstract
@Override @Override
protected void renderComparison(Expression lhs, ComparisonOperator operator, Expression rhs) { protected void renderComparison(Expression lhs, ComparisonOperator operator, Expression rhs) {
final JdbcMappingContainer lhsExpressionType = lhs.getExpressionType();
if ( lhsExpressionType != null
&& lhsExpressionType.getJdbcMappings().get( 0 ).getJdbcType().getDdlTypeCode() == SqlTypes.SQLXML ) {
// In SQL Server, XMLTYPE is not "comparable", so we have to cast the two parts to varchar for this purpose
switch ( operator ) {
case EQUAL:
case NOT_DISTINCT_FROM:
case NOT_EQUAL:
case DISTINCT_FROM:
appendSql( "cast(" );
lhs.accept( this );
appendSql( " as nvarchar(max))" );
appendSql( operator.sqlText() );
appendSql( "cast(" );
rhs.accept( this );
appendSql( " as nvarchar(max))" );
return;
default:
// Fall through
break;
}
}
renderComparisonEmulateIntersect( lhs, operator, rhs ); renderComparisonEmulateIntersect( lhs, operator, rhs );
} }

View File

@ -66,7 +66,7 @@ public class SybaseASEDialect extends SybaseDialect {
Integer precision, Integer precision,
Integer scale, Integer scale,
Long length) { Long length) {
switch ( jdbcType.getDefaultSqlTypeCode() ) { switch ( jdbcType.getDdlTypeCode() ) {
case Types.FLOAT: case Types.FLOAT:
// Sybase ASE allows FLOAT with a precision up to 48 // Sybase ASE allows FLOAT with a precision up to 48
if ( precision != null ) { if ( precision != null ) {

View File

@ -54,7 +54,7 @@ public class ConcatPipeFunction extends AbstractSqmSelfRenderingFunctionDescript
final Expression expression = (Expression) sqlAstArguments.get( i ); final Expression expression = (Expression) sqlAstArguments.get( i );
final JdbcType jdbcType = expression.getExpressionType().getJdbcMappings().get( 0 ).getJdbcType(); final JdbcType jdbcType = expression.getExpressionType().getJdbcMappings().get( 0 ).getJdbcType();
sqlAppender.appendSql( separator ); sqlAppender.appendSql( separator );
switch ( jdbcType.getJdbcTypeCode() ) { switch ( jdbcType.getDdlTypeCode() ) {
case SqlTypes.CLOB: case SqlTypes.CLOB:
case SqlTypes.NCLOB: case SqlTypes.NCLOB:
clobPatternRenderer.render( sqlAppender, Collections.singletonList( expression ), walker ); clobPatternRenderer.render( sqlAppender, Collections.singletonList( expression ), walker );

View File

@ -57,7 +57,7 @@ public class LengthFunction extends AbstractSqmSelfRenderingFunctionDescriptor {
SqlAstTranslator<?> walker) { SqlAstTranslator<?> walker) {
final Expression expression = (Expression) sqlAstArguments.get( 0 ); final Expression expression = (Expression) sqlAstArguments.get( 0 );
final JdbcType jdbcType = expression.getExpressionType().getJdbcMappings().get( 0 ).getJdbcType(); final JdbcType jdbcType = expression.getExpressionType().getJdbcMappings().get( 0 ).getJdbcType();
switch ( jdbcType.getJdbcTypeCode() ) { switch ( jdbcType.getDdlTypeCode() ) {
case SqlTypes.CLOB: case SqlTypes.CLOB:
case SqlTypes.NCLOB: case SqlTypes.NCLOB:
clobPatternRenderer.render( sqlAppender, sqlAstArguments, walker ); clobPatternRenderer.render( sqlAppender, sqlAstArguments, walker );

View File

@ -73,7 +73,7 @@ class SumReturnTypeResolver implements FunctionReturnTypeResolver {
return impliedType; return impliedType;
} }
} }
switch ( basicType.getJdbcType().getJdbcTypeCode() ) { switch ( basicType.getJdbcType().getDefaultSqlTypeCode() ) {
case Types.SMALLINT: case Types.SMALLINT:
case Types.TINYINT: case Types.TINYINT:
case Types.INTEGER: case Types.INTEGER:
@ -102,7 +102,7 @@ class SumReturnTypeResolver implements FunctionReturnTypeResolver {
} }
// Resolve according to JPA spec 4.8.5 // Resolve according to JPA spec 4.8.5
final BasicValuedMapping specifiedArgType = extractArgumentValuedMapping( arguments, 1 ); final BasicValuedMapping specifiedArgType = extractArgumentValuedMapping( arguments, 1 );
switch ( specifiedArgType.getJdbcMapping().getJdbcType().getJdbcTypeCode() ) { switch ( specifiedArgType.getJdbcMapping().getJdbcType().getDefaultSqlTypeCode() ) {
case Types.SMALLINT: case Types.SMALLINT:
case Types.TINYINT: case Types.TINYINT:
case Types.INTEGER: case Types.INTEGER:

View File

@ -45,7 +45,7 @@ public class StandardTemporaryTableExporter implements TemporaryTableExporter {
for ( TemporaryTableColumn column : temporaryTable.getColumnsForExport() ) { for ( TemporaryTableColumn column : temporaryTable.getColumnsForExport() ) {
buffer.append( column.getColumnName() ).append( ' ' ); buffer.append( column.getColumnName() ).append( ' ' );
final int sqlTypeCode = column.getJdbcMapping().getJdbcType().getDefaultSqlTypeCode(); final int sqlTypeCode = column.getJdbcMapping().getJdbcType().getDdlTypeCode();
final String databaseTypeName = column.getSqlTypeDefinition(); final String databaseTypeName = column.getSqlTypeDefinition();
buffer.append( databaseTypeName ); buffer.append( databaseTypeName );

View File

@ -135,7 +135,7 @@ public class TemporaryTable implements Exportable, Contributable {
this, this,
uuidType, uuidType,
typeConfiguration.getDdlTypeRegistry().getTypeName( typeConfiguration.getDdlTypeRegistry().getTypeName(
uuidType.getJdbcType().getDefaultSqlTypeCode(), uuidType.getJdbcType().getDdlTypeCode(),
size size
), ),
size size
@ -406,7 +406,7 @@ public class TemporaryTable implements Exportable, Contributable {
final String rowNumberType; final String rowNumberType;
if ( dialect.supportsWindowFunctions() ) { if ( dialect.supportsWindowFunctions() ) {
rowNumberType = typeConfiguration.getDdlTypeRegistry().getTypeName( rowNumberType = typeConfiguration.getDdlTypeRegistry().getTypeName(
integerBasicType.getJdbcType().getJdbcTypeCode(), integerBasicType.getJdbcType().getDdlTypeCode(),
dialect.getSizeStrategy().resolveSize( dialect.getSizeStrategy().resolveSize(
integerBasicType.getJdbcType(), integerBasicType.getJdbcType(),
integerBasicType.getJavaTypeDescriptor(), integerBasicType.getJavaTypeDescriptor(),
@ -418,7 +418,7 @@ public class TemporaryTable implements Exportable, Contributable {
} }
else if ( dialect.getIdentityColumnSupport().supportsIdentityColumns() ) { else if ( dialect.getIdentityColumnSupport().supportsIdentityColumns() ) {
rowNumberType = typeConfiguration.getDdlTypeRegistry().getTypeName( rowNumberType = typeConfiguration.getDdlTypeRegistry().getTypeName(
integerBasicType.getJdbcType().getJdbcTypeCode(), integerBasicType.getJdbcType().getDdlTypeCode(),
dialect.getSizeStrategy().resolveSize( dialect.getSizeStrategy().resolveSize(
integerBasicType.getJdbcType(), integerBasicType.getJdbcType(),
integerBasicType.getJavaTypeDescriptor(), integerBasicType.getJavaTypeDescriptor(),
@ -426,13 +426,13 @@ public class TemporaryTable implements Exportable, Contributable {
null, null,
null null
) )
) + " " + ) + " " + dialect.getIdentityColumnSupport()
dialect.getIdentityColumnSupport().getIdentityColumnString( integerBasicType.getJdbcType().getJdbcTypeCode() ); .getIdentityColumnString( integerBasicType.getJdbcType().getDdlTypeCode() );
} }
else { else {
LOG.multiTableInsertNotAvailable( entityBinding.getEntityName() ); LOG.multiTableInsertNotAvailable( entityBinding.getEntityName() );
rowNumberType = typeConfiguration.getDdlTypeRegistry().getTypeName( rowNumberType = typeConfiguration.getDdlTypeRegistry().getTypeName(
integerBasicType.getJdbcType().getJdbcTypeCode(), integerBasicType.getJdbcType().getDdlTypeCode(),
dialect.getSizeStrategy().resolveSize( dialect.getSizeStrategy().resolveSize(
integerBasicType.getJdbcType(), integerBasicType.getJdbcType(),
integerBasicType.getJavaTypeDescriptor(), integerBasicType.getJavaTypeDescriptor(),

View File

@ -13,6 +13,7 @@ import java.util.NoSuchElementException;
import org.hibernate.FetchMode; import org.hibernate.FetchMode;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.boot.model.relational.Database; import org.hibernate.boot.model.relational.Database;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.engine.spi.Mapping; import org.hibernate.engine.spi.Mapping;
import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
@ -37,7 +38,7 @@ public class ExportableColumn extends Column {
type, type,
database.getTypeConfiguration() database.getTypeConfiguration()
.getDdlTypeRegistry() .getDdlTypeRegistry()
.getTypeName( type.getJdbcType().getDefaultSqlTypeCode(), database.getDialect() ) .getTypeName( type.getJdbcType().getDdlTypeCode(), database.getDialect() )
); );
} }

View File

@ -330,7 +330,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
private void resolveColumn(Column column, Dialect dialect) { private void resolveColumn(Column column, Dialect dialect) {
if ( column.getSqlTypeCode() == null ) { if ( column.getSqlTypeCode() == null ) {
column.setSqlTypeCode( resolution.getJdbcType().getDefaultSqlTypeCode() ); column.setSqlTypeCode( resolution.getJdbcType().getDdlTypeCode() );
} }
if ( resolution.getValueConverter() != null ) { if ( resolution.getValueConverter() != null ) {

View File

@ -241,7 +241,7 @@ public class Column implements Selectable, Serializable, Cloneable, ColumnTypeIn
final BasicType<?> elementType = containerType.getElementType(); final BasicType<?> elementType = containerType.getElementType();
final int sqlTypeCode; final int sqlTypeCode;
try { try {
sqlTypeCode = elementType.getJdbcType().getDefaultSqlTypeCode(); sqlTypeCode = elementType.getJdbcType().getDdlTypeCode();
} }
catch (Exception e) { catch (Exception e) {
throw new MappingException( throw new MappingException(

View File

@ -724,7 +724,7 @@ public abstract class SimpleValue implements KeyValue {
} }
} }
); );
int jdbcTypeCode = recommendedJdbcType.getDefaultSqlTypeCode(); int jdbcTypeCode = recommendedJdbcType.getDdlTypeCode();
if ( isLob() ) { if ( isLob() ) {
if ( LobTypeMappings.isMappedToKnownLobCode( jdbcTypeCode ) ) { if ( LobTypeMappings.isMappedToKnownLobCode( jdbcTypeCode ) ) {
jdbcTypeCode = LobTypeMappings.getLobCodeTypeMapping( jdbcTypeCode ); jdbcTypeCode = LobTypeMappings.getLobCodeTypeMapping( jdbcTypeCode );

View File

@ -60,10 +60,6 @@ public class NamedEnumValueConverter<E extends Enum<E>> implements EnumValueConv
@Override @Override
public int getJdbcTypeCode() { public int getJdbcTypeCode() {
return jdbcType.getJdbcTypeCode();
}
public int getDefaultSqlTypeCode() {
return jdbcType.getDefaultSqlTypeCode(); return jdbcType.getDefaultSqlTypeCode();
} }

View File

@ -50,7 +50,7 @@ public class OrdinalEnumValueConverter<E extends Enum<E>, N extends Number> impl
@Override @Override
public int getJdbcTypeCode() { public int getJdbcTypeCode() {
return jdbcType.getJdbcTypeCode(); return jdbcType.getDefaultSqlTypeCode();
} }
@Override @Override

View File

@ -2742,7 +2742,7 @@ public abstract class AbstractEntityPersister
.getIdentitySelectString( .getIdentitySelectString(
getTableName( 0 ), getTableName( 0 ),
getKeyColumns( 0 )[0], getKeyColumns( 0 )[0],
( (BasicType<?>) getIdentifierType() ).getJdbcType().getDefaultSqlTypeCode() ( (BasicType<?>) getIdentifierType() ).getJdbcType().getDdlTypeCode()
); );
} }

View File

@ -591,7 +591,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
// If there is no selectable mapping for a table name, we render a null expression // If there is no selectable mapping for a table name, we render a null expression
selectableMapping = selectableMappings.values().iterator().next(); selectableMapping = selectableMappings.values().iterator().next();
final int sqlType = selectableMapping.getJdbcMapping().getJdbcType() final int sqlType = selectableMapping.getJdbcMapping().getJdbcType()
.getDefaultSqlTypeCode(); .getDdlTypeCode();
buf.append( dialect.getSelectClauseNullString( sqlType, getFactory().getTypeConfiguration() ) ) buf.append( dialect.getSelectClauseNullString( sqlType, getFactory().getTypeConfiguration() ) )
.append( " as " ); .append( " as " );
} }

View File

@ -33,18 +33,18 @@ import jakarta.persistence.ParameterMode;
*/ */
public class FunctionReturnImpl<T> implements FunctionReturnImplementor<T> { public class FunctionReturnImpl<T> implements FunctionReturnImplementor<T> {
private final ProcedureCallImplementor<T> procedureCall; private final ProcedureCallImplementor<T> procedureCall;
private final int jdbcTypeCode; private final int sqlTypeCode;
private OutputableType<T> ormType; private OutputableType<T> ormType;
public FunctionReturnImpl(ProcedureCallImplementor<T> procedureCall, int jdbcTypeCode) { public FunctionReturnImpl(ProcedureCallImplementor<T> procedureCall, int sqlTypeCode) {
this.procedureCall = procedureCall; this.procedureCall = procedureCall;
this.jdbcTypeCode = jdbcTypeCode; this.sqlTypeCode = sqlTypeCode;
} }
public FunctionReturnImpl(ProcedureCallImplementor<T> procedureCall, OutputableType<T> ormType) { public FunctionReturnImpl(ProcedureCallImplementor<T> procedureCall, OutputableType<T> ormType) {
this.procedureCall = procedureCall; this.procedureCall = procedureCall;
this.jdbcTypeCode = ormType.getJdbcType().getJdbcTypeCode(); this.sqlTypeCode = ormType.getJdbcType().getDefaultSqlTypeCode();
this.ormType = ormType; this.ormType = ormType;
} }
@ -85,7 +85,7 @@ public class FunctionReturnImpl<T> implements FunctionReturnImplementor<T> {
@Override @Override
public int getJdbcTypeCode() { public int getJdbcTypeCode() {
return jdbcTypeCode; return sqlTypeCode;
} }
@Override @Override
@ -137,7 +137,7 @@ public class FunctionReturnImpl<T> implements FunctionReturnImplementor<T> {
return new FunctionReturnImpl<>( procedureCall, ormType ); return new FunctionReturnImpl<>( procedureCall, ormType );
} }
else { else {
return new FunctionReturnImpl<>( procedureCall, jdbcTypeCode ); return new FunctionReturnImpl<>( procedureCall, sqlTypeCode );
} }
}; };
} }

View File

@ -320,7 +320,7 @@ public abstract class AbstractSelectionQuery<R>
} }
} }
if ( jdbcType != null ) { if ( jdbcType != null ) {
switch ( jdbcType.getJdbcTypeCode() ) { switch ( jdbcType.getDefaultSqlTypeCode() ) {
case Types.DATE: case Types.DATE:
if ( resultClass.isAssignableFrom( java.sql.Date.class ) ) { if ( resultClass.isAssignableFrom( java.sql.Date.class ) ) {
return; return;

View File

@ -140,8 +140,8 @@ public class StandardFunctionReturnTypeResolvers {
//that is determined by how the function is used in the HQL query. In essence //that is determined by how the function is used in the HQL query. In essence
//the types are compatible if the map to the same JDBC type, of if they are //the types are compatible if the map to the same JDBC type, of if they are
//both numeric types. //both numeric types.
int impliedTypeCode = ((BasicType<?>) implied).getJdbcMapping().getJdbcType().getJdbcTypeCode(); int impliedTypeCode = ((BasicType<?>) implied).getJdbcMapping().getJdbcType().getDefaultSqlTypeCode();
int definedTypeCode = ((BasicType<?>) defined).getJdbcMapping().getJdbcType().getJdbcTypeCode(); int definedTypeCode = ((BasicType<?>) defined).getJdbcMapping().getJdbcType().getDefaultSqlTypeCode();
return impliedTypeCode == definedTypeCode return impliedTypeCode == definedTypeCode
|| isNumeric( impliedTypeCode ) && isNumeric( definedTypeCode ); || isNumeric( impliedTypeCode ) && isNumeric( definedTypeCode );
} }
@ -181,8 +181,8 @@ public class StandardFunctionReturnTypeResolvers {
//that is determined by how the function is used in the HQL query. In essence //that is determined by how the function is used in the HQL query. In essence
//the types are compatible if the map to the same JDBC type, of if they are //the types are compatible if the map to the same JDBC type, of if they are
//both numeric types. //both numeric types.
int impliedTypeCode = implied.getJdbcMapping().getJdbcType().getJdbcTypeCode(); int impliedTypeCode = implied.getJdbcMapping().getJdbcType().getDefaultSqlTypeCode();
int definedTypeCode = defined.getJdbcMapping().getJdbcType().getJdbcTypeCode(); int definedTypeCode = defined.getJdbcMapping().getJdbcType().getDefaultSqlTypeCode();
return impliedTypeCode == definedTypeCode return impliedTypeCode == definedTypeCode
|| isNumeric( impliedTypeCode ) && isNumeric( definedTypeCode ); || isNumeric( impliedTypeCode ) && isNumeric( definedTypeCode );

View File

@ -5525,7 +5525,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
else { else {
SqlTypedMapping sqlTypedMapping = null; SqlTypedMapping sqlTypedMapping = null;
if ( bindable instanceof BasicType<?> ) { if ( bindable instanceof BasicType<?> ) {
final int sqlTypeCode = ( (BasicType<?>) bindable ).getJdbcType().getDefaultSqlTypeCode(); final int sqlTypeCode = ( (BasicType<?>) bindable ).getJdbcType().getDdlTypeCode();
if ( sqlTypeCode == SqlTypes.NUMERIC || sqlTypeCode == SqlTypes.DECIMAL ) { if ( sqlTypeCode == SqlTypes.NUMERIC || sqlTypeCode == SqlTypes.DECIMAL ) {
// For numeric and decimal parameter types we must determine the precision/scale of the value. // For numeric and decimal parameter types we must determine the precision/scale of the value.
// When we need to cast the parameter later, it is necessary to know the size to avoid truncation. // When we need to cast the parameter later, it is necessary to know the size to avoid truncation.

View File

@ -6120,7 +6120,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
final BasicPluralType<?, ?> containerType = (BasicPluralType<?, ?>) expressionType; final BasicPluralType<?, ?> containerType = (BasicPluralType<?, ?>) expressionType;
final BasicType<?> elementType = containerType.getElementType(); final BasicType<?> elementType = containerType.getElementType();
final String elementTypeName = sessionFactory.getTypeConfiguration().getDdlTypeRegistry() final String elementTypeName = sessionFactory.getTypeConfiguration().getDdlTypeRegistry()
.getDescriptor( elementType.getJdbcType().getDefaultSqlTypeCode() ) .getDescriptor( elementType.getJdbcType().getDdlTypeCode() )
.getCastTypeName( .getCastTypeName(
elementType, elementType,
castTarget.getLength(), castTarget.getLength(),
@ -6135,7 +6135,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
} }
final DdlTypeRegistry ddlTypeRegistry = getSessionFactory().getTypeConfiguration().getDdlTypeRegistry(); final DdlTypeRegistry ddlTypeRegistry = getSessionFactory().getTypeConfiguration().getDdlTypeRegistry();
DdlType ddlType = ddlTypeRegistry DdlType ddlType = ddlTypeRegistry
.getDescriptor( expressionType.getJdbcMapping().getJdbcType().getDefaultSqlTypeCode() ); .getDescriptor( expressionType.getJdbcMapping().getJdbcType().getDdlTypeCode() );
if ( ddlType == null ) { if ( ddlType == null ) {
// this may happen when selecting a null value like `SELECT null from ...` // this may happen when selecting a null value like `SELECT null from ...`
// some dbs need the value to be cast so not knowing the real type we fall back to INTEGER // some dbs need the value to be cast so not knowing the real type we fall back to INTEGER

View File

@ -50,7 +50,7 @@ public abstract class AbstractStandardBasicType<T>
public AbstractStandardBasicType(JdbcType jdbcType, JavaType<T> javaType) { public AbstractStandardBasicType(JdbcType jdbcType, JavaType<T> javaType) {
this.jdbcType = jdbcType; this.jdbcType = jdbcType;
this.sqlTypes = new int[] { jdbcType.getDefaultSqlTypeCode() }; this.sqlTypes = new int[] { jdbcType.getDdlTypeCode() };
this.javaType = javaType; this.javaType = javaType;
this.jdbcValueBinder = jdbcType.getBinder( javaType ); this.jdbcValueBinder = jdbcType.getBinder( javaType );
@ -347,7 +347,7 @@ public abstract class AbstractStandardBasicType<T>
// and the cast type determination here. Note that we interpret the converter in ConvertedBasicTypeImpl // and the cast type determination here. Note that we interpret the converter in ConvertedBasicTypeImpl
// to properly determine the correct cast type // to properly determine the correct cast type
final JdbcType jdbcType = getJdbcType(); final JdbcType jdbcType = getJdbcType();
final int jdbcTypeCode = jdbcType.getJdbcTypeCode(); final int jdbcTypeCode = jdbcType.getDdlTypeCode();
switch ( jdbcTypeCode ) { switch ( jdbcTypeCode ) {
case Types.BIT: case Types.BIT:
case Types.SMALLINT: case Types.SMALLINT:

View File

@ -140,7 +140,7 @@ public class CustomType<J>
@Override @Override
public int[] getSqlTypeCodes(Mapping pi) { public int[] getSqlTypeCodes(Mapping pi) {
return new int[] { jdbcType.getDefaultSqlTypeCode() }; return new int[] { jdbcType.getDdlTypeCode() };
} }
@Override @Override

View File

@ -60,7 +60,7 @@ public class SerializableToBlobType<T extends Serializable> implements BasicType
public SerializableToBlobType() { public SerializableToBlobType() {
this.jdbcType = BlobJdbcType.DEFAULT; this.jdbcType = BlobJdbcType.DEFAULT;
this.sqlTypes = new int[] { jdbcType.getDefaultSqlTypeCode() }; this.sqlTypes = new int[] { jdbcType.getDdlTypeCode() };
this.javaType = new SerializableJavaType( Serializable.class ); this.javaType = new SerializableJavaType( Serializable.class );
this.jdbcValueBinder = jdbcType.getBinder( javaType ); this.jdbcValueBinder = jdbcType.getBinder( javaType );

View File

@ -29,7 +29,7 @@ public class StandardBasicTypeTemplate<J> extends AbstractSingleColumnStandardBa
this.registrationKeys = registrationKeys; this.registrationKeys = registrationKeys;
this.name = javaType.getJavaType() == null ? "(map-mode)" : javaType.getJavaType().getTypeName() this.name = javaType.getJavaType() == null ? "(map-mode)" : javaType.getJavaType().getTypeName()
+ " -> " + jdbcType.getJdbcTypeCode(); + " -> " + jdbcType.getDefaultSqlTypeCode();
} }
@Override @Override

View File

@ -142,7 +142,7 @@ public class DurationJavaType extends AbstractClassJavaType<Duration> {
@Override @Override
public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType) { public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType) {
if ( jdbcType.getDefaultSqlTypeCode() == SqlTypes.INTERVAL_SECOND ) { if ( jdbcType.getDdlTypeCode() == SqlTypes.INTERVAL_SECOND ) {
// Usually the maximum precision for interval types // Usually the maximum precision for interval types
return 18; return 18;
} }
@ -158,7 +158,7 @@ public class DurationJavaType extends AbstractClassJavaType<Duration> {
@Override @Override
public int getDefaultSqlScale(Dialect dialect, JdbcType jdbcType) { public int getDefaultSqlScale(Dialect dialect, JdbcType jdbcType) {
if ( jdbcType.getDefaultSqlTypeCode() == SqlTypes.INTERVAL_SECOND ) { if ( jdbcType.getDdlTypeCode() == SqlTypes.INTERVAL_SECOND ) {
// The default scale necessary is 9 i.e. nanosecond resolution // The default scale necessary is 9 i.e. nanosecond resolution
return 9; return 9;
} }

View File

@ -183,7 +183,7 @@ public class ArrayJdbcType implements JdbcType {
.resolveSize( elementJdbcType, containerJavaType.getElementJavaType(), null, null, null ); .resolveSize( elementJdbcType, containerJavaType.getElementJavaType(), null, null, null );
String typeName = session.getTypeConfiguration() String typeName = session.getTypeConfiguration()
.getDdlTypeRegistry() .getDdlTypeRegistry()
.getDescriptor( elementJdbcType.getDefaultSqlTypeCode() ) .getDescriptor( elementJdbcType.getDdlTypeCode() )
.getTypeName( size ); .getTypeName( size );
int cutIndex = typeName.indexOf( '(' ); int cutIndex = typeName.indexOf( '(' );
if ( cutIndex > 0 ) { if ( cutIndex > 0 ) {

View File

@ -12,6 +12,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import org.hibernate.query.sqm.CastType;
import org.hibernate.type.descriptor.ValueBinder; import org.hibernate.type.descriptor.ValueBinder;
import org.hibernate.type.descriptor.ValueExtractor; import org.hibernate.type.descriptor.ValueExtractor;
import org.hibernate.type.descriptor.WrapperOptions; import org.hibernate.type.descriptor.WrapperOptions;
@ -43,10 +44,15 @@ public class DoubleJdbcType implements JdbcType {
* @return {@link Types#FLOAT} for schema generation * @return {@link Types#FLOAT} for schema generation
*/ */
@Override @Override
public int getDefaultSqlTypeCode() { public int getDdlTypeCode() {
return Types.FLOAT; return Types.FLOAT;
} }
@Override
public CastType getCastType() {
return CastType.DOUBLE;
}
@Override @Override
public String getFriendlyName() { public String getFriendlyName() {
return "DOUBLE"; return "DOUBLE";

View File

@ -70,6 +70,18 @@ public interface JdbcType extends Serializable {
*/ */
int getJdbcTypeCode(); int getJdbcTypeCode();
/**
* A {@linkplain SqlTypes JDBC type code} that identifies the SQL column type.
* <p>
* This value might be different from {@link #getDdlTypeCode()} if the actual type
* e.g. JSON is emulated through a type like CLOB.
*
* @return a JDBC type code
*/
default int getDefaultSqlTypeCode() {
return getJdbcTypeCode();
}
/** /**
* A {@linkplain SqlTypes JDBC type code} that identifies the SQL column type to * A {@linkplain SqlTypes JDBC type code} that identifies the SQL column type to
* be used for schema generation. * be used for schema generation.
@ -78,9 +90,10 @@ public interface JdbcType extends Serializable {
* to obtain the SQL column type. * to obtain the SQL column type.
* *
* @return a JDBC type code * @return a JDBC type code
* @since 6.2
*/ */
default int getDefaultSqlTypeCode() { default int getDdlTypeCode() {
return getJdbcTypeCode(); return getDefaultSqlTypeCode();
} }
default <T> JavaType<T> getJdbcRecommendedJavaTypeMapping( default <T> JavaType<T> getJdbcRecommendedJavaTypeMapping(
@ -148,37 +161,37 @@ public interface JdbcType extends Serializable {
} }
default boolean isInteger() { default boolean isInteger() {
int typeCode = getJdbcTypeCode(); int typeCode = getDdlTypeCode();
return SqlTypes.isIntegral(typeCode) return SqlTypes.isIntegral(typeCode)
|| typeCode == Types.BIT; //HIGHLY DUBIOUS! || typeCode == Types.BIT; //HIGHLY DUBIOUS!
} }
default boolean isFloat() { default boolean isFloat() {
return SqlTypes.isFloatOrRealOrDouble( getJdbcTypeCode() ); return SqlTypes.isFloatOrRealOrDouble( getDdlTypeCode() );
} }
default boolean isDecimal() { default boolean isDecimal() {
return SqlTypes.isNumericOrDecimal( getJdbcTypeCode() ); return SqlTypes.isNumericOrDecimal( getDdlTypeCode() );
} }
default boolean isNumber() { default boolean isNumber() {
return SqlTypes.isNumericType( getJdbcTypeCode() ); return SqlTypes.isNumericType( getDdlTypeCode() );
} }
default boolean isBinary() { default boolean isBinary() {
return SqlTypes.isBinaryType( getJdbcTypeCode() ); return SqlTypes.isBinaryType( getDdlTypeCode() );
} }
default boolean isString() { default boolean isString() {
return SqlTypes.isCharacterOrClobType( getJdbcTypeCode() ); return SqlTypes.isCharacterOrClobType( getDdlTypeCode() );
} }
default boolean isTemporal() { default boolean isTemporal() {
return SqlTypes.isTemporalType( getDefaultSqlTypeCode() ); return SqlTypes.isTemporalType( getDdlTypeCode() );
} }
default boolean isLob() { default boolean isLob() {
return isLob( getJdbcTypeCode() ); return isLob( getDdlTypeCode() );
} }
static boolean isLob(int jdbcTypeCode) { static boolean isLob(int jdbcTypeCode) {
@ -193,7 +206,7 @@ public interface JdbcType extends Serializable {
} }
default boolean isNationalized() { default boolean isNationalized() {
return isNationalized( getJdbcTypeCode() ); return isNationalized( getDdlTypeCode() );
} }
static boolean isNationalized(int jdbcTypeCode) { static boolean isNationalized(int jdbcTypeCode) {
@ -210,11 +223,11 @@ public interface JdbcType extends Serializable {
} }
default boolean isInterval() { default boolean isInterval() {
return SqlTypes.isIntervalType( getDefaultSqlTypeCode() ); return SqlTypes.isIntervalType( getDdlTypeCode() );
} }
default CastType getCastType() { default CastType getCastType() {
return getCastType( getJdbcTypeCode() ); return getCastType( getDdlTypeCode() );
} }
static CastType getCastType(int typeCode) { static CastType getCastType(int typeCode) {

View File

@ -97,7 +97,7 @@ public class DdlTypeImpl implements DdlType {
Long length = null; Long length = null;
Integer precision = null; Integer precision = null;
Integer scale = null; Integer scale = null;
switch ( jdbcType.getDefaultSqlTypeCode() ) { switch ( jdbcType.getDdlTypeCode() ) {
case SqlTypes.VARCHAR: case SqlTypes.VARCHAR:
length = (long) dialect.getMaxVarcharLength(); length = (long) dialect.getMaxVarcharLength();
break; break;

View File

@ -87,7 +87,7 @@ public class ConvertedBasicTypeImpl<J> implements ConvertedBasicType<J>,
this.description = description; this.description = description;
this.converter = converter; this.converter = converter;
this.jdbcType = jdbcType; this.jdbcType = jdbcType;
this.sqlTypes = new int[] { jdbcType.getDefaultSqlTypeCode() }; this.sqlTypes = new int[] { jdbcType.getDdlTypeCode() };
this.jdbcValueBinder = (ValueBinder<J>) jdbcType.getBinder( converter.getRelationalJavaType() ); this.jdbcValueBinder = (ValueBinder<J>) jdbcType.getBinder( converter.getRelationalJavaType() );
this.jdbcValueExtractor = (ValueExtractor<J>) jdbcType.getExtractor( converter.getRelationalJavaType() ); this.jdbcValueExtractor = (ValueExtractor<J>) jdbcType.getExtractor( converter.getRelationalJavaType() );
this.jdbcLiteralFormatter = (JdbcLiteralFormatter<J>) jdbcType.getJdbcLiteralFormatter( converter.getRelationalJavaType() ); this.jdbcLiteralFormatter = (JdbcLiteralFormatter<J>) jdbcType.getJdbcLiteralFormatter( converter.getRelationalJavaType() );
@ -377,7 +377,7 @@ public class ConvertedBasicTypeImpl<J> implements ConvertedBasicType<J>,
@Override @Override
public CastType getCastType() { public CastType getCastType() {
final JdbcType jdbcType = getJdbcType(); final JdbcType jdbcType = getJdbcType();
final int jdbcTypeCode = jdbcType.getJdbcTypeCode(); final int jdbcTypeCode = jdbcType.getDefaultSqlTypeCode();
switch ( jdbcTypeCode ) { switch ( jdbcTypeCode ) {
case Types.BIT: case Types.BIT:
case Types.SMALLINT: case Types.SMALLINT:

View File

@ -63,7 +63,7 @@ public abstract class BaseUserTypeSupport<T> implements UserType<T> {
@Override @Override
public int getSqlType() { public int getSqlType() {
ensureResolved(); ensureResolved();
return jdbcType.getDefaultSqlTypeCode(); return jdbcType.getDdlTypeCode();
} }
@Override @Override

View File

@ -96,7 +96,7 @@ public class StaticUserTypeSupport<T> implements UserType<T> {
@Override @Override
public int getSqlType() { public int getSqlType() {
return jdbcType.getDefaultSqlTypeCode(); return jdbcType.getDdlTypeCode();
} }
@Override @Override

View File

@ -543,8 +543,8 @@ public abstract class AbstractCollectionMetadataGenerator extends AbstractMetada
if ( !type.isComponentType() && !type.isAssociationType() && type instanceof BasicType<?> ) { if ( !type.isComponentType() && !type.isAssociationType() && type instanceof BasicType<?> ) {
final BasicType<?> basicType = (BasicType<?>) type; final BasicType<?> basicType = (BasicType<?>) type;
return basicType.getJavaType() == String.class && ( return basicType.getJavaType() == String.class && (
basicType.getJdbcType().getJdbcTypeCode() == Types.CLOB basicType.getJdbcType().getDdlTypeCode() == Types.CLOB
|| basicType.getJdbcType().getJdbcTypeCode() == Types.NCLOB || basicType.getJdbcType().getDdlTypeCode() == Types.NCLOB
); );
} }
} }

View File

@ -451,8 +451,8 @@ public class ValidityAuditStrategy implements AuditStrategy {
if ( collectionElementType instanceof BasicType<?> ) { if ( collectionElementType instanceof BasicType<?> ) {
final BasicType<?> basicType = (BasicType<?>) collectionElementType; final BasicType<?> basicType = (BasicType<?>) collectionElementType;
return basicType.getJavaType() == String.class && ( return basicType.getJavaType() == String.class && (
basicType.getJdbcType().getJdbcTypeCode() == Types.CLOB basicType.getJdbcType().getDdlTypeCode() == Types.CLOB
|| basicType.getJdbcType().getJdbcTypeCode() == Types.NCLOB || basicType.getJdbcType().getDdlTypeCode() == Types.NCLOB
); );
} }
return false; return false;