For a stateful session bean, which method is activated by the container to save the state of the bean?
-
ejbCreate()
-
ejbPassivate()
-
ejbStore()
-
ejbSave()
C
Correct answer
Explanation
For stateful session beans, ejbPassivate() serializes the bean to secondary storage (temporarily saving it), and ejbActivate() restores it. However, ejbStore() is the method that explicitly saves the bean's state to persistent storage during passivation or before container shutdown. ejbCreate() (A) is for initialization, not saving state. ejbPassivate() (B) triggers the passivation process but ejbStore() does the actual saving work. ejbSave() (D) doesn't exist in the EJB API.