I am using the Hibernate 3.5.1 and EntityManager for data persistence (with JPA 2.0 and EHCache 1.5). I can obtain the query by the following code:
EntityManager em;
...
Query query = em.createQuery(...);
...
Now, the problem is that EntityManager's createQuery() method returns javax.persistence.Query which, unlike org.hibernate.Query (returned by the SessionFactory's createQuery() method), does not have the org.hibernate.Query.setCacheable() method.
How am I, then, supposed to cache the queries with EntityManager (or some other part of Hibernate)?