Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » How to configure query cache invalidation with JPA queries?
How to configure query cache invalidation with JPA queries? [message #386054] Mon, 23 March 2009 07:34 Go to next message
Eclipse UserFriend
Query cache seems to work nice with cache-usage hint
CheckCacheThenDatabase. However, I need to be able to invalidate cached
queries after a timeout.

EclipseLink documentation contains this example:

readQuery.setQueryResultsCachePolicy(
new QueryResultsCachePolicy(new
TimeToLiveCacheInvalidationPolicy(1000))
);

Our code is currently fully JPA compliant, but we would like to use some
EclipseLink extensions like the query cache. Because we are currently
getting the javax.persistence.Query objects from EntityManager's
createNamedQuery() method, is there a way to set invalidation policy for
them without completely rewriting query code?
Re: How to configure query cache invalidation with JPA queries? [message #386058 is a reply to message #386054] Mon, 23 March 2009 09:56 Go to previous messageGo to next message
Eclipse UserFriend
In EclipseLink 1.1 you can configure the query cache, and invalidation
using query hints in any NamedQuery.

The list of query hints are defined here:
http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persi stence/config/QueryHints.html

The ones for the query cache are:
"eclipselink.query-results-cache"
"eclipselink.query-results-cache.expiry"
"eclipselink.query-results-cache.size"

The cache-usage option is for the object cache however, not the query
cache. For the object cache you can set the invalidation using the @Cache
annotation, EclipseLink orm.xml, or persistence.xml properties.

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html
Re: How to configure query cache invalidation with JPA queries? [message #386065 is a reply to message #386058] Tue, 24 March 2009 05:21 Go to previous message
Eclipse UserFriend
Thanks James! I upgraded to release 1.1.

Cache seems to work now the way I wanted, by adding one hint to the query:
query.setHint(QueryHints.CACHE_USAGE, CacheUsage.CheckCacheThenDatabase);

And one annotation to the Entity:
@Cache ( expiry=100000 )
Previous Topic:mapping problem: entity as join table
Next Topic:Optimistic locking without EclipseLink dependency in my domain objects?
Goto Forum:
  


Current Time: Sat Jul 05 02:26:07 EDT 2025

Powered by FUDForum. Page generated in 0.03976 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top