Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Configuring Cache Existence Checking at the Descriptor Level

When TopLink writes an object to the database, TopLink runs an existence check to determine whether to perform an insert or an update.

By default, TopLink checks against the cache. Oracle recommends that you use this default existence check option for most applications. Checking the database for existence can cause a performance bottleneck in your application.

Table 28-17 summarizes which descriptors support existence checking.

Table 28-17 Descriptor Support for Existence Checking

Descriptor Using TopLink Workbench
Using Java

Relational DescriptorsFoot 1 

Supported.


Supported.


Object-Relational Descriptors

Unsupported

Supported.


EIS DescriptorsFoot 2 

Supported.


Supported.


XML Descriptors

Unsupported
Unsupported

Footnote 1 Relational class descriptors only (see "Relational Class Descriptors").

Footnote 2 EIS root descriptors only (see "EIS Root Descriptors").

You can configure existence checking at the descriptor level to override the project level configuration (see "Configuring Existence Checking at the Project Level").

For more information see:

Using TopLink Workbench

To specify the existence checking information for a descriptor, use this procedure:

  1. Select the descriptor in the Navigator.

  2. Select the Caching tab in the Editor. The Caching tab appears.

    Figure 28-29 Caching Tab, Existence Checking Options

    Description of Figure 28-29  follows
    Description of "Figure 28-29 Caching Tab, Existence Checking Options"

Use this table to enter data in the following fields of the tab to specify the existence checking options for newly created descriptors:

Field Description
Check Cache Check the session cache. If the object is not in the cache, assume that the object does not exist (do an insert). If the object is in the cache, assume that the object exists (do an update). Oracle recommends using this option for most applications.
Check Cache then Database If an object is not in the cache, query the database to determine if the object exists. If the object exists, do an update. Otherwise, do an insert. Selecting this option may negatively impact performance. For more information, see "Check Database".
Assume Existence Always assume objects exist: always do an update (never do an insert). For more information, see "Assume Existence".
Assume Non-Existence Always assume objects do not exist: always do an insert (never do an update). For more information, see "Assume Nonexistence".

Using Java

To configure existence checking at the descriptor level using Java, use ClassDescriptor method getQueryManager to acquire the DescriptorQueryManager from the descriptor and then use one of the following DescriptorQueryManager methods (see Example 28-8):

  • checkCacheForDoesExist–check the session cache. If the object is not in the cache, assume that the object does not exist (do an insert). If the object is in the cache, assume that the object exists (do an update). Oracle recommends using this option for most applications.

  • checkDatabaseForDoesExist–if an object is not in the cache, query the database to determine if the object exists. If the object exists, do an update. Otherwise, do an insert. Selecting this option may negatively impact performance. For more information, see "Check Database".

  • assumeExistenceForDoesExist–always assume objects exist: always do an update (never do an insert). For more information, see "Assume Existence".

  • assumeNonExistenceForDoesExist–always assume objects do not exist: always do an insert (never do an update). For more information, see "Assume Nonexistence".

Example 28-8 Configuring Existence Checking Using Java

descriptor.getQueryManager().checkCacehForDoesExist();