Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
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 |
|
|
Object-Relational Descriptors |
![]() |
|
EIS DescriptorsFoot 2 |
|
|
XML Descriptors |
![]() |
![]() |
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:
To specify the existence checking information for a descriptor, use this procedure:
Select the descriptor in the Navigator.
Select the Caching tab in the Editor. The Caching tab appears.
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". |
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".