问题
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?
回答1:
<property name="age" type="integer">
<column name="age" not-null="false" default="null" />
</property>
来源:https://stackoverflow.com/questions/10610211/specify-default-value-in-hibernates-xml-configuration-file