Skip to content

Commit d5489ea

Browse files
committed
Add logging for QueryBatch similar to Loader.DoQuery
1 parent e8bba30 commit d5489ea

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/NHibernate/Multi/QueryBatchItemBase.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace NHibernate.Multi
1616
/// </summary>
1717
public abstract partial class QueryBatchItemBase<TResult> : IQueryBatchItem<TResult>, IQueryBatchItemWithAsyncProcessResults
1818
{
19+
private static readonly INHibernateLogger Log = NHibernateLogger.For(typeof(QueryBatch));
20+
1921
protected ISessionImplementor Session;
2022
private List<EntityKey[]>[] _subselectResultKeys;
2123
private List<QueryInfo> _queryInfos;
@@ -175,6 +177,7 @@ public int ProcessResultsSet(DbDataReader reader)
175177

176178
var dialect = Session.Factory.Dialect;
177179
var hydratedObjects = new List<object>[_queryInfos.Count];
180+
var isDebugLog = Log.IsDebugEnabled();
178181

179182
using (Session.SwitchCacheMode(_cacheMode))
180183
{
@@ -217,8 +220,15 @@ public int ProcessResultsSet(DbDataReader reader)
217220
var optionalObjectKey = Loader.Loader.GetOptionalObjectKey(queryParameters, Session);
218221
var tmpResults = new List<object>();
219222

220-
for (var count = 0; count < maxRows && reader.Read(); count++)
223+
if (isDebugLog)
224+
Log.Debug("processing result set");
225+
226+
int count;
227+
for (count = 0; count < maxRows && reader.Read(); count++)
221228
{
229+
if (isDebugLog)
230+
Log.Debug("result set row: {0}", count);
231+
222232
rowCount++;
223233

224234
var o =
@@ -242,6 +252,9 @@ public int ProcessResultsSet(DbDataReader reader)
242252
tmpResults.Add(o);
243253
}
244254

255+
if (isDebugLog)
256+
Log.Debug("done processing result set ({0} rows)", count);
257+
245258
queryInfo.Result = tmpResults;
246259
if (queryInfo.CanPutToCache)
247260
queryInfo.ResultToCache = new List<object>(tmpResults);

0 commit comments

Comments
 (0)