JPA TemporalType.Date giving wrong date

前端 未结 6 1133

I have a class that has a date field representing a \"valid from\" date for a piece of data. It is defined like this:

@Temporal( TemporalType.DATE )
private          


        
6条回答
  •  心在旅途
    2020-12-04 17:31

    I had the same problem. Don't know the reason but my workaround was the following:

    In the database I changed the column type from DATE to DATETIME.

    In the entity class I changed the @Temporal annotation but kept the datatype Date:

    @Temporal(TemporalType.TIMESTAMP)
    private Date myDate;
    

提交回复
热议问题