简体   繁体   English

org.hibernate.MappingException:关联引用未映射 class

[英]org.hibernate.MappingException: Association references unmapped class

The configuration for User class:用户 class 的配置:

<class name="User" table="users" lazy="false">
    <id name="id" column="id">
        <generator class="native"/>
    </id>        
    <property name="type" column="type"/>         
    <many-to-one name="parent" column="parent"/>
    <property name="loginName" column="login_name" unique="true" not-null="true" index="idx_users_login_name" length="50"/>
    <property name="name" column="name" length="50"/>
    <property name="password" column="password"/>
    <property name="email" column="email" length="50"/>
    <property name="locale" column="locale" length="20"/>
    <property name="locked" column="locked"/>
    <many-to-one name="metadata" column="metadata_id"/>
    <set name="userSpaceRoles" cascade="all" inverse="true" lazy="false">
        <key column="user_id"/>
        <one-to-many class="UserSpaceRole"/>
    </set>      
</class>

and for the class MeetingItem is:对于 class MeetingItem 是:

<class name="MeetingItem" table="meeting_item">
    <id name="id" column="meeting_item_id" type="long">
        <generator class="native"/>
    </id>
    <property name="summary" column="summary" type="string"/>
    <property name="detail" column="detail" type="string"/>
    <many-to-one name="space" column="space_id"/>
    <property name="date" column="date" type="date"/>
    <list name="users" cascade="all" lazy="false">
        <key column="meeting_item_id"/>
        <index column="idx"/>
        <one-to-many class="User"/>
    </list>
</class>

The problem is I am getting the exception:问题是我遇到了异常:

org.hibernate.MappingException: Association references unmapped class: info.domain.User
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2380)
at org.hibernate.cfg.HbmBinder.bindListSecondPass(HbmBinder.java:2231)
at org.hibernate.cfg.HbmBinder$ListSecondPass.secondPass(HbmBinder.java:2729)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:936)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:140)

The mapping of the list is creating the problem.列表的映射正在产生问题。 What I am doing wrong?我做错了什么?


Edit:编辑:

This two configuration resides in different file, if these two are placed in same xml then the problem is not occurring.这两个配置位于不同的文件中,如果这两个配置在同一个 xml 中,则不会出现问题。

please add a reference to the mapping file (which maps info.domain.User ) into hibernate.cfg.xml.请将映射文件(映射info.domain.User )的引用添加到 hibernate.cfg.xml 中。

Please add class level annotations to register the class as a Spring bean, ie @Entity in this case since you are not using xml configuration.请添加 class 级别注释以将 class 注册为 Spring bean,即 @Entity 在这种情况下,因为您没有使用 Z0F635D0EZ8F328 配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 线程“ main” org.hibernate.MappingException中的异常:关联引用未映射的类hibernate - Exception in thread “main” org.hibernate.MappingException: Association references unmapped class hibernate 无法映射第二类:** org.hibernate.MappingException:来自表employee的关联是指未映射的类** - unable to map second class : ** org.hibernate.MappingException: An association from the table employee refers to an unmapped class** org.hibernate.MappingException:来自表X的关联引用了未映射的类 - org.hibernate.MappingException: An association from the table X refers to an unmapped class Hibernate org.hibernate.MappingException…与未映射类的关联-多对多 - Hibernate org.hibernate.MappingException… an associon ..to unmapped class- Many toMany 关联引用未映射的类处于休眠状态 - Association references unmapped class hibernate Hibernate org.hibernate.MappingException - Hibernate org.hibernate.MappingException @ManyToMany org.hibernate.MappingException - @ManyToMany org.hibernate.MappingException 获取org.hibernate.MappingException - Getting org.hibernate.MappingException org.hibernate.MappingException:持久性 class 未知:对于非实体 class - org.hibernate.MappingException: persistent class not known: for non entity class org.hibernate.MappingException:找不到实体类:dto.CityDTO - org.hibernate.MappingException: entity class not found: dto.CityDTO
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM