Querying with Criteria and Example
In the previous chapter, you saw how to use Hibernate Query Language (HQL) and Java Persistence Query Language (JPA QL). HQL forces you to interact with the database using SQL-like syntax. You must have some knowledge of SQL to create complex queries, which makes it difficult to develop applications that use multicriteria queries.
With HQL and JPA QL, it’s easy to make mistakes with string concatenation and SQL syntax.1 Sometimes, errors occur simply because there is no space between two clauses in SQL. Because these errors are uncovered only at runtime, if you don’t have decent unit tests, you must ...