Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.1.0) Part Number B28221-02 |
|
|
View PDF |
You can configure an entity bean with container-managed persistence as read-only. By doing so, you enter into a contract with OC4J, by which you guarantee not to change the state of the entity bean with container-managed persistence after it is activated. Unlike read-only entity beans with container-managed persistence, no exception will be thrown if you do update a read-only bean with bean-managed persistence.
When you configure an entity bean with bean-managed persistence as read-only, OC4J uses a special case of commit option A (see "Configuring Commit Options for an Entity Bean With Bean-Managed Persistence") to improve performance by the following:
Caching the instance
Not calling ejbLoad
after activation
Not updating the instance or calling ejbStore
when the transaction commits
As Figure 15-1 shows, multiple clients accessing the same read-only entity bean with bean-managed persistence by primary key are allocated a single instance. Both Client 1 and Client 2 are satisfied by the same cached instance of a read-only entity bean with bean-managed persistence. Because the entity bean with bean-managed persistence is read-only, both transactions can proceed in parallel.
Without this optimization, each client is allocated a separate instance, and each instance requires the execution of all life cycle methods.
Figure 15-1 Read-Only Entity Beans With Bean-Managed Persistence and Commit Option A
Example 15-4 shows the orion-ejb-jar.xml
file entity-deployment
element locking-mode
attribute mode
configured to specify an entity bean with bean-managed persistence as read-only.