Thursday, October 25, 2007

Concurrency Levels - WebLogic and Oracle

Oracle supports only 'Read-Committed' and 'Serializable' Concurrency levels.
Most of the applications require 'Repeatable-Read' concurrency level (consider the banking fund transfer transaction - you read the balance, reduce the balance and then update the reduced balance to database). (I don't know why Oracle doesn't support 'Repeatable-Read'!!!)
WebLogic Server has the following isolation-level for Oracle to support 'Repeatable-Read' semantics - 'READ_COMMITTED_FOR_UPDATE'.
However there is one issue; It supports only CMP entity beans (obviously - what WebLogic does it it uses 'select for update' for all select queries to get row lock which it can do only for container generated queries). Currently for direct SQLs and BMP entity beans has to hard code 'select for update' in its code.

You may want one entity bean 'Repeatable-read' in one transaction and 'Read-Committed' in another transaction. How will you achieve this?
You have to specify the isolation-level for session bean (where actual transaction starts) than for the entity bean.
However in a business transaction there may be many entity beans involved however you may want only one entity bean to have 'Repeatable-Read', all other to use 'read-committed'. How to achieve this?
You are asking too much! There is no way to achieve that currently. You have to either specify isolation level for entity bean and lock the bean whenever it participate in a transaction OR specify isolation level at session bean level and lock all the entity beans participated.
You have a (better?) third choice! Not using entity beans (for that matter any OM mapping solutions)!!!
'READ_COMMITTED_FOR_UPDATE' is supposed to be supported only for CMP entity beans however I have observed that it works for session beans as well (if you specify this for session beans, then all the entity beans involved in that transaction will be using 'READ_COMMITTED_FOR_UPDATE'.
if a request propagate from on method with one isolation level to another method with another isolation level, does the isolation level changes when it enter the new method? Don't know!!! I should, but I am not sure if it does so now!

No comments: