From d40b25614d6d3d55ad263a97d01f98c09abf6ce9 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Wed, 7 Dec 2016 14:46:13 +0800 Subject: [PATCH] Update JdbcUtils to improve enum support Since we have StringToEnumConverter and IntegerToEnumConverter in shared DefaultConversionService, BeanPropertyRowMapper supports Enum now, but there is a little problem with jdbc 4.1 rs.getObject(index,type), if type is Enum it will always return null, actually we need String or Integer here, use rs.getObject(index) is fine. --- .../main/java/org/springframework/jdbc/support/JdbcUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java index a8ffad62c679..2709dc521865 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java @@ -131,7 +131,7 @@ public static void closeResultSet(ResultSet rs) { * @see #getResultSetValue(ResultSet, int) */ public static Object getResultSetValue(ResultSet rs, int index, Class requiredType) throws SQLException { - if (requiredType == null) { + if (requiredType == null || requiredType.isEnum()) { return getResultSetValue(rs, index); }