Thanks Valentin. I was kinda hoping i'd be wrong.:
Here from
http://www.precisejava.com/javaperf/j2ee/EJB.htm Use dirty flag to avoid unchanged buffer data updation
EJB Container calls ejbStore() method when the business method execution completes or when the transaction completes irrespective of change in the bean's data. The entity bean's data may not change every time when the client calls the business method.
So there will be lot of updates ( calls to ejbStore() ) to the database even though it doesn't require, thus degrading performance. To avoid this problem, you can configure dirty flag property in vendor specific deployment descriptor file for CMP1.1, for example is-modified-method-name in weblogic server's weblogic-ejb-jar.xml file.
For EJB2.0 CMP, it does not require to configure because EJB2.0 CMP Container supports this feature implicitly. For BMP, you need to write this method in bean's class and call this method wherever necessary. This technique reduces calls to the database unless the bean's data changes, thus improving performance.
And bottom line kinda:
One of the CMP performance improvement technique in EJB2.0 is that the Container can monitor bean's data (in-memory buffer) change and if any changes happens in that data then only Container will update the database. Because of this monitoring capability, CMP gives better performance than BMP. And another technique is when you call finder method in BMP, it initially retrieves primary key with first call to the database and then instance data by placing a second call to the database. It makes two calls to the database. But CMP gets the data with single call to the database for the finder methods. Thus CMP gives better performance than BMP because Container has good hold on CMP.
Well my world kinda crumbled after that one. It really kinda makes me wonder about the usefullnes of entity beans.I thought that by caching them would make a real improvement on selects. Turns out that the optimised use
pattern is to read in a sesion bean outside of the entity bean and go for direct jdbc calls that use powerfull database caching mecanism when you use prepared statements, not through the getAll() method of the ejb. Why would i use an entity bean for then? So that instead of writting one line SQL and isolate it in a transaction i would go for looking up a home object and call a method on the bean so that it would be more OO like?
Maybe CMP beans look more atractive. I can't use them in my project. I thought of using JMS to pass the SQL to replicate to other servers in the ejbStore(). Anyway i still see sql instructions, they are now called EJB-QL, got to learn that too-yeah right-, should we? We already know JDBC and the 3.0 has some nifty features i would like to have control over them myself. Well right now i'm stuck with them so i'll stop my bitchin.
Well the ejbStore() is not so bad. I think i resolved it with implementing another private variable
private boolean isDirty;
In ejbLoad() i set it to false. On any method that changes the data, i set it true. In the ejbStore() first instr. is if(isDirty) then u may enter. Hope that does not rise any problems. It can't i guess. Still....
[ March 27, 2005: Message edited by: Balamaci Serban ]