CHAPTER 9

image

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 ...

Get Hibernate Recipes: A Problem-Solution Approach, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.