Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » How to bypass cache for a specific query?
How to bypass cache for a specific query? [message #389747] Fri, 26 June 2009 09:32 Go to next message
Eclipse UserFriend
I have specified the following cache for an entity:

@Entity
@Cache(expiry = 3600000,
size = 10000)

However, in one specific case I need to be able to query entry using its
primary key directly from the database in order to see that no one has
changed it outside my application.

I have not so far found a way to accomplish this. For example the
following query still returns the entity from cache and not from the
database:

@NamedQuery(name = "Table.findByPK", query = "select o from Table o WHERE
o.pk1=:PK1 and o.pk2=:PK2", hints = { @QueryHint(name =
QueryHints.CACHE_USAGE, value = CacheUsage.DoNotCheckCache) }) })

Do I need to use explicit call to em.refresh or is there another way?
Re: How to bypass cache for a specific query? [message #389750 is a reply to message #389747] Fri, 26 June 2009 10:14 Go to previous messageGo to next message
Eclipse UserFriend
Flushing query cache explicitly isn't enough because that seems to leave
entity cache intact. Is there a way to flush the entity cache for a
specific entity?
Re: How to bypass cache for a specific query? [message #389753 is a reply to message #389747] Mon, 29 June 2009 10:24 Go to previous message
Eclipse UserFriend
refresh will refresh the object in the cache.

That cache usage option will just ignore the cache hit before accessing
the database, but will still maintain the cache after fetching the data.

Other query hints are:

"eclipselink.refresh"="true" , refreshes the object in the cache.

"eclipselink.maintain-cache"="false" , this will ignore the cache entirely
and return you a different copy of the object directly from the database.
Previous Topic:transaction not commiting
Next Topic:[V2] Jar locked during webapplication redeploy
Goto Forum:
  


Current Time: Sat Jul 12 18:44:09 EDT 2025

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

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

Back to the top