Fine-grained versus coarse-grained Entity beans—
Many designers make the mistake of modeling all their entities as EJBs. The decision of what entities to model as EJBs and at what level of granularity is a critical issue to overall system performance.
Use the appropriate modeling techniques for your job. Use JDBC, JDO, EJBs, or other data access techniques as appropriate.
Business logic in Entity beans—
Entity beans should encapsulate additional business logic such as marking an account to be closed, determining the type or level of users, or the total for an order. Advanced features of the WebLogic Query Language make this easier. This enforces the MVC architecture.
Optimize data access—
It's important to limit the complexity of joins and other long-running data access operations. We should also minimize data access by retrieving multiple data entries in one query. The use of field groups and relationship caching can be used to help with some of these issues.
It's a good idea to use local interfaces when possible to avoid network access. Network access costs time and resources.
Allowing the container to manage transactions is often a better option than managing them yourself in an EJB. In general, try to use the optimal strategy when deciding when and how to manage transactions. Using the wrong transaction granularity and isolation level can harm performance.
Never expose Entity beans to anything but Session EJBs. Each call to the EJB container is a transaction. The façade allows a single transaction to access the various methods of the Entity bean through one call to a Session EJB. This façade implementation also provides a loose coupling that allows the Entity bean to swapped out if needed.
CMP over BMP—
In general, use CMP EJBs if you can model your business using them. You get added performance benefits of optimizations from WebLogic's CMP engine (for example, relationship caching) with CMP, which you wouldn't get with BMP.
The use of the appropriate transaction isolation level is important for performance. Chapter 9, "Processing Transactions with the Java Transaction API," explores the isolation levels in detail.
Indexes for queries—
For better database performance, ensure that appropriate indexes have been create for all EJB-QL queries.
Fast lane reader—
The fast lane reader design pattern uses Entity beans for inserts, updates, and deletes to the database. However, for reading data, it uses straight JDBC. This is especially important if you're reading large amounts of data.