Cayenne User Documentation
RefreshQuery

### Refresh a collection of objects

Internally Cayenne will remove those objects from caches. All object relationships should be invalidated as well. No query results are affected, but objects in those result lists should get invalidated.

Limitation: shared list cache stores all results as DataRows and doesn't use uniquing ... so such refresh would fail to invalidate ids stored in the shared cache; possible solution - store ObjectIds in the shared cache instead of full DataRows and resolve them on the fly.

### Refresh a single object

A special case of refresh collection of objects. Should probably use the same logic.

### Refresh results of a query

Query lists are removed from caches. Since any objects matched by query need to be refreshed as well, the query is executed eagerly.

### Refresh results of a group of queries identified by one or more cache group names.

Removes or invalidates query results for the specified group keys, in hope that the objects will be refreshed the next time any query from the group is executed.

Limitation: This is the only case that doesn't allow to target individual objects.

### Refresh All

Refreshes all objects (including reverting and refreshing dirty objects) and all query results. This can be done lazily. Not sure if we need fine-grained control (refresh a single context; refresh shared caches).

## Proposed Solution: RefreshQuery

Related JIRA issue: http://issues.apache.org/cayenne/browse/CAY-632
RefreshQuery: http://svn.apache.org/repos/asf/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/RefreshQuery.java

There are the following advantages to this approach:

- Hiding the difference between "eager refresh" (refetch) and "lazy refresh" (invalidate), leaving it up to Cayenne to decide. For instance if Cayenne can't reliably match all objects in memory, it would do a refetch; if it can - it will do invalidate).
- Invalidate query lists and objects in those queries in one shot. (In case a query result is cached and there is a way to infer the objects involved; otherwise it will do a fetch).

.
Copyright ©2001-2007 Apache Software Foundation