+

Search Tips   |   Advanced Search

Enterprise bean development best practices

Use the following guidelines when designing and developing enterprise beans.


Batched commands for container managed persistence

From JDBC 2.0 on, PreparedStatement objects can maintain a list of commands that can be submitted together as a batch. Instead of multiple database round trips, there is only one database round trip for all the batched persistence requests.

We can enable the use of this feature for EJB container managed persistence (CMP). When we do, the run time defers ejbStore/ejbCreate/ejbRemove or the equivalent database persistence requests (insert/update/delete) until they are needed. This can be at the end of the transaction, or when a flush is needed for finders related to this EJB type. When the persistence operation finally happens, run time accumulates the database requests and uses JDBC PreparedStatement batch operation to make a single JDBC call for multiple rows of the same operation.

The product enables us to make the same settings using assembly tools.


Deferred Create for container managed persistence

For CMP during the ejbCreate, the container can create the representation of the entity in the database immediately, or defer it to a later time.

We can turn this option on from the EJB CMP side. When we choose this option, the runtime defers ejbCreate, or the equivalent database persistence request, until it is needed. This can be at the end of the transaction, or when a flush is needed for finders related to this EJB type. By doing this we can reduce two round trips for the newly created entity (insert and update) to one (insert).

The product enables us to make the same settings using assembly tools.


Related:

  • Partial column update feature for container managed persistence
  • Task overview: Using enterprise beans in applications
  • Set the run time for batched commands with JVM arguments
  • Set the run time for deferred create with JVM arguments