-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Wrong timestamps from MySQL via Hibernate ORM #44413
Comments
Hello,
This is very, very likely to be a problem in Hibernate, or something in the MySQL JDBC driver that Hibernate does not successfully work around. Or simply an expected behavior in Hibernate. My bet would be on Hibernate ORM's Regardless, if you want a change/fix here, it's probably worth creating a reproducer based on https://github.com/hibernate/hibernate-test-case-templates/blob/main/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeORMUnitTestCase.java and report to the Hibernate ORM project instead. |
As to why you're fine with H2... each DB and JDBC driver works differently, so even with the same input, you get different results. It's a mess. |
By the way, I did see similar behavior when running your reproducer:
Actual time was Which makes me think the value for |
I'm not saying it's at fault. I'm saying the same value in the DB has a different interpretation in Hibernate ORM depending on the column (and the type of the JPA attribute mapped to the column), and thus is not, in practice, the same. Yes I know, it's confusing.
Yeah I can see how that would happen. Like I said, different types, different interpretations of the stored data.
Yeah I wouldn't take what clients show for granted... It's complicated. From what I see in the docs though, the It's really looking like something that should be brought up in the Hibernate ORM tracker instead of here though :)
When you report to Hibernate ORM, can you also tell what the timezone of your application and DB is? Depending on the environment, Docker and similar might force it to UTC, so it's worth checking. |
Yeah, I know. I just hope this is not intended behavior, because it is not only unintuitive in this case, it feels completely wrong.
I didn't have to for my reproducer to show the issue on my machine. But I tried setting it to other timezones and the times of the
Will do. Thanks for your feedback. Unfortunately Hibernate ORM doesn't use GitHub issue tracking, so I'll have to create an account first. I will post a link here once I get around to it.
Yeah, good point. In my case it's all CET on server and client (connection) side. This usually avoids problems like here. |
Describe the bug
I'm not sure if this problem is specific to Quarkus or if it is a bug in Hibernate:
Instant
entity fields give wrong times if querying in a time zone other than UTC+0.Timestamp
entity fields, however, work as expected.I didn't test the other types Hibernate ORM supports.
Expected behavior
Instant
entity fields should have the same time asTimestamp
fields, given the same SQL timestamp.Actual behavior
Instant
entity fields can differ fromTimestamp
fields, depending on the time zone setting.How to Reproduce?
Reproducer: reproducer.zip
It contains a test class to demonstrate the issue.
I also tested the reproducer with a H2 database, where there was no problem using the same configuration. It looks like
quarkus.hibernate-orm.jdbc.timezone
is partly ignored with MySQL.Output of
uname -a
orver
No response
Output of
java -version
No response
Quarkus version or git rev
3.16.2
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: