liquidform - Language Integrated QUeries For ORM is a libray that adds a DSL on top of JPA. In particular, the DSL allows for queries to use domain objects in a typesafe manner. for example:

List people = em.createQuery(

"SELECT FROM Person p WHERE p.surname LIKE 'Smith%'")



becomes (notice the use of p.getSurname() for type safety on Person methods)


Person p = LiquidForm.use(Person.class, "p");

List people2 = em.createQuery(

select(p).from(Person.class).as(p).where(like(p.getSurname(), "Smith%")).toString()).getResultList();