File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 11
11
using System . Collections . Generic ;
12
12
using System . Linq ;
13
13
using System . Reflection ;
14
+ using NHibernate . Criterion ;
14
15
using NHibernate . DomainModel . Northwind . Entities ;
15
16
using NHibernate . Engine . Query ;
17
+ using NHibernate . Linq ;
16
18
using NHibernate . Linq . Visitors ;
17
19
using NHibernate . Util ;
18
20
using NUnit . Framework ;
19
- using NHibernate . Linq ;
20
21
21
22
namespace NHibernate . Test . Linq
22
23
{
Original file line number Diff line number Diff line change 1
1
using System . Collections . Generic ;
2
2
using System . Linq ;
3
3
using System . Reflection ;
4
+ using NHibernate . Criterion ;
4
5
using NHibernate . DomainModel . Northwind . Entities ;
5
6
using NHibernate . Engine . Query ;
7
+ using NHibernate . Linq ;
6
8
using NHibernate . Linq . Visitors ;
7
9
using NHibernate . Util ;
8
10
using NUnit . Framework ;
@@ -257,6 +259,44 @@ public void PlansAreCached()
257
259
}
258
260
}
259
261
262
+ //GH-2298 - Different Update queries - same query cache plan
263
+ [ Test ]
264
+ public void DmlPlansAreProperlyHandled ( )
265
+ {
266
+ var queryPlanCacheType = typeof ( QueryPlanCache ) ;
267
+
268
+ var cache = ( SoftLimitMRUCache )
269
+ queryPlanCacheType
270
+ . GetField ( "planCache" , BindingFlags . Instance | BindingFlags . NonPublic )
271
+ . GetValue ( Sfi . QueryPlanCache ) ;
272
+ cache . Clear ( ) ;
273
+
274
+ using ( session . BeginTransaction ( ) )
275
+ {
276
+ using ( var spy = new SqlLogSpy ( ) )
277
+ {
278
+ var listOfGuids = new [ ] { "UNKNOWN" , "UNKNOWN2" } . ToList ( ) ;
279
+ db . Customers . Where ( x => listOfGuids . Contains ( x . CustomerId ) ) . Update (
280
+ x => new Customer
281
+ {
282
+ CompanyName = "Constant1"
283
+ } ) ;
284
+
285
+ db . Customers . Where ( x => listOfGuids . Contains ( x . CustomerId ) )
286
+ . Update (
287
+ x => new Customer
288
+ {
289
+ ContactName = "Constant1"
290
+ } ) ;
291
+
292
+ Assert . That (
293
+ cache . Count ,
294
+ Is . EqualTo ( 0 ) . Or . EqualTo ( 2 ) ,
295
+ "Query plans should either be cached separately or not cached at all." ) ;
296
+ }
297
+ }
298
+ }
299
+
260
300
[ Test ]
261
301
public void PlansWithNonParameterizedConstantsAreNotCached ( )
262
302
{
You can’t perform that action at this time.
0 commit comments