@@ -109,25 +109,31 @@ protected boolean needsLob(JdbcTypeIndicators indicators) {
109
109
if ( length > maxLength ) {
110
110
return true ;
111
111
}
112
-
113
- final DdlTypeRegistry ddlTypeRegistry = indicators .getTypeConfiguration ().getDdlTypeRegistry ();
114
- final String typeName = ddlTypeRegistry .getTypeName ( getDdlTypeCode (), dialect );
115
- return typeName .equals ( ddlTypeRegistry .getTypeName ( SqlTypes .CLOB , dialect ) )
116
- || typeName .equals ( ddlTypeRegistry .getTypeName ( SqlTypes .NCLOB , dialect ) );
112
+ else {
113
+ final DdlTypeRegistry ddlTypeRegistry = indicators .getTypeConfiguration ().getDdlTypeRegistry ();
114
+ final String typeName = ddlTypeRegistry .getTypeName ( getDdlTypeCode (), dialect );
115
+ return typeName .equals ( ddlTypeRegistry .getTypeName ( SqlTypes .CLOB , dialect ) )
116
+ || typeName .equals ( ddlTypeRegistry .getTypeName ( SqlTypes .NCLOB , dialect ) );
117
+ }
117
118
}
118
119
119
120
@ Override
120
121
public <X > ValueBinder <X > getBinder (JavaType <X > javaType ) {
121
122
if ( nationalized ) {
122
123
return new BasicBinder <>( javaType , this ) {
124
+
125
+ private XmlAsStringJdbcType getXmlAsStringJdbcType () {
126
+ return (XmlAsStringJdbcType ) getJdbcType ();
127
+ }
128
+
129
+ private String getXml (X value , WrapperOptions options ) throws SQLException {
130
+ return getXmlAsStringJdbcType ().toString ( value , getJavaType (), options );
131
+ }
132
+
123
133
@ Override
124
134
protected void doBind (PreparedStatement st , X value , int index , WrapperOptions options )
125
135
throws SQLException {
126
- final String xml = ( (XmlAsStringJdbcType ) getJdbcType () ).toString (
127
- value ,
128
- getJavaType (),
129
- options
130
- );
136
+ final String xml = getXml ( value , options );
131
137
if ( options .getDialect ().supportsNationalizedMethods () ) {
132
138
st .setNString ( index , xml );
133
139
}
@@ -139,11 +145,7 @@ protected void doBind(PreparedStatement st, X value, int index, WrapperOptions o
139
145
@ Override
140
146
protected void doBind (CallableStatement st , X value , String name , WrapperOptions options )
141
147
throws SQLException {
142
- final String xml = ( (XmlAsStringJdbcType ) getJdbcType () ).toString (
143
- value ,
144
- getJavaType (),
145
- options
146
- );
148
+ final String xml = getXml ( value , options );
147
149
if ( options .getDialect ().supportsNationalizedMethods () ) {
148
150
st .setNString ( name , xml );
149
151
}
@@ -155,26 +157,25 @@ protected void doBind(CallableStatement st, X value, String name, WrapperOptions
155
157
}
156
158
else {
157
159
return new BasicBinder <>( javaType , this ) {
160
+
161
+ private XmlAsStringJdbcType getXmlAsStringJdbcType () {
162
+ return (XmlAsStringJdbcType ) getJdbcType ();
163
+ }
164
+
165
+ private String getXml (X value , WrapperOptions options ) throws SQLException {
166
+ return getXmlAsStringJdbcType ().toString ( value , getJavaType (), options );
167
+ }
168
+
158
169
@ Override
159
170
protected void doBind (PreparedStatement st , X value , int index , WrapperOptions options )
160
171
throws SQLException {
161
- final String xml = ( (XmlAsStringJdbcType ) getJdbcType () ).toString (
162
- value ,
163
- getJavaType (),
164
- options
165
- );
166
- st .setString ( index , xml );
172
+ st .setString ( index , getXml ( value , options ) );
167
173
}
168
174
169
175
@ Override
170
176
protected void doBind (CallableStatement st , X value , String name , WrapperOptions options )
171
177
throws SQLException {
172
- final String xml = ( (XmlAsStringJdbcType ) getJdbcType () ).toString (
173
- value ,
174
- getJavaType (),
175
- options
176
- );
177
- st .setString ( name , xml );
178
+ st .setString ( name , getXml ( value , options ) );
178
179
}
179
180
};
180
181
}
@@ -218,20 +219,21 @@ protected X doExtract(CallableStatement statement, String name, WrapperOptions o
218
219
}
219
220
220
221
private X getObject (String xml , WrapperOptions options ) throws SQLException {
221
- if ( xml == null ) {
222
- return null ;
223
- }
224
- return ( (XmlAsStringJdbcType ) getJdbcType () ).fromString (
225
- xml ,
226
- getJavaType (),
227
- options
228
- );
222
+ return xml == null ? null : getXmlAsStringJdbcType ().fromString ( xml , getJavaType (), options );
223
+ }
224
+
225
+ private XmlAsStringJdbcType getXmlAsStringJdbcType () {
226
+ return (XmlAsStringJdbcType ) getJdbcType ();
229
227
}
230
228
};
231
229
}
232
230
else {
233
231
return new BasicExtractor <>( javaType , this ) {
234
232
233
+ private XmlAsStringJdbcType getXmlAsStringJdbcType () {
234
+ return (XmlAsStringJdbcType ) getJdbcType ();
235
+ }
236
+
235
237
@ Override
236
238
protected X doExtract (ResultSet rs , int paramIndex , WrapperOptions options ) throws SQLException {
237
239
return getObject ( rs .getString ( paramIndex ), options );
@@ -249,14 +251,7 @@ protected X doExtract(CallableStatement statement, String name, WrapperOptions o
249
251
}
250
252
251
253
private X getObject (String xml , WrapperOptions options ) throws SQLException {
252
- if ( xml == null ) {
253
- return null ;
254
- }
255
- return ( (XmlAsStringJdbcType ) getJdbcType () ).fromString (
256
- xml ,
257
- getJavaType (),
258
- options
259
- );
254
+ return xml == null ? null : getXmlAsStringJdbcType ().fromString ( xml , getJavaType (), options );
260
255
}
261
256
};
262
257
}
0 commit comments