Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 366006

Summary: Query cache does not work with <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
Product: z_Archived Reporter: Frederick <frederickkaempfer>
Component: EclipselinkAssignee: Project Inbox <eclipselink.orm-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Frederick CLA 2011-12-08 05:59:58 EST
I am trying to get the eclipse link query result cache to work with <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode> setting in persistence.xml, so far without success. It works fine with DISABLE_SELECTIVE and ALL.

Here's a NamedQuery example:

@NamedQuery(name = "MyEntity.findAll", query = "select m from MyEntity m where m.active=true order by m.id",
    hints = {
        @QueryHint(name = QueryHints.CACHE_USAGE, value = CacheUsage.CheckCacheThenDatabase),
        @QueryHint(name = QueryHints.QUERY_TYPE, value = QueryType.ReadAll),
        @QueryHint(name = QueryHints.QUERY_RESULTS_CACHE, value = HintValues.TRUE)
    })}

Even though the QUERY_RESULTS_CACHE is enabled, every execution of the named query hits the database. If it matters MyEntity has both a @Cacheable and a  annotation and org.eclipse.persistence.annotations.Cache.

I also tried using the JPA2 properties:
@QueryHint(name = QueryHints.CACHE_STORE_MODE, value="USE"),
@QueryHint(name = QueryHints.CACHE_RETRIEVE_MODE, value="USE")
Comment 1 Tom Ware CLA 2011-12-22 10:37:17 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:05:43 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink