我正在将旧项目与NHibernate团队创建的here inside graphics.c
一起转换为Nhibernate 5。当使用像这样的查询缓存时,我遇到了奇怪的问题:
session.GetSession().Query<Entity>()
.WithOptions(o => o.SetCacheable(true))
.Where(x=> x.y.Id == yId)
.ToArray();
如果我删除SetCacheable
,它会起作用。执行可以来自不同的实体,其中某些实体将起作用,如果Redis被刷新,则其中的一些实体将不起作用。代码已与NH5 / Syscache和NH4 / Couchbase提供程序一起使用。结果调用堆栈如下。该错误用芬兰语表示,该键不能为null。预先感谢。
编辑: 修改代码后(即删除了一个可缓存的设备,甚至没有刷新帮助,将一些异步更改为同步,以及其他我不需要更改的东西),当一切都在刷新的Redis上启动时,系统就运行了。如果重新启动IIS Express或启动工作节点,则会发生错误。连接新节点是整个过程的重点。
[ArgumentNullException: Arvo ei voi olla tyhjäarvo.
Parametrin nimi: key]
System.Collections.Generic.Dictionary`2.FindEntry(TKey key) +13006529
System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value) +13
NHibernate.Impl.SessionFactoryObjectFactory.GetNamedInstance(String name) +165
NHibernate.Impl.SessionFactoryImpl.GetRealObject(StreamingContext context) +134
System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHolder holder) +65
System.Runtime.Serialization.ObjectManager.DoFixups() +267
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) +143
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) +186
NHibernate.Caches.CoreDistributedCache.CoreDistributedCache.Get(Object key) +236
NHibernate.Cache.StandardQueryCache.Get(QueryKey key, ICacheAssembler[] returnTypes, Boolean isNaturalKeyLookup, ISet`1 spaces, ISessionImplementor session) +212
NHibernate.Loader.Loader.GetResultFromQueryCache(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IQueryCache queryCache, QueryKey key) +230
NHibernate.Loader.Loader.ListUsingQueryCache(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces) +62
NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces) +54
NHibernate.Loader.Hql.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters) +48
NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters) +328
NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results) +556
NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results, Object filterConnection) +183
[GenericADOException: Could not execute query[SQL: SQL not available]]
NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results, Object filterConnection) +252
NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results) +15
NHibernate.Impl.AbstractSessionImpl.List(IQueryExpression queryExpression, QueryParameters parameters) +144
NHibernate.Impl.AbstractQueryImpl2.List() +118
NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression nhLinqExpression, IQuery query, NhLinqExpression nhQuery) +36
NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression nhLinqExpression, IQuery query) +14
NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) +40
NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) +36
Remotion.Linq.QueryableBase`1.GetEnumerator() +53
System.Linq.Buffer`1..ctor(IEnumerable`1 source) +205
System.Linq.Enumerable.ToArray(IEnumerable`1 source) +76