Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 二级缓存不在NHibernate中缓存筛选的集合?_Asp.net_Hibernate_Nhibernate_Second Level Cache - Fatal编程技术网

Asp.net 二级缓存不在NHibernate中缓存筛选的集合?

Asp.net 二级缓存不在NHibernate中缓存筛选的集合?,asp.net,hibernate,nhibernate,second-level-cache,Asp.net,Hibernate,Nhibernate,Second Level Cache,我正在使用NHibernate 3.0配置二级缓存。二级缓存对于实体和集合非常有效,但我也有一些实体具有过滤的集合 <bag name="EntityTrans" cascade="all-delete-orphan" table="EntityTrans"> <key column="entityId" not-null="true" /> <one-to-many class="MyDomain.EntityTr

我正在使用NHibernate 3.0配置二级缓存。二级缓存对于实体和集合非常有效,但我也有一些实体具有过滤的集合

 <bag name="EntityTrans" cascade="all-delete-orphan" table="EntityTrans">
            <key column="entityId" not-null="true" />
            <one-to-many class="MyDomain.EntityTran, MyDomain" />
            <filter name="cultureFilter" condition=":cultureCode = CultureCode" />
        </bag>

NHibernate二级缓存不缓存上述筛选的集合。我可以在NHProf中看到,对于过滤后的集合,查询被发送到数据库。我的NHibernate配置文件包含以下条目

<class-cache class="MyDomain.EntityTran, MuDomain" region="MyRegion" usage="read-only"/>
<collection-cache collection="MyDomain.Entity.EntityTrans" region="MyRegion" usage="read-only"/>


是否需要添加更多内容来缓存已筛选的集合?

目前,NHibernate不支持对已筛选集合进行二级缓存

首先我找到了这个。然后我查看了代码()并发现以下内容:

if (!(session.EnabledFilters.Count == 0) && persister.IsAffectedByEnabledFilters(session))
{
    // some filters affecting the collection are enabled on the session, so do not do the put into the cache.
    log.Debug("Refusing to add to cache due to enabled filters");
    // todo : add the notion of enabled filters to the CacheKey to differentiate filtered collections from non-filtered;
    //      but CacheKey is currently used for both collections and entities; would ideally need to define two separate ones;
    //      currently this works in conjunction with the check on
    //      DefaultInitializeCollectionEventHandler.initializeCollectionFromCache() (which makes sure to not read from
    //      cache with enabled filters).
    return; // EARLY EXIT!!!!!
}