What are the diffrent factors u all consider while deciding to use CMP or BMP ?
I think ther's no a deffinitive answer to your question... but there´s a quite real way to follow, DON´T MESS IT.
This is the only all my enquires and investigations meeting point.
I hope this helps you, Harish.
Both have their pros and cons. It really depends on what you're trying to achieve or what is the size of your project. If your project is not too big, i.e. a few entities, than BMPs may prove to be more flexible. But, for large projects I prefer CMPs as I don't have to write the persistence logic myself.
With CMPs, the object state can be cached between method calls (this feature is vendor-dependent). Most commercial EJB containers provide this caching facility implicitly. This results in better performance than BMPs. Another benefit of CMPs is that you can switch from one DB to another as long as your server vendor supports the DB. However, if you're trying to optimize your database queries, you do not have much control over the generated SQL. Also, the number of SQL statements generated can be significantly larger than BMPs.
With BMPs, of course, you have more control over your persistence logic and you can perform optimization as required. In some cases, this flexibility is highly desirable. Another benefit of BMPs, in my opinion, is that you can write entity beans that more accurately reflect your object model. With BMPS you can write coarse-grained entity beans rather easily. I have always found this to be a challenge with CMPs.
To summarize it all:
BMPs: Flexible, optimization of SQL possible, conforms more easily to your object model and allows coarse-grained/aggregate entity beans.
CMPs: Less code, caching improves performance, code is not specific to a data source, you can (arguably) switch DBs and even vendors with relative ease.
Hope this helps.
For Container managed Persistence all the persistence activities are taken care by EJB Container.here Persistence activities includes loading and storing the data to the database and at the same time activation and passivation of ejb instances are also taken care by EJB container. CMP Beans are bit more performance compared to BMP beans
Where as the if we take Bean managed persistence all these activities should be taken care by bean developer.mens EjbLoad() and EjbStore() and activation passivation logic should be taken care by bean developer.
and some other things which will decide either CMP/BMP is that complexity of queries.if your sql query is straight forward without having complex senarios like joins among multiple tables,groupby cluases etc you can go for CMP.
for complex query situations BMP would be best suited.