blob: e385edf9cb02bbdda609b4307efa5627096d745a [file] [log] [blame]
Title: Caching Lookup Tables
<P>Query result caching feature can be used to implement caching of lookup tables. &quot;Lookup&quot; or &quot;configuration&quot; 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.</P>
<P>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:</P>
<UL>
<LI>Create a named SelectQuery in CayenneModeler. Call it something like &quot;AllCountries&quot;. Select a root to be Country ObjEntity, select shared caching and uncheck &quot;refresh&quot; checkbox.</LI>
<LI>Whenever a list of countries is needed, use a local DataContext to get it from cache - <TT>context.performQuery(&quot;AllCountries&quot;, false)</TT>.</LI>
</UL>