The value added by the isModified method is seen when
creating a Bean Managed Persistence (BMP) EJB and preparing to do an
ejbStore. The EJB calls isModified to see if the data in the EJB has been
modified. It returns true if the data is changed and false if it is not.
The application then decides whether to store the EJB. Not storing the EJB
when it has not been changed saves processing time.
To accomplish this in WebSphere, enhance the code in the EJB so that
the bean code tracks modifications of the instance variables. You can do
this by following these steps:
- Define a nonpersistent instance variable called isModified in the BMP.
- Make sure that methods that modify the persistent variables set this
flag to true.
- When the variable is set to true, put code in the ejbStore
method that writes to the database. ejbStore is still called; however, if
the variable is not true, the method returns.
|