(using Hibernate 3.x)
Person and Building have multiple Addresses.
Person and Building are persisted in their own table. They do not share anything in common (separate class hierarchies).
I'd like to persist the Addresses in a single table, whether they are attached to a Person or a Building.
Code:
public class Person {
...
Collection<Address> addresses;
...
}
public class Building {
...
Collection<Address> addresses;
...
}
In addition, the Address's lifecycle is bounded to the one of its owner, ie. Person's addresses should be deleted when the Person is deleted.
In other words, Addresses are not shared between different entities.
I have tried many different mapping strategies with no (real) success... Hibernate offers so many options since the 3.x series - I'm getting lost.
Can someone please help me on this subject ?
Thx
/bertrand