From 07096e7cc10292405d42d76255399171dadf659d Mon Sep 17 00:00:00 2001 From: Gavin King Date: Fri, 23 Jul 2021 21:24:09 +0200 Subject: [PATCH] introduce JDBCTypeDescriptor.getDefaultSqlTypeCode() and rename sqlType -> jdbcTypeCode in Type hierarchy for consistency See https://github.com/hibernate/hibernate-orm/discussions/4088 --- .../mapping/basic/BitSetUserType.java | 2 +- .../source/internal/hbm/ModelBinder.java | 8 +-- .../java/org/hibernate/dialect/Dialect.java | 2 +- .../org/hibernate/dialect/MySQLDialect.java | 3 +- .../hibernate/dialect/PostgreSQLDialect.java | 2 +- .../hibernate/dialect/SybaseASEDialect.java | 3 +- .../org/hibernate/id/ExportableColumn.java | 2 +- .../org/hibernate/mapping/BasicValue.java | 2 +- .../java/org/hibernate/mapping/Column.java | 2 +- .../org/hibernate/mapping/SimpleValue.java | 2 +- .../entity/AbstractEntityPersister.java | 2 +- .../persister/entity/DiscriminatorType.java | 10 +-- .../internal/idtable/TempIdTableExporter.java | 2 +- ...AbstractSingleColumnStandardBasicType.java | 4 +- .../type/AbstractStandardBasicType.java | 6 +- .../main/java/org/hibernate/type/AnyType.java | 4 +- .../org/hibernate/type/CollectionType.java | 2 +- .../org/hibernate/type/ComponentType.java | 4 +- .../java/org/hibernate/type/CustomType.java | 4 +- .../java/org/hibernate/type/DoubleType.java | 2 +- .../org/hibernate/type/ManyToOneType.java | 4 +- .../java/org/hibernate/type/MetaType.java | 4 +- .../java/org/hibernate/type/OneToOneType.java | 2 +- .../org/hibernate/type/PostgresUUIDType.java | 5 -- .../org/hibernate/type/SingleColumnType.java | 2 +- .../hibernate/type/SpecialOneToOneType.java | 4 +- .../main/java/org/hibernate/type/Type.java | 2 +- .../descriptor/java/DoubleTypeDescriptor.java | 2 +- .../descriptor/java/FloatTypeDescriptor.java | 8 +++ .../type/descriptor/jdbc/BasicBinder.java | 12 ++-- .../type/descriptor/jdbc/BasicExtractor.java | 12 ++-- .../descriptor/jdbc/DoubleTypeDescriptor.java | 13 +++- .../descriptor/jdbc/FloatTypeDescriptor.java | 72 ++++++++++++++++++- .../descriptor/jdbc/JdbcTypeDescriptor.java | 26 ++++--- .../descriptor/jdbc/RealTypeDescriptor.java | 62 ++-------------- .../type/internal/StandardBasicTypeImpl.java | 2 +- .../hibernate/type/spi/TypeConfiguration.java | 4 +- .../nested/NestedEmbeddableMetadataTest.java | 2 +- ...dAccessedNestedEmbeddableMetadataTest.java | 2 +- .../id/usertype/UserTypeComparableIdTest.java | 4 +- .../usertype/UserTypeNonComparableIdTest.java | 4 +- .../converter/AndNationalizedTests.java | 3 +- .../mapping/formula/FormulaFromHbmTests.java | 4 +- ...AttributeOverrideEnhancedUserTypeTest.java | 4 +- .../dynamicparameterized/MyStringType.java | 2 +- .../test/usertype/StringWrapperUserType.java | 2 +- .../components/dynamic/AgeType.java | 2 +- 47 files changed, 180 insertions(+), 153 deletions(-) diff --git a/documentation/src/test/java/org/hibernate/userguide/mapping/basic/BitSetUserType.java b/documentation/src/test/java/org/hibernate/userguide/mapping/basic/BitSetUserType.java index 27f78160ec..ca0fc7187e 100644 --- a/documentation/src/test/java/org/hibernate/userguide/mapping/basic/BitSetUserType.java +++ b/documentation/src/test/java/org/hibernate/userguide/mapping/basic/BitSetUserType.java @@ -27,7 +27,7 @@ public class BitSetUserType implements UserType { @Override public int[] sqlTypes() { - return new int[] {StringType.INSTANCE.sqlType()}; + return new int[] {StringType.INSTANCE.getJdbcTypeDescriptor().getDefaultSqlTypeCode()}; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java index 3eaf42e004..2a14d0b0fe 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java @@ -1983,7 +1983,7 @@ public class ModelBinder { .getBasicTypeRegistry() .getRegisteredType( value.getTypeName() ); if ( basicType instanceof AbstractSingleColumnStandardBasicType ) { - if ( isLob( basicType.getJdbcTypeDescriptor().getJdbcType(), null ) ) { + if ( isLob( basicType.getJdbcTypeDescriptor().getJdbcTypeCode(), null ) ) { value.makeLob(); } } @@ -2004,9 +2004,9 @@ public class ModelBinder { private static boolean isLob(Integer sqlType, String sqlTypeName) { if ( sqlType != null ) { - return ClobType.INSTANCE.getJdbcTypeDescriptor().getJdbcType() == sqlType || - BlobType.INSTANCE.getJdbcTypeDescriptor().getJdbcType() == sqlType || - NClobType.INSTANCE.getJdbcTypeDescriptor().getJdbcType() == sqlType; + return ClobType.INSTANCE.getJdbcTypeDescriptor().getJdbcTypeCode() == sqlType || + BlobType.INSTANCE.getJdbcTypeDescriptor().getJdbcTypeCode() == sqlType || + NClobType.INSTANCE.getJdbcTypeDescriptor().getJdbcTypeCode() == sqlType; } else if ( sqlTypeName != null ) { return ClobType.INSTANCE.getName().equalsIgnoreCase( sqlTypeName ) || diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java index 5f3c7fe10b..002c3b4d0c 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -1097,7 +1097,7 @@ public abstract class Dialect implements ConversionContext { } public String getTypeName(JdbcTypeDescriptor jdbcTypeDescriptor) throws HibernateException { - return getTypeName( jdbcTypeDescriptor.getJdbcTypeCode() ); + return getTypeName( jdbcTypeDescriptor.getDefaultSqlTypeCode() ); } public String getTypeName(int code) throws HibernateException { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java index d15bd27371..35a261db30 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java @@ -191,8 +191,7 @@ public class MySQLDialect extends Dialect { Integer precision, Integer scale, Long length) { - final int jdbcTypeCode = jdbcType.getJdbcType(); - switch ( jdbcTypeCode ) { + switch ( jdbcType.getDefaultSqlTypeCode() ) { case Types.BIT: // MySQL allows BIT with a length up to 64 if ( length != null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java index 4bd072679d..d5d26fd90b 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java @@ -110,7 +110,7 @@ public class PostgreSQLDialect extends Dialect { registerColumnType( Types.LONGNVARCHAR, "text" ); if ( getVersion() >= 820 ) { - registerColumnType( PostgresUUIDType.INSTANCE.sqlType(), "uuid" ); + registerColumnType( PostgresUUIDType.INSTANCE.getJdbcTypeDescriptor().getDefaultSqlTypeCode(), "uuid" ); if ( getVersion() >= 920 ) { registerColumnType( Types.JAVA_OBJECT, "json" ); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASEDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASEDialect.java index 409e4a234e..559105c156 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASEDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASEDialect.java @@ -109,8 +109,7 @@ public class SybaseASEDialect extends SybaseDialect { Integer precision, Integer scale, Long length) { - final int jdbcTypeCode = jdbcType.getJdbcType(); - switch ( jdbcTypeCode ) { + switch ( jdbcType.getDefaultSqlTypeCode() ) { case Types.FLOAT: // Sybase ASE allows FLOAT with a precision up to 48 if ( precision != null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/id/ExportableColumn.java b/hibernate-core/src/main/java/org/hibernate/id/ExportableColumn.java index af1086b432..122ad957cc 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/ExportableColumn.java +++ b/hibernate-core/src/main/java/org/hibernate/id/ExportableColumn.java @@ -36,7 +36,7 @@ public class ExportableColumn extends Column { table, name, type, - database.getDialect().getTypeName( type.sqlTypes( null )[0] ) + database.getDialect().getTypeName( type.getSqlTypeCodes( null )[0] ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java index 3fad26862f..90674c3831 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java @@ -256,7 +256,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeDescriptorIndicat if ( column instanceof Column && resolution.getValueConverter() == null ) { final Column physicalColumn = (Column) column; if ( physicalColumn.getSqlTypeCode() == null ) { - physicalColumn.setSqlTypeCode( resolution.getJdbcTypeDescriptor().getJdbcTypeCode() ); + physicalColumn.setSqlTypeCode( resolution.getJdbcTypeDescriptor().getDefaultSqlTypeCode() ); } final BasicType basicType = resolution.getLegacyResolvedBasicType(); diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Column.java b/hibernate-core/src/main/java/org/hibernate/mapping/Column.java index da07df5cb4..c79e6bc285 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Column.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Column.java @@ -202,7 +202,7 @@ public class Column implements Selectable, Serializable, Cloneable { public int getSqlTypeCode(Mapping mapping) throws MappingException { org.hibernate.type.Type type = getValue().getType(); try { - int sqlTypeCode = type.sqlTypes( mapping )[getTypeIndex()]; + int sqlTypeCode = type.getSqlTypeCodes( mapping )[getTypeIndex()]; if ( getSqlTypeCode() != null && getSqlTypeCode() != sqlTypeCode ) { throw new MappingException( "SQLType code's does not match. mapped as " + sqlTypeCode + " but is " + getSqlTypeCode() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java index 433b27392e..25e52bf3a6 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java @@ -649,7 +649,7 @@ public abstract class SimpleValue implements KeyValue { // todo (6.0) : handle the other JdbcRecommendedSqlTypeMappingContext methods metadata::getTypeConfiguration ); - int jdbcTypeCode = recommendedJdbcType.getJdbcType(); + int jdbcTypeCode = recommendedJdbcType.getJdbcTypeCode(); if ( isLob() ) { if ( LobTypeMappings.isMappedToKnownLobCode( jdbcTypeCode ) ) { jdbcTypeCode = LobTypeMappings.getLobCodeTypeMapping( jdbcTypeCode ); diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index 8f6c7ff096..ad3625624f 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -3430,7 +3430,7 @@ public abstract class AbstractEntityPersister .getIdentitySelectString( getTableName( 0 ), getKeyColumns( 0 )[0], - getIdentifierType().sqlTypes( getFactory() )[0] + getIdentifierType().getSqlTypeCodes( getFactory() )[0] ); } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/DiscriminatorType.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/DiscriminatorType.java index 63d423b76d..8289985804 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/DiscriminatorType.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/DiscriminatorType.java @@ -22,14 +22,8 @@ import org.hibernate.engine.spi.Mapping; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.internal.util.collections.ArrayHelper; -import org.hibernate.mapping.IndexedConsumer; -import org.hibernate.metamodel.mapping.JdbcMapping; -import org.hibernate.metamodel.mapping.MappingType; -import org.hibernate.metamodel.model.domain.DomainType; -import org.hibernate.sql.ast.Clause; import org.hibernate.type.AbstractType; import org.hibernate.type.BasicType; -import org.hibernate.type.Type; import org.hibernate.type.descriptor.ValueBinder; import org.hibernate.type.descriptor.ValueExtractor; import org.hibernate.type.descriptor.WrapperOptions; @@ -207,8 +201,8 @@ public class DiscriminatorType extends AbstractType implements org.hibernate. // simple delegation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @Override - public int[] sqlTypes(Mapping mapping) throws MappingException { - return underlyingType.sqlTypes( mapping ); + public int[] getSqlTypeCodes(Mapping mapping) throws MappingException { + return underlyingType.getSqlTypeCodes( mapping ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/TempIdTableExporter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/TempIdTableExporter.java index dfa7d7249f..3c53e871af 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/TempIdTableExporter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/TempIdTableExporter.java @@ -57,7 +57,7 @@ public class TempIdTableExporter implements IdTableExporter { } buffer.append( column.getColumnName() ).append( ' ' ); - final int sqlTypeCode = column.getJdbcMapping().getJdbcTypeDescriptor().getJdbcType(); + final int sqlTypeCode = column.getJdbcMapping().getJdbcTypeDescriptor().getDefaultSqlTypeCode(); final String databaseTypeName = databaseTypeNameResolver.apply( sqlTypeCode ); buffer.append( " " ).append( databaseTypeName ).append( " " ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/AbstractSingleColumnStandardBasicType.java b/hibernate-core/src/main/java/org/hibernate/type/AbstractSingleColumnStandardBasicType.java index c69c5420e5..7351dc4f67 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/AbstractSingleColumnStandardBasicType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/AbstractSingleColumnStandardBasicType.java @@ -28,8 +28,8 @@ public abstract class AbstractSingleColumnStandardBasicType } @Override - public final int sqlType() { - return getJdbcTypeDescriptor().getJdbcType(); + public final int getJdbcTypeCode() { + return getJdbcTypeDescriptor().getJdbcTypeCode(); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java b/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java index 0455801945..4908253f9a 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java @@ -54,7 +54,7 @@ public abstract class AbstractStandardBasicType public AbstractStandardBasicType(JdbcTypeDescriptor jdbcTypeDescriptor, JavaTypeDescriptor javaTypeDescriptor) { this.jdbcTypeDescriptor = jdbcTypeDescriptor; - this.sqlTypes = new int[] { jdbcTypeDescriptor.getJdbcType() }; + this.sqlTypes = new int[] { jdbcTypeDescriptor.getDefaultSqlTypeCode() }; this.javaTypeDescriptor = javaTypeDescriptor; this.jdbcValueBinder = jdbcTypeDescriptor.getBinder( javaTypeDescriptor ); @@ -156,7 +156,7 @@ public abstract class AbstractStandardBasicType public final void setSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) { this.jdbcTypeDescriptor = jdbcTypeDescriptor; - this.sqlTypes = new int[] { jdbcTypeDescriptor.getJdbcType() }; + this.sqlTypes = new int[] { jdbcTypeDescriptor.getDefaultSqlTypeCode() }; this.jdbcValueBinder = getJdbcTypeDescriptor().getBinder( javaTypeDescriptor ); this.jdbcValueExtractor = getJdbcTypeDescriptor().getExtractor( javaTypeDescriptor ); @@ -173,7 +173,7 @@ public abstract class AbstractStandardBasicType } @Override - public final int[] sqlTypes(Mapping mapping) throws MappingException { + public final int[] getSqlTypeCodes(Mapping mapping) throws MappingException { return sqlTypes; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/AnyType.java b/hibernate-core/src/main/java/org/hibernate/type/AnyType.java index 54792b6175..aa9b334096 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/AnyType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/AnyType.java @@ -81,8 +81,8 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT } @Override - public int[] sqlTypes(Mapping mapping) throws MappingException { - return ArrayHelper.join( discriminatorType.sqlTypes( mapping ), identifierType.sqlTypes( mapping ) ); + public int[] getSqlTypeCodes(Mapping mapping) throws MappingException { + return ArrayHelper.join( discriminatorType.getSqlTypeCodes( mapping ), identifierType.getSqlTypeCodes( mapping ) ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java b/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java index 0256a30fef..9dd310ca32 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java @@ -163,7 +163,7 @@ public abstract class CollectionType extends AbstractType implements Association } @Override - public int[] sqlTypes(Mapping session) throws MappingException { + public int[] getSqlTypeCodes(Mapping session) throws MappingException { return ArrayHelper.EMPTY_INT_ARRAY; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/ComponentType.java b/hibernate-core/src/main/java/org/hibernate/type/ComponentType.java index 0f49e7f621..b94efa8ed0 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/ComponentType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/ComponentType.java @@ -113,12 +113,12 @@ public class ComponentType extends AbstractType implements CompositeType, Proced } @Override - public int[] sqlTypes(Mapping mapping) throws MappingException { + public int[] getSqlTypeCodes(Mapping mapping) throws MappingException { //Not called at runtime so doesn't matter if it's slow :) int[] sqlTypes = new int[getColumnSpan( mapping )]; int n = 0; for ( int i = 0; i < propertySpan; i++ ) { - int[] subtypes = propertyTypes[i].sqlTypes( mapping ); + int[] subtypes = propertyTypes[i].getSqlTypeCodes( mapping ); for ( int subtype : subtypes ) { sqlTypes[n++] = subtype; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/CustomType.java b/hibernate-core/src/main/java/org/hibernate/type/CustomType.java index a03c52f6a9..a3013d9a43 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/CustomType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/CustomType.java @@ -128,8 +128,8 @@ public class CustomType } @Override - public int[] sqlTypes(Mapping pi) { - return new int[] { jdbcTypeDescriptor.getJdbcType() }; + public int[] getSqlTypeCodes(Mapping pi) { + return new int[] { jdbcTypeDescriptor.getDefaultSqlTypeCode() }; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/type/DoubleType.java b/hibernate-core/src/main/java/org/hibernate/type/DoubleType.java index 32494d6cc1..04b1369c37 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/DoubleType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/DoubleType.java @@ -25,7 +25,7 @@ public class DoubleType public static final Double ZERO = 0.0; public DoubleType() { - super( org.hibernate.type.descriptor.jdbc.FloatTypeDescriptor.INSTANCE, DoubleTypeDescriptor.INSTANCE ); + super( org.hibernate.type.descriptor.jdbc.DoubleTypeDescriptor.INSTANCE, DoubleTypeDescriptor.INSTANCE ); } @Override public String getName() { diff --git a/hibernate-core/src/main/java/org/hibernate/type/ManyToOneType.java b/hibernate-core/src/main/java/org/hibernate/type/ManyToOneType.java index a1a1634231..f4482d62d6 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/ManyToOneType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/ManyToOneType.java @@ -108,8 +108,8 @@ public class ManyToOneType extends EntityType { } @Override - public int[] sqlTypes(Mapping mapping) throws MappingException { - return requireIdentifierOrUniqueKeyType( mapping ).sqlTypes( mapping ); + public int[] getSqlTypeCodes(Mapping mapping) throws MappingException { + return requireIdentifierOrUniqueKeyType( mapping ).getSqlTypeCodes( mapping ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/type/MetaType.java b/hibernate-core/src/main/java/org/hibernate/type/MetaType.java index cd4348bb47..ec64899154 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/MetaType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/MetaType.java @@ -51,8 +51,8 @@ public class MetaType extends AbstractType { return discriminatorValuesToEntityNameMap; } - public int[] sqlTypes(Mapping mapping) throws MappingException { - return baseType.sqlTypes(mapping); + public int[] getSqlTypeCodes(Mapping mapping) throws MappingException { + return baseType.getSqlTypeCodes(mapping); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/type/OneToOneType.java b/hibernate-core/src/main/java/org/hibernate/type/OneToOneType.java index 83f4bd527b..5e94cf24f9 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/OneToOneType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/OneToOneType.java @@ -84,7 +84,7 @@ public class OneToOneType extends EntityType { } @Override - public int[] sqlTypes(Mapping session) throws MappingException { + public int[] getSqlTypeCodes(Mapping session) throws MappingException { return ArrayHelper.EMPTY_INT_ARRAY; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/PostgresUUIDType.java b/hibernate-core/src/main/java/org/hibernate/type/PostgresUUIDType.java index 61fe5c23ba..c231a52070 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/PostgresUUIDType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/PostgresUUIDType.java @@ -70,11 +70,6 @@ public class PostgresUUIDType extends AbstractSingleColumnStandardBasicType extends Type { - int sqlType(); + int getJdbcTypeCode(); String toString(T value) throws HibernateException; diff --git a/hibernate-core/src/main/java/org/hibernate/type/SpecialOneToOneType.java b/hibernate-core/src/main/java/org/hibernate/type/SpecialOneToOneType.java index 90232beda4..17723fc6a8 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/SpecialOneToOneType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/SpecialOneToOneType.java @@ -60,8 +60,8 @@ public class SpecialOneToOneType extends OneToOneType { return super.getIdentifierOrUniqueKeyType( mapping ).getColumnSpan( mapping ); } - public int[] sqlTypes(Mapping mapping) throws MappingException { - return super.getIdentifierOrUniqueKeyType( mapping ).sqlTypes( mapping ); + public int[] getSqlTypeCodes(Mapping mapping) throws MappingException { + return super.getIdentifierOrUniqueKeyType( mapping ).getSqlTypeCodes( mapping ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/type/Type.java b/hibernate-core/src/main/java/org/hibernate/type/Type.java index 72bf4b9b67..3191d7c3dd 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/Type.java +++ b/hibernate-core/src/main/java/org/hibernate/type/Type.java @@ -108,7 +108,7 @@ public interface Type extends Serializable { * * @throws MappingException Generally indicates an issue accessing the passed mapping object. */ - int[] sqlTypes(Mapping mapping) throws MappingException; + int[] getSqlTypeCodes(Mapping mapping) throws MappingException; /** * Return the column sizes dictated by this type. For example, the mapping for a {@code char}/{@link Character} would diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/DoubleTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/DoubleTypeDescriptor.java index bf46f9f23f..6f01b777f5 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/DoubleTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/DoubleTypeDescriptor.java @@ -31,7 +31,7 @@ public class DoubleTypeDescriptor extends AbstractClassTypeDescriptor im @Override public JdbcTypeDescriptor getRecommendedJdbcType(JdbcTypeDescriptorIndicators indicators) { - return indicators.getTypeConfiguration().getJdbcTypeDescriptorRegistry().getDescriptor( Types.REAL ); + return org.hibernate.type.descriptor.jdbc.DoubleTypeDescriptor.INSTANCE; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/FloatTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/FloatTypeDescriptor.java index cfde0d6378..950ff91b42 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/FloatTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/FloatTypeDescriptor.java @@ -13,6 +13,8 @@ import java.util.Locale; import org.hibernate.dialect.Dialect; import org.hibernate.type.descriptor.WrapperOptions; import org.hibernate.type.descriptor.java.spi.Primitive; +import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor; +import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptorIndicators; /** * Descriptor for {@link Float} handling. @@ -25,6 +27,12 @@ public class FloatTypeDescriptor extends AbstractClassTypeDescriptor impl public FloatTypeDescriptor() { super( Float.class ); } + + @Override + public JdbcTypeDescriptor getRecommendedJdbcType(JdbcTypeDescriptorIndicators indicators) { + return org.hibernate.type.descriptor.jdbc.FloatTypeDescriptor.INSTANCE; + } + @Override public String toString(Float value) { return value == null ? null : value.toString(); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BasicBinder.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BasicBinder.java index bcce34e793..73bb9b88b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BasicBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BasicBinder.java @@ -50,7 +50,7 @@ public abstract class BasicBinder implements ValueBinder, Serializable { String.format( NULL_BIND_MSG_TEMPLATE, index, - JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcType() ) + JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcTypeCode() ) ) ); } @@ -62,7 +62,7 @@ public abstract class BasicBinder implements ValueBinder, Serializable { String.format( BIND_MSG_TEMPLATE, index, - JdbcTypeNameMapper.getTypeName( jdbcTypeDescriptor.getJdbcType() ), + JdbcTypeNameMapper.getTypeName( jdbcTypeDescriptor.getJdbcTypeCode() ), getJavaTypeDescriptor().extractLoggableRepresentation( value ) ) ); @@ -79,7 +79,7 @@ public abstract class BasicBinder implements ValueBinder, Serializable { String.format( NULL_BIND_MSG_TEMPLATE, name, - JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcType() ) + JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcTypeCode() ) ) ); } @@ -91,7 +91,7 @@ public abstract class BasicBinder implements ValueBinder, Serializable { String.format( BIND_MSG_TEMPLATE, name, - JdbcTypeNameMapper.getTypeName( jdbcTypeDescriptor.getJdbcType() ), + JdbcTypeNameMapper.getTypeName( jdbcTypeDescriptor.getJdbcTypeCode() ), getJavaTypeDescriptor().extractLoggableRepresentation( value ) ) ); @@ -110,7 +110,7 @@ public abstract class BasicBinder implements ValueBinder, Serializable { * @throws SQLException Indicates a problem binding to the prepared statement. */ protected void doBindNull(PreparedStatement st, int index, WrapperOptions options) throws SQLException { - st.setNull( index, jdbcTypeDescriptor.getJdbcType() ); + st.setNull( index, jdbcTypeDescriptor.getJdbcTypeCode() ); } /** @@ -123,7 +123,7 @@ public abstract class BasicBinder implements ValueBinder, Serializable { * @throws SQLException Indicates a problem binding to the callable statement. */ protected void doBindNull(CallableStatement st, String name, WrapperOptions options) throws SQLException { - st.setNull( name, jdbcTypeDescriptor.getJdbcType() ); + st.setNull( name, jdbcTypeDescriptor.getJdbcTypeCode() ); } /** diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BasicExtractor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BasicExtractor.java index e10c08aa7b..b5b9952825 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BasicExtractor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BasicExtractor.java @@ -47,7 +47,7 @@ public abstract class BasicExtractor implements ValueExtractor, Serializab JdbcExtractingLogging.LOGGER.tracef( "extracted value ([%s] : [%s]) - [null]", paramIndex, - JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcType() ) + JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcTypeCode() ) ); } return null; @@ -57,7 +57,7 @@ public abstract class BasicExtractor implements ValueExtractor, Serializab JdbcExtractingLogging.LOGGER.tracef( "extracted value ([%s] : [%s]) - [%s]", paramIndex, - JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcType() ), + JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcTypeCode() ), getJavaTypeDescriptor().extractLoggableRepresentation( value ) ); } @@ -85,7 +85,7 @@ public abstract class BasicExtractor implements ValueExtractor, Serializab JdbcExtractingLogging.LOGGER.tracef( "extracted procedure output parameter ([%s] : [%s]) - [null]", paramIndex, - JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcType() ) + JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcTypeCode() ) ); } return null; @@ -95,7 +95,7 @@ public abstract class BasicExtractor implements ValueExtractor, Serializab JdbcExtractingLogging.LOGGER.tracef( "extracted procedure output parameter ([%s] : [%s]) - [%s]", paramIndex, - JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcType() ), + JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcTypeCode() ), getJavaTypeDescriptor().extractLoggableRepresentation( value ) ); } @@ -123,7 +123,7 @@ public abstract class BasicExtractor implements ValueExtractor, Serializab JdbcExtractingLogging.LOGGER.tracef( "extracted named procedure output parameter ([%s] : [%s]) - [null]", paramName, - JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcType() ) + JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcTypeCode() ) ); } return null; @@ -133,7 +133,7 @@ public abstract class BasicExtractor implements ValueExtractor, Serializab JdbcExtractingLogging.LOGGER.tracef( "extracted named procedure output parameter ([%s] : [%s]) - [%s]", paramName, - JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcType() ), + JdbcTypeNameMapper.getTypeName( getJdbcTypeDescriptor().getJdbcTypeCode() ), getJavaTypeDescriptor().extractLoggableRepresentation( value ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DoubleTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DoubleTypeDescriptor.java index fa9a7814b3..32dd148324 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DoubleTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DoubleTypeDescriptor.java @@ -31,11 +31,22 @@ public class DoubleTypeDescriptor implements JdbcTypeDescriptor { public DoubleTypeDescriptor() { } + /** + * @return {@link Types#DOUBLE} + */ @Override public int getJdbcType() { return Types.DOUBLE; } + /** + * @return {@link Types#FLOAT} for schema generation + */ + @Override + public int getDefaultSqlTypeCode() { + return Types.FLOAT; + } + @Override public String getFriendlyName() { return "DOUBLE"; @@ -43,7 +54,7 @@ public class DoubleTypeDescriptor implements JdbcTypeDescriptor { @Override public String toString() { - return "SqlTypeDescriptor(" + getFriendlyName() + ")"; + return "DoubleTypeDescriptor"; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/FloatTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/FloatTypeDescriptor.java index ed7a377807..82dab4341f 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/FloatTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/FloatTypeDescriptor.java @@ -6,9 +6,18 @@ */ package org.hibernate.type.descriptor.jdbc; +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import java.sql.Types; +import org.hibernate.type.descriptor.ValueBinder; +import org.hibernate.type.descriptor.ValueExtractor; +import org.hibernate.type.descriptor.WrapperOptions; import org.hibernate.type.descriptor.java.BasicJavaDescriptor; +import org.hibernate.type.descriptor.java.JavaTypeDescriptor; +import org.hibernate.type.descriptor.jdbc.internal.JdbcLiteralFormatterNumericData; import org.hibernate.type.spi.TypeConfiguration; /** @@ -16,19 +25,76 @@ import org.hibernate.type.spi.TypeConfiguration; * * @author Steve Ebersole */ -public class FloatTypeDescriptor extends RealTypeDescriptor { +public class FloatTypeDescriptor implements JdbcTypeDescriptor { public static final FloatTypeDescriptor INSTANCE = new FloatTypeDescriptor(); public FloatTypeDescriptor() { } + @Override + public int getJdbcType() { + return Types.FLOAT; + } + + @Override + public String getFriendlyName() { + return "FLOAT"; + } + + @Override + public String toString() { + return "FloatTypeDescriptor"; + } + + @Override + public boolean canBeRemapped() { + return true; + } + @Override public BasicJavaDescriptor getJdbcRecommendedJavaTypeMapping(TypeConfiguration typeConfiguration) { return (BasicJavaDescriptor) typeConfiguration.getJavaTypeDescriptorRegistry().getDescriptor( Double.class ); } @Override - public int getJdbcType() { - return Types.FLOAT; + @SuppressWarnings("unchecked") + public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaTypeDescriptor javaTypeDescriptor) { + return new JdbcLiteralFormatterNumericData( javaTypeDescriptor, Float.class ); + } + + @Override + public ValueBinder getBinder(final JavaTypeDescriptor javaTypeDescriptor) { + return new BasicBinder( javaTypeDescriptor, this ) { + @Override + protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { + st.setFloat( index, javaTypeDescriptor.unwrap( value, Float.class, options ) ); + } + + @Override + protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) + throws SQLException { + st.setFloat( name, javaTypeDescriptor.unwrap( value, Float.class, options ) ); + } + }; + } + + @Override + public ValueExtractor getExtractor(final JavaTypeDescriptor javaTypeDescriptor) { + return new BasicExtractor( javaTypeDescriptor, this ) { + @Override + protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { + return javaTypeDescriptor.wrap( rs.getFloat( paramIndex ), options ); + } + + @Override + protected X doExtract(CallableStatement statement, int index, WrapperOptions options) throws SQLException { + return javaTypeDescriptor.wrap( statement.getFloat( index ), options ); + } + + @Override + protected X doExtract(CallableStatement statement, String name, WrapperOptions options) throws SQLException { + return javaTypeDescriptor.wrap( statement.getFloat( name ), options ); + } + }; } } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JdbcTypeDescriptor.java index 8ce7f78592..83a942c190 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JdbcTypeDescriptor.java @@ -29,7 +29,7 @@ public interface JdbcTypeDescriptor extends Serializable { * A "friendly" name for use in logging */ default String getFriendlyName() { - return Integer.toString( getJdbcType() ); + return Integer.toString( getJdbcTypeCode() ); } /** @@ -50,6 +50,16 @@ public interface JdbcTypeDescriptor extends Serializable { return getJdbcType(); } + /** + * Get a JDBC type code that identifies the SQL column type to be + * used for schema generation. + * + * @see #getJdbcType + */ + default int getDefaultSqlTypeCode() { + return getJdbcType(); + } + /** * Is this descriptor available for remapping? * @@ -63,7 +73,7 @@ public interface JdbcTypeDescriptor extends Serializable { default BasicJavaDescriptor getJdbcRecommendedJavaTypeMapping(TypeConfiguration typeConfiguration) { // match legacy behavior return (BasicJavaDescriptor) typeConfiguration.getJavaTypeDescriptorRegistry().getDescriptor( - JdbcTypeJavaClassMappings.INSTANCE.determineJavaClassForJdbcTypeCode( getJdbcType() ) + JdbcTypeJavaClassMappings.INSTANCE.determineJavaClassForJdbcTypeCode( getJdbcTypeCode() ) ); } @@ -95,7 +105,7 @@ public interface JdbcTypeDescriptor extends Serializable { ValueExtractor getExtractor(JavaTypeDescriptor javaTypeDescriptor); default boolean isInteger() { - switch ( getJdbcType() ) { + switch ( getJdbcTypeCode() ) { case Types.BIT: case Types.TINYINT: case Types.SMALLINT: @@ -107,7 +117,7 @@ public interface JdbcTypeDescriptor extends Serializable { } default boolean isNumber() { - switch ( getJdbcType() ) { + switch ( getJdbcTypeCode() ) { case Types.BIT: case Types.TINYINT: case Types.SMALLINT: @@ -124,7 +134,7 @@ public interface JdbcTypeDescriptor extends Serializable { } default boolean isBinary() { - switch ( getJdbcType() ) { + switch ( getJdbcTypeCode() ) { case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: @@ -135,7 +145,7 @@ public interface JdbcTypeDescriptor extends Serializable { } default boolean isString() { - switch ( getJdbcType() ) { + switch ( getJdbcTypeCode() ) { case Types.CHAR: case Types.NCHAR: case Types.VARCHAR: @@ -150,7 +160,7 @@ public interface JdbcTypeDescriptor extends Serializable { } default boolean isTemporal() { - switch ( getJdbcType() ) { + switch ( getJdbcTypeCode() ) { case Types.DATE: case Types.TIME: case Types.TIMESTAMP: @@ -161,7 +171,7 @@ public interface JdbcTypeDescriptor extends Serializable { } default CastType getCastType() { - switch ( getJdbcType() ) { + switch ( getJdbcTypeCode() ) { case Types.INTEGER: case Types.TINYINT: case Types.SMALLINT: diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/RealTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/RealTypeDescriptor.java index e3a8adbfff..32810ee880 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/RealTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/RealTypeDescriptor.java @@ -6,27 +6,20 @@ */ package org.hibernate.type.descriptor.jdbc; -import java.sql.CallableStatement; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; import java.sql.Types; -import org.hibernate.type.descriptor.ValueBinder; -import org.hibernate.type.descriptor.ValueExtractor; -import org.hibernate.type.descriptor.WrapperOptions; import org.hibernate.type.descriptor.java.BasicJavaDescriptor; -import org.hibernate.type.descriptor.java.FloatTypeDescriptor; -import org.hibernate.type.descriptor.java.JavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.internal.JdbcLiteralFormatterNumericData; import org.hibernate.type.spi.TypeConfiguration; /** * Descriptor for {@link Types#REAL REAL} handling. * * @author Steve Ebersole + * + * @deprecated use {@link FloatTypeDescriptor} */ -public class RealTypeDescriptor implements JdbcTypeDescriptor { +@Deprecated +public class RealTypeDescriptor extends FloatTypeDescriptor { public static final RealTypeDescriptor INSTANCE = new RealTypeDescriptor(); public RealTypeDescriptor() { @@ -47,55 +40,8 @@ public class RealTypeDescriptor implements JdbcTypeDescriptor { return "RealTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaDescriptor getJdbcRecommendedJavaTypeMapping(TypeConfiguration typeConfiguration) { return (BasicJavaDescriptor) typeConfiguration.getJavaTypeDescriptorRegistry().getDescriptor( Float.class ); } - - @Override - @SuppressWarnings("unchecked") - public JdbcLiteralFormatter getJdbcLiteralFormatter(JavaTypeDescriptor javaTypeDescriptor) { - return new JdbcLiteralFormatterNumericData( javaTypeDescriptor, Float.class ); - } - - @Override - public ValueBinder getBinder(final JavaTypeDescriptor javaTypeDescriptor) { - return new BasicBinder( javaTypeDescriptor, this ) { - @Override - protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { - st.setFloat( index, javaTypeDescriptor.unwrap( value, Float.class, options ) ); - } - - @Override - protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) - throws SQLException { - st.setFloat( name, javaTypeDescriptor.unwrap( value, Float.class, options ) ); - } - }; - } - - @Override - public ValueExtractor getExtractor(final JavaTypeDescriptor javaTypeDescriptor) { - return new BasicExtractor( javaTypeDescriptor, this ) { - @Override - protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { - return javaTypeDescriptor.wrap( rs.getFloat( paramIndex ), options ); - } - - @Override - protected X doExtract(CallableStatement statement, int index, WrapperOptions options) throws SQLException { - return javaTypeDescriptor.wrap( statement.getFloat( index ), options ); - } - - @Override - protected X doExtract(CallableStatement statement, String name, WrapperOptions options) throws SQLException { - return javaTypeDescriptor.wrap( statement.getFloat( name ), options ); - } - }; - } } diff --git a/hibernate-core/src/main/java/org/hibernate/type/internal/StandardBasicTypeImpl.java b/hibernate-core/src/main/java/org/hibernate/type/internal/StandardBasicTypeImpl.java index caadfbecd6..2bbd73c4e7 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/internal/StandardBasicTypeImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/type/internal/StandardBasicTypeImpl.java @@ -61,7 +61,7 @@ public class StandardBasicTypeImpl @Override public CastType getCastType() { if ( getJavaTypeDescriptor() == BooleanTypeDescriptor.INSTANCE ) { - switch ( sqlType() ) { + switch ( getJdbcTypeCode() ) { case Types.BIT: case Types.SMALLINT: case Types.TINYINT: diff --git a/hibernate-core/src/main/java/org/hibernate/type/spi/TypeConfiguration.java b/hibernate-core/src/main/java/org/hibernate/type/spi/TypeConfiguration.java index dcb2a9c2e7..3689f6b849 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/spi/TypeConfiguration.java +++ b/hibernate-core/src/main/java/org/hibernate/type/spi/TypeConfiguration.java @@ -233,7 +233,7 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable { ); try { - int[] jdbcTypes = basicType.sqlTypes( null ); + int[] jdbcTypes = basicType.getSqlTypeCodes( null ); if ( jdbcTypes.length == 1 ) { int jdbcType = jdbcTypes[0]; @@ -650,7 +650,7 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable { return getSqlTemporalType( ( (BasicValuedMapping) type ).getJdbcMapping().getJdbcTypeDescriptor() ); } else if (type instanceof SingleColumnType) { - return getSqlTemporalType( ((SingleColumnType) type).sqlType() ); + return getSqlTemporalType( ((SingleColumnType) type).getJdbcTypeCode() ); } return null; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/nested/NestedEmbeddableMetadataTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/nested/NestedEmbeddableMetadataTest.java index 6c4626cca8..3f24070f2f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/nested/NestedEmbeddableMetadataTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/nested/NestedEmbeddableMetadataTest.java @@ -55,7 +55,7 @@ public class NestedEmbeddableMetadataTest { Component amountMetadata = (Component) investmentMetadata.getProperty( "amount" ).getValue(); SimpleValue currencyMetadata = (SimpleValue) amountMetadata.getProperty( "currency" ).getValue(); CustomType currencyType = (CustomType) currencyMetadata.getType(); - int[] currencySqlTypes = currencyType.sqlTypes( metadata ); + int[] currencySqlTypes = currencyType.getSqlTypeCodes( metadata ); assertEquals( 1, currencySqlTypes.length ); assertJdbcTypeCode( Types.VARCHAR, currencySqlTypes[0] ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/nested/fieldaccess/FieldAccessedNestedEmbeddableMetadataTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/nested/fieldaccess/FieldAccessedNestedEmbeddableMetadataTest.java index 2926ca1066..451dd2bac9 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/nested/fieldaccess/FieldAccessedNestedEmbeddableMetadataTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/nested/fieldaccess/FieldAccessedNestedEmbeddableMetadataTest.java @@ -53,7 +53,7 @@ public class FieldAccessedNestedEmbeddableMetadataTest { Component amountMetadata = (Component) investmentMetadata.getProperty( "amount" ).getValue(); SimpleValue currencyMetadata = (SimpleValue) amountMetadata.getProperty( "currency" ).getValue(); CustomType currencyType = (CustomType) currencyMetadata.getType(); - int[] currencySqlTypes = currencyType.sqlTypes( metadata ); + int[] currencySqlTypes = currencyType.getSqlTypeCodes( metadata ); assertEquals( 1, currencySqlTypes.length ); assertJdbcTypeCode( Types.VARCHAR, currencySqlTypes[0] ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeComparableIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeComparableIdTest.java index 0f50da992f..f3d448676a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeComparableIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeComparableIdTest.java @@ -132,7 +132,7 @@ public class UserTypeComparableIdTest { @Override public int[] sqlTypes() { - return new int[] { SQL_TYPE.sqlType() }; + return new int[] { SQL_TYPE.getJdbcTypeCode() }; } @Override @@ -152,7 +152,7 @@ public class UserTypeComparableIdTest { CustomId customId = (CustomId) value; if ( customId == null ) { - preparedStatement.setNull( index, SQL_TYPE.sqlType() ); + preparedStatement.setNull( index, SQL_TYPE.getJdbcTypeCode() ); } else { preparedStatement.setLong( index, customId.getValue() ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeNonComparableIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeNonComparableIdTest.java index 497c004e64..ad7f2b9d3d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeNonComparableIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeNonComparableIdTest.java @@ -119,7 +119,7 @@ public class UserTypeNonComparableIdTest { @Override public int[] sqlTypes() { - return new int[] { SQL_TYPE.sqlType() }; + return new int[] { SQL_TYPE.getJdbcTypeCode() }; } @Override @@ -139,7 +139,7 @@ public class UserTypeNonComparableIdTest { CustomId customId = (CustomId) value; if ( customId == null ) { - preparedStatement.setNull( index, SQL_TYPE.sqlType() ); + preparedStatement.setNull( index, SQL_TYPE.getJdbcTypeCode() ); } else { preparedStatement.setLong( index, customId.getValue() ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/AndNationalizedTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/AndNationalizedTests.java index 7bdcb2a63d..e4015f0203 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/AndNationalizedTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/AndNationalizedTests.java @@ -6,7 +6,6 @@ */ package org.hibernate.orm.test.mapping.converted.converter; -import java.sql.Types; import javax.persistence.AttributeConverter; import javax.persistence.Convert; import javax.persistence.Entity; @@ -49,7 +48,7 @@ public class AndNationalizedTests extends BaseUnitTestCase { final Dialect dialect = metadata.getDatabase().getDialect(); assertEquals( dialect.getNationalizationSupport().getVarcharVariantCode(), - entityBinding.getProperty( "name" ).getType().sqlTypes( metadata )[0] + entityBinding.getProperty( "name" ).getType().getSqlTypeCodes( metadata )[0] ); } finally { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/formula/FormulaFromHbmTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/formula/FormulaFromHbmTests.java index 87d447dce2..c2b0ef2886 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/formula/FormulaFromHbmTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/formula/FormulaFromHbmTests.java @@ -39,7 +39,7 @@ public class FormulaFromHbmTests { (rootClass) -> { final Property stringFormula = rootClass.getProperty( "stringFormula" ); { - final int[] sqlTypes = stringFormula.getType().sqlTypes( scope.getDomainModel() ); + final int[] sqlTypes = stringFormula.getType().getSqlTypeCodes( scope.getDomainModel() ); assertThat( sqlTypes.length, is( 1 ) ); assertThat( sqlTypes[ 0 ], is( Types.VARCHAR ) ); @@ -49,7 +49,7 @@ public class FormulaFromHbmTests { final Property integerFormula = rootClass.getProperty( "integerFormula" ); { - final int[] sqlTypes = integerFormula.getType().sqlTypes( scope.getDomainModel() ); + final int[] sqlTypes = integerFormula.getType().getSqlTypeCodes( scope.getDomainModel() ); assertThat( sqlTypes.length, is( 1 ) ); assertThat( sqlTypes[ 0 ], is( Types.INTEGER ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/attributeoverrides/AttributeOverrideEnhancedUserTypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/attributeoverrides/AttributeOverrideEnhancedUserTypeTest.java index c09df790be..418ce7d600 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/attributeoverrides/AttributeOverrideEnhancedUserTypeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/attributeoverrides/AttributeOverrideEnhancedUserTypeTest.java @@ -108,8 +108,8 @@ public class AttributeOverrideEnhancedUserTypeTest { @Override public int[] sqlTypes() { return new int[] { - IntegerType.INSTANCE.sqlType(), - IntegerType.INSTANCE.sqlType(), + IntegerType.INSTANCE.getJdbcTypeCode(), + IntegerType.INSTANCE.getJdbcTypeCode(), }; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/type/dynamicparameterized/MyStringType.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/type/dynamicparameterized/MyStringType.java index 678889c905..487ea7a523 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/type/dynamicparameterized/MyStringType.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/type/dynamicparameterized/MyStringType.java @@ -107,7 +107,7 @@ public class MyStringType implements UserType, DynamicParameterizedType { @Override public int[] sqlTypes() { - return new int[] { StringType.INSTANCE.sqlType() }; + return new int[] { StringType.INSTANCE.getJdbcTypeCode() }; } @Override diff --git a/hibernate-core/src/test/java/org/hibernate/test/usertype/StringWrapperUserType.java b/hibernate-core/src/test/java/org/hibernate/test/usertype/StringWrapperUserType.java index ca146024f4..1dd28bc39c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/usertype/StringWrapperUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/test/usertype/StringWrapperUserType.java @@ -25,7 +25,7 @@ public class StringWrapperUserType implements UserType { @Override public int[] sqlTypes() { - return new int[] {StringType.INSTANCE.sqlType()}; + return new int[] {StringType.INSTANCE.getJdbcTypeCode()}; } @Override diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AgeType.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AgeType.java index eae8715774..47e589fd14 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AgeType.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AgeType.java @@ -21,7 +21,7 @@ public class AgeType implements UserType { @Override public int[] sqlTypes() { return new int[] { - IntegerType.INSTANCE.sqlType() + IntegerType.INSTANCE.getJdbcTypeCode() }; }