remove older getJdbcType() method

This commit is contained in:
Gavin King 2021-07-26 16:00:03 +02:00 committed by Christian Beikov
parent 526b3659c8
commit 7aeb03beea
45 changed files with 60 additions and 65 deletions

View File

@ -21,7 +21,7 @@ import org.hibernate.type.descriptor.jdbc.VarbinaryTypeDescriptor;
*/ */
public class CustomBinaryJdbcType implements JdbcTypeDescriptor { public class CustomBinaryJdbcType implements JdbcTypeDescriptor {
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.VARBINARY; return Types.VARBINARY;
} }

View File

@ -298,7 +298,7 @@ public abstract class AbstractHANADialect extends Dialect {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.BLOB; return Types.BLOB;
} }
@ -583,7 +583,7 @@ public abstract class AbstractHANADialect extends Dialect {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.BLOB; return Types.BLOB;
} }

View File

@ -69,7 +69,7 @@ public class TimestampaddFunction
else { else {
final Expression magnitude = (Expression) arguments.get( 1 ); final Expression magnitude = (Expression) arguments.get( 1 );
final JdbcMapping magnitudeJdbcMapping = magnitude.getExpressionType().getJdbcMappings().get( 0 ); final JdbcMapping magnitudeJdbcMapping = magnitude.getExpressionType().getJdbcMappings().get( 0 );
switch ( magnitudeJdbcMapping.getJdbcTypeDescriptor().getJdbcType() ) { switch ( magnitudeJdbcMapping.getJdbcTypeDescriptor().getJdbcTypeCode() ) {
case Types.INTEGER: case Types.INTEGER:
case Types.TINYINT: case Types.TINYINT:
case Types.SMALLINT: case Types.SMALLINT:

View File

@ -32,7 +32,7 @@ public class FunctionReturnImpl implements FunctionReturnImplementor {
public FunctionReturnImpl(ProcedureCallImplementor procedureCall, AllowableOutputParameterType ormType) { public FunctionReturnImpl(ProcedureCallImplementor procedureCall, AllowableOutputParameterType ormType) {
this.procedureCall = procedureCall; this.procedureCall = procedureCall;
this.jdbcTypeCode = ormType.getJdbcTypeDescriptor().getJdbcType(); this.jdbcTypeCode = ormType.getJdbcTypeDescriptor().getJdbcTypeCode();
this.ormType = ormType; this.ormType = ormType;
} }

View File

@ -66,7 +66,7 @@ public class PostgresUUIDType extends AbstractSingleColumnStandardBasicType<UUID
private static final int JDBC_TYPE_CODE = 3975; private static final int JDBC_TYPE_CODE = 3975;
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return JDBC_TYPE_CODE; return JDBC_TYPE_CODE;
} }

View File

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

View File

@ -51,8 +51,8 @@ public class AttributeConverterJdbcTypeDescriptorAdapter implements JdbcTypeDesc
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return delegate.getJdbcType(); return delegate.getJdbcTypeCode();
} }
@Override @Override

View File

@ -32,7 +32,7 @@ public class BigIntTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.BIGINT; return Types.BIGINT;
} }

View File

@ -19,7 +19,7 @@ public class BinaryTypeDescriptor extends VarbinaryTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.BINARY; return Types.BINARY;
} }
} }

View File

@ -33,7 +33,7 @@ public abstract class BlobTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.BLOB; return Types.BLOB;
} }

View File

@ -31,7 +31,7 @@ public class BooleanTypeDescriptor implements JdbcTypeDescriptor {
public BooleanTypeDescriptor() { public BooleanTypeDescriptor() {
} }
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.BOOLEAN; return Types.BOOLEAN;
} }

View File

@ -27,7 +27,7 @@ public class CharTypeDescriptor extends VarcharTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.CHAR; return Types.CHAR;
} }

View File

@ -27,7 +27,7 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
*/ */
public abstract class ClobTypeDescriptor implements JdbcTypeDescriptor { public abstract class ClobTypeDescriptor implements JdbcTypeDescriptor {
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.CLOB; return Types.CLOB;
} }

View File

@ -36,7 +36,7 @@ public class DateTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.DATE; return Types.DATE;
} }

View File

@ -33,7 +33,7 @@ public class DecimalTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.DECIMAL; return Types.DECIMAL;
} }

View File

@ -35,7 +35,7 @@ public class DoubleTypeDescriptor implements JdbcTypeDescriptor {
* @return {@link Types#DOUBLE} * @return {@link Types#DOUBLE}
*/ */
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.DOUBLE; return Types.DOUBLE;
} }

View File

@ -32,7 +32,7 @@ public class FloatTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.FLOAT; return Types.FLOAT;
} }

View File

@ -32,7 +32,7 @@ public class IntegerTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.INTEGER; return Types.INTEGER;
} }

View File

