• ↑↓ to navigate
  • ↵ to open
  • ⟶ to select
  • ⌘ ⌥ ↵ to open in a panel
  • ←→ to navigate
  • esc to dismiss
⌘ '
keyboard shortcuts

The Problem

How do you have full control over how entity beans interact with the database?

Core Idea

With bean-managed persistence (BMP), the developer writes explicit JDBC code (or uses other database APIs) in the entity bean to handle all database operations. The developer is responsible for implementing ejbCreate(), ejbRemove(), ejbFind(), and other data access methods.

How It Works

  • Developer writes JDBC code in bean methods
  • ejbCreate() inserts data into the database
  • ejbRemove() deletes data from the database
  • Finder methods (ejbFindByPrimaryKey, etc.) query the database
  • Container calls these methods, but developer implements the SQL logic

Key Properties

  • Full control over database operations
  • Developer writes JDBC code
  • More flexibility than CMP
  • More code to maintain
  • Container still provides middleware services

Visual Explanation

Bean_Managed_Persistence A Bean Managed Persist Input B Bean Managed Persist Core Mechanism A->B triggers C Bean Managed Persist Output B->C produces

Semantic Network

semantic_Bean_Managed_Persistence THIS Bean Managed Persist REL1 Related Concept THIS--REL1 related REL2 Builds Into THIS--REL2 builds into

Edge Cases & Gotchas

  • More error-prone than CMP
  • Database-specific code may reduce portability
  • Must handle transactions manually in some cases