We're writing some code that has the potential for multiple threads in one server to access the same set of rows of data, possibly updating them. More so we know that when we add more servers to the cluster, each server could be accessing the same set of rows in a table, possibly each via multiple threads. I can't seem to find much good info with regards to using entity beans and read/write locks. This is new territory for us as thus far we've been working on a prototype and now we're gaining some traction and all the issues of scaling are creeping up on us. I can't find any books at all on the area of JEE 6 clustering/scalability.. I realize each server does it differently (too bad JEE6 didn't define a standard scalability mechanism). We're using GlassFish 3.1 right now but are going to be switching to JBoss 7 as soon as we can. Regardless of the container, the use of entity bean locking I assume is what we need to use? Does entity bean locking apply to the db table/row, or is it only the object in memory on a specifid container?
Any links to info or experience would be fantastic on the subjects.
I suppose that the EntityManager handle it.
With EJB3.1 there are more options, see  chapter 3.4 special 184.108.40.206.
you should use 'entityManager.lock(<your entity>, LockModeType.PESIMISTIC_WRITE)'
 JSR317 JPA 2.0 http://jcp.org/en/jsr/detail?id=317