struts2与hibernate 复合主外键在映射文件*.hbm.xml中的配置,为双外键的配置方法
代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.pms.bean.bc.scan.ScannerEnvBean" table="TbScannerEnv">
<!-- <id name="scanner" column="SE_Scanner" length="20">-->
<!-- <generator class="assigned"/>-->
<!-- </id>-->
<!-- <many-to-one name="depart" class="com.pms.bean.dialog.DepartmentDialogBean" outer-join="true" not-null="true" lazy="false">-->
<!-- <column name="SL_LINE"></column>-->
<!-- </many-to-one>-->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.pms.bean.bc.scan.ScannerEnvBean" table="TbScannerEnv">
<!-- <id name="scanner" column="SE_Scanner" length="20">-->
<!-- <generator class="assigned"/>-->
<!-- </id>-->
<!-- <many-to-one name="depart" class="com.pms.bean.dialog.DepartmentDialogBean" outer-join="true" not-null="true" lazy="false">-->
<!-- <column name="SL_LINE"></column>-->
<!-- </many-to-one>-->
<!-- scanner即是主键又是外键 -->
<composite-id>
<key-many-to-one name="scanner" class="com.pms.bean.bc.scan.ScannerBean">
<column name="SE_Scanner" length="20"></column>
</key-many-to-one>
</composite-id>
<composite-id>
<key-many-to-one name="scanner" class="com.pms.bean.bc.scan.ScannerBean">
<column name="SE_Scanner" length="20"></column>
</key-many-to-one>
</composite-id>
<!-- order_Aufnr是是外键 -->
<many-to-one name="order_Aufnr" class="com.pms.bean.base.OrderBean" outer-join="true" not-null="true" lazy="false">
<column name="SE_WO"></column>
</many-to-one>
<property name="boxCode" type="string" column="SE_BoxCode" length="100"></property>
<property name="demo" type="string" column="SE_Demo" length="100"></property>
</class>
</hibernate-mapping>
<many-to-one name="order_Aufnr" class="com.pms.bean.base.OrderBean" outer-join="true" not-null="true" lazy="false">
<column name="SE_WO"></column>
</many-to-one>
<property name="boxCode" type="string" column="SE_BoxCode" length="100"></property>
<property name="demo" type="string" column="SE_Demo" length="100"></property>
</class>
</hibernate-mapping>
为双外键的配置方法:
<many-to-one name="dispatcherBean" class="com.pms.bean.base.prd.DispatcherBean" outer-join="true" not-null="true" lazy="false">
<column name="MA_FEVOR"/>
<column name="MA_WERKS"/>
</many-to-one>