You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Francesco Chicchiriccò <il...@apache.org> on 2012/01/23 13:56:35 UTC
Proper way to use query cache
Hi all,
I was used (in Hibernate) to enable query cache on a per-query base by
mean of query hints like as follows:
Query query = entityManager.createQuery("SELECT e FROM "
+ SchemaMapping.class.getSimpleName() + " e");
query.setHint("javax.persistence.cache.retrieveMode",
CacheRetrieveMode.USE);
return query.getResultList();
Even though I've found this approach not for hibernate only (see [1],
[2] and [3] for example), I've understood that OpenJPA does not support
it (yet?).
Now my question is: provided that I've set
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
and
<property name="openjpa.DataCache" value="true" />
<property name="openjpa.QueryCache" value="true" />
in my persistence unit,
how can I activate query cache for a certain query?
TIA.
Regards.
[1] http://en.wikibooks.org/wiki/Java_Persistence/Caching#JPA_2.0_Cache_APIs
[2]
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching#How_to_refresh_the_cache
[3] http://www.objectdb.com/java/jpa/persistence/cache
--
Francesco Chicchiriccò
Apache Cocoon Committer and PMC Member
http://people.apache.org/~ilgrosso/