5
我已經設置了一個簡單的模型:具有多個圖像的文檔實體。圖像保存在另一個數據庫中,並且從其他舊版應用程序更新,因此我的應用程序僅具有隻讀訪問權限。我安裝了一個synonim,以便我可以將另一臺服務器上的圖像表用作本地表。 我的映射如下:爲什麼在構建NHibernate會話工廠時獲得「配置爲可變的只讀緩存」?
<class name="Image" mutable="false" table="ImageExternal">
<cache region="images" usage="read-only" />
<id name="Id">
<generator class="assigned" />
</id>
<property name="Name" update="false" />
<!-- other properties -->
</class>
<class name="Document" table="Document">
<id name="Id">
<generator class="guid.comb" />
</id>
<!-- other properties -->
<set name="Images" mutable="false">
<cache region="images" usage="read-only" />
<key column="some_guid_column" />
<one-to-many class="Image" />
</set>
</class>
圖像類本身是可變的,但我可以把它一成不變的,通過改變訪問策略,以保護領域。 我在Image映射上設置了mutable =「false」,它的所有屬性都有update =「false」,並且在父關係中設置的圖像也標記爲mutable =「false」。 但是,在構建會話工廠時,由於緩存使用情況爲「只讀」,因此我得到了「爲mutable:images配置的只讀緩存」警告。
那麼,我什麼時候可以使用只讀緩存?它是不是可變=「假」收藏和只讀緩存兼容? – Vasea 2011-02-09 18:44:15