Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Concurrency control / optimistic locking in Scout
Concurrency control / optimistic locking in Scout [message #1687849] Thu, 19 March 2015 21:00 Go to next message
Michiel Arentsen is currently offline Michiel ArentsenFriend
Messages: 11
Registered: October 2014
Junior Member
Hello experts,

As a newby following the minicrm tutorial, i have a question about the way Scout can handle concurrency control / optimistic locking.

Does SQL.update have any builtin mechanism for optimistic locking?
Can it check if the DB record has changed before updating?

Thanks for any hints in the right direction..
Re: Concurrency control / optimistic locking in Scout [message #1688185 is a reply to message #1687849] Fri, 20 March 2015 09:32 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
If you use the Sql Service provided by Scout, you just get some convenience over the JDBC, meaning no locking mechanism.

I know application having implemented a Semaphore Locking.

Bigger scout applications uses JPA (Hibernate) and use the locking mechanism provided by the framework.

.
Re: Concurrency control / optimistic locking in Scout [message #1688197 is a reply to message #1688185] Fri, 20 March 2015 09:58 Go to previous messageGo to next message
Michiel Arentsen is currently offline Michiel ArentsenFriend
Messages: 11
Registered: October 2014
Junior Member
Thanks Jeremie,

Thanks for your reply.
I thought so, but just wanted to check.

In fact, we are looking into removing JPA from our Scout project, hence the question.

Re: Concurrency control / optimistic locking in Scout [message #1689712 is a reply to message #1688197] Tue, 24 March 2015 06:48 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
There is nothing stopping you from implementing your own optimistic locking exception. Add a "version" field to your entities (either a long or a timestamp) that you always read when accessing an object. In your update call, before doing the SQL.update, first read the object from the DB and compare the version to the one in the modified object you are about to write to the db. If they are different, throw an OptimisticLockException.
Re: Concurrency control / optimistic locking in Scout [message #1689960 is a reply to message #1689712] Tue, 24 March 2015 18:26 Go to previous message
Michiel Arentsen is currently offline Michiel ArentsenFriend
Messages: 11
Registered: October 2014
Junior Member
Hello Urs,

Thanks for the tip, we are looking into this option.
Since our Scout application does not access database tables directly, but it can only access views with instead of triggers in a database 'service' schema, we can actually check the version field in the view's instead of trigger, and raise an SQL exception when the :old and :new version number are not te same.
Then instead of reporting just a 'Processing error' to the user, we give the user a message like ' Record has been changed by another user"

Previous Topic:ERROR: Duplicate alias. Failed to register servlet for
Next Topic:Error in Tutorial?
Goto Forum:
  


Current Time: Tue Mar 19 06:46:27 GMT 2024

Powered by FUDForum. Page generated in 0.02683 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top