Why Use Container-Managed Persistence (CMP)?

In Chapter 7, "Creating an Entity Bean," you saw how to create an entity bean that uses BMP (bean-managed persistence) to store the bean in the database. BMP gives you direct control over the storage of the bean and you can handle any odd database relationships just by writing additional SQL code. If you create a lot of entity beans, it doesn't take long for you to get tired of writing SQL code. It's boring, repetitive, and error-prone.

Container-managed persistence (CMP) eliminates a lot of the unpleasantness of entity bean coding by handling the database operations for you. You don't need to write any SQL code (with the possible exception of the WHERE clauses for the finder methods). Aside from freeing ...

Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.