mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-10 21:24:49 +00:00
HHH-17276 Be more forgiving when determining lobness
This commit is contained in:
parent
e507f596ec
commit
1b789ff3c4
@ -242,7 +242,7 @@ private boolean supportsWindowFunctions() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitCastTarget(CastTarget castTarget) {
|
public void visitCastTarget(CastTarget castTarget) {
|
||||||
String sqlType = MySQLSqlAstTranslator.getSqlType( castTarget, dialect );
|
String sqlType = MySQLSqlAstTranslator.getSqlType( castTarget, getSessionFactory() );
|
||||||
if ( sqlType != null ) {
|
if ( sqlType != null ) {
|
||||||
appendSql( sqlType );
|
appendSql( sqlType );
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ public MySQLLegacyDialect getDialect() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitCastTarget(CastTarget castTarget) {
|
public void visitCastTarget(CastTarget castTarget) {
|
||||||
String sqlType = MySQLSqlAstTranslator.getSqlType( castTarget, getDialect() );
|
String sqlType = MySQLSqlAstTranslator.getSqlType( castTarget, getSessionFactory() );
|
||||||
if ( sqlType != null ) {
|
if ( sqlType != null ) {
|
||||||
appendSql( sqlType );
|
appendSql( sqlType );
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ private boolean supportsWindowFunctions() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitCastTarget(CastTarget castTarget) {
|
public void visitCastTarget(CastTarget castTarget) {
|
||||||
String sqlType = MySQLSqlAstTranslator.getSqlType( castTarget, dialect );
|
String sqlType = MySQLSqlAstTranslator.getSqlType( castTarget, getSessionFactory() );
|
||||||
if ( sqlType != null ) {
|
if ( sqlType != null ) {
|
||||||
appendSql( sqlType );
|
appendSql( sqlType );
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,20 @@ public MySQLSqlAstTranslator(SessionFactoryImplementor sessionFactory, Statement
|
|||||||
super( sessionFactory, statement );
|
super( sessionFactory, statement );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #getSqlType(CastTarget, SessionFactoryImplementor)} instead
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public static String getSqlType(CastTarget castTarget, Dialect dialect) {
|
public static String getSqlType(CastTarget castTarget, Dialect dialect) {
|
||||||
final String sqlType = castTarget.getSqlType();
|
return getSqlType( castTarget, castTarget.getSqlType(), dialect );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getSqlType(CastTarget castTarget, SessionFactoryImplementor factory) {
|
||||||
|
final String sqlType = getSqlTypeName( castTarget, factory );
|
||||||
|
return getSqlType( castTarget, sqlType, factory.getJdbcServices().getDialect() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getSqlType(CastTarget castTarget, String sqlType, Dialect dialect) {
|
||||||
if ( sqlType != null ) {
|
if ( sqlType != null ) {
|
||||||
int parenthesesIndex = sqlType.indexOf( '(' );
|
int parenthesesIndex = sqlType.indexOf( '(' );
|
||||||
final String baseName = parenthesesIndex == -1 ? sqlType : sqlType.substring( 0, parenthesesIndex );
|
final String baseName = parenthesesIndex == -1 ? sqlType : sqlType.substring( 0, parenthesesIndex );
|
||||||
@ -63,10 +74,14 @@ public static String getSqlType(CastTarget castTarget, Dialect dialect) {
|
|||||||
case "varchar":
|
case "varchar":
|
||||||
case "nchar":
|
case "nchar":
|
||||||
case "nvarchar":
|
case "nvarchar":
|
||||||
return "char";
|
return castTarget.getLength() == null
|
||||||
|
? "char"
|
||||||
|
: ( "char(" + castTarget.getLength() + ")" );
|
||||||
case "binary":
|
case "binary":
|
||||||
case "varbinary":
|
case "varbinary":
|
||||||
return "binary";
|
return castTarget.getLength() == null
|
||||||
|
? "binary"
|
||||||
|
: ( "binary(" + castTarget.getLength() + ")" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sqlType;
|
return sqlType;
|
||||||
@ -286,7 +301,7 @@ public MySQLDialect getDialect() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitCastTarget(CastTarget castTarget) {
|
public void visitCastTarget(CastTarget castTarget) {
|
||||||
String sqlType = getSqlType( castTarget, getDialect() );
|
String sqlType = getSqlType( castTarget, getSessionFactory() );
|
||||||
if ( sqlType != null ) {
|
if ( sqlType != null ) {
|
||||||
appendSql( sqlType );
|
appendSql( sqlType );
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ public TiDBDialect getDialect() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitCastTarget(CastTarget castTarget) {
|
public void visitCastTarget(CastTarget castTarget) {
|
||||||
String sqlType = MySQLSqlAstTranslator.getSqlType( castTarget, dialect );
|
String sqlType = MySQLSqlAstTranslator.getSqlType( castTarget, getSessionFactory() );
|
||||||
if ( sqlType != null ) {
|
if ( sqlType != null ) {
|
||||||
appendSql( sqlType );
|
appendSql( sqlType );
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
import org.hibernate.tool.schema.extract.spi.ColumnTypeInformation;
|
import org.hibernate.tool.schema.extract.spi.ColumnTypeInformation;
|
||||||
import org.hibernate.type.SqlTypes;
|
import org.hibernate.type.SqlTypes;
|
||||||
import org.hibernate.type.descriptor.jdbc.AggregateJdbcType;
|
import org.hibernate.type.descriptor.jdbc.AggregateJdbcType;
|
||||||
|
import org.hibernate.type.descriptor.sql.DdlType;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
import static org.hibernate.type.SqlTypes.BIGINT;
|
import static org.hibernate.type.SqlTypes.BIGINT;
|
||||||
@ -232,7 +233,7 @@ public WriteExpressionRenderer aggregateCustomWriteExpressionRenderer(
|
|||||||
final int aggregateSqlTypeCode = aggregateColumn.getJdbcMapping().getJdbcType().getDefaultSqlTypeCode();
|
final int aggregateSqlTypeCode = aggregateColumn.getJdbcMapping().getJdbcType().getDefaultSqlTypeCode();
|
||||||
switch ( aggregateSqlTypeCode ) {
|
switch ( aggregateSqlTypeCode ) {
|
||||||
case JSON:
|
case JSON:
|
||||||
return jsonAggregateColumnWriter( aggregateColumn, columnsToUpdate );
|
return jsonAggregateColumnWriter( aggregateColumn, columnsToUpdate, typeConfiguration );
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException( "Unsupported aggregate SQL type: " + aggregateSqlTypeCode );
|
throw new IllegalArgumentException( "Unsupported aggregate SQL type: " + aggregateSqlTypeCode );
|
||||||
}
|
}
|
||||||
@ -270,8 +271,9 @@ enum JsonSupport {
|
|||||||
|
|
||||||
private WriteExpressionRenderer jsonAggregateColumnWriter(
|
private WriteExpressionRenderer jsonAggregateColumnWriter(
|
||||||
SelectableMapping aggregateColumn,
|
SelectableMapping aggregateColumn,
|
||||||
SelectableMapping[] columns) {
|
SelectableMapping[] columns,
|
||||||
return new RootJsonWriteExpression( aggregateColumn, columns, this );
|
TypeConfiguration typeConfiguration) {
|
||||||
|
return new RootJsonWriteExpression( aggregateColumn, columns, this, typeConfiguration );
|
||||||
}
|
}
|
||||||
|
|
||||||
interface JsonWriteExpression {
|
interface JsonWriteExpression {
|
||||||
@ -294,7 +296,10 @@ public AggregateJsonWriteExpression(
|
|||||||
this.ddlTypeName = aggregateSupport.determineJsonTypeName( selectableMapping );
|
this.ddlTypeName = aggregateSupport.determineJsonTypeName( selectableMapping );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initializeSubExpressions(SelectableMapping[] columns, OracleAggregateSupport aggregateSupport) {
|
protected void initializeSubExpressions(
|
||||||
|
SelectableMapping[] columns,
|
||||||
|
OracleAggregateSupport aggregateSupport,
|
||||||
|
TypeConfiguration typeConfiguration) {
|
||||||
for ( SelectableMapping column : columns ) {
|
for ( SelectableMapping column : columns ) {
|
||||||
final SelectablePath selectablePath = column.getSelectablePath();
|
final SelectablePath selectablePath = column.getSelectablePath();
|
||||||
final SelectablePath[] parts = selectablePath.getParts();
|
final SelectablePath[] parts = selectablePath.getParts();
|
||||||
@ -319,13 +324,33 @@ protected void initializeSubExpressions(SelectableMapping[] columns, OracleAggre
|
|||||||
aggregateSupport.jsonCustomWriteExpression(
|
aggregateSupport.jsonCustomWriteExpression(
|
||||||
customWriteExpression,
|
customWriteExpression,
|
||||||
sqlTypeCode,
|
sqlTypeCode,
|
||||||
column.getColumnDefinition()
|
determineTypeName( column, typeConfiguration )
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String determineTypeName(SelectableMapping column, TypeConfiguration typeConfiguration) {
|
||||||
|
final String typeName;
|
||||||
|
if ( column.getColumnDefinition() == null ) {
|
||||||
|
final DdlType ddlType = typeConfiguration.getDdlTypeRegistry().getDescriptor(
|
||||||
|
column.getJdbcMapping().getJdbcType().getDefaultSqlTypeCode()
|
||||||
|
);
|
||||||
|
return ddlType.getCastTypeName(
|
||||||
|
column.getJdbcMapping().getJdbcType(),
|
||||||
|
column.getJdbcMapping().getJavaTypeDescriptor(),
|
||||||
|
column.getLength(),
|
||||||
|
column.getPrecision(),
|
||||||
|
column.getScale()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
typeName = column.getColumnDefinition();
|
||||||
|
}
|
||||||
|
return typeName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void append(
|
public void append(
|
||||||
SqlAppender sb,
|
SqlAppender sb,
|
||||||
@ -364,11 +389,12 @@ private static class RootJsonWriteExpression extends AggregateJsonWriteExpressio
|
|||||||
RootJsonWriteExpression(
|
RootJsonWriteExpression(
|
||||||
SelectableMapping aggregateColumn,
|
SelectableMapping aggregateColumn,
|
||||||
SelectableMapping[] columns,
|
SelectableMapping[] columns,
|
||||||
OracleAggregateSupport aggregateSupport) {
|
OracleAggregateSupport aggregateSupport,
|
||||||
|
TypeConfiguration typeConfiguration) {
|
||||||
super( aggregateColumn, aggregateSupport );
|
super( aggregateColumn, aggregateSupport );
|
||||||
this.nullable = aggregateColumn.isNullable();
|
this.nullable = aggregateColumn.isNullable();
|
||||||
this.path = aggregateColumn.getSelectionExpression();
|
this.path = aggregateColumn.getSelectionExpression();
|
||||||
initializeSubExpressions( columns, aggregateSupport );
|
initializeSubExpressions( columns, aggregateSupport, typeConfiguration );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
import org.hibernate.type.descriptor.jdbc.ArrayJdbcType;
|
import org.hibernate.type.descriptor.jdbc.ArrayJdbcType;
|
||||||
import org.hibernate.type.descriptor.JdbcTypeNameMapper;
|
import org.hibernate.type.descriptor.JdbcTypeNameMapper;
|
||||||
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
import org.hibernate.type.descriptor.sql.DdlType;
|
import org.hibernate.type.descriptor.sql.DdlType;
|
||||||
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
|
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
@ -60,7 +61,7 @@ public class Column implements Selectable, Serializable, Cloneable, ColumnTypeIn
|
|||||||
private boolean unique;
|
private boolean unique;
|
||||||
private String sqlTypeName;
|
private String sqlTypeName;
|
||||||
private Integer sqlTypeCode;
|
private Integer sqlTypeCode;
|
||||||
private boolean sqlTypeLob;
|
private Boolean sqlTypeLob;
|
||||||
private boolean quoted;
|
private boolean quoted;
|
||||||
int uniqueInteger;
|
int uniqueInteger;
|
||||||
private String comment;
|
private String comment;
|
||||||
@ -494,6 +495,46 @@ public void setSqlType(String typeName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSqlTypeLob() {
|
public boolean isSqlTypeLob() {
|
||||||
|
return sqlTypeLob != null && sqlTypeLob;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSqlTypeLob(Metadata mapping) {
|
||||||
|
final Database database = mapping.getDatabase();
|
||||||
|
final DdlTypeRegistry ddlTypeRegistry = database.getTypeConfiguration().getDdlTypeRegistry();
|
||||||
|
final Dialect dialect = database.getDialect();
|
||||||
|
if ( sqlTypeLob == null ) {
|
||||||
|
final Type type = getValue().getType();
|
||||||
|
try {
|
||||||
|
if ( isArray( type ) ) {
|
||||||
|
sqlTypeLob = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final int typeCode = getSqlTypeCode( mapping );
|
||||||
|
final DdlType descriptor = ddlTypeRegistry.getDescriptor( typeCode );
|
||||||
|
if ( descriptor == null ) {
|
||||||
|
sqlTypeLob = JdbcType.isLob( typeCode );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final Size size = getColumnSize( dialect, mapping );
|
||||||
|
sqlTypeLob = descriptor.isLob( size );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( MappingException cause ) {
|
||||||
|
throw cause;
|
||||||
|
}
|
||||||
|
catch ( Exception cause ) {
|
||||||
|
throw new MappingException(
|
||||||
|
String.format(
|
||||||
|
Locale.ROOT,
|
||||||
|
"Unable to determine SQL type name for column '%s' of table '%s'",
|
||||||
|
getName(),
|
||||||
|
getValue().getTable().getName()
|
||||||
|
),
|
||||||
|
cause
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
return sqlTypeLob;
|
return sqlTypeLob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,12 +287,12 @@ protected boolean finishInitialization(
|
|||||||
final boolean nullable;
|
final boolean nullable;
|
||||||
if ( selectable instanceof Column ) {
|
if ( selectable instanceof Column ) {
|
||||||
final Column column = (Column) selectable;
|
final Column column = (Column) selectable;
|
||||||
columnDefinition = column.getSqlType( creationProcess.getCreationContext().getMetadata() );
|
columnDefinition = column.getSqlType();
|
||||||
length = column.getLength();
|
length = column.getLength();
|
||||||
precision = column.getPrecision();
|
precision = column.getPrecision();
|
||||||
scale = column.getScale();
|
scale = column.getScale();
|
||||||
nullable = column.isNullable();
|
nullable = column.isNullable();
|
||||||
isLob = column.isSqlTypeLob();
|
isLob = column.isSqlTypeLob( creationProcess.getCreationContext().getMetadata() );
|
||||||
selectablePath = basicValue.createSelectablePath( column.getQuotedName( dialect ) );
|
selectablePath = basicValue.createSelectablePath( column.getQuotedName( dialect ) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -87,7 +87,7 @@ public static DiscriminatedAssociationMapping from(
|
|||||||
declaringModelPart,
|
declaringModelPart,
|
||||||
tableName,
|
tableName,
|
||||||
metaColumn.getText( dialect ),
|
metaColumn.getText( dialect ),
|
||||||
metaColumn.getSqlType( creationProcess.getCreationContext().getMetadata() ),
|
metaColumn.getSqlType(),
|
||||||
metaColumn.getLength(),
|
metaColumn.getLength(),
|
||||||
metaColumn.getPrecision(),
|
metaColumn.getPrecision(),
|
||||||
metaColumn.getScale(),
|
metaColumn.getScale(),
|
||||||
@ -106,7 +106,7 @@ public static DiscriminatedAssociationMapping from(
|
|||||||
declaringModelPart,
|
declaringModelPart,
|
||||||
tableName,
|
tableName,
|
||||||
keyColumn.getText( dialect ),
|
keyColumn.getText( dialect ),
|
||||||
keyColumn.getSqlType( creationProcess.getCreationContext().getMetadata() ),
|
keyColumn.getSqlType(),
|
||||||
keyColumn.getLength(),
|
keyColumn.getLength(),
|
||||||
keyColumn.getPrecision(),
|
keyColumn.getPrecision(),
|
||||||
keyColumn.getScale(),
|
keyColumn.getScale(),
|
||||||
|
@ -383,11 +383,11 @@ private boolean finishInitialization(
|
|||||||
final boolean nullable;
|
final boolean nullable;
|
||||||
if ( selectable instanceof Column ) {
|
if ( selectable instanceof Column ) {
|
||||||
final Column column = (Column) selectable;
|
final Column column = (Column) selectable;
|
||||||
columnDefinition = column.getSqlType( creationProcess.getCreationContext().getMetadata() );
|
columnDefinition = column.getSqlType();
|
||||||
length = column.getLength();
|
length = column.getLength();
|
||||||
precision = column.getPrecision();
|
precision = column.getPrecision();
|
||||||
scale = column.getScale();
|
scale = column.getScale();
|
||||||
isLob = column.isSqlTypeLob();
|
isLob = column.isSqlTypeLob( creationProcess.getCreationContext().getMetadata() );
|
||||||
nullable = bootPropertyDescriptor.isOptional() && column.isNullable() ;
|
nullable = bootPropertyDescriptor.isOptional() && column.isNullable() ;
|
||||||
selectablePath = basicValue.createSelectablePath( column.getQuotedName( dialect ) );
|
selectablePath = basicValue.createSelectablePath( column.getQuotedName( dialect ) );
|
||||||
}
|
}
|
||||||
|
@ -184,13 +184,13 @@ public static SelectableMapping from(
|
|||||||
else {
|
else {
|
||||||
Column column = (Column) selectable;
|
Column column = (Column) selectable;
|
||||||
columnExpression = selectable.getText( dialect );
|
columnExpression = selectable.getText( dialect );
|
||||||
columnDefinition = column.getSqlType( creationContext.getMetadata() );
|
columnDefinition = column.getSqlType();
|
||||||
length = column.getLength();
|
length = column.getLength();
|
||||||
precision = column.getPrecision();
|
precision = column.getPrecision();
|
||||||
scale = column.getScale();
|
scale = column.getScale();
|
||||||
|
|
||||||
isNullable = forceNotNullable ? false : column.isNullable();
|
isNullable = forceNotNullable ? false : column.isNullable();
|
||||||
isLob = column.isSqlTypeLob();
|
isLob = column.isSqlTypeLob( creationContext.getMetadata() );
|
||||||
selectableName = column.getQuotedName( dialect );
|
selectableName = column.getQuotedName( dialect );
|
||||||
}
|
}
|
||||||
return new SelectableMappingImpl(
|
return new SelectableMappingImpl(
|
||||||
|
@ -5037,7 +5037,7 @@ protected EntityDiscriminatorMapping generateDiscriminatorMapping(
|
|||||||
scale = null;
|
scale = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
columnDefinition = column.getSqlType( modelCreationProcess.getCreationContext().getMetadata() );
|
columnDefinition = column.getSqlType();
|
||||||
length = column.getLength();
|
length = column.getLength();
|
||||||
precision = column.getPrecision();
|
precision = column.getPrecision();
|
||||||
scale = column.getScale();
|
scale = column.getScale();
|
||||||
@ -5214,7 +5214,7 @@ protected EntityIdentifierMapping generateIdentifierMapping(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Column column = bootEntityDescriptor.getIdentifier().getColumns().get( 0 );
|
Column column = bootEntityDescriptor.getIdentifier().getColumns().get( 0 );
|
||||||
columnDefinition = column.getSqlType( creationProcess.getCreationContext().getMetadata() );
|
columnDefinition = column.getSqlType();
|
||||||
length = column.getLength();
|
length = column.getLength();
|
||||||
precision = column.getPrecision();
|
precision = column.getPrecision();
|
||||||
scale = column.getScale();
|
scale = column.getScale();
|
||||||
@ -5273,7 +5273,7 @@ protected static EntityVersionMapping generateVersionMapping(
|
|||||||
bootModelRootEntityDescriptor.getVersion().getName(),
|
bootModelRootEntityDescriptor.getVersion().getName(),
|
||||||
entityPersister.getTableName(),
|
entityPersister.getTableName(),
|
||||||
column.getText( dialect ),
|
column.getText( dialect ),
|
||||||
column.getSqlType( creationProcess.getCreationContext().getMetadata() ),
|
column.getSqlType(),
|
||||||
column.getLength(),
|
column.getLength(),
|
||||||
column.getPrecision(),
|
column.getPrecision(),
|
||||||
column.getScale(),
|
column.getScale(),
|
||||||
@ -5318,11 +5318,11 @@ protected AttributeMapping generateNonIdAttributeMapping(
|
|||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
"?",
|
"?",
|
||||||
column.getSqlType( creationProcess.getCreationContext().getMetadata() ),
|
column.getSqlType(),
|
||||||
column.getLength(),
|
column.getLength(),
|
||||||
column.getPrecision(),
|
column.getPrecision(),
|
||||||
column.getScale(),
|
column.getScale(),
|
||||||
column.isSqlTypeLob(),
|
column.isSqlTypeLob( creationProcess.getCreationContext().getMetadata() ),
|
||||||
column.isNullable(),
|
column.isNullable(),
|
||||||
value.isColumnInsertable( 0 ),
|
value.isColumnInsertable( 0 ),
|
||||||
value.isColumnUpdateable( 0 ),
|
value.isColumnUpdateable( 0 ),
|
||||||
@ -5350,11 +5350,11 @@ protected AttributeMapping generateNonIdAttributeMapping(
|
|||||||
customReadExpr = null;
|
customReadExpr = null;
|
||||||
customWriteExpr = "?";
|
customWriteExpr = "?";
|
||||||
Column column = value.getColumns().get( 0 );
|
Column column = value.getColumns().get( 0 );
|
||||||
columnDefinition = column.getSqlType( creationProcess.getCreationContext().getMetadata() );
|
columnDefinition = column.getSqlType();
|
||||||
length = column.getLength();
|
length = column.getLength();
|
||||||
precision = column.getPrecision();
|
precision = column.getPrecision();
|
||||||
scale = column.getScale();
|
scale = column.getScale();
|
||||||
isLob = column.isSqlTypeLob();
|
isLob = column.isSqlTypeLob( creationProcess.getCreationContext().getMetadata() );
|
||||||
nullable = column.isNullable();
|
nullable = column.isNullable();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -5377,12 +5377,12 @@ protected AttributeMapping generateNonIdAttributeMapping(
|
|||||||
);
|
);
|
||||||
customWriteExpr = selectable.getWriteExpr( (JdbcMapping) attrType, creationContext.getDialect() );
|
customWriteExpr = selectable.getWriteExpr( (JdbcMapping) attrType, creationContext.getDialect() );
|
||||||
Column column = value.getColumns().get( 0 );
|
Column column = value.getColumns().get( 0 );
|
||||||
columnDefinition = column.getSqlType( creationContext.getMetadata() );
|
columnDefinition = column.getSqlType();
|
||||||
length = column.getLength();
|
length = column.getLength();
|
||||||
precision = column.getPrecision();
|
precision = column.getPrecision();
|
||||||
scale = column.getScale();
|
scale = column.getScale();
|
||||||
nullable = column.isNullable();
|
nullable = column.isNullable();
|
||||||
isLob = column.isSqlTypeLob();
|
isLob = column.isSqlTypeLob( creationContext.getMetadata() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final String[] attrColumnFormulaTemplate = propertyColumnFormulaTemplates[ propertyIndex ];
|
final String[] attrColumnFormulaTemplate = propertyColumnFormulaTemplates[ propertyIndex ];
|
||||||
|
@ -1186,7 +1186,7 @@ protected EntityIdentifierMapping generateIdentifierMapping(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final Column column = bootEntityDescriptor.getIdentifier().getColumns().get( 0 );
|
final Column column = bootEntityDescriptor.getIdentifier().getColumns().get( 0 );
|
||||||
columnDefinition = column.getSqlType( creationProcess.getCreationContext().getMetadata() );
|
columnDefinition = column.getSqlType();
|
||||||
length = column.getLength();
|
length = column.getLength();
|
||||||
precision = column.getPrecision();
|
precision = column.getPrecision();
|
||||||
scale = column.getScale();
|
scale = column.getScale();
|
||||||
|
@ -6192,15 +6192,19 @@ public void visitTrimSpecification(TrimSpecification trimSpecification) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitCastTarget(CastTarget castTarget) {
|
public void visitCastTarget(CastTarget castTarget) {
|
||||||
|
appendSql( getSqlTypeName( castTarget, sessionFactory ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getSqlTypeName(CastTarget castTarget, SessionFactoryImplementor factory) {
|
||||||
if ( castTarget.getSqlType() != null ) {
|
if ( castTarget.getSqlType() != null ) {
|
||||||
appendSql( castTarget.getSqlType() );
|
return castTarget.getSqlType();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final SqlExpressible expressionType = (SqlExpressible) castTarget.getExpressionType();
|
final SqlExpressible expressionType = (SqlExpressible) castTarget.getExpressionType();
|
||||||
if ( expressionType instanceof BasicPluralType<?, ?> ) {
|
if ( expressionType instanceof BasicPluralType<?, ?> ) {
|
||||||
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 = factory.getTypeConfiguration().getDdlTypeRegistry()
|
||||||
.getDescriptor( elementType.getJdbcType().getDdlTypeCode() )
|
.getDescriptor( elementType.getJdbcType().getDdlTypeCode() )
|
||||||
.getCastTypeName(
|
.getCastTypeName(
|
||||||
elementType,
|
elementType,
|
||||||
@ -6208,13 +6212,12 @@ public void visitCastTarget(CastTarget castTarget) {
|
|||||||
castTarget.getPrecision(),
|
castTarget.getPrecision(),
|
||||||
castTarget.getScale()
|
castTarget.getScale()
|
||||||
);
|
);
|
||||||
final String arrayTypeName = dialect.getArrayTypeName( elementTypeName );
|
final String arrayTypeName = factory.getJdbcServices().getDialect().getArrayTypeName( elementTypeName );
|
||||||
if ( arrayTypeName != null ) {
|
if ( arrayTypeName != null ) {
|
||||||
appendSql( arrayTypeName );
|
return arrayTypeName;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final DdlTypeRegistry ddlTypeRegistry = getSessionFactory().getTypeConfiguration().getDdlTypeRegistry();
|
final DdlTypeRegistry ddlTypeRegistry = factory.getTypeConfiguration().getDdlTypeRegistry();
|
||||||
DdlType ddlType = ddlTypeRegistry
|
DdlType ddlType = ddlTypeRegistry
|
||||||
.getDescriptor( expressionType.getJdbcMapping().getJdbcType().getDdlTypeCode() );
|
.getDescriptor( expressionType.getJdbcMapping().getJdbcType().getDdlTypeCode() );
|
||||||
if ( ddlType == null ) {
|
if ( ddlType == null ) {
|
||||||
@ -6223,13 +6226,11 @@ public void visitCastTarget(CastTarget castTarget) {
|
|||||||
ddlType = ddlTypeRegistry.getDescriptor( SqlTypes.INTEGER );
|
ddlType = ddlTypeRegistry.getDescriptor( SqlTypes.INTEGER );
|
||||||
}
|
}
|
||||||
|
|
||||||
appendSql(
|
return ddlType.getCastTypeName(
|
||||||
ddlType.getCastTypeName(
|
expressionType,
|
||||||
expressionType,
|
castTarget.getLength(),
|
||||||
castTarget.getLength(),
|
castTarget.getPrecision(),
|
||||||
castTarget.getPrecision(),
|
castTarget.getScale()
|
||||||
castTarget.getScale()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user