Miłosz Tylenda-3 wrote:
> 
> OpenJPA uses "FOR UPDATE" or an equivalent clause when selecting sequence
> value. Most often this results in a row lock in database although a
> particular database may lock a page (a few rows) or even the whole table.
> As far as I remember, DB2 would lock a row in this case.
> 

I set up a prototyp application using class-table strategy, i.e. one row per
persisted entity, and let our DBAs judge the resulting SQL (DB2 dialect):

TRACE 09:14:06 - <t 17480852, conn 26064257> executing prepstmnt 22298479 
SELECT SEQUENCE_VALUE 
    FROM PR.OPENJPA_SEQUENCE_TABLE 
    WHERE ID = ? FOR READ ONLY WITH RS USE AND KEEP UPDATE LOCKS 
[params=(String)
com.provinzial.beispielanwendung.firmenverwaltung.entity.Person]
TRACE 09:14:06 - <t 17480852, conn 26064257> [15 ms] spent
TRACE 09:14:06 - <t 17480852, conn 26064257> executing prepstmnt 1095698 
UPDATE PR.OPENJPA_SEQUENCE_TABLE 
    SET SEQUENCE_VALUE = ? 
    WHERE ID = ? AND SEQUENCE_VALUE = ? 
[params=(long) 51, (String) com.xxx.entity.Person, (long) 1]
TRACE 09:14:06 - <t 17480852, conn 26064257> [0 ms] spent

Performance: good.
Locking: only a single row is locked.

We are going to setup load tests now to see how this works with a number of
parallel users.

Cheers,
Tobias
-- 
View this message in context: 
http://openjpa.208410.n2.nabble.com/Experiences-with-GenerationType-TABLE-based-sequences-tp5818894p5859013.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to