@ -33,31 +33,26 @@ public interface JdbcTypeDescriptor extends Serializable {
} }
/** /**
* Return the {@linkplain java.sql.Types JDBC type-code} for the column mapped by this type. * Return the {@linkplain java.sql.Types JDBC type code} used when interacting
* with JDBC APIs.
* *
* @apiNote Prefer {@link #getJdbcTypeCode} * For example, it's used when calling {@link java.sql.PreparedStatement#setNull(int, int)}.
* *
* @return typeCode The JDBC type-code * @return a JDBC type code
*/ */
int getJdbcType(); int getJdbcTypeCode();
/** /**
* Get the JDBC type code associated with this SQL type descriptor * Get a JDBC type code that identifies the SQL column type to be used for
* schema generation.
*
* This value is passed to {@link org.hibernate.dialect.Dialect#getTypeName(int)}
* to obtain the SQL column type.
* *
* @see #getJdbcType * @return a JDBC type code
*/
default int getJdbcTypeCode() {
return getJdbcType();
}
/**
* Get a JDBC type code that identifies the SQL column type to be
* used for schema generation.
*
* @see #getJdbcType
*/ */
default int getDefaultSqlTypeCode() { default int getDefaultSqlTypeCode() {
return getJdbcType(); return getJdbcTypeCode();
} }
/** /**

View File

@ -25,7 +25,7 @@ public class LongNVarcharTypeDescriptor extends NVarcharTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.LONGNVARCHAR; return Types.LONGNVARCHAR;
} }
} }

View File

@ -20,7 +20,7 @@ public class LongVarbinaryTypeDescriptor extends VarbinaryTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.LONGVARBINARY; return Types.LONGVARBINARY;
} }
} }

View File

@ -25,7 +25,7 @@ public class LongVarcharTypeDescriptor extends VarcharTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.LONGVARCHAR; return Types.LONGVARCHAR;
} }
} }

View File

@ -25,7 +25,7 @@ public class NCharTypeDescriptor extends NVarcharTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.NCHAR; return Types.NCHAR;
} }
} }

View File

@ -27,7 +27,7 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
*/ */
public abstract class NClobTypeDescriptor implements JdbcTypeDescriptor { public abstract class NClobTypeDescriptor implements JdbcTypeDescriptor {
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.NCLOB; return Types.NCLOB;
} }

View File

@ -32,7 +32,7 @@ public class NVarcharTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.NVARCHAR; return Types.NVARCHAR;
} }

View File

@ -25,7 +25,7 @@ public class NumericTypeDescriptor extends DecimalTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.NUMERIC; return Types.NUMERIC;
} }
} }

View File

@ -35,7 +35,7 @@ public class ObjectJdbcTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return jdbcTypeCode; return jdbcTypeCode;
} }

View File

@ -26,7 +26,7 @@ public class RealTypeDescriptor extends FloatTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.REAL; return Types.REAL;
} }

View File

@ -32,7 +32,7 @@ public class SmallIntTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.SMALLINT; return Types.SMALLINT;
} }

View File

@ -36,7 +36,7 @@ public class TimeTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.TIME; return Types.TIME;
} }

View File

@ -36,7 +36,7 @@ public class TimestampTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.TIMESTAMP; return Types.TIMESTAMP;
} }

View File

@ -35,7 +35,7 @@ public class TimestampWithTimeZoneDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.TIMESTAMP_WITH_TIMEZONE; return Types.TIMESTAMP_WITH_TIMEZONE;
} }

View File

@ -35,7 +35,7 @@ public class TinyIntTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.TINYINT; return Types.TINYINT;
} }

View File

@ -49,7 +49,7 @@ public class VarbinaryTypeDescriptor implements JdbcTypeDescriptor {
return "VarbinaryTypeDescriptor"; return "VarbinaryTypeDescriptor";
} }
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.VARBINARY; return Types.VARBINARY;
} }

View File

@ -32,7 +32,7 @@ public class VarcharTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.VARCHAR; return Types.VARCHAR;
} }

View File

@ -47,7 +47,7 @@ public class UserTypeSqlTypeAdapter<J> implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return userType.sqlTypes()[0]; return userType.sqlTypes()[0];
} }

View File

@ -616,7 +616,7 @@ class BitTypeDescriptor implements JdbcTypeDescriptor {
public BitTypeDescriptor() { public BitTypeDescriptor() {
} }
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.BIT; return Types.BIT;
} }

View File

