-
Notifications
You must be signed in to change notification settings - Fork 350
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
Same type (java.sql.Timestamp) turns into different SQL-types #1089
Comments
Same thing happens with a
Logs:
|
Please provide a Minimimal Reproducable Example, preferable as a Github repository. Make sure to include the database, either as an in memory database or if that is not possible using Testcontainers. |
Here you go: https://github.com/olereidar/spring-jdbc-help I used Testcontainers. Run the test via gradle |
We do make a mistake when determining the You can work around that by returning a
We should try to determine the |
Thank you, this works. Do you have any plans on fixing this, or do you consider this workaround a permanent solution? EDIT: It only works partly. If the value is nullable (which it is in this case) it crashes when inserting null. Same error:
Any ideas on workaround here? |
I don't consider this workaround a permanent solution. |
Ok, thank you anyways! Let me know if you find a more permanent solution. Have a nice day. |
Somewhat related SO question https://stackoverflow.com/questions/62004522/convert-null-to-some-value-in-spring-converter |
Just stumbled upon the same problem as described by @olereidar . Did you eventually change the design and use a different datatype in the entity? |
We are trying to now use OffsetDateTime in the entity, as the jdbc drivers seem to work properly with them and Spring conversion code is not needed then. |
@huima unfortunately no. We ended up using another library. Awesome if its fixed :D |
Hello, I am not sure where this happens, but I am having some trouble with ZonedDateTime.
I have read in the documentation that ZonedDateTime is not supported (https://docs.spring.io/spring-data/jdbc/docs/current/reference/html/#jdbc.entity-persistence.types), therefore I wrote a converter (ZonedDateTime -> java.sql.Timestamp).
I have the following data class:
Converter:
Repository:
Ok, here is the issue: I am unable to save this as a timestamp. The error is
Translating SQLException with SQL state '42804', error code '0', message [ERROR: column "travel_date" is of type timestamp without time zone but expression is of type character varying
which is quite odd.After investigating this further (and enabling TRACE-logging), it seems like the parameter gets converted into a VARCHAR/string type(?) AND a different type than the `LocalDateTime
Look at logs below:
It seems like String and ZonedDateTime turns into the same SQL type.
The text was updated successfully, but these errors were encountered: