This section summarises the various locking and caching modes that can be configured for the Bean Managed Persistence (BMP) Entity Beans. BMP Entity beans can be configured to perform pessimistic or optimistic locking.
Default behavior of Bean Managed Persistence
Following is the default BMP behavior:
- Locking
- Container locks the entity bean instances within a transaction
- For Non-Transactional calls, locking is at the method level
- Caching
- Entity is cached once it is fetched, or is created by the container
- Cache is updated on successful commit of the transaction
- As long as the entity is available in the cache, ejbLoad() callback is never invoked
Note: This behavior must be used when all updates to the entity are through the container.
Bean Managed Persistence - Cache and Load at Transaction Begin behavior
- Locking
- Container locks the entity bean instances participating in a transaction
- For Non-Transactional calls, locking is at the BMP business method level
- Caching
- Entity is cached once fetched or created by the container
- ejbLoad() callback is given at the beginning of every transaction
- Cache is updated on successful commit of the transaction
- Cache and Load at Transaction Begin BMP mode provides DB level read committed behavior
Note: This behavior can be used when there are external updates to the entities in the database.
Bean Managed Persistence - No Lock behavior
No Lock behavior does not lock entities at the container level.
- Locking
- Entity bean instances are not locked at the Container level
- The application may acquire DB locks to guarantee data consistency
- Caching
- ejbLoad() callback is given at the beginning of every transaction
Configuring Bean Managed Persistence Modes
Following is the procedure for configuring BMP modes:
- BMP locking and caching can be configured through the bmp-locking-option tag in pramati-j2ee-server.xml.
- To configure at module level, add the bmp-locking-option tag under ejb-module tag.
- Alternatively, to configure at bean level, add the bmp-locking-option tag under the corresponding ejb tag.
- Following are the permitted values for the bmp-locking-option tag:
- lock-with-cache-enabled - To achieve BMP default behavior. This is also the default behavior if the tag is not present.
- no-lock - To achieve No Lock BMP behavior.
- lock-and-load-in-transaction - To achieve the Cache and Load at Transaction Begin behavior.
Note: To provide backward compatibility, lock-bmp tag is still supported in Pramati Server 6.0.
One to one correspondence between lock-bmp and bmp-locking-option values:
| BMP behavior |
lock-bmp value |
bmp-locking-option value |
| Default behavior |
true |
lock-with-cache-enabled |
| Cache and Load at Transaction Begin behavior |
pre50 |
lock-and-load-in-transaction |
| No Lock behavior |
false |
no-lock |
A summary of Bean Managed Persistence behavior
The following table summarises the BMP behavior:
| Behavior |
Transaction |
Default BMP |
Cache and Load at Transaction Begin BMP |
No Lock BMP |
| Lock |
Tx |
Yes |
Yes |
No |
| Lock |
Non-Tx |
Yes |
Yes |
No |
| Load |
Tx |
If not cached |
Yes |
Yes |
| Load |
Non-Tx |
If not cached |
If not cached |
If not cached |
| Store |
Tx |
Yes |
Yes |
Yes |
| Store |
Non-Tx |
No |
No |
No |
| Master Copy |
- |
No |
No |
Yes |
| Multiple instances |
- |
No |
No |
Yes |
 |
| © Pramati Technologies 2007 |
|