Reputation: 32984
As answered here, NHibernate includes the SQL of queries as well as parameter values when it encounters an ADO exception. Due to data sensitivity concerns, I need to redact or suppress the values of parameters that were sent to the database so that they don't end up in application logs. Is there a way to configure NHibernate so that it does not include the parameter values? Or something that I can override to achieve that?
Upvotes: 1
Views: 64
Reputation: 9864
You may use your own custom dialect overriding the BuildSQLExceptionConverter
method for yielding a custom NHibernate.Exceptions.ISQLExceptionConverter
. (See its default implementation, or see examples in the test project.)
Removing the parameter values here will likely imply some dirty hacking of the Message
and/or Sql
properties values of the exceptionInfo
parameter received by the Convert
method.
There is currently no way to prevent NHibernate from formatting the sql parameters values in these properties values.
Using a custom dialect is usually done by extending the one your application is currently using, then configuring it with the dialect
setting.
Upvotes: 1