Closed AlwaysNoobCoder closed 9 months ago
want to extract the column name which caused this exception, but with current API, it's not possible, except directly cast to org.postgresql.util.PSQLException
Even if you did that, you still need to parse the error message to find it is about a column. The exception itself does not expose that information.
can we add some a method to DataAccessingException to get causing column ?, it's a optional feature, if underlying jdbc driver support this, then return column name, if not return null...
I am afraid not. We're not going to add database-specific exception message parsing to provide a higher-level API as it's far too error prone and us parsing error messages like that is not a good idea. Thanks for the suggestion.
@snicoll thanks, totally understand.
just want to mention this: with postgresql's org.postgresql.util.PSQLException
, you can get a ServerErrorMessage Object, which already expose many method to extract useful information, including causing column
Affects: Srping 5
I am using mybatis + spring against postgresql
when updating a column with unique constraints, the exception is like below:
I want to extract the column name which caused this exception, but with current API, it's not possible, except directly cast to
org.postgresql.util.PSQLException
, but that's a vendor specific way..I want the column name to display user friendly error message to end user, the front-end can using the column name to highlight a input box in a form
can we add some a method to
DataAccessingException
to get causing column ?, it's a optional feature, if underlying jdbc driver support this, then return column name, if not return null...