Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何用JPA映射MySql中毫秒精度的时间戳字段_Jpa_Timestamp_Milliseconds - Fatal编程技术网

如何用JPA映射MySql中毫秒精度的时间戳字段

如何用JPA映射MySql中毫秒精度的时间戳字段,jpa,timestamp,milliseconds,Jpa,Timestamp,Milliseconds,我需要将毫秒精度的时间戳存储到数据库中 我用谷歌搜索做了很多尝试。但每次尝试都失败了。 它们都被截断了毫秒,只返回到秒 我的尝试有什么问题 这里我列出了我尝试过的东西 //环境 JPA 2.1 Hibernate 5.2.10 MySql 5.5.28 //我的努力。。。 问题解决了。这是mysql版本问题。升级最新5.7版本后。一切正常。 // Failed to get milliseconds @Temporal(TemporalType.TIMESTAMP) private java.

我需要将毫秒精度的时间戳存储到数据库中

我用谷歌搜索做了很多尝试。但每次尝试都失败了。 它们都被截断了毫秒,只返回到秒

我的尝试有什么问题

这里我列出了我尝试过的东西

//环境

JPA 2.1
Hibernate 5.2.10
MySql 5.5.28
//我的努力。。。
问题解决了。这是mysql版本问题。升级最新5.7版本后。一切正常。
// Failed to get milliseconds
@Temporal(TemporalType.TIMESTAMP)
private java.util.Date updatedAt;


// Failed to get milliseconds
private java.sql.Timestamp updatedAt;


// Failed to get milliseconds
@Column(columnDefinition = "TIMESTAMP")
private java.sql.Timestamp updatedAt;


// Failed to get milliseconds
@Column(columnDefinition = "TIMESTAMP (3)")
private java.sql.Timestamp updatedAt;


// Failed to get milliseconds
@Column(columnDefinition = "TIMESTAMP (6)")
private java.sql.Timestamp updatedAt;


// Failed to get milliseconds
// with converter https://github.com/leapfrogtechnology/vyaguta-commons/blob/master/src/main/java/com/lftechnology/vyaguta/commons/jpautil/LocalDateTimeAttributeConverter.java
private LocalDateTime updatedAt;


// Failed to get milliseconds
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
private org.joda.time.DateTime updatedAt;