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 Read-Only Mappings

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.


Note:

The primary key mappings cannot not be read-only.

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.

Using TopLink Workbench

To specify a mapping as read-only, use this procedure:

  1. Select the mapped attribute in the Navigator. Its properties appear in the Editor.

  2. Click the General tab. The General tab appears.

    Figure 35-1 General Tab, Read-Only Options

    Description of Figure 35-1  follows
    Description of "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.

Using Java

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.

Example 35-1 Configuring Read Only Mappings in Java

// Map the phones attribute
phonesMapping.setAttributeName("phones");
 
// Specify read-only
phonesMapping.readOnly();