Lesson 10 | Entity bean callbacks: ejbRemove() |
Objective | Explore the code for the ejbRemove() callback. |
Entity bean callbacks: ejbRemove()
ejbRemove()
The container calls the ejbRemove()
method when one of its remove methods is invoked and the instance is in the ready state. After its invocation, the instance is put back in the ready pool.
ejbRemove()
executes in the transaction context of the method that triggered it. The responsibility of the ejbRemove()
method is to remove the underlying entity object. In addition to removing the entity object,
the method is responsible for releasing any resources in the same way as ejbPassivate() does
.
The Customer ejbRemove()
is as follows:
public void ejbRemove() {
try {
deleteRow(custnum);
} catch (Exception e) {
throw new EJBException("ejbRemove: "
+ e.getMessage());
}
// release any resources here.
}
The command deleteRow()
invokes the appropriate JDBC code to remove the entity object using the primary key from the instance variables.
Callbacks ejbRemove - Quiz
Callbacks ejbRemove - Quiz
Click the Quiz link below to review your understanding of container callbacks.
The next lesson reviews the entity bean lifecycle.