Sunday, January 16, 2011

OptUpdate Locking Mode in ADF 11g PS3 and Centralized ADF BC Config

Hey, exciting news - JDeveloper 11g PS3, SOA 11g PS3 and WebLogic 11g PS3 are available. But there are no WebCenter 11g PS3 yet, Ok  - we can wait (we expect really good quality release). Download new JDeveloper 11g PS3 - download page. I didn't see anywhere separate download of ADF 11g PS3 runtime for standalone WebLogic deployment, but you can use the same JDeveloper 11g PS3 install wizard for this purpose. In order to get up to speed with new features of ADF 11g PS3, I recommend to read What's New sections from available developer guides - ADF Developer Guide and ADF Web Developer Guide. There are many new interesting features, one of them - additional locking mode (Optupdate). This locking mode works without executing database lock on data change. Previous ADF 11g releases were working with two locking modes - Pessimistic and Optimistic.

Download sample application - OptUpdateADF.zip.

Some of the ADF Business Components configuration settings can be set now from one central place - adf-config.xml file. Before researching new Optupdate locking, let's look into behavior without any locking mode at all. Locking mode - None:


One user is editing FirstName field - saving change:


Update and Commit are done without any locking:


There is another user, who is editing the same record at the same time - changing and saving LastName field:


Even the same record was modified by another user - we still can commit without any warning:


We can change and update even the same field, previously modified by another user - FirstName:


There will be no errors, data will be updated and saved successfully:


Now we change Locking Mode to Optupdate, new Locking Mode available in PS3:


Let's change FirstName field and save:


Data was saved without executing lock, similar as with no locking mode:


Second user work with the same record, updates and saves LastName field:


RowNoFound exception is generated:


ADF reports error about not found row:


In case of Pessimistic or Optimistic lockings, user would be informed about data changed by another user. In this case, user will be forced to refresh VO data, for example by clicking Undo button. It seems like Optupdate locking mode is useful, when there is no concurrency and mostly only single user is doing updates. However, we still want to prevent possible concurrency cases from simultaneous updates (as it happens in no locking mode).

Press Undo button to refresh VO with latest data:


Now this user can change and save data as well:


Let's test how it works when validation error happens. One user is changing foreign key value and gets validation error:


The same as with Optimistic locking, while validation error is not fixed, still other user will be able to change and save data (because lock is not set by the first user):

6 comments:

Vipin said...

Hi Andre,

This is quite informative article about the locking. I have read some more of your article about the adf BC row level locking.

Can you please tell me which of the configuration before this PS3, was governing the feature of locking, or in simple words where to configure locking mode before ps3.

Thanks
Vipin

Andrejus Baranovskis said...

Hi,

Yes - just right click on Application Module, select Configuration and then press Edit. Go to Properties tab and manually type locking mode, as it is shown in first screenshot from that blog - http://andrejusb.blogspot.com/2010/03/optimistic-and-pessimistic-locking-in.html

Regards,
Andrejus

Vipin said...

Thanks for the clarification Andre,

Still some confusion over there, like if the project have two AM and both with the different locking mode to the adfc-config.xml which one to take presedence.

Thanks
Vipin

Andrejus Baranovskis said...

Hi,

This can be easily tested, I will check it and let you know.

Andrejus

Andrejus Baranovskis said...

Hi,

If you choose Locking mode configuration in adf-config.xml, then you will not be able to change locking mode inside individual App Module.

You can simply test it.

Regards,
Andrejus

Vipin said...

Thanks Andre,

for this usefull information.

--Vipin