Replace some uses of Type#getSqlTypeCodes with BasicType#getJdbcType

This commit is contained in:
Christian Beikov 2022-01-20 14:00:52 +01:00
parent 445cedfec7
commit 5fcacce3b1
5 changed files with 8 additions and 18 deletions

View File

@ -36,7 +36,7 @@ public class ExportableColumn extends Column {
table,
name,
type,
database.getDialect().getTypeName( type.getSqlTypeCodes( null )[0] )
database.getDialect().getTypeName( type.getJdbcType().getDefaultSqlTypeCode() )
);
}

View File

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

View File

@ -23,6 +23,7 @@ import org.hibernate.type.descriptor.jdbc.TimestampJdbcType;
* datatype is supported). Depends on the frequency of DML operations...
*
* @author Steve Ebersole
* @deprecated We should replace this with a different contract to handle DB generation
*/
@Deprecated
public class DbTimestampType extends AbstractSingleColumnStandardBasicType<Date> {

View File

@ -30,6 +30,7 @@ import jakarta.persistence.TemporalType;
* Wrapper Java type descriptor for that uses the database timestamp as seed value for versions.
*
* @author Christian Beikov
* @deprecated We should replace this with a different contract to handle DB generation
*/
@Deprecated
public class DbTimestampJavaType<T> implements VersionJavaType<T>, TemporalJavaType<T> {

View File

@ -236,22 +236,10 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable {
() -> basicType.getJavaTypeDescriptor()
);
try {
int[] jdbcTypes = basicType.getSqlTypeCodes( null );
if ( jdbcTypes.length == 1 ) {
int jdbcType = jdbcTypes[0];
Set<String> hibernateTypes = jdbcToHibernateTypeContributionMap.computeIfAbsent(
jdbcType,
k -> new HashSet<>()
);
hibernateTypes.add( basicType.getName() );
}
}
catch (Exception e) {
log.errorf( e, "Cannot register [%s] Hibernate Type contribution", basicType.getName() );
}
jdbcToHibernateTypeContributionMap.computeIfAbsent(
basicType.getJdbcType().getDefaultSqlTypeCode(),
k -> new HashSet<>()
).add( basicType.getName() );
}
}