Reputation: 616
I want to discriminate by type in a query, but what I want to discriminate is not the entity in the SELECT clause, but a member of it.
For example, instead of using TYPE like this:
SELECT p
FROM Project p
WHERE TYPE(p) = DesignProject OR TYPE(p) = QualityProject
I need to use it like this:
SELECT p
FROM Project p
WHERE TYPE(p.leader) = Architect OR TYPE(p.leader) = Engineer
Architect
and Engineer
are subclasses of Leader
class.
I have already tried that, but I am getting this error:
org.hibernate.QueryException: could not resolve property
Upvotes: 1
Views: 1234
Reputation: 19543
Try this.
SELECT d
FROM Project p join p.leader d
WHERE TYPE(d) = Architect OR TYPE(d) = Engineer
Upvotes: 3