Hi, Is there a way to prevent JPA/OpenJPA from doing multiple inserts?
I have a somewhat inconvenient database design, whereby some types held in a table only allow a single instance to be created (other types do allow it). This makes preventing multiple instances not so easy to achieve with simple unique constraints. What I effectively want to do is something like this: INSERT INTO Applications (..., type) VALUES (..., someType) WHERE NOT EXISTS (SELECT FROM Applications WHERE type = someType) That is for some Applications where only a single instance is allowed for a type, to prevent multiple instances from being inserted. Only answer I have found so far is: http://www.quora.com/Relational-Databases/JPA-conditional-insertion-RDBMS-transactions-isolation But I cannot make sense of it. Thanks for your help. Rupert