2.10.1.6. Polymorphic Queries
All JPQL queries are polymorphic, which means the from clause of a query includes not only instances of the specific entity class to which it refers, but all subclasses of that class as well.
The instances returned by a query include instances of the subclasses that satisfy the query conditions.
For example, the following query may return instances of Magazine, as well as Tabloid and Digest instances, where Tabloid and Digest are Magazine subclasses.
SELECT x FROM Magazine x WHERE x.price 5
Non-polymorphic queries or queries whose polymorphism is restricted can be specified using entity type expressions (see Entity Type Expressions ) in the WHERE clause to restrict the domain of the query.
For example, the following query returns instances of Digest:
SELECT x FROM Magazine WHERE TYPE(x) = Digest