title: JPA Criteria API With Named Query
body: <p>The title says it all: is it possible to use a named query inside of a query built with the JPA criteria API ? Something along the lines of (simple example):</p>
  
  <pre><code>@Entity
  @NamedQuery(name = "complexFooQuery", query = "FROM Foo where ....")
  class Foo {
      ////....
  }
  
  List&lt;Foo&gt; getFoo() {
      CriteriaQuery&lt;Foo&gt; cq = em.createQuery(Foo.class);
      cq.select(&lt;somehow specify complex foo named query&gt;);
      return em.createQuery(cq).getResultList();
  }
  </code></pre>