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>  
  • 相关阅读:
    0102-进程操作(面向对象简单工厂模式,打开输入文件)
    0101-进程操作(变量命名)
    win10无法成功完成操作因为文件包含病毒或潜在的垃圾软件如何处理
    序列化和反序列化
    __slot__的用法
    python中typeguard包
    pandas如何将多个DataFrame写入同一个excel工作簿中
    DEAP库遗传算法
    【教程】如何把喜马拉雅音频下载到电脑
    oracle安装路径查看方式
  • 原文地址:https://www.cnblogs.com/Jeely/p/11102531.html
Copyright © 2011-2022 走看看