JPA 2.0 Proposed Final Draft

Spec lead Linda DeMichiel describes in her blog all the new features.

Specially the Criteria API will change the way queries could be exposed:

For example:
QueryBuilder qb = em.getQueryBuilder();
CriteriaQuery q = qb.create();
Root customer = q.from(Customer.class);
Join item = customer.join(Customer_.orders).join(Order_.items);
q.where(qb.equals(item.get(Item_.product).get(Product_.productType), "printer"))
.select(customer.get(Customer_.name));

You may wonder what Customer_.orders or Oders_.items is. This comes from the new Metamodel API also introduced in JPA 2.0. The classes with the prefix _ contains alle the meta information of your entities which looks like that:

import javax.persistence.metamodel.*;
@TypesafeMetamodel
public class Customer_ {
public static volatile Attribute custId;
public static volatile Attribute name;
public static volatile Set orders;
...
}

Together with the Metamodel API the Criteria API becomes no type save!
This comes very close to .NETs LINQ! Which in my opinion is a big step for JPA!