为了账号安全,请及时绑定邮箱和手机立即绑定

Nhibernate二级缓存

Nhibernate二级缓存

扬帆大鱼 2018-12-06 16:00:39
最近学缓存,我配置好像都通过编译,而且已经成功运行,但是我调试的时候,发现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里根本就没有。
查看完整描述

1 回答

?
呼如林

TA贡献1798条经验 获得超3个赞

短消息回过了这个问题

查看完整回答
反对 回复 2019-01-21
  • 1 回答
  • 0 关注
  • 309 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信