You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Dougall Squair <Do...@metcash.com> on 2003/06/30 09:08:33 UTC
Questions on caching and threads
Hi,
It appears that the cache returns the same object reference for the same
primary key. Does this
have threading implications?
E.g. (Where "query" is same for both threads)
Thread # 1
DataObject dataObject1 = (DataObject)
persistenceBroker.getObjectByQuery(query);
dataObject1.setValue(value2); // <--- Posible thread conflict here as
dataObject1 == dataObject2
persistenceBroker.store(dataObject1);
Thread # 2
DataObject dataObject2 = (DataObject)
persistenceBroker.getObjectByQuery(query);
dataObject1.setValue(value2);
persistenceBroker.store(dataObject2);
Even though the two Threads are within the context of separate transactions
they
seem to be both able to alter the value of the cached object.
Regards
Dougall