在Hibernate的XML配置文件中指定默认值 [英] Specify default value in Hibernate's XML configuration file
本文介绍了在Hibernate的XML配置文件中指定默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< class name =Persontable =person >
< id name =idcolumn =idtype =long/>
< property name =namecolumn =nametype =string/>
< property name =agecolumn =agetype =integer/>
< / class>
如何将 age
设为可空并且默认为空?
解决方案
< property name =agetype =整数>
< column name =agenot-null =falsedefault =null/>
< / property>
I'm configuring Hibernate via the mapping configuration file.
<class name="Person" table="person">
<id name="id" column="id" type="long"/>
<property name="name" column="name" type="string"/>
<property name="age" column="age" type="integer"/>
</class>
How do I set age
to be nullable and default to null?
解决方案
<property name="age" type="integer">
<column name="age" not-null="false" default="null" />
</property>
这篇关于在Hibernate的XML配置文件中指定默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文