在hibernate java中设置lazy = true时获取无效的映射异常

时间:2018-02-20 10:43:40

标签: java hibernate exception jersey-2.0 hbmxml

我想在hibernate中使用 lazy =" true" ,同时在JAVA中使用 Jersey 加载详细信息。但我得到错误。 (hbm版本5.1.3.Final)

这是我的代码:

 <class name="com.icaube.application.prac.details.PracAccountDetail" table="prac_account_master">
    <id column="account_id" name="accountId">
        <generator class="com.icube.platform.IdGenerator">
            <param name="componentName">PracAccount</param>
        </generator>
    </id>

//here lazy=true     
<many-to-one name="pracRankDetail" class="com.icaube.application.prac.details.PracRankDetail" column="rank_id" lazy="true"/>  

<one-to-one name="pracAddressDetail" property-ref="accountId" lazy="false"  />

<property column="name" name="name"  not-null="true" unique="false"/>

    <property column="rank_id" name="rankId"  not-null="true" unique="false"/>
</class>

获取错误:   Initial SessionFactory creation failed.org.hibernate.boot.InvalidMappingEelloxception: Could not parse mapping document: PracComponents.hbm.xml (RESOURCE)

这有什么问题?我怎样才能使它正确?

谢谢: - )

2 个答案:

答案 0 :(得分:0)

你的班级标签

<class name="com.icaube.application.prac.details.PracAccountDetail" table="prac_account_master">

未关闭或您未在xml文件中发布所有内容。

答案 1 :(得分:0)

错误无法解析映射文档是关于您的xml文件格式不正确。当出现此错误时,我们最好仔细检查我们的xml文件,看看它们是否正常(所有标签都已正确关闭等等)。

要了解更多信息,请参阅以下链接:

org.hibernate.InvalidMappingException: Could not parse mapping document from resource *.hbm.xml

https://coderanch.com/t/217940/databases/Hibernate-InvalidMappingException-parse-mapping-document