Spring Lock Timeout with Concurrent updates in a table
<p>I'm working on a WebService using spring boot, hibernate, JPA repository, and a reactor for an Event-Driven Application.
I've set of long jobs running in parallel, and I'm stuck trying to resolve an error caused by this flow of exceptions:</p>

<pre><code>Could not execute statement; SQL [n/a]; nested exception is org.hibernate.PessimisticLockException: could not execute statement
org.springframework.dao.PessimisticLockingFailureException: could not execute statement; SQL [n/a];nested exception is org.hibernate.PessimisticLockException: could not execute statement
...
Caused by: org.hibernate.PessimisticLockException: could not execute statement
...
Caused by: org.h2.jdbc.JdbcSQLException: Timeout trying to lock table ; SQL statement: update 
...
Caused by: org.h2.jdbc.JdbcSQLException: Concurrent update in table "INTERACTIVE_EXPERIMENT": another transaction has updated or deleted the same row [90131-191]
...
Caused by: reactor.core.support.Exceptions$ValueCause: Exception while signaling value: reactor.bus.Event.class : Event{id=null, headers=null, replyTo=null, key=channel2, data=InteractiveExperiment(id=60, instanceName=myJson, simulationsManager=it.polimi.diceH2020.launcher.model.SimulationsWIManager@2a074bbd, simType=WI, thinkTime=10000, numUsers=1, numVMs=1, responseTime=0.0, gamma=null, provider=, numSolutions=0, iter=3, experimentalDuration=0, state=error, done=false)}
</code></pre>

<p>I get "Concurrent update in table "INTERACTIVE_EXPERIMENT": another transaction has updated or deleted the same row", I've concurrent updates but they are all on different row!
(But they have a @ManyToOne field in common).</p>

<p>I've tried both optimistic and pessimistic locks but nothing solved this.
With a couple of concurrent updates i get this error.</p>