Spring Roo Date Field with Current Timestamp

前端 未结 2 1875
暗喜
暗喜 2021-01-26 17:31

Most databases allow to have field with current timestamp (act as creation timestamp), for example in MySQL:

CREATE TABLE t (ts TIMESTAMP DEFAULT CURRENT_TIMESTA         


        
2条回答
  •  清酒与你
    2021-01-26 17:59

    This would be created with:

    field date --fieldName ts --type java.util.Date --persistenceType JPA_TIMESTAMP
    

    This will add:

     @Temporal(TemporalType.TIMESTAMP) 
    

    to the field, which should cause the auto-generator to create a TIMESTAMP field. If you want more control, you can always annotate the generated entity field further with

     @Column(name="ts", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
    

提交回复
热议问题