If duplicate keys are used in a single upsert (ON CONFLICT DO UPDATE) statement, then postgres returns a cardinality violation error.

There are some options to translate it: - UncategorizedSQLException (current) - DuplicateKeyException - DataIntegrityViolationException - a new CardinalityViolationException somewhere in the inheritance tree

I'm currently overriding sql-error-codes.xml in order to return a DuplicateKeyException, as the user cause and exception handling are the same.

Comment From: jhoeller

Reading up on it, DuplicateKeyException seems like a good fit indeed. We'll revisit this for 5.3.3, possibly backporting it to 5.2.13.

Comment From: jhoeller

Since there is potentially a mismatch with existing duplicate key handling, I've only added this to 5.3.3 for the time being. There is an easy solution for 5.2.x after all, simply adding the error code to a sql-error-codes.xml file as mentioned above.