Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on Concurrency Control achieved by EJB transdactions.

 
ArunKumar Kandregula
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I am working on EJB 2.0 CMP entity beans on Weblogic 8.1 to test concurrency control. Back end is Oracle 10g.
I am having hard time understanding how container transactions in entity beans achieve concurrency control. I tried calling a business method on an entity bean. I have introduced sleep behaviour at 2 places in the bussiness method so that i can try modifying that specific database record from sql plus while the entity bean was already involved in a bussiness method call ( and hence in a Container Managed Transaction).

// Sample code
Class Account extends EntityBean{

public void deposit(int deposit_amount){

// sleep for 60 seconds

//bussiness logic
amt += deposit_amount;

// sleep for another 60 seconds...just to make sure that i have enough time to
// try to update the db record from sql plus.
}
}

As expected, this method called ejbActivate(), ejbLoad(), ejbStore().
Again ejbLoad() and then bussiness logic...and than again ejbStore().

But while it is sleeping in middle of the method, I opened sqlplus and tried to update the db record success fully.
I thought as entity beans call each method in a container managed transaction, it should essensially lock the db record and then call ejbLoad(), bussinesMethod(), ejbStore().

But it seems, it didnt locked the DB record. So my question is Why?

Isnt that how transactions achieve Isolation in ACID properties?

Can you please clarify my question? Why didnt it lock the record ?

I am running CMT Entity beans in Weblogic 8.1 application server.

Thank you.
Arun Kumar Kandregula.
SCJP ( 98% )
SCBCD( 92% )
 
ArunKumar Kandregula
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone, please answer this. Does Weblogic, by default wont lock the record. Does it just follow READ_COMITTED transaction isolation level by default. Is there is way to enforce REPEATABLE_READ isolation level? I am I missing something.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35752
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you know you are updating after the update and not before it? Also, some containers let you update locally and don't even try to commit/get locks until the end of the transaction - don't know if WebLogic is one of those.
 
Arun Kandregula
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got the answer to this question. Weblogic by default delegates the concurrency/isolation strategy to database. As Oracle uses READ_COMITTED mode of isolation, it allows anyone to read comitted data. Hence no locks are being aquired by default by Weblogic server. Thank you for your reply.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!