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 1111using System . Collections . Generic ;
1212using System . Linq ;
1313using System . Reflection ;
14+ using NHibernate . Criterion ;
1415using NHibernate . DomainModel . Northwind . Entities ;
1516using NHibernate . Engine . Query ;
17+ using NHibernate . Linq ;
1618using NHibernate . Linq . Visitors ;
1719using NHibernate . Util ;
1820using NUnit . Framework ;
19- using NHibernate . Linq ;
2021
2122namespace NHibernate . Test . Linq
2223{
Original file line number Diff line number Diff line change 11using System . Collections . Generic ;
22using System . Linq ;
33using System . Reflection ;
4+ using NHibernate . Criterion ;
45using NHibernate . DomainModel . Northwind . Entities ;
56using NHibernate . Engine . Query ;
7+ using NHibernate . Linq ;
68using NHibernate . Linq . Visitors ;
79using NHibernate . Util ;
810using NUnit . Framework ;
@@ -257,6 +259,44 @@ public void PlansAreCached()
257259 }
258260 }
259261
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+
260300 [ Test ]
261301 public void PlansWithNonParameterizedConstantsAreNotCached ( )
262302 {
You can’t perform that action at this time.
0 commit comments