猿问

hibernate配置一对多出错。。求指点

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="orders" table="orders" catalog="hibernate">
        <id name="oid" type="integer">
            <column name="oid" />
            <generator class="identity"></generator>
        </id>
        <property name="price" type="float">
            <column name="price" precision="12" scale="0" />
        </property>
        <property name="id" type="string">
            <column name="id" length="10" />
        </property>
        
        <many-to-one name="stu" column="id" class="Student"></many-to-one>
        
    </class>
</hibernate-mapping>



<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="Student" table="student" catalog="hibernate">
        <id name="id" type="string">
            <column name="id" length="10" />
            <generator class="assigned"></generator>
        </id>
        <property name="name" type="string">
            <column name="name" length="20" />
        </property>
        <property name="age" type="integer">
            <column name="age" />
        </property>
        
 
        
        <set name="order">
        	<key column="id"></key>
        	<one-to-many class="orders"/>
        </set>
        
    </class>
</hibernate-mapping>


qq_莫非
浏览 1123回答 1
1回答

HZK135

<one-to-many class="orders"/> 和 <many-to-one name="stu" column="id" class="Student"></many-to-one> 的class属性要用类的全名
随时随地看视频慕课网APP

相关分类

Java
我要回答