I have trouble with a polymorphic unidirectional relation with single tabled inheritance. As not yet have that much experiences from JPA programming am I not quite sure if I break any syntactic rules or if it is a bug. I use OpenJPA 2 and have a class Depot which have a unidirectional relation to transactions that implements DepotTransactions where the class AbstractDepotTransaction is an entity and superclass with subclasses that implements different type of transaction types. This is how the relation is defined in the Depot class:
Persist of concrete transactions through this list works fine but when a Depot is queried is the list always empty. The problem seems to be that the query actually executed queries for transaction types of a specific type and in case that type is AbstractDepotTransaction will never anyone be found:
The part "WHERE t1.TX_TYPE = ?" is what seems to cause the problem as it limits the result set to entities of a specific type. The TX_TYPE is the discriminator column. So the question is, should this work? Or am I breaking some rule?
I hope that someone of you that have got more JPA experiences than I have so far knows. Thanks a lot in advance for any help!
Truly agile Java application developer with Extreme Programming and high quality craftsmanship