Right now I have a class heirarchy for example:
Code:
abstract class A {}
class B extends A {} // maps to table TB
class C extends A {} // maps to table TC
and I will have code to save the objects:
Code:
A b = new B();
A c = new C();
session.save(b); // inserted into table TB
session.save(c); // inserted into table TC
what I would like is the ability to have parallel set of tables depending on the entity name attribute provided to the save method, for example:
Code:
abstract class A {} // mapped to entity-names E1,E2 in different <class>
class B extends A {} // maps to table TB1 and TB2 respectively
class C extends A {} // maps to table TC1 and TC2 respectively
Code:
A b1 = new B();
A c1 = new C();
A b2 = new B();
A c2 = new C();
session.save("E1",b1); // inserted into table TB1
session.save("E1",c1); // inserted into table TC1
session.save("E2",b2); // inserted into table TB2
session.save("E2",c2); // inserted into table TC2
I would like the entity-name attribute inherited so I don't have to know what subclass is being saved. I did notice
someone have a problem with inheriting entity-name
but I do not mind hard-coding the entity-name for each subclass to be the same.
I've tried setting this up using two xml mapping files and have the entity-name attribute be inherited and just hardcoded to be the same for each heirarchy, but run into errors while parsing the configuration files. Is this even possible??
thanks