Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Is there a way to automatically expire entity from cache when using EM's find()?
Is there a way to automatically expire entity from cache when using EM's find()? [message #389446] Wed, 10 June 2009 12:32 Go to next message
Torben Putkonen is currently offline Torben PutkonenFriend
Messages: 34
Registered: July 2009
Member
I'm using extensively EntityManager's find() method to retrieve entities.
My issue is, that sometimes also external systems update the database, and
I need to pick up the changes, not immediately after they occur but in ten
minutes. find() method seems to ignore expiry time set using @Cache
annotation.

Is there any other way to refresh the entity than to call
EntityManager.refresh() method explicitly?

If not, is there a way to disable cache usage for find() method
completely? (I haven't yet been able to verify whether setting CacheType
to none does the trick, as it throws an error as I posted five minutes
ago.)
Re: Is there a way to automatically expire entity from cache when using EM's find()? [message #389453 is a reply to message #389446] Wed, 10 June 2009 13:34 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

find() should not be ignoring the cache invalidation time, I can't see how
this could occur. Ensure that the object has been invalidated or expired.
If you have already read the object into the persistence context
(transaction/entity-manager) then find() will (must) return the same
object for transaction isolation and will not check invalidation. Ensure
you have not already read the object in the same EntityManager.

Setting shared=false will disable the shared cache (but not the local
EntityManager cache, to avoid that you must clear the EntityManager, or
create a new one).

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Re: Is there a way to automatically expire entity from cache when using EM's find()? [message #389463 is a reply to message #389453] Fri, 12 June 2009 08:22 Go to previous message
Torben Putkonen is currently offline Torben PutkonenFriend
Messages: 34
Registered: July 2009
Member
Thanks once again James. I was experiencing with the cache using the same
transaction. It started to work perfectly after starting a new
transaction. That's great.
Previous Topic:Eclipselink with Java Web Start
Next Topic:No Cache Option
Goto Forum:
  


Current Time: Fri Apr 26 01:32:25 GMT 2024

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

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

Back to the top