I'm using NHibernate 3.2 with appfabric 1.1 for the 2nd level cache. I’ve 2 
classes mapped on the same table. The first class 
*AFullEntity*(MonitorLayoutData in the sample), inherit a second class which is 
lightweight class (MonitorLayout). MonitorLayoutData contains a heavy 
property that is not present in the base class. For example : 

<?xml version="1.0" encoding="utf-8"?><hibernate-mapping 
xmlns="urn:nhibernate-mapping-2.2">
  <class name="Entities.MonitorLayout,Entities" table="MonitorLayouts2" 
lazy="false" schema="dbo" polymorphism="explicit">
    <cache usage="nonstrict-read-write"/>
    <id name="Id" column="MonitorLayout_ID" type="int">
      <generator class="native" />
    </id>
    <property name="Name" column="MonitorLayout" type="string" />
    <property name="UserId" column="User_ID" type="int" />
    <property name="IsPublic" column="IsPublic" type="Boolean" not-null="true" 
/>
    <property name="ViewGuid" column="ViewGuid" type="string" not-null="true" />
    <property name="TreeNode" column="TreeNode" type="string" />
    <property name="IncludeNodeChildren" column="IncludeNodeChildren" 
type="Boolean" />

  </class>

  <class name="Entities.MonitorLayoutData,Entities" table="MonitorLayouts2" 
lazy="false" schema="dbo" polymorphism="explicit">
    <cache usage="nonstrict-read-write"/>
    <id name="Id" column="MonitorLayout_ID" type="int">
      <generator class="native" />
    </id>
    <property name="Name" column="MonitorLayout" type="string" />
    <property name="UserId" column="User_ID" type="int" />
    <property name="IsPublic" column="IsPublic" type="Boolean" not-null="true" 
/>
    <property name="ViewGuid" column="ViewGuid" type="string" not-null="true" />
    <property name="TreeNode" column="TreeNode" type="string" />
    <property name="IncludeNodeChildren" column="IncludeNodeChildren" 
type="Boolean" />
    <property name="LayoutData" column="LayoutData" type="BinaryBlob" 
not-null="false"/>
  </class></hibernate-mapping>

Those classes use an explicit polymorphism to retrieve only entities for 
the selected type like note in the documentation : “Explicit polymorphism 
is useful when two different classes are mapped to the same table (this 
allows a "lightweight" class that contains a subset of the table columns)”. 

However I got a problem when entities are cached. When I update a 
AFullEntity changes are not report in the lightweight class and this is a 
big problem for us. I try other mechanism like subclass or extends but 
NHibernate force me to declare a discriminator element, which is not 
required for me.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/x7L5JV8AEQMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to