• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Question on Concurrency Control achieved by EJB transdactions.

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 42160
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic