0

次のマッピングを取得しました

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

と:

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

次のエラーが発生します

Module.CRM.Models.CallRecordの識別子が見つかりません。

弁別器を指定していませんか?

編集

さらに調査を行いました。ディスクリミネーターは私が使用すべきものではありません。crm_call_recordsのcall_record_idは、call_recordsのidを指します。マッピングファイルはどのように見えるべきですか?

4

1 に答える 1

1

CallRecord マッピングに識別子を追加する必要があります。すなわち

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

Ayende - NHibernate マッピング - 継承の例を次に示します。

于 2010-10-28T01:24:27.873 に答える