开发者

single-table-per-hierarchy mapping error

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>
      </gen开发者_开发问答erator>
    </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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