openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christiaan <christiaan...@hotmail.com>
Subject Use of List increases chance on concurrency contention
Date Mon, 22 Oct 2007 15:08:30 GMT

Hi,
I am writing this since this may be useful to others. I’ve quite some
classes which have a List attribute. OpenJPA create a relationship table
with an order column to maintain the order of the elements. Recently we
encountered quite some blocking scenarios when using it in a multi-user
environment. The reason was that when List.add(index, object) is being used
OpenJPA sends the following sql statement, so the order of the elements can
be built up from scratch:
“Delete from RELATION_TABLE where ID = “

In ms sql server this causes an exclusive lock on the entire table which of
course easily introduces blocking issues (long running transactions having a
shared lock or other client who like to insert objects in their list as
well). 

List.add(Object) does not have this behaviour so when adding objects to the
end of the list it is always better to use this method. My suggestions:
1)	In the proxy list openjpa creates add a check to List.add(index, object)
whether index is equal to List.size() so it can use the same logic as add()
2)	May be provide some other mode for updating the order of elements when
elements are being inserted, eg. execute update statements instead of a
deletion?

Kind regards,
Christiaan

-- 
View this message in context: http://www.nabble.com/Use-of-List-increases-chance-on-concurrency-contention-tf4670571.html#a13342370
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message