This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Discriminator column in JPA: how to differentiate

 
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: 661
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic