@WhenCreated

由 Ebean 管理的日期时间属性,仅在 insert 中设置。

通常,我们在映射超类上同时使用 @WhenCreated@WhenModified

 

示例

@WhenCreated
private Instant whenCreated;

@WhenModified
private Instant whenModified;

}

 

映射超类上的示例

@MappedSuperclass
public abstract class BaseDomain {

    @Id
    protected UUID id;

    @Version
    private long version;

    @WhenCreated
    private Instant whenCreated;

    @WhenModified
    private Instant whenModified;

    public UUID getId() {
        return id;
    }

    public long getVersion() {
        return version;
    }

    public Instant getWhenCreated() {
        return whenCreated;
    }

    public Instant getWhenModified() {
        return whenModified;
    }
}