@ -152,7 +152,7 @@ public class JdbcTypeTests {
public static class CustomJdbcTypeDescriptor implements JdbcTypeDescriptor { public static class CustomJdbcTypeDescriptor implements JdbcTypeDescriptor {
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.TINYINT; return Types.TINYINT;
} }

View File

@ -238,7 +238,7 @@ public class AttributeConverterTest extends BaseUnitTestCase {
} }
AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type ); AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type );
assertSame( StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() ); assertSame( StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() );
assertEquals( Types.VARCHAR, basicType.getJdbcTypeDescriptor().getJdbcType() ); assertEquals( Types.VARCHAR, basicType.getJdbcTypeDescriptor().getJdbcTypeCode() );
} }
finally { finally {
StandardServiceRegistryBuilder.destroy( ssr ); StandardServiceRegistryBuilder.destroy( ssr );

View File

@ -63,7 +63,7 @@ public class CustomTypeConverterTest extends BaseUnitTestCase {
); );
assertThat( assertThat(
bootTypeConfiguration.getJdbcTypeDescriptorRegistry().getDescriptor( MyCustomJdbcTypeDescriptor.INSTANCE.getJdbcType() ), bootTypeConfiguration.getJdbcTypeDescriptorRegistry().getDescriptor( MyCustomJdbcTypeDescriptor.INSTANCE.getJdbcTypeCode() ),
sameInstance( MyCustomJdbcTypeDescriptor.INSTANCE ) sameInstance( MyCustomJdbcTypeDescriptor.INSTANCE )
); );

View File

@ -39,7 +39,7 @@ public class MyCustomJdbcTypeDescriptor implements JdbcTypeDescriptor {
} }
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
// given the Oracle example above we might want to replace the // given the Oracle example above we might want to replace the
// handling of VARCHAR // handling of VARCHAR
return Types.VARCHAR; return Types.VARCHAR;
@ -57,7 +57,7 @@ public class MyCustomJdbcTypeDescriptor implements JdbcTypeDescriptor {
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
final String valueStr = javaTypeDescriptor.unwrap( value, String.class, options ); final String valueStr = javaTypeDescriptor.unwrap( value, String.class, options );
if ( StringHelper.isBlank( valueStr ) ) { if ( StringHelper.isBlank( valueStr ) ) {
st.setNull( index, getJdbcType() ); st.setNull( index, getJdbcTypeCode() );
} }
else { else {
st.setString( index, valueStr ); st.setString( index, valueStr );
@ -68,7 +68,7 @@ public class MyCustomJdbcTypeDescriptor implements JdbcTypeDescriptor {
protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) throws SQLException { protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) throws SQLException {
final String valueStr = javaTypeDescriptor.unwrap( value, String.class, options ); final String valueStr = javaTypeDescriptor.unwrap( value, String.class, options );
if ( StringHelper.isBlank( valueStr ) ) { if ( StringHelper.isBlank( valueStr ) ) {
st.setNull( name, getJdbcType() ); st.setNull( name, getJdbcTypeCode() );
} }
else { else {
st.setString( name, valueStr ); st.setString( name, valueStr );

View File

@ -96,7 +96,7 @@ public class QueryParametersValidationArrayTest {
public static final StringArrayJdbcTypeDescriptor INSTANCE = new StringArrayJdbcTypeDescriptor(); public static final StringArrayJdbcTypeDescriptor INSTANCE = new StringArrayJdbcTypeDescriptor();
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.ARRAY; return Types.ARRAY;
} }

View File

@ -184,7 +184,7 @@ public class SmokeTests {
assertThat( selectedExpressable, instanceOf( StandardBasicTypeImpl.class ) ); assertThat( selectedExpressable, instanceOf( StandardBasicTypeImpl.class ) );
final StandardBasicTypeImpl basicType = (StandardBasicTypeImpl) selectedExpressable; final StandardBasicTypeImpl basicType = (StandardBasicTypeImpl) selectedExpressable;
assertThat( basicType.getJavaTypeDescriptor().getJavaTypeClass(), AssignableMatcher.assignableTo( Integer.class ) ); assertThat( basicType.getJavaTypeDescriptor().getJavaTypeClass(), AssignableMatcher.assignableTo( Integer.class ) );
assertThat( basicType.getJdbcTypeDescriptor().getJdbcType(), is( Types.TINYINT ) ); assertThat( basicType.getJdbcTypeDescriptor().getJdbcTypeCode(), is( Types.TINYINT ) );
assertThat( sqlAst.getDomainResultDescriptors().size(), is( 1 ) ); assertThat( sqlAst.getDomainResultDescriptors().size(), is( 1 ) );

View File

@ -31,7 +31,7 @@ public class InetJdbcTypeDescriptor implements JdbcTypeDescriptor {
public static final InetJdbcTypeDescriptor INSTANCE = new InetJdbcTypeDescriptor(); public static final InetJdbcTypeDescriptor INSTANCE = new InetJdbcTypeDescriptor();
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.OTHER; return Types.OTHER;
} }

View File

@ -30,7 +30,7 @@ public class JsonJdbcTypeDescriptor implements JdbcTypeDescriptor {
public static final JsonJdbcTypeDescriptor INSTANCE = new JsonJdbcTypeDescriptor(); public static final JsonJdbcTypeDescriptor INSTANCE = new JsonJdbcTypeDescriptor();
@Override @Override
public int getJdbcType() { public int getJdbcTypeCode() {
return Types.OTHER; return Types.OTHER;
} }