On 10 June 2014 18:50, ljnelson <ljnel...@gmail.com> wrote: > (Just an observer here.) > > Sounds like--leaving JPA out of it for a moment--you must also be using > pessimistic locking in the database, right? to ensure that this > not-enforced-by-the-database constraint is holding?
I'll try that. The quora link I posted suggests that this will work: 1. Start a transaction. 2. Insert the new entity without checking any condition. 3. Select all entities similar to the one you inserted, using OPTIMISTIC_FORCE_INCREMENT. If it returns more than one entity abort, else commit. I couldn't see how that would work, but I haven't tried it. Rupert