openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rupert Smith <>
Subject Re: How to prevent multiple inserts of same item (by some criteria)
Date Tue, 10 Jun 2014 17:43:30 GMT
On 10 June 2014 16:31, Kevin Sutter <> wrote:

> I think you are just describing a unique constraint for a column (other
> than the primary key).

Sadly not, it isn't simply a question of putting a unique constraint on
some columns. As I pointed out, in some cases a duplicate is allowed, in
others it is not. I could just re-arrange the database design, but I don't
own the design it is something that has been given to me.

Consider the case where the criteria to allow an insert to happen is some
arbitrary query, not just a unique constraint. This can be accomplished
with a WHERE NOT EXISTS (SELECT ... the arbitrary insertion condition). How
can this be done with JPA/OpenJPA?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message