[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Object in EntityManager conext: no cache settings are relevant?
|
Hi Andrei,
In the situation below, the cache settings will not be relevant. When you
have an entity that is in the managed state, (it is in the EM context), you will
have to somehow do a refresh to get new data from that database - this is just
the way JPA works.
Aside from refresh and clear, you can use our query hints to cause a refresh:
http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Refresh
This can be used in any query and additionally, in JPA 2.0 provided in the
list of properties that in em.find(Class<T> entityClass, Object primaryKey,
Map<String, Object> properties)
The scenario where you might want to play with the cache settings, is if in
#3 you were using a different entityManager. In that case, you should use the
cache settings to disable shared caching. See the "shared" setting on the Cache
annotation here:
http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Using_EclipseLink_JPA_Extensions_for_Entity_Caching
-Tom
Andrei Shakirin wrote:
Hello everyone,
I need a short advice regarding EclipseLink cache settings.
Imagine the following situation:
1. JPA Client reads the entity using EntityManager. So entity becomes
into EM context.
2. Other external SQL client deletes this entity from the DB.
3. JPA Client reads the entity again using the same EM.
Question: are EM.refresh(entity) or EM.clear() only the ways to force EM
to re-read entity on step 3?
Is it possible to achieve it also using any EclipseLink cache settings?
The following properties don't affect EM behavior in this case:
<property name="_eclipselink_.cache.shared.default"
value="false"/>
<property name="_eclipselink_.cache.type.default"
value="NONE"/>
Regards,
Andrei.
------------------------------------------------------------------------
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users