如果value为null,则设置Database的默认值

时间:2015-10-05 11:42:24

标签: java hibernate

在java hibernate中如果使用hibernate hbm属性将值inseting为null,如何在列中设置数据库的默认值?

1 个答案:

答案 0 :(得分:0)

对于你可以使用的.hbm文件,默认元素 例如: -

<catalog>
    <product product-id="D158413" mode="delete"/>
    <product product-id="556204380">
    <ean>5014414203648</ean>
    <display-name>Double duvet cover</display-name>
    <long-description>Line</long-description>
    <online-flag>true</online-flag>
    <available-flag>true</available-flag>
    <searchable-flag>true</searchable-flag>
    <tax-class-id>default</tax-class-id>
    <brand>Linea</brand>
    <manufacturer-name>Linea</manufacturer-name>
    <custom-attributes>
        <custom-attribute attribute-id="Care Instructions">Machine</custom-attribute>
        <custom-attribute attribute-id="Colour">Pink</custom-attribute>
        <custom-attribute attribute-id="Finish">Plain</custom-attribute>
        <custom-attribute attribute-id="Guarantee">N/A</custom-attribute>
    </product>  
</catalog>