Closed
Description
NHibernate: Version="5.3.9"
NHibernate.Caches.CoreMemoryCache: Version="5.7.0"
Problem
The second level cache is failing to match existing entries when with the CoreMemoryCache - this seems to be down to the ResultTransformer being included in the QueryKey equality and for SQL queries this gets updated to be a CacheableResultTransformer. The equality then fails with the next identical query due to the CacheableResultTransformer.
Example of query below, with 2nd level cache enabled.
query = session.CreateSQLQuery("replace this with a simple select returning a single value");
query.SetCacheable(true);
query.List();
##Work Around
Implementing my own CoreMemoryCache that doesn't use the QueryKey object directly works:
if (!(key is QueryKey queryKey)) return new Tuple<string, object>(_fullRegion, key);
return new Tuple<string, object>(_fullRegion, queryKey.ToString()); // Fix for unequal QueryKey due to CacheableResultTransformer