Seems an easy fix. Why don't you create a JIRA issue, and, if possible, 
submit a pull request with a correction?

RP

On Monday, July 7, 2014 2:54:06 PM UTC+1, Marcin Kotula wrote:
>
> Hi,
>
> I have a question regarding how NHibernate.AdoNet.SqlClientBatchingBatcher 
> handles DbExceptions in:
>
> https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs
>
> protected override void DoExecuteBatch(IDbCommand ps)
> {
>  {...}
>  if (Factory.Settings.SqlStatementLogger.IsDebugEnabled)
>       {
>       
> *Factory.Settings.SqlStatementLogger.LogBatchCommand(_currentBatchCommandsLog.ToString());*
> *     _currentBatchCommandsLog = new StringBuilder().AppendLine("Batch 
> commands:");*
>       }
> int rowsAffected;
> try
> {
>       rowsAffected = _currentBatch.ExecuteNonQuery();
> }
> catch (DbException e)
> {
>       *throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, 
> "could not execute batch command.");*
> }
> {...}
> }
>
> *Why _currentBatchCommandsLog isn't **passed to the 
> ADOExceptionHelper.Convert method?*
>
> This way the information about the sql statement causing the DbException is 
> lost and in the end I'm left only with the MS SQL exception message. I don't 
> want to log the batch commands always because this would cause too much 
> overhead. 
>
> Further investigation showed that ADOExceptionHelper.Convert tries to extract 
> the sql query from the DbException using:
> string sql1 = (string) sqle.Data[(object) "actual-sql-query"];
>
> But this exception data is set only in AbstractBatcher.ExecuteNonQuery, but 
> in this case SqlCommandSet.ExecuteNonQuery is executed instead. 
>
> I can't see any extensions/injection points thus it seems that my hands are 
> tied with the current codebase. Maybe I'm missing something? It looks like an 
> inconsistent behavior though.
>
> --
> Marcin Kotula
>  
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to