Header Ads

  • Breaking Now

    What are Entity Bean and Session Bean?

    An Entity Bean is :
    - a persistent business data object in a business process, which provides an OR (Object Relational) mapping over an underlying RDBMS.It is transactional in nature. An in memory objects can be mapped with a field of table in RDBMS database.
    -can be expressed as a Noun e.g. a Customer, a Product, an Account, Purchase Order etc.
    -long lasting as they represent data in the database.

    Entity beans can be of two types:
    CMP Entity Bean: EJB container manages data persistence and a bean developer do not have to bother about business data persistence logic.
    BMP Entity Bean: A bean managed persistent entity bean is persisted in the database by hand or say programmatically. A component developer has to code to translate in memory objects to underlying RDBMS or object database.

    A Session Bean incorporates business logic or business rules or workflow related logic of an enterprise. A session bean exists only until a session exists between a client and server so it has real short period of its existence.

    Session beans are of two types:

    Stateless Session Bean
    In case where state between a client and a server interaction is not to be persisted then Stateless session bean is to be used. e.g. executing calculating tax or validating a credit card etc. The stateless bean instance does not have longevity.
    Stateful Session Bean
    Stateful Session bean keeps a conversational state of a client over a series of method calls, keeping it in a persistent area. They are more functional than stateless session bean as they store conversational state.

    Whenever a client access a stateful session bean with a series of method calls, before moving the bean instance into passivated state, the conversational state is stored into the persistent area i.e. hard disk. This makes smart resource management. Whenever the same client is making a request again over the stateful session bean then state is pulled out of hard disk into in memory of bean. This is called activated state. Thus state of a client is saved in between context switching in a persistent storage area.

    Post Top Ad

    Post Bottom Ad