Read-ahead hints
Read-ahead hints enable applications to minimize the number of database roundtrips by retrieving a working set of EJB 2.x CMP entity beans for the transaction within one query.
Read-ahead hints can be set only using the WAS Enterprise assembly tool or through the Add Access Intent wizard of the IBM WebSphere Studio Application Developer product.
Currently, only findByPrimaryKey methods can have read-ahead hints. Only beans related to the requested beans by a container-managed relationship (CMR), either directly or indirectly through other beans, can be read ahead. Beans that use EJB inheritance should not be used in a read-ahead hint.
A read-ahead hint takes the form of a character string. You do not have to provide the string; the wizard generates it for you based on CMRs defined for the bean. For example, suppose a CMP bean type A has a finder method that returns instances of bean A. A read-ahead hint for this method is specified using the following notation: RelB.RelC; RelD
Interpret the preceding notation as follows...
- Bean type A has a CMR with bean types B and D.
- Bean type B has a CMR with bean type C.
For each bean of type A that is retrieved from the database, its directly-related B and D beans and its indirectly-related C beans are also retrieved. The order of the retrieved bean data columns in each row of the result set is the same as their order in the read-ahead hint: an A bean, a B bean (or null), a C bean (or null), a D bean (or null). For hints in which the same relationship is mentioned more than once (for example, RelB.RelC;RelB.RelE), a bean's data columns appear only once, at the position it first appears in the hint.
The tokens shown in the notation (RelB and so on) must be CMR field names for the relationships as defined in the deployment descriptor for the bean. In indirect relationships such as RelB.RelC, RelC is a CMR field name defined in the deployment descriptor for bean type B.
A single read-ahead hint cannot refer to the same bean type in more than one relationship. For example, if a Department bean has a relationship employees with the Employee bean and also has a relationship manager with the Employee bean, the read-ahead hint cannot specify both employees and manager.
See also: