Caused by: org.hibernate.MappingException: Association references unmapped class: com.elone.pm.product.dao.TAttribute
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/elone/pm/applicationContext.xml]:
Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: com.elone.pm.product.dao.TAttribute
Caused by: org.hibernate.MappingException: Association references unmapped class: com.elone.pm.product.dao.TAttribute
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:1127)
=============================================
applicationContext.xml
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:/com/elone/pm/hibernate.cfg.xml</value>
</property>
</bean>
<bean id="attributeDAO" class="com.elone.pm.product.dao.hibernate.TAttributeDAOImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
=================================
hibernate.cfg.xml
<mapping
resource="com/elone/pm/product/pojo/TAttribute.hbm.xml" />
==========================================================
TAttribute.hbm.xml
<hibernate-mapping>
<class name="com.elone.pm.product.pojo.TAttribute" table="T_ATTRIBUTE" schema="ELPLAT">
<id name="typeid" type="java.lang.String">
<column name="TYPEID" length="32" />
<generator class="uuid.hex" />
</id>
<many-to-one name="protype" lazy="false" class="com.elone.pm.product.pojo.TProtype" fetch="select">
<column name="PROCLASSID" length="32" />
</many-to-one>
<many-to-one name="parent" lazy="false" class="com.elone.pm.product.pojo.TAttribute" fetch="select">
<column name="PARENTID" length="32" />
</many-to-one>
<property name="attname" type="java.lang.String">
<column name="ATTNAME" length="50" />
</property>
<property name="attorder" type="java.lang.String">
<column name="ATTORDER" length="50" />
</property>
<property name="attstyle" type="java.lang.String">
<column name="ATTSTYLE" length="50" />
</property>
<property name="attsign" type="java.lang.String">
<column name="ATTSIGN" length="50" />
</property>
<set name="childrens" lazy="false" inverse="true">
<key>
<column name="PARENTID" length="32" />
</key>
<one-to-many class="com.elone.pm.product.pojo.TAttribute" />
</set>
</class>
</hibernate-mapping>
=============================================
public class TAttribute implements Serializable {
private String typeid;
private TProtype protype;
private TAttribute parent;
private String attname;
private String attorder;
private String attstyle;
private String attsign;
private Set childrens =new HashSet(0);
===============================================
郁闷了一下午 不知道错在哪了``一直就是这个错,看了包,类名 路径 均没错.映射也没看出错来.也是按顺序编译的 怕里面映射用到别的类时,别的类还没编译,
真不知道哪里错了 各位大虾瞄瞄
[解决办法]
看起来好像没什么问题
把<many-to-one name="parent" lazy="false" class="com.elone.pm.product.pojo.TAttribute" fetch="select">
<column name="PARENTID" length="32" />
</many-to-one>
这段放到最后面去试试看
我的异常网推荐解决方案:org.hibernate.MappingException: Association references unmapped class,http://www.myexception.cn/j2ee/326371.html