문제

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

도움이 되었습니까?

해결책

Try this.

   SELECT d
    FROM Project p join p.leader d
    WHERE TYPE(d) = Architect OR TYPE(d) = Engineer
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top