@Generated(GenerationTime.ALWAYS) @Column(name =“ create_date”,insertable = false,updatable = false)
答案 0 :(得分:0)
您有3个选择。
ALWAYS
Indicates the value is generated on insert and on update.
INSERT
Indicates the value is generated on insert.
NEVER
Indicates the value is never generated.
答案 1 :(得分:0)
GenerationTime.ALWAYS
GenerationTime.ALWAYS在插入时间和 更新。对于GenerationTime.ALWAYS,该属性不应 可以插入和更新。
@Generated(GenerationTime.ALWAYS)
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "modified_date", updatable = false, insertable = false)
private Date modifiedDate;
GenerationTime.INSERT
GenerationTime.INSERT仅在插入时更新实体。对于GenerationTime.INSERT,该属性不应 可以插入。
@Generated(GenerationTime.INSERT)
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created_date", insertable = false)
private Date createdDate;
GenerationTime.Never
GenerationTime.NEVER既不会在更新时间也不会在插入时间更新实体。
@Generated(GenerationTime.NEVER)
这些注释也可以用于以下每种类型:
java.sql.Timestamp
@Column
@CreationTimestamp
private LocalDateTime createDateTime;
@Column
@UpdateTimestamp
private LocalDateTime updateDateTime;