Hi,
This posting is to discuss the issue of how to make out real type of an (associated) entity that is retrieved by using polymorphism.
Let us take the case of entity type B being associated to entity type A. B', B", ... are subtypes of B. A typical code to retrieve instances of B (or its subtypes) would be,
A a = (A) session.get (A.class, aid);
B b = a.getB();
B' bb = (B') session.load (B'.class, b.getId());
...
As we can see here, an object of type B' gets created because the code specifies B'.class.
As far as context of A is concerned, it should suffice to use instance of B' as instance of B. But outside of this context, the application code may want to know the real type of the instance.
How does application know real type? Does Hibernate support retrieval of real type? Or is it a responsibility of the application to retrieve the real type of an instance by (storing and) retrieving "real-type" field from the DB?
Please let us know and thanks a lot for your help.
Regards,
Jay
|