Skip Headers

Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g Release 3 (10.1.3) B14428-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Configuring a Read-Only BMP Entity Bean

You can configure a BMP entity bean as read-only. By doing so, you enter into a contract with OC4J by which you guarantee not to change the BMP entity bean's state after it is activated. Unlike CMP read-only, no exception will be thrown if you do update a read-only BMP bean.

When you configure a BMP entity bean as read-only, OC4J uses a special case of commit option A (see "Configuring BMP Commit Options") to improve performance by:

- 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 BMP entity bean by primary key are allocated a single instance. Both Client 1 and Client 2 are satisfied by the same cached read-only BMP entity bean instance. Because the BMP entity bean 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 lifecycle methods.

Figure 15-1 Read-Only BMP Entity Beans and Commit Option A

Description of "Figure 15-1 Read-Only BMP Entity Beans and Commit Option A"

## Using Deployment XML

Example 15-1 shows the `orion-ejb-jar.xml` file `entity-deployment` element `locking-mode` attribute `mode` configured to specify a BMP entity bean as read-only.

Example 15-1 orion-ejb-jar.xml For Read-Only

    <entity-deployment
        name=EmployeeBean"
        location="bmpapp/EmployeeBean"
        locking-mode="read-only"
    >
    ...
    </entity-deployment>