I use the Querydsl framework because I'm using JPA 1.0 which does not include the Criteria API and I also needed the features you described. Writing Querydsl code is easy and the code is shorter than Criteria API code. Querydsl is free to use and it supports typesafe queries.