两个实体:
public class Employee {
Company company;
Long employeeId;
}
public class Project {
Company company;
Long projectId;
Collection<Employee> employees;
}
三张桌子:
xml中的映射:
<entity class="domain.Project">
<attributes>
<many-to-many name="employees" >
<join-table name="PROJECT_EMPLOYEE">
<join-column name="companyId" referenced-column-name="companyId"/>
<join-column name="employeeId" referenced-column-name="employeeId" />
<inverse-join-column name="companyId" referenced-column-name="companyId" />
<inverse-join-column name="projectId" referenced-column-name="projectId" />
</join-table>
</many-to-many>
</attributes>
</entity>
我收到错误抱怨公司多次出现: 收集映射中的重复列:Project.employees列:companyId
Hibernate用
映射它<formula>companyId</formula>
JPA 1.0是否支持此功能?