In hibernate, I want to select the discriminator value. Something like
select discriminator, id, name, age from Animal
The idea is to send the result of this query to the client side, so that I can display a different icon based on the value of the discriminator column (i.e. cat, dog, elephant, etc).
Is that possible? How?
Hibernate query objects, does not know columns. So unless you have a property named discriminator in your Animal object you cant do that. You can do the query in sql or get the entire object and then to get the inherited type, for that you can use "instanceof"
You can do it as follows:
From Hibernate Documentation: