When you will chose CMP and BMP

Showing Answers 1 - 6 of 6 Answers

John

  • May 3rd, 2005
 

BMP  
- Bean managed persistence 
- Developer has to write persistence code for ejbLoad(),ejbStore() for entity beans 
- Should follow this approach only when its bare necessity to write your own persistence logic.Usually container managed persistence is quite sufficient and less error prone. 
 
CMP 
- Container managed persistence 
- Developer maps the bean fields with the database fields in the deployment descriptors. 
- Developer need not provide persistence logic (JDBC) within the bean class. 
- Containiner manages the bean field to DB field synchronization. 
 
The point is only ENTITY beans can have theier pesristence mechanism as CMP or BMP. Session beans, which usually contains workflow or business logic should never have persistence code.Incase you choose to write persistence within your session bean, its usefull to note that the persistence is managed by the container BMP.Session beans cannot be CMP and its not possibel to provide field mapping for session bean.

  Was this answer useful?  Yes

RokkamRajesh

  • Jun 2nd, 2005
 

BMPs are much harder to develop and maintain than CMPs.All other things are being equal,choose CMPs over BMPs for pure maintainability. 
 
There are limitations in the types of the data sources that may be supported for CMPs by a container provide.Support for non JDBC type data sources,such as CICS,are not supported by the current CMP mapping and invocation schema.Therefore accessing these would require a BMP. 
 
Complex queries might not be possible with the basic EJBQL for CMPs.So prefer BMPs for complex queries. 
 
If relations between entity beans are established then CMPs may be necessary.CMR has ability to define manage relationships between entity beans. 
 
Container will tyr to optimize the SQL code for the CMPs,so they may be scalable entity beans than the BMPs. 
 
BMPs may be inappropriate for larger and more performance sesitive applications.

gskumar

  • Sep 12th, 2005
 

When ever you want to use SAP or any ERP concept for ur back end then it is better to go for BMP's .If u are very particular about the performance of application then better use BMP rather than using CMP.

  Was this answer useful?  Yes

CMP gets complex when the query involves two or more tables. In such case you might want to go for a BMP.


BMP is a good choice when the task involves two or more tables.

CMP does not have support for certain JDBC CICS. In such case BMP is a good choice.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions