Hibernate组件作为复合标识符

时间:2016-06-16 02:52:17

标签: hibernate postgresql hibernate-mapping composite-component composite-key

我在postgres中有以下3个表...

table Address { address_id, address_line1, country, zip, owner_id, owner_type }

table Employee { employee_id, first_name, last_name }

table Company { company_id, description }

以下是我的域名类......

class Address { addressLine1, country, zip }

class Employee { id, firstName, lastName, List<Address>}

class Company { id, description, List<Address> }

员工和公司与地址有一对多的关系。

如果是员工地址,则owner_id = employee_id和owner_type =&#39;员工&#39;

如果是公司地址,owner_id = company_id和owner_type =&#39;公司&#39;

如何使用xml配置实现与hibernate的这种关系?我的域名类在一个普通的jar中,所以我没有直接接触它们的自由。

0 个答案:

没有答案