Skip to content

Commit cebef16

Browse files
committed
clean up of VarcharJdbcType
1 parent aa9bb26 commit cebef16

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/CharJdbcType.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,13 @@ public int getJdbcTypeCode() {
3333
return Types.CHAR;
3434
}
3535

36-
3736
@Override
38-
public JdbcType resolveIndicatedType(
39-
JdbcTypeIndicators indicators,
40-
JavaType<?> domainJtd) {
41-
assert domainJtd != null;
42-
43-
final TypeConfiguration typeConfiguration = indicators.getTypeConfiguration();
44-
final JdbcTypeRegistry jdbcTypeRegistry = typeConfiguration.getJdbcTypeRegistry();
45-
46-
final int jdbcTypeCode;
37+
protected int resolveIndicatedJdbcTypeCode(JdbcTypeIndicators indicators) {
4738
if ( indicators.isLob() ) {
48-
jdbcTypeCode = indicators.isNationalized() ? Types.NCLOB : Types.CLOB;
39+
return indicators.isNationalized() ? Types.NCLOB : Types.CLOB;
4940
}
5041
else {
51-
jdbcTypeCode = indicators.isNationalized() ? Types.NCHAR : Types.CHAR;
42+
return indicators.isNationalized() ? Types.NCHAR : Types.CHAR;
5243
}
53-
54-
return jdbcTypeRegistry.getDescriptor( indicators.resolveJdbcTypeCode( jdbcTypeCode ) );
5544
}
5645
}

hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/VarcharJdbcType.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.hibernate.type.descriptor.WrapperOptions;
2020
import org.hibernate.type.descriptor.java.JavaType;
2121
import org.hibernate.type.descriptor.jdbc.internal.JdbcLiteralFormatterCharacterData;
22-
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
2322
import org.hibernate.type.spi.TypeConfiguration;
2423

2524
/**
@@ -53,37 +52,32 @@ public <T> JavaType<T> getJdbcRecommendedJavaTypeMapping(
5352
Integer length,
5453
Integer scale,
5554
TypeConfiguration typeConfiguration) {
56-
if ( length != null && length == 1 ) {
57-
return typeConfiguration.getJavaTypeRegistry().getDescriptor( Character.class );
58-
}
59-
return typeConfiguration.getJavaTypeRegistry().getDescriptor( String.class );
55+
return typeConfiguration.getJavaTypeRegistry()
56+
.getDescriptor( length != null && length == 1 ? Character.class : String.class );
6057
}
6158

6259
@Override
6360
public <T> JdbcLiteralFormatter<T> getJdbcLiteralFormatter(JavaType<T> javaType) {
64-
//noinspection unchecked
65-
return new JdbcLiteralFormatterCharacterData( javaType );
61+
return new JdbcLiteralFormatterCharacterData<>( javaType );
6662
}
6763

6864
@Override
6965
public JdbcType resolveIndicatedType(JdbcTypeIndicators indicators, JavaType<?> domainJtd) {
7066
assert domainJtd != null;
67+
return indicators.getTypeConfiguration().getJdbcTypeRegistry()
68+
.getDescriptor( indicators.resolveJdbcTypeCode( resolveIndicatedJdbcTypeCode( indicators ) ) );
69+
}
7170

72-
final TypeConfiguration typeConfiguration = indicators.getTypeConfiguration();
73-
final JdbcTypeRegistry jdbcTypeRegistry = typeConfiguration.getJdbcTypeRegistry();
74-
75-
final int jdbcTypeCode;
71+
protected int resolveIndicatedJdbcTypeCode(JdbcTypeIndicators indicators) {
7672
if ( indicators.isLob() ) {
77-
jdbcTypeCode = indicators.isNationalized() ? Types.NCLOB : Types.CLOB;
73+
return indicators.isNationalized() ? Types.NCLOB : Types.CLOB;
7874
}
7975
else if ( shouldUseMaterializedLob( indicators ) ) {
80-
jdbcTypeCode = indicators.isNationalized() ? SqlTypes.MATERIALIZED_NCLOB : SqlTypes.MATERIALIZED_CLOB;
76+
return indicators.isNationalized() ? SqlTypes.MATERIALIZED_NCLOB : SqlTypes.MATERIALIZED_CLOB;
8177
}
8278
else {
83-
jdbcTypeCode = indicators.isNationalized() ? Types.NVARCHAR : Types.VARCHAR;
79+
return indicators.isNationalized() ? Types.NVARCHAR : Types.VARCHAR;
8480
}
85-
86-
return jdbcTypeRegistry.getDescriptor( indicators.resolveJdbcTypeCode( jdbcTypeCode ) );
8781
}
8882

8983
protected boolean shouldUseMaterializedLob(JdbcTypeIndicators indicators) {

0 commit comments

Comments
 (0)