NHibernate是否有办法通知视图中的查询缓存无效?
我用连接的表创建了一个视图,希望在更新视图的基表(在ORM上下文中)时,它的二级查询缓存失效。视图被映射为NHibernate上的表NHibernate是否有办法通知视图中的查询缓存无效?,nhibernate,Nhibernate,我用连接的表创建了一个视图,希望在更新视图的基表(在ORM上下文中)时,它的二级查询缓存失效。视图被映射为NHibernate上的表 这在NHibernate上可能吗?如何在xml映射上实现这一点?流畅的映射也可以信不信由你,即使使用NHibernate也可以。例如,如果您有如下映射的类: <class name="Contact" table="[dbo].[Contact]" lazy="true" > <cache usage="read-write" regio
这在NHibernate上可能吗?如何在xml映射上实现这一点?流畅的映射也可以信不信由你,即使使用
NHibernate
也可以。例如,如果您有如下映射的类:
<class name="Contact" table="[dbo].[Contact]" lazy="true" >
<cache usage="read-write" region="ShortTerm"/>
然后,魔术设置直接位于
下,称为
<class name="ViewContact" table="[dbo].[ViewContact]" lazy="true" >
<cache usage="read-write" region="ShortTerm"/>
<synchronize table="[dbo].[Contact]"/>
<!-- now both caches are synchornized -->
现在,对映射类Contact的任何更改都将触发映射到视图的ViewContact类的缓存清理+1,您每天都会学到一些东西。。。。从来不知道缓存区域可以通过这种方式共享。
<class name="ViewContact" table="[dbo].[ViewContact]" lazy="true" >
<cache usage="read-write" region="ShortTerm"/>
<synchronize table="[dbo].[Contact]"/>
<!-- now both caches are synchornized -->