1

附属类的配置是:

<class name="AffiliatesDO" table="AFFILIATES">
    <id name="affiliateId" column="affiliate_id" type="java.lang.String">
        <generator class="assigned" />
    </id>
    <property name="customerId" column="customer_id" type="int" />
    <property name="affiliateType" column="affiliate_type" type="java.lang.String" />
    <property name="site" column="site" type="java.lang.String" />
    <property name="status" column="status" type="java.lang.String" />
    <property name="createdBy" column="created_by" type="java.lang.String" />
    <property name="creationDate" column="creation_date" type="java.util.Date" />
    <property name="lastUpdatedBy" column="last_updated_by" type="java.lang.String" />
    <property name="lastUpdated" column="last_updated" type="java.util.Date" />
      <set name="address" lazy="true" inverse="true" order-by="address_id asc">
        <key column="address_id"/>
        <one-to-many class="AddressDO"/>
    </set>
</class>

地址类的配置是

<class name="Address"
    table="Address">
    <id name="addressId" column="address_id"
        type="java.lang.String">
        <generator class="assigned" />
    </id>


    <property name="name" column="name" type="java.lang.String" />

    <property name="address1" column="address1" type="java.lang.String" />


    <property name="phone" column="phone" type="java.lang.String" />

    <property name="landLineNumber" column="land_line_number" type="java.lang.String" />

    <property name="faxNumber" column="fax_number" type="java.lang.String" />

</class>

我收到以下错误

org.hibernate.MappingException: Association references unmapped class: com.infibeam.customerservice.dbObjects.AddressDO
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2370)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2652)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1054)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentConfiguration.java:38)
at org.codehaus.mojo.hibernate3.HibernateExporterMojo.configureExporter(HibernateExporterMojo.java:186)
at org.codehaus.mojo.hibernate3.exporter.Hbm2JavaGeneratorMojo.configureExporter(Hbm2JavaGeneratorMojo.java:69)

请告诉我我犯的错误.. 我想使用一对多关系 AffiliateDO->AddressDO

4

2 回答 2

1

看起来您的父类映射指的是 AddressDO,但随后的子映射指的是 Address(没有“DO”)...如果我不得不猜测,您应该将第二个映射更改为 AddressDO(反之亦然)。无论如何,对我来说似乎是一个错字。

于 2012-06-14T12:00:37.813 回答
0

考虑到 Do 是 Addrees xml 中的拼写错误,地址映射似乎不正确,必须 address_id 必须是多对一的,当前它是生成新的。

于 2012-06-14T12:05:13.020 回答