What is the difference between Session bean and Entity bean?

The Session bean and Entity bean are two main parts of EJB container.

Session Bean

  • represents a workflow on behalf of a client
  • one-to-one logical mapping to a client
  • created and destroyed by a client
  • not permanent objects
  • lives its EJB container(generally) does noot survive system shut down
  • There are two two types of Session Bean:
    • stateless session bean
    • stateful session bean

Entity Bean

  • represents persistent data and behavior off this data
  • can be shared among multiple clients
  • persists across multiple invocations
  • findable permanent objects
  • outlives its EJB container, survives systeem shutdown
  • There are two two types of Entity Bean:
    • container managed persistence(CCMP)
    • bean managed persistence(BMP)