I use JPA 2 with Hibernate. There are two entity classes, CardElement
and IdentityDocumentKind
. The last one is an inherited entity of the first one. SINGLE_TABLE inheritance strategy is used. When I try to select an instance of the parent class by query from CardElement where id = '123456'
the following error occures:
Object with id: 123456 was not of the specified subclass: org.cp.cardsystem.CardElement (Discriminator: SDocClass)
I don't have a subclass for "SDocClass" discriminator value. Actually at the moment of developing IdentityDocumentKind
class querying of CardElement
was used widely across the application. So I can't create a subclass of CardElement
for each discriminator value and replace CardElement
with it in all existent queries. It would be cost too much efforts for me. Is there a way to instantiate parent entity class when SINGLE_TABLE inheritance strategy is used?