Right not `ConstraintViolationException` have method getConstraintName() which can return the name of the SQL string constrain . However, there's no general way to link this constraint name to the bean field(s) which the value breaks this constrain.
As this exception always have an `SQLException` as its cause, it should be possible to get more information from the error message of that exception.
For example for Postgres driver (`PSQLException`) the error may looks something like
``` ERROR: duplicate key value violates unique constraint "member_username_key" Detail: Key (username)=(some-username-which-already-dup-in-system) already exists. ```
and currently getConstraintName() can return "member_username_key".
It should be possible to return the table column name `username`, or even better return the field `String username` in domain bean `Member`. |
|