• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

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

Edge Cases & Gotchas

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