• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

EJB CMP Vs. BMP performance

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is one table Test with 10 columns column1 ... column10;

Now in CMP if make 5 calls setColumn1 ... setColumn5, it is likely that 10 update calls are made by the container.

But if I use the BMP then only one update statement will do that. In this case BMP is cheaper than CMP. Isn't it?

Please comment on this.
 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Now in CMP if make 5 calls setColumn1 ... setColumn5, it is likely that 10 update calls are made by the container.



I did not understand what you say.How come there will be ten update calls when we actually make only 5 calls.

Assuming it is a typo,What you said is correct! We can achieve it in a single update statement if we use BMP .

But in practice we will generally try to avoid BMP in our design due to the bottlenecks of writing JDBC code.

Please comment on this
 
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If all of your assumptions are correct, then you conclusion is correct, but your assumptions may not be correct.

I've been surprised to find the WebSphere Application Server do a bunch of shortcuts with db2 that I never expected. Voodoo and magic for sure, but some transactions that I would expect to happen in multiple steps often happen in less than one. Okay, in one, but still, it's impressive. Maybe IBM does know more about their software than I do?

I love going into a shop and maintaining the custom BMPs some super-genious created to perform a millisecond faster than a CMP. The code is never commented, totally indecipherable, and impossible for a mere-mortal like myself to maintain. The consulting $$$ just keep piling up.

The most important aspect of any enterprise application is the long-term maintainability of the code. A CMP, with no code in it, is much easier to maintain that a component with lots of code in it.

Here's some more info on the benefits and drawbacks of BMPs and CMPs.

Bean Managed Persistence vs. Container Managed Persistence. EJB Stuff.

Cheers!

-Cameron McKenzie
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am a beginner in the field of EJBs.About the current thread i would like to float an idea. All the database access code in CMP is written by the container. Also the container starts a transaction locks the entity in the database and does all the updates only once before the end of the transaction. So wont it be more efficient to club updates to all the fields in a single call something like

update tablename set col1=value1,col2=value2....where primarykey=primarykeyvalue

also more efficient would be to only update the fields that have been modified or only update the fields if the entity has been modified
    Bookmark Topic Watch Topic
  • New Topic