This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Concurrency in entity bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Concurrency in entity bean" Watch "Concurrency in entity bean" New topic

Concurrency in entity bean

Raj Neets
Ranch Hand

Joined: Nov 12, 2002
Posts: 46
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
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
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 Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
I agree. Here's the link:
subject: Concurrency in entity bean
It's not a secret anymore!