I'm a newbie to Hibernate, but can't seem to find an answer in the Help docs or Google. I have a situation where my class structure is as follows:
Code:
public class AddressType {
private String id; // PK
private String description;
.....
}
public class Address {
private int personId; // 1 part of composite Id
private AddressType addrType = ...; // 2nd part of composite Id
.....
}
For Address, the Primary Key is actually a compound key: "Address.personId" and "Address.addrType.id". I believe I have the first part of the mapping which maps personId, but I can't figure out how to do the 2nd part (the mapping of "Address.addrType.id").
Code:
<hibernate-mapping>
<class name="com.Address" table="Address">
<composite-id>
<key-many-to-one entity-name="com.Person"
name="personId"
column="PersonId"
foreign-key="true"/>
</composite-id>
</class>
</hibernate-mapping>
I recognize that I could just remove the AddressType object and use regular addressTypeId as a class int variable, but I was hoping someone could shed some light on how I could fix this problem. Any help anyone could lend would be appreciated.
Hibernate version: 3rc1
Mapping documents:
Name and version of the database you are using: HSQLDB for testing, MS SQL Server 2000 for production