Believe or not, even this is possible with NHibernate
. If you'd have for example class mapped like this:
<class name="Contact" table="[dbo].[Contact]" lazy="true" >
<cache usage="read-write" region="ShortTerm"/>
And there is a view on top of the table [dbo].[Contact]
which is mapped to another class:
<class name="ViewContact" table="[dbo].[ViewContact]" lazy="true" >
<cache usage="read-write" region="ShortTerm"/>
<!-- at this moment the View and table are treated differently -->
Then the magic setting goes directly under the <cache>
and and is called <synchronize>
<class name="ViewContact" table="[dbo].[ViewContact]" lazy="true" >
<cache usage="read-write" region="ShortTerm"/>
<synchronize table="[dbo].[Contact]"/>
<!-- now both caches are synchornized -->
And now, any changes to mapped class Contact will also trigger the cache cleaning of the ViewContact class mapped to the view