What optimizations can be made to increase the performance of finder methods, especially when retrieving large result sets?

Xavier Schaefer

Here is a very good presentation of patterns to improve the performance of your beans.
The method that I used, and that showed very good results, is the following.

  • For each Entity Bean class, create a serializable base class (i.e. the Entity Bean class should inherit from this class).
  • Move all public attributes, getters and setters to this class (they are not needed any more in the Bean class, but are inherited).
  • Add a returnBase method in the Entity Bean, which returns a copy of its data, in the form of a base class instance (i.e. a standard java class).
  • Avoid direct client - Entity Bean interaction, but wrap the entity bean by a session bean.
  • When undertaking a select statement,
    • the client asks the intermediate session bean to call the finder,
    • the intermediate session bean calls the returnBase method for each EJB and stores all the resulting instances in a Vector.
    • The vector is returned to the client in one throw !