Pregunta

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

¿Fue útil?

Solución

Try this.

   SELECT d
    FROM Project p join p.leader d
    WHERE TYPE(d) = Architect OR TYPE(d) = Engineer
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top