Oracle8i Enterprise JavaBeans Developer's Guide and Reference Release 3 (8.1.7) Part Number A83725-01 |
Library | Service | Contents | Index

## Difference Between Session and Entity Beans

The major differences between session and entity beans is that entity beans involve a framework for persistent data management, a persistent identity, and complex business logic. The interface requirements on entity beans provides callback functions that the container calls when persistent data should be managed or when a bean should be retrieved based upon its identity.

With an entity bean, the interfaces have been designed so that each callback method is called at the appropriate time. For example, right before the transaction is committed, the `ejbStore` method is always invoked. This enables the entity bean to save all of its persistent data before the transaction is completed. Each of these callback methods are discussed further in "Implementing Callback Methods".

The following table illustrates the different interfaces for session and entity beans. Notice that the difference between the two types of EJBs exists within the bean class and the primary key. All of the persistent data management is done within the bean class methods.

| Entity Bean | Session Bean
--- | --- | ---
Remote interface | Extends `javax.ejb.EJBObject` | Extends `javax.ejb.EJBObject`
Home interface | Extends `javax.ejb.EJBHome` | Extends `javax.ejb.EJBHome`
Bean class | Extends `javax.ejb.EntityBean` | Extends `javax.ejb.SessionBean`
Primary key | Used to identify and retrieve specific bean instances | Not used for session beans

| Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
Library | Service | Contents | Index