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
>
This archive was generated by hypermail 2.0.0 : Wed Jan 03 2007 - 12:36:41 EST