Hi all,
We have a mapping problem:
In our domain model, we have a
Container that has a
set of
Entities (i.e. it is a one-to-many association).
Entity is an interface, and the concrete implementation classes are each mapped to a
different database table. This is what "Hibernate in Action" refers to as - "table-per-class" model. (It means that each implementation class has a separate hbm.xml file, as opposed to creating a single hbm.xml for the super-class/interface and using a discriminator column...).
Here is the relevant code:
Code:
public class Container
{
private Set<Entity> entities;
}
public interface Entity
{
Container getParent();
void setParent(Container container);
}
public class User implements Entity
public class Device implements Entity
The problem, is how to map a one-to-many, when the "many" is polymorphic, and in separate tables. (i.e. how to map the above
Container class)
We have already encountered a similar problem, but with the polymorphism being in the "one" side of the many-to-one association. We were able to map it using the Hibernate "
any" mapping element. Unfortunately, "
any" is not available for a "
set" mapping-element.
We would appreciate any insights.
Thanks a lot,
Naaman