org.hibernate.PropertyNotFoundException: field [MainClass] not found on com.lyq.persistence.Category你的MainClass这个参数在.Category这个类里没有。你看你的配置是不是哪里。不小心写错了什么的。表和实体要对应好

解决方案 »

  1.   

    我觉得是不是你那个MainClass的问题。你那个名字可以换换 。你看看这个
        <?xml version="1.0" encoding="utf-8"?>  
        <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">  
         <!--一方-->
            <hibernate-mapping>  
                <class name="com.suxiaolei.hibernate.pojos.Customer" table="customer">  
                    <!-- 主键设置 -->  
                    <id name="id" type="string">  
                        <column name="id"></column>  
                        <generator class="uuid"></generator>  
                    </id>  
                    <!-- 属性设置 -->  
                    <property name="username" column="username" type="string"></property>  
                    <property name="balance" column="balance" type="integer"></property>  
                      
                    <set name="orders" inverse="true" cascade="all">  
                        <key column="customer_id" ></key>  
                        <one-to-many class="com.suxiaolei.hibernate.pojos.Order"/>  
                    </set>  
                </class>  
            </hibernate-mapping> 
    <!--多方 -->
        <?xml version="1.0" encoding="utf-8"?> 
        <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 
            <hibernate-mapping> 
                <class name="com.suxiaolei.hibernate.pojos.Order" table="orders"> 
                    <id name="id" type="string"> 
                        <column name="id"></column> 
                        <generator class="uuid"></generator> 
                    </id> 
                      
                    <property name="orderNumber" column="orderNumber" type="string"></property> 
                    <property name="cost" column="cost" type="integer"></property> 
                      
                    <many-to-one name="customer" class="com.suxiaolei.hibernate.pojos.Customer"   
                                 column="customer_id" cascade="save-update"> 
                    </many-to-one>          
                </class> 
            </hibernate-mapping> 
      

  2.   

    应该是MainClass问题,换一个类名
      

  3.   

    Caused by: org.hibernate.PropertyNotFoundException: field [MainClass] not found on com.lyq.persistence.Category多看看报错的情况啊 。。