[
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,
Anything that is managed in an EntityManager will be cached in that
EntityManager (i.e. the results of query.getResultList())
EclipseLink has another level of caching, and if you want to avoid that, the
best bet is to turn off shared caching. Info about how to turn that off here
(you can do it in annotations or persistence unit properties):
http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Using_EclipseLink_JPA_Extensions_for_Entity_Caching
If it is just an issue with query results, simply use the eclipselink.refresh
query hint and set it to true.
-Tom
John Ament wrote:
Tom,
No, I realize that the results of a find are cached, and this is
expected. What I am getting concerned with is that I have no cache
configuration in my app, yet the results of a Query.getResultList are
getting cached, which I don't expect. Is there a way to force these to
not cache at all?
Thanks,
John
On Wed, Feb 24, 2010 at 9:06 AM, Tom Ware <tom.ware@xxxxxxxxxx
<mailto:tom.ware@xxxxxxxxxx>> wrote:
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.
http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Using_EclipseLink_JPA_Extensions_for_Entity_Caching
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.
http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#How_to_Use_EclipseLink_JPA_Query_Hints
There is also the entityManager.refresh() operation that forces
objects to be refreshed and the entityManager.clear() operation that
cleans our the individual entityManager.
-Tom
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.
Thanks,
John
------------------------------------------------------------------------
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
------------------------------------------------------------------------
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users