Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Discriminator column in JPA: how to differentiate  RSS feed

 
Syed Mahdi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

A simple question maybe.

I have a an entity Profile which is mapped to table APP_PROFILE . I extend two more entities from it using the discriminator column as in Sales Profile and Manufacturer Profile. There is a username field in the Profile entity and some times i query the table using the user name

now I am kinda confused in my own implementation. If i query by user name like this in HQL :



it will give me the profile, but then how will I know if this is sales profile or manufacturer profile entity. depending on the profile I need to fill some values from the profile in another entity.

Also If my extended profiles have extra fields like "salesPoints" and "manufacturerstype" for each sales and manufacturer profiles respectively, they will not be querried when i use the query above it will only bring Profile entity which will not have these attributes/properties.

What do you think I shud do at this point. How shud i handle this dead lock.

thanks
ElCid...
 
Arun Kumarr
Ranch Hand
Posts: 662
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Run this query and find out if it works and I'm just intrigued, even if hibernate smartly returns the exact subclass object, can't we do an "instance of" operation to
find out what object it is?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!