Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 13:32 Go to next message
Torben Putkonen is currently offline Torben PutkonenFriend
Messages: 34
Registered: July 2009
Member
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 14:14 Go to previous messageGo to next message
Torben Putkonen is currently offline Torben PutkonenFriend
Messages: 34
Registered: July 2009
Member
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 14:24 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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.


James : Wiki : Book : Blog : Twitter
Previous Topic:transaction not commiting
Next Topic:[V2] Jar locked during webapplication redeploy
Goto Forum:
  


Current Time: Wed Apr 24 17:41:25 GMT 2024

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

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

Back to the top