title: Criteria query cache caching in Eclipselink?
body: <p>Iam using criteria queries with EclipseLink as JPA . I need to cache the query results based on their parameters .  When I used <code>query.setHint("eclipselink.QUERY_RESULTS_CACHE", "TRUE")</code> it still fires query to the database. How can I use it in context of criteria queries ?</p>
  
  <p>Here I set my query and their hints and addNamedQuery</p>
  
  <pre><code>Query query = psEntityManager.getEntityManager().createQuery(criteriaQuery);// Creating Query to supply Values
          query.setHint("eclipselink.QUERY_RESULTS_CACHE", "TRUE");
          query.setHint(QueryHints.QUERY_TYPE,QueryType.ReadObject);
          psEntityManager.getEntityManager().getEntityManagerFactory().addNamedQuery("query1", query);
  </code></pre>
  
  <p>Here is my output :</p>
  
  <pre><code>Query1-----------
  [EL Fine]: sql: 2013-10-10 21:33:35.495--ServerSession(14144548)--Connection(7200601)--SELECT PRIMARYKEY, ADDRESSLINE1, ADDRESSLINE2, PHONENUMBER, fkCityId, fkPersonId FROM ADDRESS WHERE (fkPersonId = ?)
      bind =&gt; [2]
  [EL Fine]: sql: 2013-10-10 21:33:35.527--ServerSession(14144548)--Connection(7200601)--SELECT PRIMARYKEY, CITYNAME, PINCODE, fkStateId FROM CITY WHERE (PRIMARYKEY = ?)
      bind =&gt; [2]
  [EL Fine]: sql: 2013-10-10 21:33:35.528--ServerSession(14144548)--Connection(7200601)--SELECT PRIMARYKEY, STATENAME FROM STATE WHERE (PRIMARYKEY = ?)
      bind =&gt; [1]
  [EL Fine]: sql: 2013-10-10 21:33:35.531--ServerSession(14144548)--Connection(7200601)--SELECT PRIMARYKEY, AGE, DOB, FIRSTNAME, LASTNAME, SEX, TIMESTAMP, fkDepartmentId FROM PERSON WHERE (PRIMARYKEY = ?)
      bind =&gt; [2]
  [EL Fine]: sql: 2013-10-10 21:33:35.541--ServerSession(14144548)--Connection(7200601)--SELECT PRIMARYKEY, DEPTNAME FROM DEPARTMENT WHERE (PRIMARYKEY = ?)
      bind =&gt; [2]
  [EL Fine]: sql: 2013-10-10 21:33:35.547--ServerSession(14144548)--Connection(7200601)--SELECT PRIMARYKEY, CITYNAME, PINCODE, fkStateId FROM CITY WHERE (PRIMARYKEY = ?)
      bind =&gt; [5]
  [EL Fine]: sql: 2013-10-10 21:33:35.548--ServerSession(14144548)--Connection(7200601)--SELECT PRIMARYKEY, STATENAME FROM STATE WHERE (PRIMARYKEY = ?)
      bind =&gt; [3]
  [EL Fine]: sql: 2013-10-10 21:33:35.551--ServerSession(14144548)--Connection(7200601)--SELECT PRIMARYKEY, CITYNAME, PINCODE, fkStateId FROM CITY WHERE (PRIMARYKEY = ?)
      bind =&gt; [8]
  [EL Fine]: sql: 2013-10-10 21:33:35.553--ServerSession(14144548)--Connection(7200601)--SELECT PRIMARYKEY, STATENAME FROM STATE WHERE (PRIMARYKEY = ?)
      bind =&gt; [4]
  Query2-----------
  [EL Fine]: sql: 2013-10-10 21:33:35.557--ServerSession(14144548)--Connection(7200601)--SELECT PRIMARYKEY, ADDRESSLINE1, ADDRESSLINE2, PHONENUMBER, fkCityId, fkPersonId FROM ADDRESS WHERE (fkPersonId = ?)
      bind =&gt; [2]
  Query3-----------
  [EL Fine]: sql: 2013-10-10 21:33:35.56--ServerSession(14144548)--Connection(7200601)--SELECT PRIMARYKEY, ADDRESSLINE1, ADDRESSLINE2, PHONENUMBER, fkCityId, fkPersonId FROM ADDRESS WHERE (fkPersonId = ?)
      bind =&gt; [2]
  Query4-----------
  [EL Fine]: sql: 2013-10-10 21:33:35.563--ServerSession(14144548)--Connection(7200601)--SELECT PRIMARYKEY, ADDRESSLINE1, ADDRESSLINE2, PHONENUMBER, fkCityId, fkPersonId FROM ADDRESS WHERE (fkPersonId = ?)
      bind =&gt; [2]
  </code></pre>