Example JPA Classes, getters and setters omitted for simplicity.
Then a simple query to retrieve the list of all authors, ordered alphabetically, would be:
To retrieve the list of authors that have ever been published by XYZ Press:
JPQL supports named parameters, which begin with the colon (:). We could write a function returning a list of authors with the given last name as follows:
JPQL is based on the Hibernate Query Language (HQL), an earlier non-standard query language included in the Hibernate object-relational mapping library.
Hibernate and the HQL were created before the JPA specification. As of Hibernate 3 JPQL is a subset of HQL.
Bauer, King & Gregory 2016. - Bauer, Christian; King, Gavin; Gregory, Gary (2016), Java Persistence with Hibernate (Second ed.), Manning Publications, ISBN 978-1617290459 ↩