The answer is probably somewhere in this forum but I can't formulate the correct search terms.
Code:
abstract class A {}
class Ax extends A{}
class Ay extends A{}
class B {
A anA;
void setA(A a) { anA = a; }
}
I am using table per subclass.
Code:
A a = new Ax();
session.save(a);
B b = new B();
b.setA(ax);
session.save(b);
... later...
Code:
B b = Bdao.findById(foo); // assuming foo is the id of b above
A a = b.getA(); ***
*** questions:
1. the actual class of "a" would be Ax ?
2. what the DDL for class B should look like ?
Would this suffice ?
table B [
anA long foreign key to table A
]
3. how does hibernate knows to create an Ax (instead of an Ay) if class B DDL only contains a foreign key id to table A ?
Thanx.
-cs