important distinction to make. Traditional O/RM tools primarily focus on map-
ping database tables to objects, which influences their caching. Traditional O/RM
caching maintains object identification ( OID ) just as the database would manage
the uniqueness of a row in a table. This further means that if two different results
return the same object, the object will be cached only once. This is not the case
with iBATIS . Because iBATIS is a data-centric framework that is focused on SQL
results, we do not cache objects based on their uniqueness. IBATIS caches the full
returned result regardless of whether an identical object (value-wise) exists else-
where in a cache.
Let's take some time to look at the cache model and discuss more in depth what
it is and what its common components are. We will see how they can help avoid the
mundane manual management of caching results and their dependencies.
9.3 Understanding the cache model
The simplest description of the cache model is that it is a cache configuration.
More specifically, it is the base from which all iBATIS cache implementations are
defined. The cache model configuration is defined within a SQL Map configura-
tion and can be utilized by one or more query mapped statements.
The cache configuration is defined by the <cacheModel> tag, which contains
the attributes in table 9.1.
<cacheModel> tag attributes
This value specifies the unique ID that will be referenced by query mapped statements
that want to use the cache model's configured cache.
This is the type of cache that the cache model will be configuring. Valid values include
MEMORY, LRU, FIFO, and OSCACHE. This attribute can also contain the fully qualified
class name of a custom CacheController implementation.
When set to true, this denotes that the cache will be used solely as a read-only cache.
Objects retrieved from a read-only cache should not have their properties changed.
This attribute specifies whether the cache contents should be “deep copied” upon retrieval.
The id attribute is used to identify the cache so that we can tell iBATIS which
mapped statements to store in it. Let's take a closer look at the other attributes.
iBATIS provides four default cache implementations that the cache model can
take advantage of out of the box. The four types are shown in table 9.2.
Search WWH ::