【问题标题】:getting invalid mapping exception when setting lazy=true in hibernate java在hibernate java中设置lazy = true时出现无效映射异常
【发布时间】:2018-02-20 19:49:40
【问题描述】:

我想在休眠中使用 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)

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

谢谢:-)

【问题讨论】:

    标签: java hibernate exception jersey-2.0 hbmxml


    【解决方案1】:

    你的班级标签

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

    没有被关闭,或者您没有在您的 xml 文件中发布所有内容。

    【讨论】:

      【解决方案2】:

      无法解析映射文档的错误是关于您的 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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-03-11
        • 1970-01-01
        • 2016-12-17
        • 2018-02-24
        • 2020-04-01
        • 2011-05-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多