5

I have set a simple model: Document entity with multiple images. Images are saved in another database, and they are updated from other legacy application, so my app has only readonly access. I setup a synonim so that I can use the images table on another server as a local table. My mappings are the following:

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

The image class itself is mutable, but I can make it immutable by changing the access strategy to protected fields. I set mutable="false" on the Image mapping, all its properties have update="false" and Images set in the parent relationship is also marked with mutable="false". However when building the session factory I get the "read-only cache configured for mutable: images" warning because the cache usage is "read-only".

Vasea
  • 5,043
  • 2
  • 26
  • 30

1 Answers1

2

You're specifying mutable="false" and the cache for your set. Get rid of that.

Vadim
  • 17,897
  • 4
  • 38
  • 62
  • So when can I use the read-only cache? Isn't it mutable="false" collections and read-only caches compatible? – Vasea Feb 09 '11 at 18:44
  • @Vasile, not according to the documentation. You can use it in your class mapping, but not in your collection mapping as it has already been defined. – Vadim Feb 09 '11 at 18:46