org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_stoller' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: com.itmg.stroller.dao.model.StrolllerDataModel
Caused by: org.hibernate.MappingException: Association references unmapped class: com.itmg.stroller.dao.model.StrolllerDataModel
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2380)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2662)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)<hibernate-mapping package="com.itmg.stroller.dao.model">
    <class name="StrollerContentModel" table="t_stroller_content" catalog="gocoohdb_stroller">
        <id name="id" type="integer" column="id">
            <generator class="native" />
        </id>
        <many-to-one name="category" class="StrollerCategoryModel" fetch="select">
            <column name="category_id" not-null="true" />
        </many-to-one>
        <property name="title" type="string">
            <column name="title" length="200" />
        </property>
        <property name="publishDatetime" type="date">
            <column name="publish_datetime" />
        </property>
        <property name="description" type="string">
            <column name="description" length="200" />
        </property>
        <property name="content" type="string">
            <column name="content" length="200" />
        </property>
        <set name="pictures" inverse="true" lazy="false">
            <key column="content_id" />
            <one-to-many class="StrollerPictureModel" />
        </set>
        <set name="datas" inverse="true">
         <key column="content_id"/>
         <one-to-many class="StrolllerDataModel"/>
        </set>
    </class>
</hibernate-mapping><hibernate-mapping package="com.itmg.stroller.dao.model">
    <class name="StrollerDataModel" table="t_strollerdata" catalog="gocoohdb_stroller">
        <id name="id" type="long">
            <column name="id" length="20" />
            <generator class="increment"></generator>
        </id>
        <many-to-one name="content" class="StrollerContentModel" fetch="select">
            <column name="content_id" not-null="true"/>
        </many-to-one>
        <property name="item_name" type="string">
            <column name="item_name" length="255"/>
        </property>
        <property name="item_alias" type="string">
            <column name="item_alias" length="255" />
        </property>
        <property name="item_content" type="string">
            <column name="item_content" length="255" />
        </property>
    </class>
</hibernate-mapping>
看了老半天找不到,大家帮忙看看吧

解决方案 »

  1.   

    你跟我出的一样的错,再用hibernate反转一次就好了,
    希望也能帮到以后的朋友
      

  2.   

    错误原因是实体类对应的映射文件中的映射关系(one-to-many....)中的class错了
      

  3.   

    将one-to-many中的class=包名+类名,写完整就可以了
      

  4.   

    是你的Hibernate.cfg.xml 中没有缺少那个映射文件
      

  5.   

    将one-to-many中的class=包名+类名,写完整就可以了
      

  6.   

    Caused by: org.hibernate.MappingException: Association references unmapped class: model.UserRole 本人也遇到过此异常,经研究原因是有级联关系的各个实体类没有反向映射完全。解决方法是:把所有有级联关系的表再重新反向映射一遍。LZ可以试试看哦!
      

  7.   

    您好,我也是这问题,并且[one-to-maney]中的class写法也没错,但是还是不行啊。求指教