更新到版本 3.0.3 后,MariaDB 连接器提供的日期时间精度为 3,而不是 6

发布于 2025-01-14 01:59:40 字数 597 浏览 0 评论 0原文

我有一个带有 mariaDB 的 Spring Boot 应用程序,在将连接器(“org.mariadb.jdbc:mariadb-java-client”)从版本 2.7.5 更新到 3.0.3 后,日期时间(LocalDateTime 和 ZonedDateTime)使用较低的精度。在数据库本身中,列是 DATETIME(6),因此它们应该能够保持 6 的精度。但是,如果我想从数据库获取值,则生成的 LocalDateTime/ZonedDateTime 的精度仅为 3。

示例:
我有一个时间戳为 2022-03-14T08:59:33.893372 的实体。
我将其保存到数据库中。再次从数据库取回该实体。数据库中实体的时间戳将为 2022-03-14T08:59:33.893。
这会导致两个对象的比较失败以及测试失败。

仅当我使用 mariaDB 连接器 3.0.3 时才会出现此问题。 2.7.5 版本一切正常。我不改变任何属性或其他东西。

我正在使用 spring-boot 2.6.4 和 hibernate 5.6.5.Final 和 mariaDb 服务器 10.6。

为什么会出现这种情况?有没有办法通过更新的 mariaDb 连接器获得 6 的精度?

谢谢

I have a spring boot application with mariaDB, after updating the connector ("org.mariadb.jdbc:mariadb-java-client") from version 2.7.5 to 3.0.3 the datetimes (LocalDateTime and ZonedDateTime) are using lower precision. In the database itself the columns are DATETIME(6) so they should be able to keep a precision of 6. But if I want to get a value from db the resulting LocalDateTime/ZonedDateTime only has a precison of 3.

Example:
I have an entity with timestamp 2022-03-14T08:59:33.893372.
I save it to the db. Get this entity back from db again. The timestamp from the entity out of the database will be 2022-03-14T08:59:33.893.
This leads into failing comparison of the two objects and also in failing tests.

The problem occures only if I use mariaDB connector 3.0.3. With version 2.7.5 everything works fine. I don't change any properties or something.

I am using spring-boot 2.6.4 with hibernate 5.6.5.Final and mariaDb server 10.6.

Why does this happen? Is there a way to get precision of 6 with updated mariaDb connector?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半葬歌 2025-01-21 01:59:40

I've got the same issue as yours :(
And found the connector issue https://jira.mariadb.org/browse/CONJ-947, which is fixed already.
The fix will be part of 3.0.5 version

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文