Here's my situation. I'd like to have hibernate map an interface class, and configure it as to which subclass to instantiate when it is retrieved from the database. The basic reason is that when one module has an instance of another' module's interface, the relationship between the two should not be specified in terms of interface classes
public class Module1Intf {
int getId();
void setId(int id);
Module2Intf getModule2Intf();
void setModule2Intf(Module2Intf intf);
}
public class Module2Intf {
int getId();
void setId(int id);
}
public class Module1IntfImpl implements Module1Intf{
...
}
public class Module2IntfImpl implements Module2Intf{
...
}
If mappings are done in the implementation classes, then the
mapping for Module1IntfImpl needs to know about the implementation
class for Module2Intf. This is a bad thing, as it will violate the whole
notion of implementation hiding.
What i'd like to do is to create the mappings on the interface, and
have a way of telling hibernate which class to instantiate when it
loads from the database.
Any help here would be appreciated.
|