I am developing a BMP Entity bean. I have noticed that whenever I the create method is invoked, the ejbLoad() and the ejbStore() methods are also invoked. I feel that once my database insert is done, having to do a select and update SQL queries is major overhead. is this behavior typical of all EJB containers? Is there any way to suppress these invocations?

Parag Bhagwat

This is the default behaviour for EJB. The specification states that ejbLoad() will be called before every transaction and ejbStore() after every transaction.

Each Vendor has optimizations, which are proprietary for this scenario. We will outline the properties for the popular servers below:

WebLogic 5.1

  1. The db-is-shared option, which is set in the weblogic-ejb-jar.xml file. This option by default set to true, but can be overridden. This option can be used if the WebLogic Server has exclusive access to the database. Using this option ejbLoad()will be called only once when the user obtains remote interface and then after any transaction rollback. This cannot be used in a cluster
  2. The Cache Strategy option can be set to read-only. Using this strategy the Container will never invoke ejbStore() and will limit calls to ejbLoad() as specified by the read-timeout-seconds options. Both options are also set in the weblogic-ejb-jar.xml file.
  3. The is-modified-method-name option, which is set in the weblogic-ejb-jar.xml file and is used to specify a method that the container will invoke before ejbStore(). If this method returns true then ejbStore() will be called, if it returns false, then it will not invoke ejbStore().
[RC - Please submit answers for other containers as feedback so we can provide a complete list]