• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OpenJPA-problem with polymorphic unidirectional relation with single tabled inheritance

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic