我有两张桌子:
是否可以创建 XML 配置:
答案 0 :(得分:1)
是的,xmls可能如下所示:
<hibernate-mapping>
<class name="QUALIFIED_NAME_OF_CUSTOMERS" table="CUSTOMERS" catalog="YOUR_DATABASE_NAME">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="identity" />
</id>
<one-to-one name="PERSONAL_DATA" class="QUALIFIED_NAME_OF_PERSONAL_DATA"
cascade="save-update"></one-to-one>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="QUALIFIED_NAME_OF_PERSONAL_DATA" table="PERSONAL_DATA"
catalog="YOUR_DATABASE_NAME">
<id name="customer_id" type="java.lang.Integer">
<column name="customer_id" />
<generator class="foreign">
<param name="property">CUSTOMERS</param>
</generator>
</id>
<one-to-one name="CUSTOMERS" class="QUALIFIED_NAME_OF_CUSTOMERS"
constrained="true">
</one-to-one>
<property name="id" type="java.lang.Integer">
<column name="id" />
</property>
</class>
</hibernate-mapping>