Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
Mappings that are read-only will not be affected during insert, update, and delete operations.
Use read-only mappings when multiple attributes in an object map to the same fields in the database but only one of the mappings can write to the field.
You can also use read-only mappings with bi-directional many-to-many mappings to designate which mapping will be responsible for updating the many-to-many join table.
Mappings defined for the write-lock or class indicator field must be read-only, unless the write-lock is configured not to be stored in the cache or the class indicator is part of the primary key.
Use read-only mappings only if specific mappings in a descriptor are read-only. If the entire descriptor is read-only, use the descriptor-level setting (see "Configuring Read-Only Descriptors").
Table 35-3 summarizes which mappings support this option.
To specify a mapping as read-only, use this procedure:
Select the mapped attribute in the Navigator. Its properties appear in the Editor.
Click the General tab. The General tab appears.
Figure 35-1 General Tab, Read-Only Options
Select the Read-Only option to set the mapping to be read-only and not affected during update and delete operations.
Use the following DatabaseMapping
methods to configure the read access of a mapping:
readOnly
–configures mapping read access to read-only
readWrite
–configures mapping read access to read and write (default)
Example 35-1 shows how to use these methods with a class that has a read-only attribute named phones
.