|
19 | 19 | import org.hibernate.type.descriptor.WrapperOptions;
|
20 | 20 | import org.hibernate.type.descriptor.java.JavaType;
|
21 | 21 | import org.hibernate.type.descriptor.jdbc.internal.JdbcLiteralFormatterCharacterData;
|
22 |
| -import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry; |
23 | 22 | import org.hibernate.type.spi.TypeConfiguration;
|
24 | 23 |
|
25 | 24 | /**
|
@@ -53,37 +52,32 @@ public <T> JavaType<T> getJdbcRecommendedJavaTypeMapping(
|
53 | 52 | Integer length,
|
54 | 53 | Integer scale,
|
55 | 54 | 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 ); |
60 | 57 | }
|
61 | 58 |
|
62 | 59 | @Override
|
63 | 60 | public <T> JdbcLiteralFormatter<T> getJdbcLiteralFormatter(JavaType<T> javaType) {
|
64 |
| - //noinspection unchecked |
65 |
| - return new JdbcLiteralFormatterCharacterData( javaType ); |
| 61 | + return new JdbcLiteralFormatterCharacterData<>( javaType ); |
66 | 62 | }
|
67 | 63 |
|
68 | 64 | @Override
|
69 | 65 | public JdbcType resolveIndicatedType(JdbcTypeIndicators indicators, JavaType<?> domainJtd) {
|
70 | 66 | assert domainJtd != null;
|
| 67 | + return indicators.getTypeConfiguration().getJdbcTypeRegistry() |
| 68 | + .getDescriptor( indicators.resolveJdbcTypeCode( resolveIndicatedJdbcTypeCode( indicators ) ) ); |
| 69 | + } |
71 | 70 |
|
72 |
| - final TypeConfiguration typeConfiguration = indicators.getTypeConfiguration(); |
73 |
| - final JdbcTypeRegistry jdbcTypeRegistry = typeConfiguration.getJdbcTypeRegistry(); |
74 |
| - |
75 |
| - final int jdbcTypeCode; |
| 71 | + protected int resolveIndicatedJdbcTypeCode(JdbcTypeIndicators indicators) { |
76 | 72 | if ( indicators.isLob() ) {
|
77 |
| - jdbcTypeCode = indicators.isNationalized() ? Types.NCLOB : Types.CLOB; |
| 73 | + return indicators.isNationalized() ? Types.NCLOB : Types.CLOB; |
78 | 74 | }
|
79 | 75 | else if ( shouldUseMaterializedLob( indicators ) ) {
|
80 |
| - jdbcTypeCode = indicators.isNationalized() ? SqlTypes.MATERIALIZED_NCLOB : SqlTypes.MATERIALIZED_CLOB; |
| 76 | + return indicators.isNationalized() ? SqlTypes.MATERIALIZED_NCLOB : SqlTypes.MATERIALIZED_CLOB; |
81 | 77 | }
|
82 | 78 | else {
|
83 |
| - jdbcTypeCode = indicators.isNationalized() ? Types.NVARCHAR : Types.VARCHAR; |
| 79 | + return indicators.isNationalized() ? Types.NVARCHAR : Types.VARCHAR; |
84 | 80 | }
|
85 |
| - |
86 |
| - return jdbcTypeRegistry.getDescriptor( indicators.resolveJdbcTypeCode( jdbcTypeCode ) ); |
87 | 81 | }
|
88 | 82 |
|
89 | 83 | protected boolean shouldUseMaterializedLob(JdbcTypeIndicators indicators) {
|
|
0 commit comments