The Java Persistence API (JPA) defines a query language that allows to define queries over entities and their persistent state. In this weblog I would like to point out what determines the type of the query result, such as the method to execute the query and the structure of the query SELECT clause.
Query API execution methods
The Java Persistence Query Language supports using relationships as defined in the object model in the query. The syntax of a relationship access expression is the same as in Java: a navigational expression using a dot as in o.customer. Please note, the query does not depend on the mapping of the relationship field to tables, columns and foreign keys in the underlying database schema.