简体   繁体   中英

How can I stop Hibernate's SQLExceptionConverter from converting error messages stored in a SQL Server procedure?

The issue is that I am calling a stored procedure from my java code and when I do so, it does not return the expected error messages which I specify in the procedure itself. The error I'm getting is an SQLGrammarException which, based on debugging results, occurs from Hibernate's SQLExceptionConverter. Is there some way in which I can set the number of delegates to 0? That was it would emit the original error message if I'm not mistaken.

There are a couple of options that I've come across for your need, based on the ease of implementation you could choose the best-suited option for yourself.

Option-1:

You can implement your own SQLExceptionConverter to define what needs to be passed as is and what needs to be wrapped before sending to your business logic layer. Take a look at this documentation .

Option-2:

Have a look at Hibernate Validator , which is a reference implementation of JSR-303. You can do good amount of validation yourself, even before you put your entities into the Database.

Hope this helps!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM