hibernate正向生成数据库表以及配置——Teacher.hbm.xml

<?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">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="cn.bdqn.studentInfo.entity.Teacher" table="Teacher">
        <id name="id">
            <generator class="assigned" />
        </id>
        <property name="name" >
        </property>
        <!-- 多对多关系映射 -->
            <!--
            name:映射对方表的属性名
            ttable:关系表的名字
            inverse:是否维护关系,false的话,另一方进行维护,true的话,该方进行维护
        -->
        <set name="students" table="student_teacher"  cascade="all">
        <!-- 
        name:该表的外键
         -->
            <key>
                <column name="teacherId"/>
            </key>
            <!-- 
            class:多对多的另一方的实体类
            column:另一方的外键
             -->
            <many-to-many class="cn.bdqn.studentInfo.entity.Student" column="studentid"></many-to-many>
        </set>
    </class>
</hibernate-mapping>

posted @ 2017-02-27 22:40  穆雄雄  阅读(82)  评论(0编辑  收藏  举报