Working with Identity Maps

TopLink uses identity maps to cache objects for performance and maintain object identity. TopLink provides the following identity map types on the Identity tab (see Figure 4-13):

Table 4-2 Identity Maps  

Identity Map Description
Full identity map Provides full caching and guaranteed identity. Caches all objects and does not remove them. This method may be memory intensive when many objects are read.Do not use on batch type operations.
Soft cache weak identity map (default with JDK 1.2, available since JDK 1.2) Similar to the weak identity map except that it maintains a most-frequently-used sub-cache. The size of the sub-cache is proportional to the size of the identity map as specified by descriptor's setIdentityMapSize() method. The sub-cache uses soft references to ensure that these objects are garbage-collected only if the system is low on memory.
Hard cache weak identity map (available since JDK 1.2) Identical to the soft cache weak identity map except that it uses hard references in the sub-cache. Use this identity map if soft references do not behave properly on your platform.
Weak identity map (available since JDK 1.2)  Similar to the full identity map except that the map holds the objects using weak references. This method allows for full garbage collection. It also provides full caching and guaranteed identity.
Cache identity map Furnishes caching and identity, but does not guarantee identity. A cache identity map maintains a fixed number of objects specified by the application. Objects are removed from the cache on a least-recently-used basis. This method allows object identity for the most commonly used objects.
No identity map Does not preserve object identity and does not cache objects.

Related Topics

About TopLink Descriptors

Specifying Optimistic Locking
Setting Identity Map Size
Design Guidelines
Using Object Identity
Caching Objects

Working with Descriptors

 

Copyright © 1997, 2004, Oracle. All rights reserved.