From f5c7b8a518e0338b5bdce4666a941715814ee23a Mon Sep 17 00:00:00 2001 From: Wilson Carlile Date: Wed, 15 Aug 2018 12:06:30 -0400 Subject: [PATCH 1/3] Updated BasicLoader PostInstantiate QueryException I found it difficult when updating an older application using an older version of NHibernate, to track down what entity relationship was causing the QueryException "Cannot simultaneously fetch multiple bags.". When I updated the exception to return the entityName I found it extremely easy to identify the entity that needed changing. --- src/NHibernate/Loader/BasicLoader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NHibernate/Loader/BasicLoader.cs b/src/NHibernate/Loader/BasicLoader.cs index 1e2055329cc..aeb123353e1 100644 --- a/src/NHibernate/Loader/BasicLoader.cs +++ b/src/NHibernate/Loader/BasicLoader.cs @@ -62,7 +62,7 @@ protected override void PostInstantiate() // so be careful about how you formulate your queries in this case if (bagCount > 1) { - throw new QueryException("Cannot simultaneously fetch multiple bags."); + throw new QueryException($"Cannot simultaneously fetch multiple bags: {persisters[0].EntityName}"); } } From 0cf81c5776c05fe19f2a9c386878dfa30551ea58 Mon Sep 17 00:00:00 2001 From: Wilson Carlile Date: Thu, 23 Aug 2018 16:41:32 -0400 Subject: [PATCH 2/3] Altered the QueryException to use this in the interpolation. This results in the specific query that is an issue. --- .gitignore | 3 +++ src/NHibernate/Loader/BasicLoader.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 82db001cc0c..b1cfc069089 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ NHibernate.dll TestResult.xml .vscode .DS_Store +/.vs/VSWorkspaceState.json +/.vs/slnx.sqlite +/.vs/nhibernate/v15/.suo diff --git a/src/NHibernate/Loader/BasicLoader.cs b/src/NHibernate/Loader/BasicLoader.cs index aeb123353e1..2d3ddafd877 100644 --- a/src/NHibernate/Loader/BasicLoader.cs +++ b/src/NHibernate/Loader/BasicLoader.cs @@ -62,7 +62,7 @@ protected override void PostInstantiate() // so be careful about how you formulate your queries in this case if (bagCount > 1) { - throw new QueryException($"Cannot simultaneously fetch multiple bags: {persisters[0].EntityName}"); + throw new QueryException($"Cannot simultaneously fetch multiple bags: {this}"); } } From c91217a9b4dfe79e22fa2b720622476bf4f14f57 Mon Sep 17 00:00:00 2001 From: Wilson Carlile Date: Thu, 23 Aug 2018 18:04:40 -0400 Subject: [PATCH 3/3] Removed unwanted update to .gitignore Sorry about that. I didn't mean for it to be in the commit. --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index b1cfc069089..82db001cc0c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,3 @@ NHibernate.dll TestResult.xml .vscode .DS_Store -/.vs/VSWorkspaceState.json -/.vs/slnx.sqlite -/.vs/nhibernate/v15/.suo