On Tue, Jun 10, 2014 at 11:37 AM, Rupert Smith [via OpenJPA] <
[email protected]> wrote:

> 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.
>

OK; this will only work if there's some sort of version column in your
database that can be incremented by the JPA provider (OpenJPA).  Do you
have a @Version-annotated field or property in your entity?  From your
earlier posts I was assuming you were working with a legacy schema, most of
which have no notion of a version-like column.

Best,
Laird

-- 
http://about.me/lairdnelson




--
View this message in context: 
http://openjpa.208410.n2.nabble.com/How-to-prevent-multiple-inserts-of-same-item-by-some-criteria-tp7586812p7586818.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to