Skip to content

Commit 983e664

Browse files
authored
Update CharacterTypeHandler.java
first,this is a basic error, the condition statement miss the "" condition in if(...); in this case, i execute the select sql statement, and the resultType include a property -- Character type, when the DataBase return a "", Mybatis will throw a Exception: index out of range, becasue the array's length is 0 in the statement -- "return columnValue.charAt(0);"
1 parent 0133e37 commit 983e664

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/org/apache/ibatis/type/CharacterTypeHandler.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void setNonNullParameter(PreparedStatement ps, int i, Character parameter
3333
@Override
3434
public Character getNullableResult(ResultSet rs, String columnName) throws SQLException {
3535
String columnValue = rs.getString(columnName);
36-
if (columnValue != null) {
36+
if (columnValue != null && columnValue != "") {
3737
return columnValue.charAt(0);
3838
} else {
3939
return null;
@@ -43,7 +43,7 @@ public Character getNullableResult(ResultSet rs, String columnName) throws SQLEx
4343
@Override
4444
public Character getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
4545
String columnValue = rs.getString(columnIndex);
46-
if (columnValue != null) {
46+
if (columnValue != null && columnValue != "") {
4747
return columnValue.charAt(0);
4848
} else {
4949
return null;
@@ -53,7 +53,7 @@ public Character getNullableResult(ResultSet rs, int columnIndex) throws SQLExce
5353
@Override
5454
public Character getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
5555
String columnValue = cs.getString(columnIndex);
56-
if (columnValue != null) {
56+
if (columnValue != null && columnValue != "") {
5757
return columnValue.charAt(0);
5858
} else {
5959
return null;

0 commit comments

Comments
 (0)