2. Executing a CriteriaQuery
Prev | Chapter 11. JPA Criteria | Next

## 2. Executing a CriteriaQuery

A CriteriaQuery is executed in a similar fashion to a string-based JPQL query via the EntityManager and Query interfaces.

    EntityManager em = ...
    Query query = em.createQuery(qdef);
    List result = query.getResultList();

A query definition can use named parameters, and the parameter values are set as usual in the Query instance.

A developerworks article explains details and further usage of Criteria API and its OpenJPA extensions.

Prev | Up | Next
Chapter 11. JPA Criteria | Home | 3. Extension to Criteria API