I am building a query on a generic table \"Sample\" and I have several types which inherit from this table \"SampleOne\", \"SampleTwo\". I require a query like :
You still have to be carefull in Hibernate 4.3.7, because there is still an issue with the implementation of TYPE(), for example:
from SpoForeignPilot sfp where TYPE(sfp.partDocument) = :type
This query doesn't work as it incorrectly checks the type of SpoForeignPilot and not the type of the document.
You can workaround this issue by doing something like this:
select sfp from SpoForeignPilot sfp join sfp.partDocument doc where TYPE(doc) = :type