[OJB-developers] New update lock mechanism
Brought to you by:
thma
From:
<Car...@vi...> - 2002-04-17 13:06:51
|
Hi, we are using OJB to access an existing db and it works create. But now we came to a point where we would like to implement some locking for updates to prevent users from destroying there data each other. (concurrency problem ) BRJ has implemented a locking mechanism for optimistic locking and I think it works create if you have extra columns in the database for locking such as version fields etc. Unfortunately the database we have to access does not have any special fields for a locking mechanism. So we would like to implement the locking via the changed attributes and manipulate the update statement in that way that we enhance the filter criteria so that the changed values must have the original value in the database. Example: UPDATE <table> set Field1=<newValue> where pk=<pkValue> AND Field1=<oldValue>; To get this work the locking mechanism must be implemented outside from OJB. My first idea is to define an UpdateLockManager- Interface. Such an ULM can be registered to the Class in the ClassDescriptor. If the JDBCAccess-Class finds a ULM for a specific class in the executeUpdate-Method than it would get a ready bound PreparedStatement from the ULM and executes it. Otherwise everything will work as now. The strategy do register an ULM in the repository would minimize the changes in OJB but could bring many threading problems to the implementation of the ULM. Another way could be to define another update-Method in the broker interface where you can give an ULM per call. This surely makes the threadsafe implementation of an ULM easier. Maybe it is helpful for the ULM to get some call backs from the ClassDescriptor or from the broker if something happens with the objects. So a Listener interface on the broker could be useful as well. What do you think about the ideas? sp...@vi... |