2011-04-05 23 views

回答

4

這與創建:

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

這將增加:

@Temporal(TemporalType.TIMESTAMP) 

到外地,這應該引起自動生成器來創建一個時間戳字段。如果你想要更多的控制,你可以隨時批註生成的實體領域進一步

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

這可以通過西蒙的建議來完成,但也可能是值得檢查出一個更全面的解決方案。

看看這個Spring Roo Timestamp附加組件。它將「創建」和「更新」時間戳添加到標有其註釋的所有實體。 https://github.com/rcaloras/spring-roo-addon-timestamp

(我創建了它,很樂意回答問題或添加附加功能)

相關問題