• 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

JPA: Problem with InheritanceType.SINGLE_TABLE

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have 2 class, one that inherits from the other and I'm using InheritanceType.SINGLE_TABLE with a column that identifies if the entry belongs to the base class or to the derived class.

This is the base class:



And this is the derived class:






To load the object from the database I use the following method:



Where utenteClass is either the base class or the derived one.

I've used this approach before and it worked. While now, even if the utenteClass is the derived class (if I debug I can see it), in the query that is generated the discriminator from the base class is used:


I really can't find the difference from the other project of mine in which this works. I need to use the right class since I need the right object to be instantiated and all the fields of the derived class to be populated.
What can be the reason for which this does not work? Is there another way to get what I need?

Thanks for any help.

Eve

 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems the superclass is not aware of the subclass.

Ensure that you have included the UtenteMessaggi class in your persistence.xml, it may be missing.

 
eve agostini
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right! I mean, the class was there but the package was wrong (refactoring consequences...)
Thank you!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic