Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports ConversionService on SingleColumnRowMapper [SPR-16483] #21026

Closed
spring-projects-issues opened this issue Feb 11, 2018 · 1 comment
Closed
Assignees
Labels
in: data type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Feb 11, 2018

Kazuki Shimizu opened SPR-16483 and commented

I will propose to support the ConversionService on SingleColumnRowMapper like as the BeanPropertyRowMapper.

In fact, I've encountered a problem that cannot fetch as LocalDateTime using JdbcTemplate#queryForObject on JDBC driver that does not support JDBC 4.1(e.g. HSQL 2.3.5).

e.g.)

JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
LocalDateTime localDateTime = jdbcTemplate.queryForObject(
        "SELECT current_timestamp FROM INFORMATION_SCHEMA.SYSTEM_USERS"
        , LocalDateTime.class);

Above code occurred TypeMismatchDataAccessException as follow:

org.springframework.dao.TypeMismatchDataAccessException: Type mismatch affecting row number 0 and column type 'TIMESTAMP WITH TIME ZONE': Value [2018-02-11 22:59:00.54] is of type [java.sql.Timestamp] and cannot be converted to required type [java.time.LocalDateTime]

	at org.springframework.jdbc.core.SingleColumnRowMapper.mapRow(SingleColumnRowMapper.java:108)
	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93)
	at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60)
	at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:434)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:376)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:446)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:456)
	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:467)
	at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:474)
...

WDYT?


Affects: 5.0.3

Referenced from: pull request #1678, and commits 8c623c8

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Feb 11, 2018

Juergen Hoeller commented

Good idea, and good point that it's aligned with BeanPropertyRowMapper then. Merged for 5.0.4.

@spring-projects-issues spring-projects-issues added in: data type: enhancement labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.0.4 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants