Greetings,
Not sure if you're looking to call stored procedures via @SqlInsert/@SqlUpdate/@SqlDelete, but I was and found that the simplest solution was to implement a wrapper as a stored procedure which contained only IN params which were in turn passed to the target procedure. In my situation, I had some OUT error params which I examined to determine if I got an error, and if so, raise a signal (syntax may vary) so that the driver throws an exception which you can then catch. I subclassed the dialect (ie. Db2400Dialect) and overrode the buildSQLExceptionConversionDelegate method by copying the SQLExceptionConversionDelegate and added a check like so:
Code:
public class DB2400Dialect extends org.hibernate.dialect.DB2400Dialect {
@Override
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
return new SQLExceptionConversionDelegate() {
...
@Override
public JDBCException convert(SQLException sqlException, String message, String sql) {
...
if (-438 == errorCode && "V0000".equals(sqlState)) {
..
throw new DataAccessException(...);
}
return null;
}
};
}
...
}
So, depending on which rdbms you are using, just search for a way to cause the driver to throw an exception and pass a custom SqlState value (5 characters). Hope this helps. Good luck!