我用谷歌搜索,但所有示例都只向我展示了一对一Component
的对象,例如:
我想要二合一Component
的对象,例如:
public class PhoneNumber {
// Phone details
private int areaCode = 0;
private int phoneNumber = 0;
private String name = null;
}
public class Person {
private String firstName = null;
private String nickName = null;
private String lastName = null;
// Multiple phone details
private PhoneNumber homePhone = null;
private PhoneNumber mobilePhone = null;
}
休眠映射:
<class name="Person" table="PERSON">
<id name="id" column="PERSON_ID">
<generator class="native"/>
</id>
<property name="firstName" column="FIRST_NAME" />
...
<component name="homePhone" class="PhoneNumber">
<property name="areaCode" column="HOME_AREA_CODE"/>
<property name="phoneNumber" column="HOME_PHONE_NUMBER"/>
<property name="name" column="HOME_NAME"/>
</component>
<component name="mobilePhone" class="PhoneNumber">
<property name="areaCode" column="MOBILE_AREA_CODE"/>
<property name="phoneNumber" column="MOBILE_PHONE_NUMBER"/>
<property name="name" column="MOBILE_NAME"/>
</component>
</class>
我Component
上面有两个,homePhone
和mobilePhone
。如何将上述Hibernate
映射转换为Java
注释?