-
Notifications
You must be signed in to change notification settings - Fork 346
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
After Upgrading spring-data-jdbbc from 1.1.12.RELEASE to 2.0.6.RELEASE LocalDateTime parameters in Repository methods fail #974
Comments
We now convert Currently I can't imagine why that is. I asked the Postgres team on their Slack channel for more information about this. |
So the reason this happens is because the driver doesn't know what to do with timestamp or timestamptz ahead of time. prepareStatement does not provide us this information so have to convert setTimestamp to setString and hope the server does the right thing, which apparently it does not. With LocalDateTime we know that it is a timestamp. Unfortunately this is a situation where postgres advanced data types are not helpful. |
@davecramer Thanks for shedding some light, and for confirming that what I see is actually correct. If I get it right, things would work better with Postgres when we use Out of curiosity: Is there a reason why the driver can't do the same thing it does for |
The short version is that there is no setTimestampTZ. The underlying type could be timestamp or timestamptz. The driver doesn't have that information. For the most part sending a string does the right thing... except when it doesn't. |
Most supported databases don't need that conversion. Db2 does need it and gets it through JdbcDb2Dialect. As part of the effort it became obvious that the filtering for conversions between Date and JSR310 data types was broken. It is fixed now, which required a dedicated reading conversion from LocalDateTime to Date for JdbcMySqlDialect. Closes #974
Use static import for `SoftAssertions.assertSoftly` everywhere. Polishing of the conversion filter. See #974
Thnx a lot guys. Keep up the good work 👍 |
I am trying to upgrade from Spring Boot 2.2.x to 2.3 I have encountered an issue with the upgrade of spring-data-jdbc. In 1.1.x one could write the following query and it would work as expected
Parameters passed to JDBC query are
unknown
but the postgres JDBC driver (v. 42.2.18) understands and applies the correct JDBC type:After the upgrade the same query fails. The parameters passed to JDBC query (please notice that the our
LocalDateTime
parameter is converted to ajava.util.Date
one):but
ERROR: column "preview_start" is of type timestamp without time zone but expression is of type interval
exception thrown is:After updating the query like below, by manually
CAST
ing to timestamp, all is fine again, but I hate it to be honest and there must be a better way. Is there? e.g. aConverter
or something?I also tried to replace
LocalDateTime
withjava.sql.Timestamp
as parameter, but failed with the same error again.To recap, is there anything I can do so that I get the same behavior as before upgrading
spring-data-jdbc
to v 2.x?The text was updated successfully, but these errors were encountered: