views:

23

answers:

1

I got the following mappings

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="false">
  <subclass name="Module.CRM.Models.CallRecord, Module.CRM" extends="Gate.Calls.CallRecord, Gate.SDK" discriminator-value="call_record_id">
    <property name="ContactId" column="contact_id" />
    <property name="CompanyId" column="company_id" />
  </subclass>
</hibernate-mapping>

And:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="false">
  <class name="Gate.Calls.CallRecord, Gate.SDK" table="call_records" lazy="true">
    <id name="Id" column="id">
      <generator class="sequence">
        <param name="sequence">call_records_id_seq</param>
      </generator>
    </id>

    <property name="UserId" column="user_id" type="integer" />
    <property name="SiteId" column="site_id" type="integer" />
    <property name="PhoneNumber" column="phone_number" type="string" />
    <property name="CreatedAt" column="created_at" type="datetime" />
    <property name="Duration" column="duration" type="integer" />
    <property name="IsInbound" column="is_inbound" type="boolean" />
    <property name="HangupCause" column="hangup_cause" type="integer" />
    <property name="RingDuration" column="ring_duration" type="integer" />

  </class>
</hibernate-mapping>

I get the following error

No discriminator found for Module.CRM.Models.CallRecord.

Haven't I specified a discriminator?

Edit

Done some more research: Discriminator is not what I should use. call_record_id in crm_call_records points on id in call_records. What should the mapping files look like?

A: 

You need to add a discriminator to the CallRecord mapping. i.e

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="false">
  <class name="Gate.Calls.CallRecord, Gate.SDK" table="call_records" lazy="true">
    <id name="Id" column="id">
      <generator class="sequence">
        <param name="sequence">call_records_id_seq</param>
      </generator>
    </id>
    <discriminator column="Discriminator"
            not-null="true"
            type="System.String"/>
    <property name="UserId" column="user_id" type="integer" />
    <property name="SiteId" column="site_id" type="integer" />
    <property name="PhoneNumber" column="phone_number" type="string" />
    <property name="CreatedAt" column="created_at" type="datetime" />
    <property name="Duration" column="duration" type="integer" />
    <property name="IsInbound" column="is_inbound" type="boolean" />
    <property name="HangupCause" column="hangup_cause" type="integer" />
    <property name="RingDuration" column="ring_duration" type="integer" />

  </class>

Here is an example Ayende - NHibernate Mapping – Inheritance

Iain