Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Best practices for clearing the entity manager

Hi John,

What do you mean when you say caching is not enabled? What settings are you using to disable the cache? Note that within an open entity manager there will always be a cache of the objects that are managed within that entity manager.

Rarely does disabling the cache actually achieve what you want it to since the cache is also used to maintain identity. There are a number of options you can use to fine tune your cache and/or force queries to the database.

Take a look at the following link for some caching options. Some things that might be good to try are using a CacheType of WEAK, setting the cache to not be shared, and having it expire after a certain amount of time.

Also have a look at our query hints. You could specify the eclipselink.cache-usage hint to tell a query to avoid the cache or the eclipselink.refresh hint to tell the query to refresh from the database.

There is also the entityManager.refresh() operation that forces objects to be refreshed and the entityManager.clear() operation that cleans our the individual entityManager.


John Ament wrote:
Hey everyone

So I've begun to notice that there's some odd behavior in eclipse link when it comes to a multiple server environment that's not cluster (e.g. 4 instances of glassfish running on 2 servers). Basically, it looks like repeated calls to em.find as well as execution of queries returns the same data rather than actually running the queries against the database. Does anyone have any tips on how to avoid issues like this? Caching is not enabled.




eclipselink-users mailing list

Back to the top