[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] INVALIDATE_CHANGED_OBJECTS does not invalidate related objects
|
By default any invalid object will be refreshed when accessed through a
UnitOfWork (or JPA EntityManager).
If you are using JPA the UnitOfWork is always used, unless you execute a
read-only query or the class is read-only. How are you reading the objects?
You can configure the refresh to not occur using the descriptor's
ClassInvalidationPolicy.setShouldRefreshInvalidObjectsInUnitOfWork(false).
mwolochuk wrote:
>
> We recently changed our cache synchronization type from
> SEND_NEW_OBJECTS_WITH_CHANGES to INVALIDATE_CHANGED_OBJECTS. Upon
> testing, we discovered that changes made through server1 were not
> reflected on server2. After further testing, we found that when another
> object has a direct reference to the invalidated object on the remote
> server, and you access the invalidated object through that reference, you
> get the old invalid instance.
>
> For example:
>
> 1. Assume this object graph: a->b (object a refers to object b).
>
> 2. Assume object b has a field "someField" with a value "oldValue"
>
> 3. Assume both a and b are in the cache on both servers.
>
> 4. On server1, you do this: a.getB().setSomeField("newValue"), then commit
> the transaction
>
> 5. Now on server2, you get a reference to "a" from EclipseLink: a =
> findById(A.class, A_ID)
>
> 6. Finally, you access object "b" through object "a":
> a.getB().getSomeField()
>
> The value you get in step 6 is "oldValue" instead of "newValue".
>
> EclipseLink invalidates the instance of "b" in server2 cache, but not the
> instance of "a". So if we access "b" through "a", we get the old invalid
> object.
>
> Is this expected behavior? Based on this discussion
> http://forums.oracle.com/forums/thread.jspa?threadID=982925&tstart=298
> http://forums.oracle.com/forums/thread.jspa?threadID=982925&tstart=298 ,
> it seems it is the expected behavior. I did not see anything in
> EclipseLink documentation or javadocs describing this behavior.
>
> To me this makes the setting INVALIDATE_CHANGED_OBJECTS not very useful
> since we often access objects through the object graph. Am I missing
> something?
>
-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://old.nabble.com/INVALIDATE_CHANGED_OBJECTS-does-not-invalidate-related-objects-tp29432889p29522313.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.