Entity/bean/instance death

So we all know that an entity bean is a representation of some real entity in an underlying persistent store (usually as a row in a database, blah, blah, blah). But there’s still some confusion about what distinguishes an entity from an entity bean from an entity bean instance.

Entity

The real thing in the underlying persistent store. The row in the database (although it can be more complex). An entity dies when its row is deleted from the underlying store, either through a direct database delete (like, someone using a database admin tool), or because someone calls remove() on the bean’s home or component interface.

Entity bean

The component that represents the underlying real entity. But this one’s tricky... is it the class? Is it the interface? Is it the instance of the bean class? During development and deployment, the entity bean is the whole component (the two interfaces, DD, and bean class). But at runtime, it can get a little fuzzy. S ometimes we use “entity bean” to describe the possibility of representing a particular entity as a bean. In other words, if there’s an entity for Bo Rodgers in the database, then we can say that there is a Bo Rodgers entity bean, even if there’s no bean instance currently representing that entity! If an entity exists for a particular bean type (like Customer Fred Foo), the entity bean for that entity is said to exist. An entity bean is said to die when its underlying entity is deleted, as in, “There’s no Fred Foo entity ...

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.