JBoss uses a method called isModified to determine if the entity needs to be saved. The default implementation of this simply returns true. Override this method in the bean and only return true when something has been modified. I set it local modified flag to true in all setXXX methods, then set it to false in ejbStore and ejbLoad, and use that as the return value of isModified. You may also have to reset it in ejbActivate, I don't remember...
Thanks a lot! Is this a common practice for App Servers? What about WebLogic and WebSphere? Do they have something like this isModified() function?
WebLogic does, there is a tag in the weblogic-ejb-jar to tell it which method to use.
Another thing you should look at doing is define you session been method to have the transaction attribute REQUIRED and the transaction attributes on your entity bean methods to SUPPORTS (which I think is the default). This will then roll back all the changes in the case of errors and also cause ejbStore to only be called at the end of the transaction.