【发布时间】:2013-06-21 11:50:58
【问题描述】:
我正在尝试在Country 类和PM 类之间建立one-to-one 关系。这是我尝试的xml mapping
make。但是正如错误所说,xml 有问题。
Attribute "name" is required and must be specified for element type "one-to-one".
我不明白这一点。我应该为name 属性提及什么?我提到了我正在尝试的课程
建立一对一的关系。
<class name="pojo.Country" table="country">
<id name="c_id">
<generator class="increment" />
</id>
<property name="name_c" />
<one-to-one class="pojo.PM" />
</class>
<class name="pojo.PM" table="pm">
<id name="c_id">
<generator class="increment" />
</id>
<property name="name_pm" />
</class>
有两个表名为pm 和country。我试图建立的关系是一个国家可以有一个 PM,而 PM 可以属于一个国家。
【问题讨论】:
标签: java hibernate jakarta-ee associations hibernate-mapping