openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Angelo K. Huang" <angel...@ymail.com>
Subject ReadLock Questions
Date Tue, 13 Apr 2010 22:54:09 GMT

There are two threads that are concurrently running and want to change the
same record. Both are using the following fetchplan to lock the object:

                    OpenJPAQuery oq = OpenJPAPersistence.cast(q);
                    FetchPlan fetch = oq.getFetchPlan();
                    fetch.setReadLockMode(LockModeType.WRITE);
                    fetch.setLockTimeout(-1); // no limit


I found out both threads can get the record and both hold the lock. If one
thread wants to change field "Quality" to "GOOD" and the other one wants to
change to "GREAT", the one committed first will be in the db ,however, the
other one will be rolled back. Am I right?

How could I do to change this lock behavior so that only one thread can hold
the lock until it commits?
-- 
View this message in context: http://n2.nabble.com/ReadLock-Questions-tp4898922p4898922.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message