Dynamic, typesafe queries in JPA 2.0

See the original posting on IBM developerWorks – Java

A query for persistent Java objects is typesafe if a compiler can verify
it for syntactic correctness. Version 2.0 of the Java Persistence API (JPA)
introduces the Criteria API, which brings the power of typesafe queries to
Java applications for the first time and provides a mechanism for constructing
queries dynamically at run time. This article describes how to write dynamic,
typesafe queries using the Criteria API and the closely associated Metamodel