After some more thinking, I realized that my I want is "just" a normal 
inheritance mapping.

So I used this mapping:

mapper.Class<IStatistic>(cm =>
{
...
});

mapper.Subclass<MyStat>(cm => { });

mapper.Class<Action>(cm =>
{
cm.Id(a => a.Id, idm =>
{
idm.Access(Accessor.Field);
idm.Generator(Generators.Native);
});

cm.Property(a => a.Time);

cm.ManyToOne(a => a.Statistic, pm =>
{
pm.NotNullable(false);
pm.Column("StatisticId");
});
});

which gives me this mapping:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
namespace="Emidee.CommonEntities" assembly="Emidee.CommonEntities" 
xmlns="urn:nhibernate-mapping-2.2">
  <class name="IStatistic" abstract="true">
    <id name="Id" access="property" column="IStatisticId" type="Int32">
      <generator class="native" />
    </id>
    <discriminator />
    <property name="Name" access="readonly" not-null="true" />
    <property name="Attack" access="readonly" not-null="true" />
    <property name="Value" access="readonly" not-null="true" />
  </class>
  <class name="Action">
    <id name="Id" access="field.camelcase" column="ActionId" type="Int32">
      <generator class="native" />
    </id>
    <many-to-one name="Statistic" column="StatisticId" />
    <property name="Time" not-null="true" />
  </class>
  <subclass name="Statistic" extends="IStatistic" />
  <subclass name="MyStat" extends="Statistic" />
</hibernate-mapping>

And now my test is working perfectly well.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
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