You're confusing SQL (which is what PostgreSQL expects) and HQL (which is what EntityManager.createQuery()
expects).
Those are two different languages. SQL works with tables and columns, whereas JPQL works with JPA entities, fields/properties and associations, and is translated by your JPA implementation into SQL.
If you want to execute SQL, you must use EntityManager.createNativeQuery()
.