thank you for the instant help.  

-----Ursprüngliche Nachricht-----
Von: Andrus Adamchik [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 3. Januar 2007 18:36
An: cayenne-user@incubator.apache.org
Betreff: Re: clear caches

Actually running a SelectQuery would always result in fresh data,  
unless you explicitly set it to not refresh objects and/or use cached  
results.

Where the caching can bite you is reading objects via relationships  
or via DataObjectUtils. These would use cache. See my comments below  
on how to ensure those are invalidated.

> context.getEntityResolver().clearCache();

This is not needed - it clears cached mapping metadata, not the objects.

> context.getObjectStore().getDataRowCache().clear();

Yep - this one will clear shared cache. In addition, if you want to  
refresh everything, you would also need to replace DataContext with a  
new instance. Finally there is DataContext.invalidateObjects() method  
that allows targeted invalidation of specific objects.

Andrus



On Jan 3, 2007, at 3:02 PM, Peter Schröder wrote:
> hi and happy new year,
>
> i am looking for a method that tells cayenne to clear all cached  
> objects, so that i can be sure the context will read fresh data  
> from database next time a query is performed.
>
> i found these:
>
>       context.getEntityResolver().clearCache();
>       context.getObjectStore().getDataRowCache().clear();
>
> kind regards,
> peter
>

Reply via email to