1
1
/*
2
- * Copyright 2009-2022 the original author or authors.
2
+ * Copyright 2009-2023 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
26
26
/**
27
27
* The base {@link TypeHandler} for references a generic type.
28
28
* <p>
29
- * Important: Since 3.5.0, This class never call the {@link ResultSet#wasNull()} and
30
- * {@link CallableStatement#wasNull()} method for handling the SQL {@code NULL} value.
31
- * In other words, {@code null} value handling should be performed on subclass.
29
+ * Important: Since 3.5.0, This class never call the {@link ResultSet#wasNull()} and {@link CallableStatement#wasNull()}
30
+ * method for handling the SQL {@code NULL} value. In other words, {@code null} value handling should be performed on
31
+ * subclass.
32
32
* </p>
33
33
*
34
34
* @author Clinton Begin
@@ -48,6 +48,7 @@ public abstract class BaseTypeHandler<T> extends TypeReference<T> implements Typ
48
48
*
49
49
* @param c
50
50
* the new configuration
51
+ *
51
52
* @deprecated Since 3.5.0 - See https://github.com/mybatis/mybatis-3/issues/1203. This property will remove future.
52
53
*/
53
54
@ Deprecated
@@ -65,16 +66,16 @@ public void setParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbc
65
66
ps .setNull (i , jdbcType .TYPE_CODE );
66
67
} catch (SQLException e ) {
67
68
throw new TypeException ("Error setting null for parameter #" + i + " with JdbcType " + jdbcType + " . "
68
- + "Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. "
69
- + "Cause: " + e , e );
69
+ + "Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. "
70
+ + "Cause: " + e , e );
70
71
}
71
72
} else {
72
73
try {
73
74
setNonNullParameter (ps , i , parameter , jdbcType );
74
75
} catch (Exception e ) {
75
76
throw new TypeException ("Error setting non null for parameter #" + i + " with JdbcType " + jdbcType + " . "
76
- + "Try setting a different JdbcType for this parameter or a different configuration property. "
77
- + "Cause: " + e , e );
77
+ + "Try setting a different JdbcType for this parameter or a different configuration property. " + "Cause: "
78
+ + e , e );
78
79
}
79
80
}
80
81
}
@@ -84,7 +85,8 @@ public T getResult(ResultSet rs, String columnName) throws SQLException {
84
85
try {
85
86
return getNullableResult (rs , columnName );
86
87
} catch (Exception e ) {
87
- throw new ResultMapException ("Error attempting to get column '" + columnName + "' from result set. Cause: " + e , e );
88
+ throw new ResultMapException ("Error attempting to get column '" + columnName + "' from result set. Cause: " + e ,
89
+ e );
88
90
}
89
91
}
90
92
@@ -93,7 +95,8 @@ public T getResult(ResultSet rs, int columnIndex) throws SQLException {
93
95
try {
94
96
return getNullableResult (rs , columnIndex );
95
97
} catch (Exception e ) {
96
- throw new ResultMapException ("Error attempting to get column #" + columnIndex + " from result set. Cause: " + e , e );
98
+ throw new ResultMapException ("Error attempting to get column #" + columnIndex + " from result set. Cause: " + e ,
99
+ e );
97
100
}
98
101
}
99
102
@@ -102,11 +105,13 @@ public T getResult(CallableStatement cs, int columnIndex) throws SQLException {
102
105
try {
103
106
return getNullableResult (cs , columnIndex );
104
107
} catch (Exception e ) {
105
- throw new ResultMapException ("Error attempting to get column #" + columnIndex + " from callable statement. Cause: " + e , e );
108
+ throw new ResultMapException (
109
+ "Error attempting to get column #" + columnIndex + " from callable statement. Cause: " + e , e );
106
110
}
107
111
}
108
112
109
- public abstract void setNonNullParameter (PreparedStatement ps , int i , T parameter , JdbcType jdbcType ) throws SQLException ;
113
+ public abstract void setNonNullParameter (PreparedStatement ps , int i , T parameter , JdbcType jdbcType )
114
+ throws SQLException ;
110
115
111
116
/**
112
117
* Gets the nullable result.
@@ -115,7 +120,9 @@ public T getResult(CallableStatement cs, int columnIndex) throws SQLException {
115
120
* the rs
116
121
* @param columnName
117
122
* Column name, when configuration <code>useColumnLabel</code> is <code>false</code>
123
+ *
118
124
* @return the nullable result
125
+ *
119
126
* @throws SQLException
120
127
* the SQL exception
121
128
*/
0 commit comments