Shortening JPA criteria query boilerplate I've used hibernate for a long time. Recently I started using JPA, but I can't find a short way to write a simple select in less than these seven lines (the use of criteria is a must in this project).

Is there a shorter way to build this query?

public List&lt;Transaction&gt; findDevolucionesByOriginalOperationId(String originalOperationId) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery&lt;Transaction&gt; cq = cb.createQuery(Transaction.class);
    Root&lt;Transaction&gt; root = cq.from(Transaction.class);
    Collection&lt;Predicate&gt;  predicates = new ArrayList&lt;Predicate&gt;();

    predicates.add(cb.equal(root.get("originalOperationId"), originalOperationId));

    cq.where(predicates.toArray(new Predicate[predicates.size()]));
    List&lt;Transaction&gt; resultado = em.createQuery(cq).getResultList();
    return resultado;
}
JPA Criteria API is horrific, even the creators admitted that it was designed for tooling support rather than for developers.
My personal favorite approach is to use a fluent query API like QueryDSL. 

The query in QueryDSL would look more or less as follows:

new JPAQuery().from(transaction)
    .where(transaction.originalOperationId.eq(originalOperationId))
   .list();


The difference is staggering. And the query is fully typesafe.