On Fri, May 28, 2010 at 4:43 PM, Andrus Adamchik <andru..bjectstyle.org> wrote:
>
>> it seems that domain.getQueryCache().size() is returning 1
>>
>> assertEquals(1, ((DataContext)
>> getDataContext()).getParentDataDomain().getQueryCache().size());
>> assertEquals(1, ((DataContext) getDataContext()).getQueryCache().size());
>
> I guess DataContext is assigned a different QueryCache instance somehow.
>
> Andrus
>
>
I've just traced though the code and it seems that the queryCache
member in DataContext never gets set. Cayenne uses the DataDomain
query cache which is created on the first execution of my select
query. The second select query also uses this cache. The call in the
first assertEquals uses this cache is subsequently returns the correct
result. However in the second assertEquals statement the method on
line 226 of DataContext is executed.
public QueryCache getQueryCache() {
if (queryCache == null) {
synchronized (this) {
if (queryCache == null) {
DataDomain domain = getParentDataDomain();
queryCache = domain.getQueryCacheFactory().getQueryCache(
domain.getProperties());
}
}
}
return queryCache;
}
At this point queryCache within the DataContext is still null so it
goes of and creates another one hence the cache is empty.
This could however be the correct behavior if the DataDomain holds the
shared cache, while the data context holds the local cache, but if
this is the case perhaps it needs to be documented a bit better?
Cheers,
Gary
This archive was generated by hypermail 2.0.0 : Fri May 28 2010 - 07:17:41 UTC