diff --git a/documentation/src/test/java/org/hibernate/userguide/mapping/basic/CustomBinaryJdbcType.java b/documentation/src/test/java/org/hibernate/userguide/mapping/basic/CustomBinaryJdbcType.java index be401a6c13..6129e87bf3 100644 --- a/documentation/src/test/java/org/hibernate/userguide/mapping/basic/CustomBinaryJdbcType.java +++ b/documentation/src/test/java/org/hibernate/userguide/mapping/basic/CustomBinaryJdbcType.java @@ -25,11 +25,6 @@ public class CustomBinaryJdbcType implements JdbcTypeDescriptor { return Types.VARBINARY; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueBinder getBinder(JavaTypeDescriptor javaTypeDescriptor) { return VarbinaryJdbcTypeDescriptor.INSTANCE.getBinder( javaTypeDescriptor ); diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java index e654725fd3..e642a7ea0b 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java @@ -15,6 +15,7 @@ import java.util.TimeZone; import jakarta.persistence.TemporalType; import org.hibernate.ScrollMode; +import org.hibernate.boot.model.TypeContributions; import org.hibernate.community.dialect.identity.SQLiteIdentityColumnSupport; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.NationalizationSupport; @@ -41,6 +42,7 @@ import org.hibernate.query.TemporalUnit; import org.hibernate.query.TrimSpec; import org.hibernate.query.spi.QueryEngine; import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers; +import org.hibernate.service.ServiceRegistry; import org.hibernate.sql.ast.SqlAstNodeRenderingMode; import org.hibernate.sql.ast.SqlAstTranslator; import org.hibernate.sql.ast.SqlAstTranslatorFactory; @@ -54,6 +56,7 @@ import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.descriptor.jdbc.BlobJdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.ClobJdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor; +import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeDescriptorRegistry; import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate; import static org.hibernate.query.TemporalUnit.DAY; @@ -322,15 +325,12 @@ public class SQLiteDialect extends Dialect { } @Override - public JdbcTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { - switch (sqlCode) { - case Types.BLOB: - return BlobJdbcTypeDescriptor.PRIMITIVE_ARRAY_BINDING; - case Types.CLOB: - return ClobJdbcTypeDescriptor.STRING_BINDING; - default: - return super.getSqlTypeDescriptorOverride( sqlCode ); - } + public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) { + super.contributeTypes( typeContributions, serviceRegistry ); + final JdbcTypeDescriptorRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration() + .getJdbcTypeDescriptorRegistry(); + jdbcTypeRegistry.addDescriptor( Types.BLOB, BlobJdbcTypeDescriptor.PRIMITIVE_ARRAY_BINDING ); + jdbcTypeRegistry.addDescriptor( Types.CLOB, ClobJdbcTypeDescriptor.STRING_BINDING ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java index 1ea0d73ed4..6a76af293a 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java @@ -60,6 +60,7 @@ import org.hibernate.type.descriptor.java.DataHelper; import org.hibernate.type.descriptor.java.DoubleJavaTypeDescriptor; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; import org.hibernate.type.descriptor.jdbc.*; +import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeDescriptorRegistry; import org.hibernate.type.internal.BasicTypeImpl; import java.io.*; @@ -309,11 +310,6 @@ public abstract class AbstractHANADialect extends Dialect { return Types.BLOB; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public ValueBinder getBinder(JavaTypeDescriptor javaTypeDescriptor) { return new BasicBinder( javaTypeDescriptor, this ) { @@ -604,11 +600,6 @@ public abstract class AbstractHANADialect extends Dialect { return "HANABlobTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public ValueExtractor getExtractor(final JavaTypeDescriptor javaTypeDescriptor) { return new BasicExtractor( javaTypeDescriptor, this ) { @@ -1027,29 +1018,6 @@ public abstract class AbstractHANADialect extends Dialect { return SequenceInformationExtractorHANADatabaseImpl.INSTANCE; } - @Override - protected JdbcTypeDescriptor getSqlTypeDescriptorOverride(final int sqlCode) { - switch ( sqlCode ) { - case Types.CLOB: - return this.clobTypeDescriptor; - case Types.NCLOB: - return this.nClobTypeDescriptor; - case Types.BLOB: - return this.blobTypeDescriptor; - case Types.TINYINT: - // tinyint is unsigned on HANA - return SmallIntJdbcTypeDescriptor.INSTANCE; - case Types.VARCHAR: - return this.isUseUnicodeStringTypes() ? NVarcharJdbcTypeDescriptor.INSTANCE : VarcharJdbcTypeDescriptor.INSTANCE; - case Types.CHAR: - return this.isUseUnicodeStringTypes() ? NCharJdbcTypeDescriptor.INSTANCE : CharJdbcTypeDescriptor.INSTANCE; - case Types.DOUBLE: - return this.treatDoubleTypedFieldsAsDecimal ? DecimalJdbcTypeDescriptor.INSTANCE : DoubleJdbcTypeDescriptor.INSTANCE; - default: - return super.getSqlTypeDescriptorOverride( sqlCode ); - } - } - @Override public boolean isCurrentTimestampSelectStringCallable() { return false; @@ -1471,6 +1439,8 @@ public abstract class AbstractHANADialect extends Dialect { this.treatDoubleTypedFieldsAsDecimal = configurationService.getSetting( TREAT_DOUBLE_TYPED_FIELDS_AS_DECIMAL_PARAMETER_NAME, StandardConverters.BOOLEAN, TREAT_DOUBLE_TYPED_FIELDS_AS_DECIMAL_DEFAULT_VALUE ).booleanValue(); + final JdbcTypeDescriptorRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration() + .getJdbcTypeDescriptorRegistry(); if ( this.treatDoubleTypedFieldsAsDecimal ) { registerHibernateType( Types.FLOAT, StandardBasicTypes.BIG_DECIMAL.getName() ); registerHibernateType( Types.REAL, StandardBasicTypes.BIG_DECIMAL.getName() ); @@ -1501,19 +1471,32 @@ public abstract class AbstractHANADialect extends Dialect { typeContributions.getTypeConfiguration().getJdbcToHibernateTypeContributionMap() .get( Types.DOUBLE ) .add( StandardBasicTypes.BIG_DECIMAL.getName() ); - typeContributions.getTypeConfiguration().getJdbcTypeDescriptorRegistry().addDescriptor( + jdbcTypeRegistry.addDescriptor( Types.FLOAT, NumericJdbcTypeDescriptor.INSTANCE ); - typeContributions.getTypeConfiguration().getJdbcTypeDescriptorRegistry().addDescriptor( + jdbcTypeRegistry.addDescriptor( Types.REAL, NumericJdbcTypeDescriptor.INSTANCE ); - typeContributions.getTypeConfiguration().getJdbcTypeDescriptorRegistry().addDescriptor( + jdbcTypeRegistry.addDescriptor( Types.DOUBLE, NumericJdbcTypeDescriptor.INSTANCE ); } + + jdbcTypeRegistry.addDescriptor( Types.CLOB, this.clobTypeDescriptor ); + jdbcTypeRegistry.addDescriptor( Types.NCLOB, this.nClobTypeDescriptor ); + jdbcTypeRegistry.addDescriptor( Types.BLOB, this.blobTypeDescriptor ); + // tinyint is unsigned on HANA + jdbcTypeRegistry.addDescriptor( Types.TINYINT, SmallIntJdbcTypeDescriptor.INSTANCE ); + if ( isUseUnicodeStringTypes() ) { + jdbcTypeRegistry.addDescriptor( Types.VARCHAR, NVarcharJdbcTypeDescriptor.INSTANCE ); + jdbcTypeRegistry.addDescriptor( Types.CHAR, NCharJdbcTypeDescriptor.INSTANCE ); + } + if ( this.treatDoubleTypedFieldsAsDecimal ) { + jdbcTypeRegistry.addDescriptor( Types.DOUBLE, DecimalJdbcTypeDescriptor.INSTANCE ); + } } public JdbcTypeDescriptor getBlobTypeDescriptor() { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java index 6075da8ab9..9ad825d014 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java @@ -46,6 +46,7 @@ import org.hibernate.type.JavaObjectType; import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaTypeDescriptor; import org.hibernate.type.descriptor.jdbc.*; +import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeDescriptorRegistry; import java.sql.CallableStatement; import java.sql.ResultSet; @@ -499,49 +500,37 @@ public class DB2Dialect extends Dialect { return false; } - @Override - protected JdbcTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { - final int version = getVersion(); - - if ( version < 1100 && sqlCode == Types.BOOLEAN ) { - return SmallIntJdbcTypeDescriptor.INSTANCE; - } - else if ( version < 1100 && sqlCode == Types.VARBINARY ) { - // Binary literals were only added in 11. See https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000731.html#d79816e393 - return VarbinaryJdbcTypeDescriptor.INSTANCE_WITHOUT_LITERALS; - } - else if ( version < 970 ) { - return sqlCode == Types.NUMERIC - ? DecimalJdbcTypeDescriptor.INSTANCE - : super.getSqlTypeDescriptorOverride(sqlCode); - } - else { - // See HHH-12753 - // It seems that DB2's JDBC 4.0 support as of 9.5 does not - // support the N-variant methods like NClob or NString. - // Therefore here we overwrite the sql type descriptors to - // use the non-N variants which are supported. - switch ( sqlCode ) { - case Types.NCHAR: - return CharJdbcTypeDescriptor.INSTANCE; - case Types.NCLOB: - return useInputStreamToInsertBlob() - ? ClobJdbcTypeDescriptor.STREAM_BINDING - : ClobJdbcTypeDescriptor.CLOB_BINDING; - case Types.NVARCHAR: - return VarcharJdbcTypeDescriptor.INSTANCE; - case Types.NUMERIC: - return DecimalJdbcTypeDescriptor.INSTANCE; - default: - return super.getSqlTypeDescriptorOverride(sqlCode); - } - } - } - @Override public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) { super.contributeTypes( typeContributions, serviceRegistry ); + final int version = getVersion(); + final JdbcTypeDescriptorRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration() + .getJdbcTypeDescriptorRegistry(); + + if ( version < 1100 ) { + jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, SmallIntJdbcTypeDescriptor.INSTANCE ); + // Binary literals were only added in 11. See https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000731.html#d79816e393 + jdbcTypeRegistry.addDescriptor( Types.VARBINARY, VarbinaryJdbcTypeDescriptor.INSTANCE_WITHOUT_LITERALS ); + if ( version < 970 ) { + jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcTypeDescriptor.INSTANCE ); + } + } + // See HHH-12753 + // It seems that DB2's JDBC 4.0 support as of 9.5 does not + // support the N-variant methods like NClob or NString. + // Therefore here we overwrite the sql type descriptors to + // use the non-N variants which are supported. + jdbcTypeRegistry.addDescriptor( Types.NCHAR, CharJdbcTypeDescriptor.INSTANCE ); + jdbcTypeRegistry.addDescriptor( + Types.NCLOB, + useInputStreamToInsertBlob() + ? ClobJdbcTypeDescriptor.STREAM_BINDING + : ClobJdbcTypeDescriptor.CLOB_BINDING + ); + jdbcTypeRegistry.addDescriptor( Types.NVARCHAR, VarcharJdbcTypeDescriptor.INSTANCE ); + jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcTypeDescriptor.INSTANCE ); + // DB2 requires a custom binder for binding untyped nulls that resolves the type through the statement typeContributions.contributeJdbcTypeDescriptor( ObjectNullResolvingJdbcTypeDescriptor.INSTANCE ); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java index 77521d99e5..c8e284800f 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java @@ -62,6 +62,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.ObjectNullResolvingJdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.SmallIntJdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.TimestampJdbcTypeDescriptor; +import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeDescriptorRegistry; import java.sql.DatabaseMetaData; import java.sql.SQLException; @@ -497,23 +498,16 @@ public class DerbyDialect extends Dialect { return false; } - protected JdbcTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { - if ( getVersion() < 1070 && sqlCode == Types.BOOLEAN) { - return SmallIntJdbcTypeDescriptor.INSTANCE; - } - switch ( sqlCode ) { - case Types.NUMERIC: - return DecimalJdbcTypeDescriptor.INSTANCE; - case Types.TIMESTAMP_WITH_TIMEZONE: - return TimestampJdbcTypeDescriptor.INSTANCE; - default: - return super.getSqlTypeDescriptorOverride(sqlCode); - } - } - @Override public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) { super.contributeTypes( typeContributions, serviceRegistry ); + final JdbcTypeDescriptorRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration() + .getJdbcTypeDescriptorRegistry(); + if ( getVersion() < 1070 ) { + jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, SmallIntJdbcTypeDescriptor.INSTANCE ); + } + jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcTypeDescriptor.INSTANCE ); + jdbcTypeRegistry.addDescriptor( Types.TIMESTAMP_WITH_TIMEZONE, TimestampJdbcTypeDescriptor.INSTANCE ); // Derby requires a custom binder for binding untyped nulls that resolves the type through the statement typeContributions.contributeJdbcTypeDescriptor( ObjectNullResolvingJdbcTypeDescriptor.INSTANCE ); 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 cfac83ae80..af878d1582 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -1004,6 +1004,13 @@ public abstract class Dialect implements ConversionContext { typeContributions.contributeJdbcTypeDescriptor( LongNVarcharJdbcTypeDescriptor.INSTANCE ); typeContributions.contributeJdbcTypeDescriptor( NClobJdbcTypeDescriptor.DEFAULT ); } + + if ( useInputStreamToInsertBlob() ) { + typeContributions.getTypeConfiguration().getJdbcTypeDescriptorRegistry().addDescriptor( + Types.CLOB, + ClobJdbcTypeDescriptor.STREAM_BINDING + ); + } } /** @@ -1156,58 +1163,6 @@ public abstract class Dialect implements ConversionContext { typeNames.put( code, name ); } - /** - * Allows the dialect to override a {@link JdbcTypeDescriptor}. - *

- * If the passed {@code sqlTypeDescriptor} allows itself to be remapped (per - * {@link JdbcTypeDescriptor#canBeRemapped()}), then this method uses - * {@link #getSqlTypeDescriptorOverride} to get an optional override based on the SQL code returned by - * {@link JdbcTypeDescriptor#getJdbcTypeCode()}. - *

- * If this dialect does not provide an override or if the {@code sqlTypeDescriptor} does not allow itself to be - * remapped, then this method simply returns the original passed {@code sqlTypeDescriptor} - * - * @param jdbcTypeDescriptor The {@link JdbcTypeDescriptor} to override - * @return The {@link JdbcTypeDescriptor} that should be used for this dialect; - * if there is no override, then original {@code sqlTypeDescriptor} is returned. - * @throws IllegalArgumentException if {@code sqlTypeDescriptor} is null. - * - * @see #getSqlTypeDescriptorOverride - */ - public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) { - if ( jdbcTypeDescriptor == null ) { - throw new IllegalArgumentException( "sqlTypeDescriptor is null" ); - } - if ( ! jdbcTypeDescriptor.canBeRemapped() ) { - return jdbcTypeDescriptor; - } - - final JdbcTypeDescriptor overridden = getSqlTypeDescriptorOverride( jdbcTypeDescriptor.getJdbcTypeCode() ); - return overridden == null ? jdbcTypeDescriptor : overridden; - } - - /** - * Returns the {@link JdbcTypeDescriptor} that should be used to handle the given JDBC type code. Returns - * {@code null} if there is no override. - * - * @param sqlCode A {@link Types} constant indicating the SQL column type - * @return The {@link JdbcTypeDescriptor} to use as an override, or {@code null} if there is no override. - */ - protected JdbcTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { - JdbcTypeDescriptor descriptor; - switch ( sqlCode ) { - case Types.CLOB: { - descriptor = useInputStreamToInsertBlob() ? ClobJdbcTypeDescriptor.STREAM_BINDING : null; - break; - } - default: { - descriptor = null; - break; - } - } - return descriptor; - } - /** * The legacy behavior of Hibernate. LOBs are not processed by merge */ 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 f5b934d2d7..3c216f97d0 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java @@ -71,6 +71,7 @@ import org.hibernate.type.descriptor.jdbc.BlobJdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.ClobJdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.ObjectNullAsBinaryTypeJdbcTypeDescriptor; +import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeDescriptorRegistry; import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate; import static org.hibernate.query.TemporalUnit.*; @@ -345,25 +346,6 @@ public class PostgreSQLDialect extends Dialect { } } - @Override - public JdbcTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { - // For discussion of BLOB support in Postgres, as of 8.4, have a peek at - // http://jdbc.postgresql.org/documentation/84/binary-data.html. - // For the effects in regards to Hibernate see http://in.relation.to/15492.lace - switch ( sqlCode ) { - case Types.BLOB: - // Force BLOB binding. Otherwise, byte[] fields annotated - // with @Lob will attempt to use - // BlobTypeDescriptor.PRIMITIVE_ARRAY_BINDING. Since the - // dialect uses oid for Blobs, byte arrays cannot be used. - return BlobJdbcTypeDescriptor.BLOB_BINDING; - case Types.CLOB: - return ClobJdbcTypeDescriptor.CLOB_BINDING; - default: - return super.getSqlTypeDescriptorOverride( sqlCode ); - } - } - @Override public NameQualifierSupport getNameQualifierSupport() { // This method is overridden so the correct value will be returned when @@ -943,6 +925,19 @@ public class PostgreSQLDialect extends Dialect { public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) { super.contributeTypes(typeContributions, serviceRegistry); + final JdbcTypeDescriptorRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration() + .getJdbcTypeDescriptorRegistry(); + // For discussion of BLOB support in Postgres, as of 8.4, have a peek at + // http://jdbc.postgresql.org/documentation/84/binary-data.html. + // For the effects in regards to Hibernate see http://in.relation.to/15492.lace + + // Force BLOB binding. Otherwise, byte[] fields annotated + // with @Lob will attempt to use + // BlobTypeDescriptor.PRIMITIVE_ARRAY_BINDING. Since the + // dialect uses oid for Blobs, byte arrays cannot be used. + jdbcTypeRegistry.addDescriptor( Types.BLOB, BlobJdbcTypeDescriptor.BLOB_BINDING ); + jdbcTypeRegistry.addDescriptor( Types.CLOB, ClobJdbcTypeDescriptor.CLOB_BINDING ); + if ( getVersion() >= 820 ) { // HHH-9562 typeContributions.contributeType( PostgresUUIDType.INSTANCE ); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java index 966aca4be7..0b1e1e4f3f 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java @@ -8,6 +8,7 @@ package org.hibernate.dialect; import org.hibernate.*; import org.hibernate.boot.Metadata; +import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.relational.QualifiedSequenceName; import org.hibernate.boot.model.relational.Sequence; import org.hibernate.dialect.function.CommonFunctionFactory; @@ -35,6 +36,7 @@ import org.hibernate.query.CastType; import org.hibernate.query.FetchClauseType; import org.hibernate.query.TemporalUnit; import org.hibernate.query.spi.QueryEngine; +import org.hibernate.service.ServiceRegistry; import org.hibernate.sql.ast.SqlAstNodeRenderingMode; import org.hibernate.sql.ast.SqlAstTranslator; import org.hibernate.sql.ast.SqlAstTranslatorFactory; @@ -160,10 +162,13 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { } @Override - protected JdbcTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { - return sqlCode == Types.TINYINT - ? SmallIntJdbcTypeDescriptor.INSTANCE - : super.getSqlTypeDescriptorOverride( sqlCode ); + public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) { + super.contributeTypes( typeContributions, serviceRegistry ); + + typeContributions.getTypeConfiguration().getJdbcTypeDescriptorRegistry().addDescriptor( + Types.TINYINT, + SmallIntJdbcTypeDescriptor.INSTANCE + ); } @Override 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 1b19ae0f9d..4e8ff210ca 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASEDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASEDialect.java @@ -15,6 +15,7 @@ import java.util.Map; import jakarta.persistence.TemporalType; import org.hibernate.LockOptions; +import org.hibernate.boot.model.TypeContributions; import org.hibernate.dialect.pagination.LimitHandler; import org.hibernate.dialect.pagination.TopLimitHandler; import org.hibernate.engine.jdbc.Size; @@ -27,6 +28,7 @@ import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor; import org.hibernate.exception.spi.ViolatedConstraintNameExtractor; import org.hibernate.internal.util.JdbcExceptionHelper; import org.hibernate.query.TemporalUnit; +import org.hibernate.service.ServiceRegistry; import org.hibernate.sql.ForUpdateFragment; import org.hibernate.sql.ast.SqlAstTranslator; import org.hibernate.sql.ast.SqlAstTranslatorFactory; @@ -37,6 +39,7 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor; import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.TimestampJdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.TinyIntJdbcTypeDescriptor; +import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeDescriptorRegistry; import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate; @@ -182,17 +185,15 @@ public class SybaseASEDialect extends SybaseDialect { } @Override - protected JdbcTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { - switch ( sqlCode ) { - case Types.BOOLEAN: - return TinyIntJdbcTypeDescriptor.INSTANCE; - case Types.TIMESTAMP_WITH_TIMEZONE: - // At least the jTDS driver does not support this type code - if ( jtdsDriver ) { - return TimestampJdbcTypeDescriptor.INSTANCE; - } - default: - return super.getSqlTypeDescriptorOverride( sqlCode ); + public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) { + super.contributeTypes( typeContributions, serviceRegistry ); + + final JdbcTypeDescriptorRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration() + .getJdbcTypeDescriptorRegistry(); + jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, TinyIntJdbcTypeDescriptor.INSTANCE ); + // At least the jTDS driver does not support this type code + if ( jtdsDriver ) { + jdbcTypeRegistry.addDescriptor( Types.TIMESTAMP_WITH_TIMEZONE, TimestampJdbcTypeDescriptor.INSTANCE ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java index 0d49d0c6f0..4bf5f79b8b 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java @@ -113,14 +113,6 @@ public class SybaseDialect extends AbstractTransactSQLDialect { ); } - @Override - public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) { - if ( jtdsDriver && TinyIntJdbcTypeDescriptor.INSTANCE == jdbcTypeDescriptor ) { - return SmallIntJdbcTypeDescriptor.INSTANCE; - } - return super.remapSqlTypeDescriptor( jdbcTypeDescriptor ); - } - @Override public SqmTranslatorFactory getSqmTranslatorFactory() { return new StandardSqmTranslatorFactory() { @@ -173,18 +165,23 @@ public class SybaseDialect extends AbstractTransactSQLDialect { @Override public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) { super.contributeTypes(typeContributions, serviceRegistry); - + final JdbcTypeDescriptorRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration() + .getJdbcTypeDescriptorRegistry(); if ( jtdsDriver ) { - typeContributions.getTypeConfiguration().getJdbcTypeDescriptorRegistry().addDescriptor( - Types.NCLOB, - ClobJdbcTypeDescriptor.CLOB_BINDING - ); - typeContributions.getTypeConfiguration().getJdbcTypeDescriptorRegistry().addDescriptor( - Types.NVARCHAR, - ClobJdbcTypeDescriptor.CLOB_BINDING - ); - typeContributions.contributeJdbcTypeDescriptor( ClobJdbcTypeDescriptor.CLOB_BINDING ); + jdbcTypeRegistry.addDescriptor( Types.TINYINT, SmallIntJdbcTypeDescriptor.INSTANCE ); + + // The jTDS driver doesn't support the JDBC4 signatures using 'long length' for stream bindings + jdbcTypeRegistry.addDescriptor( Types.CLOB, ClobJdbcTypeDescriptor.CLOB_BINDING ); + jdbcTypeRegistry.addDescriptor( Types.NCLOB, NClobJdbcTypeDescriptor.NCLOB_BINDING ); + // The jTDS driver doesn't support the JDBC4 setNString method + jdbcTypeRegistry.addDescriptor( Types.NVARCHAR, NClobJdbcTypeDescriptor.NCLOB_BINDING ); } + else { + // Some Sybase drivers cannot support getClob. See HHH-7889 + jdbcTypeRegistry.addDescriptor( Types.CLOB, ClobJdbcTypeDescriptor.STREAM_BINDING_EXTRACTING ); + } + + jdbcTypeRegistry.addDescriptor( Types.BLOB, BlobJdbcTypeDescriptor.PRIMITIVE_ARRAY_BINDING ); // Sybase requires a custom binder for binding untyped nulls with the NULL type typeContributions.contributeJdbcTypeDescriptor( ObjectNullAsNullTypeJdbcTypeDescriptor.INSTANCE ); @@ -206,30 +203,6 @@ public class SybaseDialect extends AbstractTransactSQLDialect { return jtdsDriver ? NationalizationSupport.IMPLICIT : super.getNationalizationSupport(); } - @Override - protected JdbcTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { - switch (sqlCode) { - case Types.BLOB: - return BlobJdbcTypeDescriptor.PRIMITIVE_ARRAY_BINDING; - case Types.CLOB: - // Some Sybase drivers cannot support getClob. See HHH-7889 - // The jTDS driver doesn't support the JDBC4 signatures using 'long length' for stream bindings - return jtdsDriver ? ClobJdbcTypeDescriptor.CLOB_BINDING : ClobJdbcTypeDescriptor.STREAM_BINDING_EXTRACTING; - case Types.NCLOB: - // The jTDS driver doesn't support the JDBC4 signatures using 'long length' for stream bindings - if ( jtdsDriver ) { - return NClobJdbcTypeDescriptor.NCLOB_BINDING; - } - case Types.NVARCHAR: - // The jTDS driver doesn't support the JDBC4 setNString method - if ( jtdsDriver ) { - return NClobJdbcTypeDescriptor.NCLOB_BINDING; - } - default: - return super.getSqlTypeDescriptorOverride( sqlCode ); - } - } - @Override public void initializeFunctionRegistry(QueryEngine queryEngine) { super.initializeFunctionRegistry(queryEngine); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingWrapperOptions.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingWrapperOptions.java index 6f7b671df7..76b6344b43 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingWrapperOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/AbstractDelegatingWrapperOptions.java @@ -38,11 +38,6 @@ public abstract class AbstractDelegatingWrapperOptions implements WrapperOptions return delegate().getLobCreator(); } - @Override - public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) { - return delegate().remapSqlTypeDescriptor( jdbcTypeDescriptor ); - } - @Override public TimeZone getJdbcTimeZone() { return delegate().getJdbcTimeZone(); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java index 611fbb7dc5..0fd8b3e0bc 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java @@ -1098,11 +1098,6 @@ public class SessionDelegatorBaseImpl implements SessionImplementor { return delegate.getLobCreator(); } - @Override - public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) { - return delegate.remapSqlTypeDescriptor( jdbcTypeDescriptor ); - } - @Override public Integer getJdbcBatchSize() { return delegate.getJdbcBatchSize(); diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java index 1457b60cbb..3b5b998c2e 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java @@ -583,11 +583,6 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont ); } - @Override - public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) { - return fastSessionServices.remapSqlTypeDescriptor( jdbcTypeDescriptor ); - } - @Override public TimeZone getJdbcTimeZone() { return jdbcTimeZone; diff --git a/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java b/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java index c90112c2db..b86f7dce22 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java @@ -254,15 +254,6 @@ public final class FastSessionServices { return elr.getEventListenerGroup( type ); } - public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) { - if ( !jdbcTypeDescriptor.canBeRemapped() ) { - return jdbcTypeDescriptor; - } - - final JdbcTypeDescriptor remapped = dialect.remapSqlTypeDescriptor( jdbcTypeDescriptor ); - return remapped == null ? jdbcTypeDescriptor : remapped; - } - private static boolean isTransactionAccessible(SessionFactoryImpl sf, TransactionCoordinatorBuilder transactionCoordinatorBuilder) { // JPA requires that access not be provided to the transaction when using JTA. // This is overridden when SessionFactoryOptions isJtaTransactionAccessEnabled() is true. 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 bc0df622b6..932b83732b 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java @@ -695,17 +695,9 @@ public abstract class SimpleValue implements KeyValue { jdbcTypeCode = NationalizedTypeMappings.toNationalizedTypeCode( jdbcTypeCode ); } - // find the standard SqlTypeDescriptor for that JDBC type code (allow it to be remapped if needed!) - final JdbcTypeDescriptor jdbcTypeDescriptor = getMetadata() - .getMetadataBuildingOptions() - .getServiceRegistry() - .getService( JdbcServices.class ) - .getJdbcEnvironment() - .getDialect() - .remapSqlTypeDescriptor( - metadata.getTypeConfiguration() + final JdbcTypeDescriptor jdbcTypeDescriptor = metadata.getTypeConfiguration() .getJdbcTypeDescriptorRegistry() - .getDescriptor( jdbcTypeCode ) ); + .getDescriptor( jdbcTypeCode ); // and finally construct the adapter, which injects the AttributeConverter calls into the binding/extraction // process... diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/SessionFactoryBasedWrapperOptions.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/SessionFactoryBasedWrapperOptions.java index 9244f85a8e..59825764c4 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/SessionFactoryBasedWrapperOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/SessionFactoryBasedWrapperOptions.java @@ -46,11 +46,6 @@ public class SessionFactoryBasedWrapperOptions implements WrapperOptions { return factory.getJdbcServices().getLobCreator( getSession() ); } - @Override - public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) { - return jdbcTypeDescriptor; - } - @Override public TimeZone getJdbcTimeZone() { return factory.getSessionFactoryOptions().getJdbcTimeZone(); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java index 5aeb04665f..34ae0224b9 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java @@ -292,11 +292,6 @@ public abstract class AbstractSqlAstTranslator implemen return sessionFactory.getFastSessionServices().getPreferredSqlTypeCodeForBoolean(); } - @Override - public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) { - return sessionFactory.getFastSessionServices().remapSqlTypeDescriptor( jdbcTypeDescriptor ); - } - @Override public TimeZone getJdbcTimeZone() { return sessionFactory.getSessionFactoryOptions().getJdbcTimeZone(); 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 cbea449882..7f9d056eaa 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java @@ -301,11 +301,7 @@ public abstract class AbstractStandardBasicType @SuppressWarnings({ "unchecked" }) protected void nullSafeSet(PreparedStatement st, Object value, int index, WrapperOptions options) throws SQLException { - remapSqlTypeDescriptor( options ).getBinder( javaTypeDescriptor ).bind( st, ( T ) value, index, options ); - } - - protected JdbcTypeDescriptor remapSqlTypeDescriptor(WrapperOptions options) { - return options.remapSqlTypeDescriptor( jdbcTypeDescriptor ); + jdbcTypeDescriptor.getBinder( javaTypeDescriptor ).bind( st, ( T ) value, index, options ); } public void set(PreparedStatement st, T value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { @@ -408,7 +404,7 @@ public abstract class AbstractStandardBasicType @Override public T extract(CallableStatement statement, int startIndex, final SharedSessionContractImplementor session) throws SQLException { - return remapSqlTypeDescriptor( session ).getExtractor( javaTypeDescriptor ).extract( + return jdbcTypeDescriptor.getExtractor( javaTypeDescriptor ).extract( statement, startIndex, session @@ -417,7 +413,7 @@ public abstract class AbstractStandardBasicType @Override public T extract(CallableStatement statement, String paramName, final SharedSessionContractImplementor session) throws SQLException { - return remapSqlTypeDescriptor( session ).getExtractor( javaTypeDescriptor ).extract( + return jdbcTypeDescriptor.getExtractor( javaTypeDescriptor ).extract( statement, paramName, session @@ -441,7 +437,7 @@ public abstract class AbstractStandardBasicType @SuppressWarnings("unchecked") protected final void nullSafeSet(CallableStatement st, Object value, String name, WrapperOptions options) throws SQLException { - remapSqlTypeDescriptor( options ).getBinder( javaTypeDescriptor ).bind( st, (T) value, name, options ); + jdbcTypeDescriptor.getBinder( javaTypeDescriptor ).bind( st, (T) value, name, options ); } @Override 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 99744fe217..984e308d3c 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 BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/WrapperOptions.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/WrapperOptions.java index 73921815b5..7ab78748b9 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/WrapperOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/WrapperOptions.java @@ -45,15 +45,6 @@ public interface WrapperOptions { */ LobCreator getLobCreator(); - /** - * Allow remapping of descriptors for dealing with sql type. - * - * @param jdbcTypeDescriptor The known descriptor - * - * @return The remapped descriptor. May be the same as the known descriptor indicating no remapping. - */ - JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor); - /** * The JDBC {@link TimeZone} used when persisting Timestamp and DateTime properties into the database. * This setting is used when storing timestamps using the {@link java.sql.PreparedStatement#setTimestamp(int, Timestamp, Calendar)} method. diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/converter/AttributeConverterJdbcTypeDescriptorAdapter.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/converter/AttributeConverterJdbcTypeDescriptorAdapter.java index c5a6d00276..2a485568db 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/converter/AttributeConverterJdbcTypeDescriptorAdapter.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/converter/AttributeConverterJdbcTypeDescriptorAdapter.java @@ -60,13 +60,6 @@ public class AttributeConverterJdbcTypeDescriptorAdapter implements JdbcTypeDesc return "AttributeConverterSqlTypeDescriptorAdapter(" + converter.getClass().getName() + ")"; } - @Override - public boolean canBeRemapped() { - // any remapping of the underlying SqlTypeDescriptor should have - // happened prior to it being passed to us. - return false; - } - // Binding ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BigIntJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BigIntJdbcTypeDescriptor.java index 8b8ecc0faa..05944b73c3 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BigIntJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BigIntJdbcTypeDescriptor.java @@ -36,11 +36,6 @@ public class BigIntJdbcTypeDescriptor implements JdbcTypeDescriptor { return Types.BIGINT; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BlobJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BlobJdbcTypeDescriptor.java index e37559ee23..fb95ac20d7 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BlobJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BlobJdbcTypeDescriptor.java @@ -47,11 +47,6 @@ public abstract class BlobJdbcTypeDescriptor implements JdbcTypeDescriptor { return "BlobTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BooleanJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BooleanJdbcTypeDescriptor.java index 97a55ca95b..16c3c5b983 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BooleanJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/BooleanJdbcTypeDescriptor.java @@ -45,11 +45,6 @@ public class BooleanJdbcTypeDescriptor implements AdjustableJdbcTypeDescriptor { return "BooleanTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ClobJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ClobJdbcTypeDescriptor.java index a07ff7d447..3a1ce652e3 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ClobJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ClobJdbcTypeDescriptor.java @@ -43,11 +43,6 @@ public abstract class ClobJdbcTypeDescriptor implements AdjustableJdbcTypeDescri return "ClobTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public JdbcTypeDescriptor resolveIndicatedType( JdbcTypeDescriptorIndicators indicators, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DateJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DateJdbcTypeDescriptor.java index d38f5bc5c0..f9099d4061 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DateJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DateJdbcTypeDescriptor.java @@ -50,11 +50,6 @@ public class DateJdbcTypeDescriptor implements JdbcTypeDescriptor { return "DateTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DecimalJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DecimalJdbcTypeDescriptor.java index 5a39c22174..87d8e9f015 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DecimalJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DecimalJdbcTypeDescriptor.java @@ -47,11 +47,6 @@ public class DecimalJdbcTypeDescriptor implements JdbcTypeDescriptor { return "DecimalTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DoubleJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DoubleJdbcTypeDescriptor.java index c12a18348b..fd912eddf1 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DoubleJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/DoubleJdbcTypeDescriptor.java @@ -57,11 +57,6 @@ public class DoubleJdbcTypeDescriptor implements JdbcTypeDescriptor { return "DoubleTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/FloatJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/FloatJdbcTypeDescriptor.java index 5af975d21f..9680e18d77 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/FloatJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/FloatJdbcTypeDescriptor.java @@ -47,11 +47,6 @@ public class FloatJdbcTypeDescriptor implements JdbcTypeDescriptor { return "FloatTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/IntegerJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/IntegerJdbcTypeDescriptor.java index 7bded1259f..34c3a1b430 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/IntegerJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/IntegerJdbcTypeDescriptor.java @@ -46,11 +46,6 @@ public class IntegerJdbcTypeDescriptor implements JdbcTypeDescriptor { return "IntegerTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, 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 940460b74b..9fae6d926e 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 @@ -55,16 +55,6 @@ public interface JdbcTypeDescriptor extends Serializable { return getJdbcTypeCode(); } - /** - * Is this descriptor available for remapping? - * - * @return {@code true} indicates this descriptor can be remapped; otherwise, {@code false} - * - * @see org.hibernate.type.descriptor.WrapperOptions#remapSqlTypeDescriptor - * @see org.hibernate.dialect.Dialect#remapSqlTypeDescriptor - */ - boolean canBeRemapped(); - default BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer precision, Integer scale, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NClobJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NClobJdbcTypeDescriptor.java index 024bacb057..2862e73e26 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NClobJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NClobJdbcTypeDescriptor.java @@ -41,11 +41,6 @@ public abstract class NClobJdbcTypeDescriptor implements JdbcTypeDescriptor { return "NClobTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public ValueExtractor getExtractor(final JavaTypeDescriptor javaTypeDescriptor) { return new BasicExtractor( javaTypeDescriptor, this ) { diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NVarcharJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NVarcharJdbcTypeDescriptor.java index aeb60dec01..a21c268ce9 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NVarcharJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NVarcharJdbcTypeDescriptor.java @@ -46,11 +46,6 @@ public class NVarcharJdbcTypeDescriptor implements JdbcTypeDescriptor { return "NVarcharTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NullJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NullJdbcTypeDescriptor.java index a98dd07bdb..8172dc176a 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NullJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/NullJdbcTypeDescriptor.java @@ -32,11 +32,6 @@ public class NullJdbcTypeDescriptor implements JdbcTypeDescriptor { return Types.NULL; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueExtractor getExtractor(JavaTypeDescriptor javaTypeDescriptor) { return null; diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectJdbcTypeDescriptor.java index 8f583b4871..38c33ec431 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/ObjectJdbcTypeDescriptor.java @@ -45,11 +45,6 @@ public class ObjectJdbcTypeDescriptor implements JdbcTypeDescriptor { return "ObjectSqlTypeDescriptor(" + jdbcTypeCode + ")"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public ValueBinder getBinder(JavaTypeDescriptor javaTypeDescriptor) { if ( Serializable.class.isAssignableFrom( javaTypeDescriptor.getJavaTypeClass() ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/SmallIntJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/SmallIntJdbcTypeDescriptor.java index 2ba3f9eb2f..7440abb51e 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/SmallIntJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/SmallIntJdbcTypeDescriptor.java @@ -46,11 +46,6 @@ public class SmallIntJdbcTypeDescriptor implements JdbcTypeDescriptor { return "SmallIntTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimeJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimeJdbcTypeDescriptor.java index da1d60bdb7..2ccd3d5fe7 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimeJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimeJdbcTypeDescriptor.java @@ -50,11 +50,6 @@ public class TimeJdbcTypeDescriptor implements JdbcTypeDescriptor { return "TimeTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampJdbcTypeDescriptor.java index 08c24fa9f6..dfad88029c 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampJdbcTypeDescriptor.java @@ -50,11 +50,6 @@ public class TimestampJdbcTypeDescriptor implements JdbcTypeDescriptor { return "TimestampTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampWithTimeZoneJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampWithTimeZoneJdbcTypeDescriptor.java index 777edca155..96aa10da00 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampWithTimeZoneJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TimestampWithTimeZoneJdbcTypeDescriptor.java @@ -49,11 +49,6 @@ public class TimestampWithTimeZoneJdbcTypeDescriptor implements JdbcTypeDescript return "TimestampWithTimeZoneDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TinyIntJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TinyIntJdbcTypeDescriptor.java index f582b29872..6f9e27da1c 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TinyIntJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/TinyIntJdbcTypeDescriptor.java @@ -49,11 +49,6 @@ public class TinyIntJdbcTypeDescriptor implements JdbcTypeDescriptor { return "TinyIntTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarbinaryJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarbinaryJdbcTypeDescriptor.java index c6734c4a11..a54e3b2422 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarbinaryJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarbinaryJdbcTypeDescriptor.java @@ -54,11 +54,6 @@ public class VarbinaryJdbcTypeDescriptor implements AdjustableJdbcTypeDescriptor return Types.VARBINARY; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarcharJdbcTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarcharJdbcTypeDescriptor.java index bee2a8c475..c2d8cb3683 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarcharJdbcTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarcharJdbcTypeDescriptor.java @@ -47,11 +47,6 @@ public class VarcharJdbcTypeDescriptor implements AdjustableJdbcTypeDescriptor { return "VarcharTypeDescriptor"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public BasicJavaTypeDescriptor getJdbcRecommendedJavaTypeMapping( Integer length, diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/JdbcTypeDescriptorRegistry.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/JdbcTypeDescriptorRegistry.java index 86813e0c0f..f6e2a7d100 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/JdbcTypeDescriptorRegistry.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/spi/JdbcTypeDescriptorRegistry.java @@ -29,7 +29,7 @@ import org.jboss.logging.Logger; public class JdbcTypeDescriptorRegistry implements JdbcTypeDescriptorBaseline.BaselineTarget, Serializable { private static final Logger log = Logger.getLogger( JdbcTypeDescriptorRegistry.class ); - private ConcurrentHashMap descriptorMap = new ConcurrentHashMap<>(); + private final ConcurrentHashMap descriptorMap = new ConcurrentHashMap<>(); public JdbcTypeDescriptorRegistry(TypeConfiguration typeConfiguration) { // this.typeConfiguration = typeConfiguration; diff --git a/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeSqlTypeAdapter.java b/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeSqlTypeAdapter.java index 1c34a170c0..3649adb19a 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeSqlTypeAdapter.java +++ b/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeSqlTypeAdapter.java @@ -51,11 +51,6 @@ public class UserTypeSqlTypeAdapter implements JdbcTypeDescriptor { return userType.sqlTypes()[0]; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override @SuppressWarnings({ "unchecked" }) public ValueBinder getBinder(JavaTypeDescriptor javaTypeDescriptor) { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/basics/sql/JdbcTypeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/basics/sql/JdbcTypeTests.java index a515bb2a74..ebad5f06cb 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/basics/sql/JdbcTypeTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/basics/sql/JdbcTypeTests.java @@ -152,11 +152,6 @@ public class JdbcTypeTests { return Types.TINYINT; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueBinder getBinder(JavaTypeDescriptor javaTypeDescriptor) { return TinyIntJdbcTypeDescriptor.INSTANCE.getBinder( javaTypeDescriptor ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/custom/MyCustomJdbcTypeDescriptor.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/custom/MyCustomJdbcTypeDescriptor.java index bdca7dee9d..697fc54c99 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/custom/MyCustomJdbcTypeDescriptor.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/custom/MyCustomJdbcTypeDescriptor.java @@ -45,11 +45,6 @@ public class MyCustomJdbcTypeDescriptor implements JdbcTypeDescriptor { return Types.VARCHAR; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueBinder getBinder(JavaTypeDescriptor javaTypeDescriptor) { return new BasicBinder( javaTypeDescriptor, this ) { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/nationalized/MaterializedNClobBindTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/nationalized/MaterializedNClobBindTest.java index 3f9fd81c7b..b92dad82e8 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/nationalized/MaterializedNClobBindTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/nationalized/MaterializedNClobBindTest.java @@ -111,11 +111,6 @@ public class MaterializedNClobBindTest { return NonContextualLobCreator.INSTANCE; } - @Override - public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) { - return null; - } - @Override public TimeZone getJdbcTimeZone() { return null; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/QueryParametersValidationArrayTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/QueryParametersValidationArrayTest.java index f76574ce52..dcb46d0837 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/QueryParametersValidationArrayTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/QueryParametersValidationArrayTest.java @@ -100,11 +100,6 @@ public class QueryParametersValidationArrayTest { return Types.ARRAY; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public ValueBinder getBinder(JavaTypeDescriptor javaTypeDescriptor) { return new BasicBinder( javaTypeDescriptor, this) { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/H2DialectOverridePrefixedVarcharSqlTypeDesc.java b/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/H2DialectOverridePrefixedVarcharSqlTypeDesc.java deleted file mode 100644 index 4172c519c5..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/H2DialectOverridePrefixedVarcharSqlTypeDesc.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.orm.test.typeoverride; - -import org.hibernate.dialect.H2Dialect; -import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.VarcharJdbcTypeDescriptor; - -/** - * - * @author Gail Badner - */ -public class H2DialectOverridePrefixedVarcharSqlTypeDesc extends H2Dialect { - @Override - public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) { - return jdbcTypeDescriptor == StoredPrefixedStringType.INSTANCE.getJdbcTypeDescriptor() ? - VarcharJdbcTypeDescriptor.INSTANCE : - super.remapSqlTypeDescriptor( jdbcTypeDescriptor ); - } -} - diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/H2DialectOverrideVarcharSqlCode.java b/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/H2DialectOverrideVarcharSqlCode.java deleted file mode 100644 index 99d31cc2ae..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/H2DialectOverrideVarcharSqlCode.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.orm.test.typeoverride; - -import java.sql.Types; - -import org.hibernate.dialect.H2Dialect; -import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor; - -/** - * - * @author Gail Badner - */ -public class H2DialectOverrideVarcharSqlCode extends H2Dialect { - @Override - public JdbcTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { - return sqlCode == Types.VARCHAR ? - StoredPrefixedStringType.INSTANCE.getJdbcTypeDescriptor() : - super.getSqlTypeDescriptorOverride( sqlCode ); - } -} - diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/TypeOverrideTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/TypeOverrideTest.java index 6ca634b803..caefdb3aa4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/TypeOverrideTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/typeoverride/TypeOverrideTest.java @@ -6,6 +6,8 @@ */ package org.hibernate.orm.test.typeoverride; +import java.sql.Types; + import org.hibernate.boot.MetadataBuilder; import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.CockroachDialect; @@ -18,6 +20,8 @@ import org.hibernate.type.descriptor.jdbc.IntegerJdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.VarbinaryJdbcTypeDescriptor; import org.hibernate.type.descriptor.jdbc.VarcharJdbcTypeDescriptor; +import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeDescriptorRegistry; +import org.hibernate.type.spi.TypeConfiguration; import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest; import org.hibernate.testing.orm.junit.SkipForDialect; @@ -46,73 +50,44 @@ public class TypeOverrideTest extends BaseSessionFactoryFunctionalTest { @Test public void testStandardBasicSqlTypeDescriptor() { + final JdbcTypeDescriptorRegistry jdbcTypeRegistry = getMetadata().getTypeConfiguration() + .getJdbcTypeDescriptorRegistry(); // no override - assertSame( IntegerJdbcTypeDescriptor.INSTANCE, remapSqlTypeDescriptor( IntegerJdbcTypeDescriptor.INSTANCE ) ); + assertSame( IntegerJdbcTypeDescriptor.INSTANCE, jdbcTypeRegistry.getDescriptor( Types.INTEGER ) ); // A few dialects explicitly override BlobTypeDescriptor.DEFAULT if ( CockroachDialect.class.isInstance( getDialect() ) ) { assertSame( VarbinaryJdbcTypeDescriptor.INSTANCE, - getDialect().remapSqlTypeDescriptor( BlobJdbcTypeDescriptor.DEFAULT ) + jdbcTypeRegistry.getDescriptor( Types.BLOB ) ); } - else if ( PostgreSQL81Dialect.class.isInstance( getDialect() ) || PostgreSQLDialect.class.isInstance( getDialect() ) ) { + else if ( PostgreSQLDialect.class.isInstance( getDialect() ) ) { assertSame( BlobJdbcTypeDescriptor.BLOB_BINDING, - getDialect().remapSqlTypeDescriptor( BlobJdbcTypeDescriptor.DEFAULT ) + jdbcTypeRegistry.getDescriptor( Types.BLOB ) ); } else if ( SybaseDialect.class.isInstance( getDialect() ) ) { assertSame( BlobJdbcTypeDescriptor.PRIMITIVE_ARRAY_BINDING, - getDialect().remapSqlTypeDescriptor( BlobJdbcTypeDescriptor.DEFAULT ) + jdbcTypeRegistry.getDescriptor( Types.BLOB ) ); } else if ( AbstractHANADialect.class.isInstance( getDialect() ) ) { assertSame( ( (AbstractHANADialect) getDialect() ).getBlobTypeDescriptor(), - getDialect().remapSqlTypeDescriptor( BlobJdbcTypeDescriptor.DEFAULT ) + jdbcTypeRegistry.getDescriptor( Types.BLOB ) ); } else { assertSame( BlobJdbcTypeDescriptor.DEFAULT, - getDialect().remapSqlTypeDescriptor( BlobJdbcTypeDescriptor.DEFAULT ) + jdbcTypeRegistry.getDescriptor( Types.BLOB ) ); } } - @Test - public void testNonStandardSqlTypeDescriptor() { - // no override - JdbcTypeDescriptor jdbcTypeDescriptor = new IntegerJdbcTypeDescriptor() { - @Override - public boolean canBeRemapped() { - return false; - } - }; - assertSame( jdbcTypeDescriptor, remapSqlTypeDescriptor( jdbcTypeDescriptor ) ); - } - - @Test - public void testDialectWithNonStandardSqlTypeDescriptor() { - assertNotSame( VarcharJdbcTypeDescriptor.INSTANCE, StoredPrefixedStringType.INSTANCE.getJdbcTypeDescriptor() ); - final Dialect dialect = new H2DialectOverridePrefixedVarcharSqlTypeDesc(); - final JdbcTypeDescriptor remapped = remapSqlTypeDescriptor( - dialect, - StoredPrefixedStringType.PREFIXED_VARCHAR_TYPE_DESCRIPTOR - ); - assertSame( VarcharJdbcTypeDescriptor.INSTANCE, remapped ); - } - - private JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) { - return remapSqlTypeDescriptor( sessionFactory().getDialect(), jdbcTypeDescriptor ); - } - - private JdbcTypeDescriptor remapSqlTypeDescriptor(Dialect dialect, JdbcTypeDescriptor jdbcTypeDescriptor) { - return dialect.remapSqlTypeDescriptor( jdbcTypeDescriptor ); - } - @AfterEach public void tearDown() { inTransaction( diff --git a/hibernate-core/src/test/java/org/hibernate/test/id/usertype/inet/InetJdbcTypeDescriptor.java b/hibernate-core/src/test/java/org/hibernate/test/id/usertype/inet/InetJdbcTypeDescriptor.java index 0b756ffb32..0f0ace07b9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/id/usertype/inet/InetJdbcTypeDescriptor.java +++ b/hibernate-core/src/test/java/org/hibernate/test/id/usertype/inet/InetJdbcTypeDescriptor.java @@ -35,11 +35,6 @@ public class InetJdbcTypeDescriptor implements JdbcTypeDescriptor { return Types.OTHER; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public ValueBinder getBinder(JavaTypeDescriptor javaTypeDescriptor) { return new BasicBinder( javaTypeDescriptor, this ) { diff --git a/hibernate-core/src/test/java/org/hibernate/test/id/usertype/json/JsonJdbcTypeDescriptor.java b/hibernate-core/src/test/java/org/hibernate/test/id/usertype/json/JsonJdbcTypeDescriptor.java index 76c8ac1f3d..9208483e7f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/id/usertype/json/JsonJdbcTypeDescriptor.java +++ b/hibernate-core/src/test/java/org/hibernate/test/id/usertype/json/JsonJdbcTypeDescriptor.java @@ -39,11 +39,6 @@ public class JsonJdbcTypeDescriptor implements JdbcTypeDescriptor { return "OTHER (json)"; } - @Override - public boolean canBeRemapped() { - return true; - } - @Override public ValueBinder getBinder(JavaTypeDescriptor javaTypeDescriptor) { return new BasicBinder( javaTypeDescriptor, this ) { diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java index 85077dba0e..075768d041 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java @@ -20,10 +20,13 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.function.Consumer; + +import org.hibernate.boot.model.TypeContributions; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.H2Dialect; +import org.hibernate.service.ServiceRegistry; import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor; import org.hibernate.testing.TestForIssue; @@ -400,14 +403,15 @@ abstract class AbstractJavaTimeTypeTest extends BaseCoreFunctionalTestCase } @Override - protected JdbcTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { - if ( overriddenSqlTypeCode == sqlCode ) { - return overriddenJdbcTypeDescriptor; - } - else { - return super.getSqlTypeDescriptorOverride( sqlCode ); - } + public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) { + super.contributeTypes( typeContributions, serviceRegistry ); + + typeContributions.getTypeConfiguration().getJdbcTypeDescriptorRegistry().addDescriptor( + overriddenSqlTypeCode, + overriddenJdbcTypeDescriptor + ); } + } } diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/db2/DB2GeometryTypeDescriptor.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/db2/DB2GeometryTypeDescriptor.java index 8241ea7083..5d740d33fc 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/db2/DB2GeometryTypeDescriptor.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/db2/DB2GeometryTypeDescriptor.java @@ -44,11 +44,6 @@ public class DB2GeometryTypeDescriptor implements JdbcTypeDescriptor { return Types.CLOB; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueBinder getBinder(final JavaTypeDescriptor javaTypeDescriptor) { diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/h2geodb/GeoDBGeometryTypeDescriptor.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/h2geodb/GeoDBGeometryTypeDescriptor.java index 7ec6343891..2ebade3225 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/h2geodb/GeoDBGeometryTypeDescriptor.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/h2geodb/GeoDBGeometryTypeDescriptor.java @@ -40,11 +40,6 @@ public class GeoDBGeometryTypeDescriptor implements JdbcTypeDescriptor { return Types.ARRAY; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueBinder getBinder(final JavaTypeDescriptor javaTypeDescriptor) { return new BasicBinder( javaTypeDescriptor, this ) { diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/hana/HANAGeometryTypeDescriptor.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/hana/HANAGeometryTypeDescriptor.java index 2619941c86..e47cac48a1 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/hana/HANAGeometryTypeDescriptor.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/hana/HANAGeometryTypeDescriptor.java @@ -38,11 +38,6 @@ public class HANAGeometryTypeDescriptor implements JdbcTypeDescriptor { return Types.OTHER; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueBinder getBinder(final JavaTypeDescriptor javaTypeDescriptor) { return new BasicBinder( javaTypeDescriptor, this ) { diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/hana/HANAPointTypeDescriptor.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/hana/HANAPointTypeDescriptor.java index c765a161b8..51b4b5a7fb 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/hana/HANAPointTypeDescriptor.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/hana/HANAPointTypeDescriptor.java @@ -35,11 +35,6 @@ public class HANAPointTypeDescriptor implements JdbcTypeDescriptor { return Types.STRUCT; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueBinder getBinder(final JavaTypeDescriptor javaTypeDescriptor) { return new BasicBinder( javaTypeDescriptor, this ) { diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/mariadb/MariaDBGeometryTypeDescriptor.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/mariadb/MariaDBGeometryTypeDescriptor.java index a73fcd8bf6..660a93ffe3 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/mariadb/MariaDBGeometryTypeDescriptor.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/mariadb/MariaDBGeometryTypeDescriptor.java @@ -39,11 +39,6 @@ public class MariaDBGeometryTypeDescriptor implements JdbcTypeDescriptor { return Types.ARRAY; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueBinder getBinder(JavaTypeDescriptor javaTypeDescriptor) { diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/mysql/MySQLGeometryTypeDescriptor.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/mysql/MySQLGeometryTypeDescriptor.java index ae37eacc5c..e0585f1c15 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/mysql/MySQLGeometryTypeDescriptor.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/mysql/MySQLGeometryTypeDescriptor.java @@ -45,11 +45,6 @@ public class MySQLGeometryTypeDescriptor implements JdbcTypeDescriptor { return Types.ARRAY; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueBinder getBinder(final JavaTypeDescriptor javaTypeDescriptor) { return new BasicBinder( javaTypeDescriptor, this ) { diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOGeometryTypeDescriptor.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOGeometryTypeDescriptor.java index ec1f2a6d14..f83df7e5ae 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOGeometryTypeDescriptor.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOGeometryTypeDescriptor.java @@ -39,11 +39,6 @@ public class SDOGeometryTypeDescriptor implements JdbcTypeDescriptor { return Types.STRUCT; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueBinder getBinder(final JavaTypeDescriptor javaTypeDescriptor) { return (ValueBinder) new SDOGeometryValueBinder( javaTypeDescriptor, this, typeFactory ); diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/postgis/PGGeometryTypeDescriptor.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/postgis/PGGeometryTypeDescriptor.java index 296b63904c..2f913383cd 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/postgis/PGGeometryTypeDescriptor.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/postgis/PGGeometryTypeDescriptor.java @@ -111,11 +111,6 @@ public class PGGeometryTypeDescriptor implements JdbcTypeDescriptor { return 5432; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueBinder getBinder(final JavaTypeDescriptor javaTypeDescriptor) { return new BasicBinder( javaTypeDescriptor, this ) { diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServer2008GeometryTypeDescriptor.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServer2008GeometryTypeDescriptor.java index 1d33af3b51..f9b2863c4f 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServer2008GeometryTypeDescriptor.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServer2008GeometryTypeDescriptor.java @@ -44,11 +44,6 @@ public class SqlServer2008GeometryTypeDescriptor implements JdbcTypeDescriptor { return Types.ARRAY; } - @Override - public boolean canBeRemapped() { - return false; - } - @Override public ValueBinder getBinder(final JavaTypeDescriptor javaTypeDescriptor) { return new BasicBinder( javaTypeDescriptor, this ) {