nested exception is org.hibernate.MappingException解决方案

1.可能是因为映射文件( Order.hbm.xm)配置的class路径出错 

Java代码   收藏代码
  1. <hibernate-mapping>  
  2.  <class name="com.web.bean.Order" table="order">  
  3.   <id name="orderId" type="java.lang.Integer" column="order_id">  
  4.    <generator class="increment"></generator>  
  5.   </id>  
  6.   <property name="price" type="double" column="order_price" length="12"></property>  
  7.   <property name="quantity" type="int" column="order_quantity"></property>  
  8.   <property name="date" type="date" column="date" length="10"></property>  
  9.   <many-to-one name="seller" column="seller_id" class="com.web.bean.Seller"  
  10.    not-null="true">  
  11.   </many-to-one>  
  12.   <many-to-one name="phone" column="phone_id" class="com.web.bean.Phone"  
  13.    not-null="true">  
  14.   </many-to-one>  
  15.   <many-to-one name="customer" column="customer_id" class="com.web.bean.Customer"  
  16.    not-null="true">  
  17.   </many-to-one>  
  18.  </class>  
  19. </hibernate-mapping>  


类的路径必须写全,或者在<hibernate-mapping>中加上属性package="com.web.bean" 

2.如果以上检查都是对的,那么就看applicationContext.xml中是否加上了 
<value>com/web/bean/Order.hbm.xml</value> 

Java代码   收藏代码
    1. <property name="mappingResources">  
    2.    <list>  
    3.     <value>com/web/bean/Customer.hbm.xml</value>  
    4.     <value>com/web/bean/Seller.hbm.xml</value>  
    5.     <value>com/web/bean/Brand.hbm.xml</value>  
    6.     <value>com/web/bean/Kind.hbm.xml</value>  
    7.     <value>com/web/bean/Order.hbm.xml</value>  
    8.     <value>com/web/bean/Phone.hbm.xml</value>  
    9.     <value>com/web/bean/SellerOwnPhone.hbm.xml</value>  
    10.    </list>  
    11.  </property>  

猜你喜欢

转载自www.cnblogs.com/Jeely/p/11102531.html
今日推荐