我正在使用PostgreSQL 9.3和spring-data-jpa 1.8.0 . 我创建了一个带有created_at列的表(类型 - 没有时区的时间戳):

CREATE TABLE users
(
  id bigint NOT NULL,
  created_at timestamp without time zone NOT NULL DEFAULT now(),
  updated_at timestamp without time zone NOT NULL DEFAULT now(),
  CONSTRAINT users_pkey PRIMARY KEY (id)
)

因此,如果我尝试使用此表中的实体类来获取数据,则createdAt字段始终为null . 我的代码:

@Column(name = "created_at", nullable = false)
@Type(type = "date")
@Temporal(value = TemporalType.TIMESTAMP)
@CreationTimestamp
public Date getCreatedAt() {
    return createdAt;
}

@PrePersist
public void onPrePersist() {
    this.setCreatedAt(new Date());
}

我究竟做错了什么?