Hi,
I can't figure out how I would map the contained object (a component) that in turn has its own inheritance hierarchy.
In the example below the Containee class is the abstract class and is contained inside of Container class. The Containee has two subclasses:
ContaineeImplA and ContaineeImplB.
The question is how would I tell Hibernate to instantiate/persists the correct subclass of the component class? Is this possible at all? I do not
want to change the object model.
Code:
public class Contatiner {
private Containee basicComponent;
/**
* Persistent property
*/
public Containee getBasicComponent() {
return basicComponent;
}
...
}
public abstract Containee {
private String someGenericProperty;
...
public abstract void someMethod();
}
public ContaineeImplA {
private String fieldA;
public void someMethod() {
}
...
}
public ContaineeImplB {
private String fieldB;
public void someMethod() {
}
...
}
Any help would be much appreciated.
Thanks