简体   繁体   English

Java ZonedDateTime保存在数据库中

[英]Java ZonedDateTime save in the Database

I have a model object where I want to have a field with a date. 我有一个模型对象,我想要一个带日期的字段。 For now I am using ZonedDateTime as it fits our needs. 目前我正在使用ZonedDateTime因为它符合我们的需求。

Hibernate stores this field in the database as a tinyblob . Hibernate将此字段作为tinyblob存储在数据库中。 Can we change the way it is saved in the database to a more readable format and more importantly to a sortable format? 我们可以将它在数据库中保存的方式更改为更易读的格式,更重要的是更改为可排序格式吗?

The database used is a mysql db. 使用的数据库是一个mysql数据库。

This issue has already been resolved as a new improvement to Hibernate 5.0.0.Beta1 , originally it was bundled in an isolated module hibernate-java8 这个问题已经解决为Hibernate 5.0.0.Beta1一项新改进 ,最初它被捆绑在一个独立的模块 hibernate-java8

Now it is directly bundled in hibernate-core , so just make sure that you are using the recent version of it (5.2.X +), in case you are using maven , it should be like this 现在它直接捆绑在hibernate-core ,所以只要确保你使用它的最新版本(5.2.X +),以防你使用maven ,它应该是这样的

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
  <version>5.2.10.Final</version>
</dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM