更新到版本 3.0.3 后,MariaDB 连接器提供的日期时间精度为 3,而不是 6
我有一个带有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我和你有同样的问题:(
并发现连接器问题 https://jira.mariadb.org/browse/CONJ-947,已经修复了。
该修复将成为 3.0.5 版本的一部分
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