强制Spring JPA插入“ insertable = false”的列

时间:2018-08-01 07:06:37

标签: spring hibernate spring-boot spring-data-jpa

我有实体:

@Getter
@Setter
@Entity(name = "sendingstate")
public class SendingState {

@Id
protected String sendingStateId;
protected String documentId;
protected String state;
@Column(insertable = false, updatable = false)
protected Date createdAt;
@Column(insertable = false, updatable = false)
protected Date updatedAt;

}

createdAt和updatedAt列由数据库自身自动填充,并且很好。但是当我编写测试时-我希望能够在这些字段中填充自定义值,以便可以将它们保存在db中。有办法吗?

0 个答案:

没有答案