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

Unsupported SQL type: TIMESTAMP_WITH_TIMEZONE when using OffsetDateTime with MySQL #30556

Closed
yotov opened this issue May 30, 2023 · 1 comment
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression
Milestone

Comments

@yotov
Copy link

yotov commented May 30, 2023

Since upgrading to spring-boot 3.1 ( spring framework 6.0.9 ) I'm experiencing a new exception for methods that uses OffsetDateTime as a parameter in database queries ( MySQL ). I'm using BeanPropertySqlParameterSource and passing a record that has OffsetDateTime as a field and here is the exception:

Unsupported SQL type: TIMESTAMP_WITH_TIMEZONE
	at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:104)
SQLExceptionSubclassTranslator.java:104
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70)
AbstractFallbackSQLExceptionTranslator.java:70
	at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1538)
JdbcTemplate.java:1538
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:667)
JdbcTemplate.java:667
	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:960)
JdbcTemplate.java:960
	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:981)
JdbcTemplate.java:981
	at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:328)

After some research, it looks like the problem is caused by #30123 because MySQL doesn't support these new types ( https://github.com/mysql/mysql-connector-j/blob/release/8.0/src/main/core-api/java/com/mysql/cj/MysqlType.java#L681 )

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 30, 2023
@jhoeller jhoeller added in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 3, 2023
@jhoeller jhoeller added this to the 6.0.10 milestone Jun 3, 2023
@jhoeller jhoeller self-assigned this Jun 3, 2023
@jhoeller
Copy link
Contributor

jhoeller commented Jun 3, 2023

Thanks for the report! We fall back to a plain setObject call without a SQL type now in case of a not-supported exception which seems generally sensible. We do the same for setNull even if MySQL is actually leniently ignoring the type value there in any case.

@jhoeller jhoeller changed the title Unsupported SQL type: TIMESTAMP_WITH_TIMEZONE when using OffsetDateTime with mysql Unsupported SQL type: TIMESTAMP_WITH_TIMEZONE when using OffsetDateTime with MySQL Jun 3, 2023
mdeinum pushed a commit to mdeinum/spring-framework that referenced this issue Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants