| I reproduced your issue but I'd argue that you are using it wrong. The polymorphic expression could be used in any sub-expression tree, imagine a query like
select pl from Place pl where pl.id > (case pl.population > 1000 then 1 else 2 end)
How would we duplicate the expression here? We don't because it's can't be done in an intuitive way. JPA 2.1 introduced the TREAT operator to actually access subtype properties, so to achieve what you want, you can use the following query.
select pl from Place pl where TREAT(pl AS Country).population > 1000 OR TREAT(pl AS Town).population > 1000
|