Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-dev] @QueryHint(name = QueryHints.QUERY_RESULTS_CACHE, value = HintValues.TRUE)

Hi,
 
I am experiencing trouble with this query hint
 
@NamedQuery(name = "getAllDepartmentsCached", query = "select d from Department d", hints = { @QueryHint(name = QueryHints.QUERY_RESULTS_CACHE, value = HintValues.TRUE) })
@Cacheable(true)
@Entity
public class Entity Department {
 
The first time, I am executing the named query, I get the expected result. But if I execute it again, the result is empty:
 
   public void testCachedQueryWithoutParameters() throws SQLException {
        init();
        EntityManager em = getEnvironment().getEntityManager();
        try {
            Query query = em.createNamedQuery("getAllDepartmentsCached");
            List<Department> result = query.getResultList();
            assertEquals(result.size(), 2);
 
            result = query.getResultList();
            assertEquals(result.size(), 2); <<<<< size is 0 now!
        } finally {
            closeEntityManager(em);
        }
    }
 
 
Are there any preconditions I’d have to fulfill in order to uses the QUERY_RESULTS_CACHE hint?
 
I have switched the default caching off:
 
<property name="eclipselink.cache.shared.default" value="false"/>
 
Any ideas?
 
-Adrian
 
Adrian Görler
SAP AG

Pflichtangaben/Mandatory Disclosure Statements: http://www.sap.com/company/legal/impressum.epx
 
 
 

Back to the top