Hi Nils,

Nils Liebelt wrote:
Hi all,



Having some trouble with the OJB caching. I use the default implementation
which should give a global cache for all Brokers.


My Business objects have a store() method that inserts/updates this object
towards the db and removes this object from the cache with the
removeFromCache() function. But the changed object still doesn't get newly
retrieved in relationships! Let's say I got an Account which has many
Contacts attached. If I change a Contact, store it and remove it from the
cache. The Account still has a reference to the old the account object? My
idea to solve it was an business function updateReferences() which needs to
be called from the "mother" object. But my OO-mind tells me that that's not
right. I don't want to pollute my simple BusinessInterface with complicated
things like that. So I could turn off the cache. Well not an option for me
or I could call the retrieveAllReferences() before retrieving which comes
close to turning off the cache. I wonder if there's not an nicer and more
clean way in doing so.



ObjectCacheDefaultImpl is a fast and "dumb" ObjectCache implementation and you have to synchronize all referenced objects by yourself. Alternative you can use refresh="true" in the 1:n, m:n collection-descriptor to force OJB to refresh the reference on each lookup of the main object (additional sql-query).
Or you can use ObjectCacheTwoLevelImpl which always build the requested object from scratch.
http://db.apache.org/ojb/docu/guides/objectcache.html#ObjectCacheTwoLevelImpl


regards,
Armin






Regards,



Nils







mtgglf




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to