java 关联引用未映射的类休眠

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11032038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 03:31:07  来源:igfitidea点击:

Association references unmapped class hibernate

javahibernate

提问by mahesh

The configuration for Affiliate class is:

Affiliate 类的配置是:

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

The Configuration for Address class is

地址类的配置是

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

I am getting the below error

我收到以下错误

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)

Kindly show me the mistakes I have made.. I want to use one to many relation AffiliateDO->AddressDO

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

采纳答案by Mainguy

It looks like your mapping of the parent class is referring to AddressDO, but the subsequent child mapping is referring to Address (No "DO")... If I had to guess, you should change the second mapping to AddressDO (or visa versa). In any event, looks like a typo to me.

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

回答by mtariq

Considering Do as a typo error in Addrees xml, The Address mapping seems incorrect, there must address_id must be many-to-one currently it is generated new one.

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