Good day!
We have a serious problem using Hibernate.
The case is that we have a Role that is played by a Party. The method call getPlayedBy() on Role results in a (subclass) of Party. The Party-class is subclassed into several classes (including Role itself) differing extraordinary in the amount and sort of attributes.
We succeeded in storing the Role and Party using the <joined-subclass> mapping mechanism. But, when we later read the persistent object, it appears not to be an instance of the specified subclass, but an instance of Party itself (although it is specified as abstract), An 'instanceof' comparison returns false. It seems Hibernate instantiates the wrong class!
We wouldn't like to use the <subclass> mapping, for that would result in a long and wide table with numerous empty fields. In that solutions discriminators are available to tell Hibernate what subclass to instantiate. Instead, we use the <joined-subclass> mapping. As stated: Storing such an object is no problem - it results in a nice ER-diagram, that is pretty good normalized.
Do you recognize the problem and do you see options to solve it?
Greetz,
Erwin
|