Nhibernate二级缓存

最近学缓存,我配置好像都通过编译,而且已经成功运行,但是我调试的时候,发现ISessionFactory对象里面没有我已经配置好的缓存,配置如下:

config里面的:

 <property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>     
      <property name ="cache.use_second_level_cache">true</property>
      <property name="cache.use_query_cache">true</property>

hmb文件里面的:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"  assembly="Test" namespace="Test">
  <class name="Test.Person,Test" table="person" >
    <cache usage="read-write"/>
    <id name="Id" column="id" type="string" >
    </id>   
    <property name="PerName" column ="perName" type="string" length="30" not-null="true"/>
    <property name ="Password" column="password" type="string" length="30" not-null="true"/>
   
    <set name="ListMessage" table="MessageContext" cascade="all" >
      <cache usage="read-write"/>
      <key column="idPerson" not-null="true"/>
      <one-to-many class="Test.messageContext,Test"/>
    </set>
    <one-to-one  name="Message"  class="Test.NewsMessage,Test" cascade="all"/>
  </class> 
</hibernate-mapping>

调试的时候只能在Statistics.SecondLevelCacheRegionNames属性里面看到名字,没发现有数据存入。

然后我有使用了查询缓存:

 IQuery qury = session.CreateQuery("from Person where Id =:idin").SetCacheable(true);
            qury.SetParameter("idin", this.txtUserID.Text);

调试,结果这个查询缓存在Statistics.SecondLevelCacheRegionNames里根本就没有。

扬帆大鱼
浏览 310回答 1
1回答

呼如林

短消息回过了这个问题
打开App,查看更多内容
随时随地看视频慕课网APP