Interest Ask. What is the generated SQL for your JPQL query? What kind of JPA mechanism are you using?
In any case, the solution is to avoid update requests when using JPA, especially if the number of objects to update is small. Request entities, update their state, and let JPA discard the changes for you.
If a large number of objects need to be updated, you can still use your own query, not a JPQL query. Or you can use two queries: one that sets preDeck, and one that sets the deck in preDeck + 1.
source share