Hi,
I created a simple class hierarchy and mapped it using the "Table per class hierarchy" approach, as described in section 3.6.2 of Hibernate in Action. The base class of my hierarchy is abstract.
I can insert a subclass without any problem. When I query the database, I find a row with the discriminator column set to the proper value.
The problem occurs when I try to do a query that selects multiple objects. When I do this, Hibernate throws up a CGLIB error complaining that it cannot instantiate the base class. I can see no reason why it should be trying to do this, since there are only objects of the subclass type stored.
If I make the base class concrete, Hibernate works fine (and the result set contains only instances of the subclasses, as expected).
In my mapping file, I did not give the base class a discriminator-value, although if I give it one anyway, the behavior is the same.
The stack trace indicates that the attempt to instantiate the abstract class is coming from the constructor of net.sf.hibernate.type.ComponentType.
Let me know what you think, thanks.
Hibernate version:
2.1
|