This is why they invented transactions.
You need to learn about EJB transactions and commit options.
Typically, you would code your "business interface" in a session bean, and give the method a trx attribute of "Requires New". The session bean method then performs all activities on the entity bean within the scope of a single transaction.
Thanks for your reply.
Before writing my question I read all aspects concerning transactions.
I tried in the past a same as you said (I mean with stateless session beans) but unfortunately it does work.
I think what I need is an optimistic concurrency like the one supported in weblogic server and the most important data base servers like the one I'm using (Postgres uses multi-versionning appoach where writes don't block reads and reads don't block writes).
Locking is performed within JBoss. Upon entering the method, the entity ben is locked.
Once the method call has finished, the TX is completed and other EJBs are allowed access to the same entity bean.
Using "for...update" is really only usefull if you are accessing the same database from some other non-jboss application. In which case you must change you commit-option to either B or C.