JPA配置实体时 insertable = false, updatable = false

发布时间 2023-08-03 12:57:05作者: 且行且思
    @Excel(name = "创建时间", format = "yyyy-MM-dd HH:mm:ss", width = 20)
    @Column(name = "created_time", insertable = false, columnDefinition = "timestamp default current_timestamp")
    @Temporal(TemporalType.TIMESTAMP)
    @Generated(GenerationTime.INSERT)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    protected Date createdTime;

 

    @Excel(name = "修改时间", format = "yyyy-MM-dd HH:mm:ss", width = 20)
    @Column(name = "updated_time")
    @org.hibernate.annotations.UpdateTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    protected Date updatedTime;