Repost using correct mail account:

Using Cayenne 3.1M2

When a cached query for a single record returns no entry, I'd like to remove 
that single result from the cache. Either the code will be creating the record, 
or it will be manually added and I want the code to notice when it is. It looks 
like this should be possible using this code:
                                DataContext dataContext = (DataContext) context;
                                String key = 
query.getMetaData(dataContext.getEntityResolver()).getCacheKey();
                                dataContext.getQueryCache().remove(key);
                                assert 
(dataContext.getQueryCache().get(query.getMetaData(dataContext.getEntityResolver()))
 == null);


And when I run the code the assert confirms that the entry has been removed.

But when I make the same query (now that the code has created the item), I'm 
getting an empty result again. 

I'd prefer not to have to flush the entire table cache whenever I create a new 
entry, is this possible?

Update: 

I tried clearing the entire group, but I'm still getting an empty result 
without a database query. I'm using this code:

                                DataContext dataContext = (DataContext) context;
                                
dataContext.getQueryCache().removeGroup("BOMModule");

The query itself was configured in Cayenne, a simple lookup on the natural key.

Joe

Reply via email to