mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-20 01:55:02 +00:00
clean up of VarcharJdbcType
This commit is contained in:
parent
aa9bb26498
commit
cebef1618d
@ -33,24 +33,13 @@ public int getJdbcTypeCode() {
|
|||||||
return Types.CHAR;
|
return Types.CHAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JdbcType resolveIndicatedType(
|
protected int resolveIndicatedJdbcTypeCode(JdbcTypeIndicators indicators) {
|
||||||
JdbcTypeIndicators indicators,
|
|
||||||
JavaType<?> domainJtd) {
|
|
||||||
assert domainJtd != null;
|
|
||||||
|
|
||||||
final TypeConfiguration typeConfiguration = indicators.getTypeConfiguration();
|
|
||||||
final JdbcTypeRegistry jdbcTypeRegistry = typeConfiguration.getJdbcTypeRegistry();
|
|
||||||
|
|
||||||
final int jdbcTypeCode;
|
|
||||||
if ( indicators.isLob() ) {
|
if ( indicators.isLob() ) {
|
||||||
jdbcTypeCode = indicators.isNationalized() ? Types.NCLOB : Types.CLOB;
|
return indicators.isNationalized() ? Types.NCLOB : Types.CLOB;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
jdbcTypeCode = indicators.isNationalized() ? Types.NCHAR : Types.CHAR;
|
return indicators.isNationalized() ? Types.NCHAR : Types.CHAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return jdbcTypeRegistry.getDescriptor( indicators.resolveJdbcTypeCode( jdbcTypeCode ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
import org.hibernate.type.descriptor.WrapperOptions;
|
import org.hibernate.type.descriptor.WrapperOptions;
|
||||||
import org.hibernate.type.descriptor.java.JavaType;
|
import org.hibernate.type.descriptor.java.JavaType;
|
||||||
import org.hibernate.type.descriptor.jdbc.internal.JdbcLiteralFormatterCharacterData;
|
import org.hibernate.type.descriptor.jdbc.internal.JdbcLiteralFormatterCharacterData;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,37 +52,32 @@ public <T> JavaType<T> getJdbcRecommendedJavaTypeMapping(
|
|||||||
Integer length,
|
Integer length,
|
||||||
Integer scale,
|
Integer scale,
|
||||||
TypeConfiguration typeConfiguration) {
|
TypeConfiguration typeConfiguration) {
|
||||||
if ( length != null && length == 1 ) {
|
return typeConfiguration.getJavaTypeRegistry()
|
||||||
return typeConfiguration.getJavaTypeRegistry().getDescriptor( Character.class );
|
.getDescriptor( length != null && length == 1 ? Character.class : String.class );
|
||||||
}
|
|
||||||
return typeConfiguration.getJavaTypeRegistry().getDescriptor( String.class );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> JdbcLiteralFormatter<T> getJdbcLiteralFormatter(JavaType<T> javaType) {
|
public <T> JdbcLiteralFormatter<T> getJdbcLiteralFormatter(JavaType<T> javaType) {
|
||||||
//noinspection unchecked
|
return new JdbcLiteralFormatterCharacterData<>( javaType );
|
||||||
return new JdbcLiteralFormatterCharacterData( javaType );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JdbcType resolveIndicatedType(JdbcTypeIndicators indicators, JavaType<?> domainJtd) {
|
public JdbcType resolveIndicatedType(JdbcTypeIndicators indicators, JavaType<?> domainJtd) {
|
||||||
assert domainJtd != null;
|
assert domainJtd != null;
|
||||||
|
return indicators.getTypeConfiguration().getJdbcTypeRegistry()
|
||||||
|
.getDescriptor( indicators.resolveJdbcTypeCode( resolveIndicatedJdbcTypeCode( indicators ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
final TypeConfiguration typeConfiguration = indicators.getTypeConfiguration();
|
protected int resolveIndicatedJdbcTypeCode(JdbcTypeIndicators indicators) {
|
||||||
final JdbcTypeRegistry jdbcTypeRegistry = typeConfiguration.getJdbcTypeRegistry();
|
|
||||||
|
|
||||||
final int jdbcTypeCode;
|
|
||||||
if ( indicators.isLob() ) {
|
if ( indicators.isLob() ) {
|
||||||
jdbcTypeCode = indicators.isNationalized() ? Types.NCLOB : Types.CLOB;
|
return indicators.isNationalized() ? Types.NCLOB : Types.CLOB;
|
||||||
}
|
}
|
||||||
else if ( shouldUseMaterializedLob( indicators ) ) {
|
else if ( shouldUseMaterializedLob( indicators ) ) {
|
||||||
jdbcTypeCode = indicators.isNationalized() ? SqlTypes.MATERIALIZED_NCLOB : SqlTypes.MATERIALIZED_CLOB;
|
return indicators.isNationalized() ? SqlTypes.MATERIALIZED_NCLOB : SqlTypes.MATERIALIZED_CLOB;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
jdbcTypeCode = indicators.isNationalized() ? Types.NVARCHAR : Types.VARCHAR;
|
return indicators.isNationalized() ? Types.NVARCHAR : Types.VARCHAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return jdbcTypeRegistry.getDescriptor( indicators.resolveJdbcTypeCode( jdbcTypeCode ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shouldUseMaterializedLob(JdbcTypeIndicators indicators) {
|
protected boolean shouldUseMaterializedLob(JdbcTypeIndicators indicators) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user