please see a state diagram for entity bean from http://www.kevinboone.com/ejb-lifecycles.html . I have some questions about it. 1. are the beans in state of the Passive not maped to any item of database? 2. what situations let container build a new bean in state of the Passive?
Originally posted by Timber Lee: 1. are the beans in state of the Passive not maped to any item of database?
Shouldn't for entity EJBs the state be called "pooled" instead of "passive"? The Entity Bean's Instance Lifecycle consists of the states: - does not exist - pooled - ready The Client's View of an Entity Beans's Lifecycle consits of the states: - Does not exist and not referenced - Does not exist and referenced - Exists and not referenced - Exists and referenced. As far as I know in the pooled (not "passive") state you find two kinds of Entity Beans: a. Instance still without identity (only newInstance() and setEntityContext() have been done). - - Usable for any find...(), not for ejbActivate(). - - As long as they have no ID they are not mapped to a database/EIS entity. b. Instance got an identity (primary key) by find...() and - - thereby has been mapped to a database/EIS entity, and - - member variables - - - have been populated from database/EIS before ejbPassivate(), - - - - i.e.have been mapped to column field values, _OR_ - - - have not yet been populated by a database load - - - - (never have bean in ready state for the current pk), - - - - i.e have not been mapped to column field values yet. - - Instance is reusable for - - - ejbActivate() (from swap file) - - - - if it had been swapped out on passivate(), _OR_ - - - any other find() resulting in an other primary key and identity. - - - - Member variables become invalid, and - - - - are no longer mapped to column field values.
Originally posted by Timber Lee: 2. what situations let container build a new bean in state of the Passive?
In the state of pooled (not "passive") never a new entity bean is (or needs to be) created for this database/EIS entity, only from state "does not exist", or again after having freed that resource by unsetEntityContext(). Literature: R. Adatia et al.: "Professional EJB", page 126 .. 128. Hope I am right, Thomas.