Okay, Rupert.  I guess I read your initial note too quickly...  :-)  Sorry
about that.

I don't see how you could automate this type of checking into a single JPA
interaction with the database.  You could accomplish something like this
with multiple SQL statements, but then the logic and locking is pretty much
left up to you.

(BTW, I didn't care for Quora's sign-in requirements, so I didn't actually
read the reference you posted.)

Good luck,
Kevin


On Tue, Jun 10, 2014 at 12:43 PM, Rupert Smith <rupertlssm...@googlemail.com
> wrote:

> On 10 June 2014 16:31, Kevin Sutter <kwsut...@gmail.com> 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?
>
> Rupert
>

Reply via email to