Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.8k views
in Technique[技术] by (71.8m points)

mysql - 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.

Hibernate stores this field in the database as a 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...