I am setting up second level cache with NHibernate 3.0. Layer 2 cache works great for objects and collections, but I also have some objects that have filtered collections .
<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 Level 2 Caching does not cache the above filtered collection . I see in NHProf that for filtered queries, collections are sent to the database. My NHibernate configuration file has the following entries.
<class-cache class="MyDomain.EntityTran, MuDomain" region="MyRegion" usage="read-only"/>
<collection-cache collection="MyDomain.Entity.EntityTrans" region="MyRegion" usage="read-only"/>
Do I need to add something else to cache the filtered collection?
source
share