hibernate 外键 插入数据问题
<hibernate-mapping>
    <class name="com.pojo.HrBranchInfo" table="hr_branch_info" schema="public">
        <id name="hbiNId" type="java.lang.Integer">
            <column name="hbi_n_id" />
            <generator class="sequence" />
        </id>
        <many-to-one name="hrEmpBase" class="com.pojo.HrEmpBase" fetch="select">
            <column name="hbi_n_operator" />
        </many-to-one>
        <many-to-one name="hrBranchInfo" class="com.pojo.HrBranchInfo" fetch="select">
            <column name="hbi_n_prior" not-null="false" />
        </many-to-one>
        <property name="hbiVName" type="java.lang.String">
            <column name="hbi_v_name" length="40" not-null="true" />
        </property>
        <property name="hbiCState" type="java.lang.String">
            <column name="hbi_c_state" length="1" not-null="true" />
        </property>
        <property name="hbiVDesc" type="java.lang.String">
            <column name="hbi_v_desc" length="200" />
        </property>
        <property name="hbiCTime" type="java.lang.String">
            <column name="hbi_c_time" length="14" />
        </property>
        <property name="hbiNSortindex" type="java.lang.String">
            <column name="hbi_n_sortindex" length="10" />
        </property>
        <property name="hbiVTemp1" type="java.lang.String">
            <column name="hbi_v_temp1" length="100" />
        </property>
        <property name="hbiVTemp2" type="java.lang.String">
            <column name="hbi_v_temp2" length="100" />
        </property>
        <property name="hbiVTemp3" type="java.lang.String">
            <column name="hbi_v_temp3" length="100" />
        </property>
        <set name="hrEmpBases" inverse="true">
            <key>
                <column name="hbi_n_id" not-null="true" />
            </key>
            <one-to-many class="com.pojo.HrEmpBase" />
        </set>
        <set name="hrRelationBranduties" inverse="true">
            <key>
                <column name="hbi_n_id" not-null="true" />
            </key>
            <one-to-many class="com.pojo.HrRelationBranduty" />
        </set>
        <set name="hrBranchInfos" inverse="true">
            <key>
                <column name="hbi_n_prior" not-null="true" />
            </key>
            <one-to-many class="com.pojo.HrBranchInfo" />
        </set>
    </class>
</hibernate-mapping>

 这是一个数据表的配置文件,在我插入数据的时候提示我“錯誤: 欄位"hbinprior"不存在”,请大家帮忙看看。

 

 

 

1个回答

[code="xml"][/code]

你把 fetch="select",这样只有查询的时候才关联吧,把这个属性去掉试试

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