Objective 4.5: State benefits and costs of Container Managed Persistence
Entity Beans can be configured to either use Container Managed Persistence or Bean Managed Persistence.
Container Managed Persistence
Benefits:
- Requires less code (faster development)
- Portable accross database vendor and schema changes
- The container may offer caching services. Therefore, the generated code might be more efficient, especially for the finder methods
Costs:
- Does not suppert (yet) difficult relationships and object types
- Is not necessarily performant (although this might change when CMP becomes more mature)
Bean Managed Persistence
Benefits:
- Offers more control over persistency, as you write the SQL yourself
- With proper constructed SQL, BMP makes a more efficient use of the database
- Can be used with EJB 1.1 container (don't try to use CMP with a container less than 2.0)
- Faster when it comes to complex relationships and datatypes
Costs:
- Needs an extra DAO layer to avoid coupling with a specific database
- Hard to maintain, as all SQL is self written
- Requires more coding