zoukankan      html  css  js  c++  java
  • 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>  
  • 相关阅读:
    最长公共子序列-动态规划
    归并排序
    最大子段和-3种方法
    kafka compaction 分析(基于kafka 0.10.2版本)
    [转载]interp1
    [转]mat2gray函数原理分析
    Java 位运算(移位、位与、或、异或、非)与逻辑运算
    ML01a
    [第1集] 机器学习的动机与应用
    tap4fun公司面试总结
  • 原文地址:https://www.cnblogs.com/Jeely/p/11102531.html
Copyright © 2011-2022 走看看