Is there a way to reduce the amount of boiler-plate code associated with a CriteriaQuery (in JPA 2.0)?
I love the type safety CriteriaQuery brings ing JPA 2.0 but it also brings a bit of boiler-plate code. For example, let say I have an entity called NamedEntity, which simply has an id and a String field called "name" (assume it has the unique constraint set to true). Here's what the NamedEntityManager might look like: public class NamedEntityManager { //inject using your framework EntityManager entityManager; //retrieve all existing entities of type NamedEntity from DB public Iterable<NamedEntity> queryAll() { CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery