2

hbm が組み込みリソースとして設定されていても、NHibernate から次のエラーが表示されます。

関連は、マップされていないクラスを参照します: UploadPromotions.Models.StagedPromotionImage

マッピングは次のとおりです。

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="UploadPromotions.Models"
namespace="UploadPromotions.Models">
  <typedef
   name="blobbedItem"
   class="UploadPromotions.Models.Blobbed, UploadPromotions.Models">
    <param name="classType">Legacy.Item,Legacy</param>
  </typedef>
  <typedef
  name="blobbedSupplier"
  class="UploadPromotions.Models.Blobbed, UploadPromotions.Models">
    <param name="classType">Legacy.ItemFromSupplier,Legacy</param>
  </typedef>
  <typedef
 name="photoText"
 class="UploadPromotions.Models.Blobbed, UploadPromotions.Models">
    <param name="classType">UploadPromotions.Models.PhotoText,UploadPromotions.Models</param>
  </typedef>
  <union-subclass name="StagedPromotionImage" extends="DiskImage">
    <many-to-one name="CurrentStage" class="Stage" column="StageId" cascade="none"></many-to-one>
    <set name="Stages" table="StageForPromotionsTable" cascade="none" batch-size="20" access="field.camelcase-underscore">
      <key column="PromotionId"/>
      <many-to-many class="Stage" column="StageId"/>
    </set>
    <many-to-one name="BaseImage" class="DiskImage" column="DiskImageId"></many-to-one>
    <property name="Created"></property>
    <property name="Modified"></property>
    <property name ="Name"></property>
    <property name="From" column="FromDate" not-null="true"></property>
    <property name="To" column="ToDate" not-null="true"></property>
    <property name="Description" type="AnsiString" length="100" not-null="true"></property>
    <property name="Commited"></property>
    <property not-null="true" name ="Art" type="NHibernate.Type.EnumStringType`1[[ADAutoTotal.UploadPromotions.Models.Art,ADAutoTotal.UploadPromotions.Models]], NHibernate"></property>
    <property not-null="true" name ="Use" column="UsageType" type="NHibernate.Type.EnumStringType`1[[ADAutoTotal.UploadPromotions.Models.Use,ADAutoTotal.UploadPromotions.Models]], NHibernate"></property>
    <component name="TemplateImage" class="Template">
      <property name="TemplateName" not-null="true"></property>
      <property name="Width" not-null="true" column="TemplateWidth"></property>
      <property name="Height" not-null="true" column="TemplateHeight"></property>
    </component>
    <property name="Headline" type="photoText"></property>
    <property name="Caption" type="photoText"></property>
    <property name="Base64Url" not-null="false"></property>
    <property name="Row" column="RowNumber" not-null="true"></property>
    <property name="Position" not-null="true"></property>
    <many-to-one name="CreatedBy" class="PromotionManager" column="ManagerId" cascade="none"></many-to-one>
    <property name="Supplier" type="blobbedSupplier" not-null="false" length="1000"></property>
    <property name="Item" column="ForItem" type="blobbedItem" not-null="false" length="1000"></property>
    <many-to-one name="LastCommitedVersion" not-null="false" class="CommitedPromotionImage" column="LastCommitedVersionId"></many-to-one>
  </union-subclass>
</hibernate-mapping>

何も問題はありません。使用場所については、次のとおりです。

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="UploadPromotions.Models"
namespace="UploadPromotions.Models">
  <class name="PromotionManager">
    .......
    <set name="StagedPromotionImages" batch-size="50" inverse="true" cascade="all-delete-orphan" access="field.camelcase-underscore">
      <key column="CreatedById"></key>
      <one-to-many class="StagedPromotionImage"/>
    </set>
  </class>
</hibernate-mapping>

そしてここ:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="UploadPromotions.Models"
namespace="UploadPromotions.Models">
  <class name="Stage" table="StagedChanges">
  .........
    <set name="StagedImages" batch-size="50" inverse="true" cascade="all-delete-orphan" access="field.camelcase-underscore">
      <key column="StageId"></key>
      <one-to-many class="StagedPromotionImage"/>
    </set>
   ............

  </class>
</hibernate-mapping>

編集:

さて、マッピング ファイル名に .hbm 部分を追加するのを忘れていました.....

4

1 に答える 1