Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.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
NHibernate是否有办法通知视图中的查询缓存无效?_Nhibernate - Fatal编程技术网

NHibernate是否有办法通知视图中的查询缓存无效?

NHibernate是否有办法通知视图中的查询缓存无效?,nhibernate,Nhibernate,我用连接的表创建了一个视图,希望在更新视图的基表(在ORM上下文中)时,它的二级查询缓存失效。视图被映射为NHibernate上的表 这在NHibernate上可能吗?如何在xml映射上实现这一点?流畅的映射也可以信不信由你,即使使用NHibernate也可以。例如,如果您有如下映射的类: <class name="Contact" table="[dbo].[Contact]" lazy="true" > <cache usage="read-write" regio

我用连接的表创建了一个视图,希望在更新视图的基表(在ORM上下文中)时,它的二级查询缓存失效。视图被映射为NHibernate上的表


这在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 -->