`

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

    博客分类:
  • db
阅读更多
出错原因

1.可能是因为映射文件( Order.hbm.xm)配置的class路径出错
<hibernate-mapping>
 <class name="com.web.bean.Order" table="order">
  <id name="orderId" type="java.lang.Integer" column="order_id">
   <generator class="increment"></generator>
  </id>
  <property name="price" type="double" column="order_price" length="12"></property>
  <property name="quantity" type="int" column="order_quantity"></property>
  <property name="date" type="date" column="date" length="10"></property>
  <many-to-one name="seller" column="seller_id" class="com.web.bean.Seller"
   not-null="true">
  </many-to-one>
  <many-to-one name="phone" column="phone_id" class="com.web.bean.Phone"
   not-null="true">
  </many-to-one>
  <many-to-one name="customer" column="customer_id" class="com.web.bean.Customer"
   not-null="true">
  </many-to-one>
 </class>
</hibernate-mapping>

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

2.如果以上检查都是对的,那么就看applicationContext.xml中是否加上了
<value>com/web/bean/Order.hbm.xml</value>
<property name="mappingResources">
   <list>
    <value>com/web/bean/Customer.hbm.xml</value>
    <value>com/web/bean/Seller.hbm.xml</value>
    <value>com/web/bean/Brand.hbm.xml</value>
    <value>com/web/bean/Kind.hbm.xml</value>
    <value>com/web/bean/Order.hbm.xml</value>
    <value>com/web/bean/Phone.hbm.xml</value>
    <value>com/web/bean/SellerOwnPhone.hbm.xml</value>
   </list>
 </property>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics