I have just started with EJB, I have doubt regarding how a container implements concurrency when it comes to Entity bean. Book(EJB by Richard) says that in entity bean instance can't be accessed concurrently though the EJBObject is shared by more than one client.My doubt is If there is pool of instance (of beans) and two EJBObject associated with two different clients, both access the EJBObject at the same. Then instance associated with two EJBObject will be different ones.But the data in database represented by the EJBObject(or bean instance) will be same.When one Client changes the data and the other overrides the change, there is a chance at some point the data represented by the instances may be different. Can some one please explain to me how a container takes care of this concurrency problem.
Thank you Raj
posted 11 years ago
Database level locking solves the problem. All the container does is use the appropriate database commands (like SELECT..FOR UPDATE) to lock the rows appropriately. Every container is different. For an explanation of how WebSphere solves this problem, take a look at this article.. Kyle