spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
55.66k stars 37.77k forks source link

JPetStore need to configure SqlMapSequenceDao#getNextId is synchronized. [SPR-1759] #6457

Closed spring-projects-issues closed 16 years ago

spring-projects-issues commented 18 years ago

Takayuki Kaneko opened SPR-1759 and commented

SqlMapSequenceDao#getNextId must be synchronized because this method need to be protected from concurrency.

I suggest followings.

Regards,


Affects: 1.2.7

spring-projects-issues commented 18 years ago

Takayuki Kaneko commented

It will be the best solution that database manage the synchronized seaquence. HSQLDB has sequence, maybe.

spring-projects-issues commented 18 years ago

Juergen Hoeller commented

Actually, the correct solution for this would be to synchronize at the database level: that is, to lock the row while reading and updating it. This could be achieved by a REQUIRES_NEW transaction for the getNextId operation. We'll update the sample accordingly.

Juergen

spring-projects-issues commented 16 years ago

Juergen Hoeller commented

Actually, this is not quite trivial to solve in a general fashion, given the custom id generation mechanism that JPetStore uses there. So for the sake of simplicity, we'll simply leave the sample as-is (which is equivalent to what the original iBATIS JPetStore did the).

Juergen