Session vs. Entity Beans
  • A significant part of designing an EJB system is to decide which components should be session beans and which should be entity beans
  • Differences between entity and session beans
    • Persistence
      • Can be handled automatically for entity beans
      • Session beans have no callbacks for DB synchronization
    • Sharing
      • Entity beans can be shared, session beans cannot
      • This implies session beans do not have finder methods
    • Lifetime
      • Entity beans live until explicitly deleted
      • Session beans lifetimes are limited by client lifetime and timeout
    • Identity
      • Entity beans have a primary key
      • Session beans do not - effectively they have no identit

Next Slide >>