You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Program is using org.springframework.jdbc.core.BeanPropertyRowMapper to map result set to the bean.
When mapping timestamp resultset column to the bean's java.time.LocalDateTime field, process fails with
org.springframework.jdbc.support.JdbcUtils getResultSetValue with error
IllegalStateException: Cannot convert value of type [java.sql.Timestamp] to required type [java.time.LocalDateTime] for property 'nameproperty': no matching editors or conversion strategy found.
The problem is not so much in JdbcUtils which simply returns what the JDBC driver gives us. We're trying JDBC 4.1's getObject(int, Class) with a java.time.LocalDateTime argument in this case, but if that call happens to fail against your JDBC driver, we'll just plain getObject(int) which usually returns a java.sql.Timestamp in such a case. I suppose that's your scenario.
However, arguably, BeanPropertyRowMapper should use its BeanWrapper preconfigured with a DefaultConversionService: Our date-time conversion capabilities are built-in there, so even if a java.sql.Timestamp comes along, we can convert it to a java.time.LocalDateTime bean property on our own. I'm looking at this as a default for Spring Framework 4.3.
For the time being, you could override the BeanPropertyRowMapper.initBeanWrapper method and call bw.setConversionService(new DefaultConversionService()); yourself.
Radmila opened SPR-13888 and commented
Program is using org.springframework.jdbc.core.BeanPropertyRowMapper to map result set to the bean.
When mapping timestamp resultset column to the bean's java.time.LocalDateTime field, process fails with
org.springframework.jdbc.support.JdbcUtils getResultSetValue with error
IllegalStateException: Cannot convert value of type [java.sql.Timestamp] to required type [java.time.LocalDateTime] for property 'nameproperty': no matching editors or conversion strategy found.
Problem with spring 4.1.6.RELEASE. and JDK 1.8
Issue Links:
Referenced from: commits 7c96059
1 votes, 3 watchers
The text was updated successfully, but these errors were encountered: