Cayenne User Documentation
Caching Lookup Tables

Query result caching feature can be used to implement caching of lookup tables. "Lookup" or "configuration" tables can be loosely defined as small tables that change rarely and mostly used in read-only fashion. Examples of such tables are COUNTRY, USER_TYPE, AREA_CODE, etc. Often data from such tables is displayed in a combo box or dropdown.

For performance reasons it makes sense to store the lookup data in the shared cache. The following steps could be taken to create and use a shared query for a Country entity:

- Create a named SelectQuery in CayenneModeler. Call it something like "AllCountries". Select a root to be Country ObjEntity, select shared caching and uncheck "refresh" checkbox.
- Whenever a list of countries is needed, use a local DataContext to get it from cache - `context.performQuery("AllCountries", false)`.

.
Copyright ©2001-2006 Apache Software Foundation