[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Re: Cache issue

I conducted some more test.
I think there is some problem using the shared cache, but I don't know if it is an eclipselink bug or it is my code bug.


Using default cache settings (shared cache enabled), it seems the cached object is not updated with the DB. The object not updated is access not directly but through entity relationship (manytomany). Let say I have object A that is related to object B that is related to object C:

A ----ManyToOne----> B -----ManyToMany----> C

the object that seems not to be updated is C.

If I load the object directly (using the load(id of C) on the entity C) the object return the right value (stored on DB).
If I access the object starting from the object A and (load(id of A)) and navigate to object C through java object, the value is not updated to DB.


All works if I set to "false" the shared cache.
Looking the FINEST logging I note that disabling the shared cache, the load(id of A) call a set of query on the DB to get values. With default cache otherwise no query have done on the DB but the object in the cache is returned (but it is not updted to the DB).


Take in mind that I update (save the new value) of the object C not throught the object A but loading directly the object C. This because I have different point of my webapp where I can load/update/delete entities. So waht is happening in my view is the following:

1. I have my webapp on
2. from a point of code I load the object A and read value of object C using object relationship
3. from another point of code (another thread...e.g. another user in my webapp) I load directly object C (I mean the sme record on the DB), edit it and save new value
4. Now if the user repeat the point 2, he see tha old value and not the update one...because the object A is in the cache and the related object B and C are also in the cache and they are not updated to the DB.


So, is it possible that the error i due to I have more entity instances of the same DB record?and one or that instance is changed and saved (merged) to the DB, the other instances are not updated?
If so, how can I solve this problem if I would like to use the default shared cache to get better performances?


BR,
Enrico




Enrico ha scritto:
I've tested the following situations (also to measure some performance results in terms of response time):

1. "eclipselink.cache.type.default"="None"
    It seems work (object is update on DB) but performances are poor;

2. "eclipselink.cache.shared.default"="false"
It seems to work and performance seems to be better than case 2. (response-time is about an half of the previous one)


3. default eclipselink cach (shared and SoftWeak)
It does not work....on the DB I note the record is updated, but when I try to read the object I continuosly get the old value. Performance are higher than previous one (response-time is about an half of the previous one)


I really would like to have both the better performance but be sure objects aI read are up to date.
I will try to run some more test, alo because currently the error seems to happen for a specific entity...maybe it can be some problem due to relations, LAZY load etc...but I need to investigate in depth.


If you have other ideas please let me know.

BR,
Enrico


James ha scritto:
I can't see how the cache could be getting out of synch if your database is getting the correct values. Can you isolate when the corruption occurs exactly? If you can perhaps log a bug and attach your test case. The only thing that I can think of is that you call persist/save for an existing object, or you new object has a reference to an existing object, that somehow causes the corruption.

You may also want to try the latest version or build if you have not already done so.

In terms of the doc you referenced, I assume you got that from the User Guide, it does seem confusing, please log a bug for this. The API doc seems more clear,

http://www.eclipse.org/eclipselink/api/1.1.2/org/eclipse/persistence/config/PersistenceUnitProperties.html#CACHE_SHARED_


http://www.eclipse.org/eclipselink/api/1.1.2/org/eclipse/persistence/config/CacheType.html