设置默认值在JPA列 [英] Setting default values for columns in JPA
本文介绍了设置默认值在JPA列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能设置在JPA列的默认值,如果,它是如何使用注释做了什么?
Is it possible to set a default value for columns in JPA, and if, how is it done using annotations?
推荐答案
其实这是有可能在JPA,虽然使用的的 columnDefinition
属性一劈一点点 @Column
注释,例如:
Actually it is possible in JPA, although a little bit of a hack using the columnDefinition
property of the @Column
annotation, for example:
@Column(name="Price", columnDefinition="Decimal(10,2) default '100.00'")
这篇关于设置默认值在JPA列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文