Found some pointers on the web which explained that adding a method
public boolean isModified()
to ejb implementation class helps.
It should return true if the state has changed. JBoss 2.4.x does not store the ejb if the state has not changed.
You can also specify <tuned-updates>true</tuned-updates> in jaws.xml. Either as the default or for each entity bean. <tuned-updates> acceessed whether the bean has changed or not. For us, using Jboss 2.2.1, 2.4.0, and 2.4.3, setting this eliminated the multiple calls to ejbStore without implementing the isModified()
But <tuned-updates>true</tuned-updates> doesn't work in jboss 2.4.4. Is there any replacement or workaround for CMP beans? isModified() is non-standart.
The problem is that you transactions are to small. When each transaction completes the container must sync the entity with the database. Assuming that you have tuned updates on, persistence engine checks each field to see if the value has changed, and if it has it will store the value in the database.
A common problem occurs when a web interface loads form input into an entity. Programmers commonly forget to wrap these sets with a transaction, so you get one transaction for each field in your form.