I have classes and annotations as following.
class A {
@Embedded
B getB() {
return b;
}
}
@Embeddable
abstract class B {
}
class C extends B {
}
class D extends B {
}
See, I declare B an Embeddable entity. Also I turned on Discriminator parameters for B, C and D.
I try to persist instances of A.
A a = new A();
a.setB(new C());
session.save(a);
But Hibernate tries to instantiate an instance of B and save it, which fails since B is abstract. So my question is how to let Hibernate tell which is the real class to persist with? I tried @Target, but it only allows one class specified.
Best,
bonjovi
|