Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
You can configure a relational class or EIS root descriptor as read-only. This indicates that instances of the reference class will never be modified.
Read-only descriptors are usually used within a unit of work as a performance gain, because there is no need to register, clone, and merge the read-only classes. For more information, see Chapter 100, "Understanding TopLink Transactions".
In a CMP project, you can declare an entity bean as read-only within the TopLink deployment XML file. For more information, see "Using Read-Only Entity Beans".
Table 28-4 summarizes which descriptors support read-only configuration.
Table 28-4 Descriptor Support for Read Only
Descriptor | Using TopLink Workbench
|
Using Java
|
---|---|---|
Relational DescriptorsFoot 1 |
|
|
Object-Relational Descriptors |
|
|
EIS DescriptorFoot 2 |
|
|
XML Descriptors |
|
|
Footnote 1 Relational class descriptors only (see "Relational Class Descriptors").
Footnote 2 EIS root descriptors only (see "EIS Root Descriptors")
Note: Relational aggregate and EIS composite descriptors get their read-only setting from their owner. |
TopLink can declare a CMP entity bean as read-only. This ensures that the entity bean cannot be modified and allows TopLink to optimize unit of work performance.
If an attempt is made to modify a read-only entity bean (create, update, or remove), TopLink immediately throws a javax.ejb.EJBException
: TopLink does not wait until the transaction commits.
If an attempt is made to change a CMR field on a read-only entity bean, TopLink throws a javax.ejb.EJBException
.
When TopLink is configured as the OC4J persistence manager, the TopLink read-only bean configuration replaces the OC4J READ-ONLY
CMP concurrency mode.
To configure a descriptor as read-only use this procedure:
Select a descriptor in the Navigator. Its properties appear in the Editor.
Click the Descriptor Info tab. The Descriptor Info tab appears.
Figure 28-2 Descriptor Info Tab, Read Only Option
Specify whether this descriptor is read-only or not.
Use ClassDescriptor
method setReadOnly
.