为什么我在序列化类时遇到'org.hibernate.type.SerializationException:无法反序列化?

时间:2018-04-07 02:04:55

标签: java hibernate

@Table(name="Article")
@Access(value = AccessType.FIELD)
public class Articles implements Serializable {

  private static final long serialVersionUID = -6652995014527706545L;

  public Articles() {
      OffsetDateTime dateTime = OffsetDateTime.now();
//    Timestamp timestamp = Timestamp.valueOf(dateTime.atZoneSameInstant(ZoneId.of("Z")).toLocalDateTime());
      this.timeStamp = dateTime;
  }

  @Column(name = "timeStamp")
    @Access(value = AccessType.FIELD)
    private OffsetDateTime timeStamp;

    public OffsetDateTime getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(OffsetDateTime timeStamp) {

}

我几乎没有其他类变量,但只有在添加timeStamp变量后,我才遇到这个问题

1 个答案:

答案 0 :(得分:0)

确定。我自己找到了。使用java.time导入是个问题。我应该使用sql.time。它解决了它。