Oracle® Application Server TopLink Mapping Workbench User's Guide
10g Release 2 (10.1.2) Part No. B15900-01 |
|
Previous |
Next |
OracleAS TopLink uses identity maps to cache objects for performance and maintain object identity. The OracleAS TopLink Mapping Workbench provides the following identity map types on the Identity tab (see Figure 4–19):
Table 4-2 Identity Maps
The default identity map size is 100.
For the cache identity map policy, the size indicates the maximum number of objects stored in the identity map.
For the full identify map policy, the size determines the starting size of the map.
For the soft/hard cache weak identity map, the most recently used sub-cache is proportional to the size.
Use the following guidelines when employing an identity map:
If using a Java 2-compatible Virtual Machine (VM), objects with a long lifespan, and object identity are important, use a SoftCacheWeakIdentityMap or HardCacheWeakIdentityMap policy.
If using a Java 2-compatible VM, and object identity is important but caching is not, use a WeakIdentityMap policy.
If an object has a long lifespan or requires frequent access, or is important, use a FullIdentityMap policy.
If an object has a short lifespan or requires frequent access, and identity is not important, use a CacheIdentityMap policy.
If objects are discarded immediately after being read from the database, such as in a batch operation, use a NoIdentityMap policy.
Note: The NoIdentityMap does not preserve object identity. |
In a Java application, object identity is preserved if each object in memory is represented by one, and only one, object instance. Multiple retrievals of the same object return references to the same object instance — not multiple copies of the same object.
Maintaining object identity is extremely important when the application's object model contains circular references between objects. You must ensure that two are referencing each other directly, rather than copies of each other. Object identity is important when multiple parts of the application may be modifying the same object simultaneously.
Turn identity off when object identity is not important (for example, for read-only objects).