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% )