How to bypass cache for a specific query? [message #389747] |
Fri, 26 June 2009 09:32  |
Eclipse User |
|
|
|
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 #389753 is a reply to message #389747] |
Mon, 29 June 2009 10:24  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.03268 seconds