zoukankan      html  css  js  c++  java
  • 映射

    一对一映射文件配置

      //主动方

       <one to one name="被动方实体类变量" class="被动方实体类路径" cascade="all"        property="关联类"/>

       EG:<one-to-one name="prove" class="com.li.www.entity.Prove" cascade="all" property-ref="student" />

      //被动方

       <many-to-one name="主动方实体类属性" class="主动方实体类路径" lazy="false" unique="true">

        <column name="主动方主键" />

        <many-to-one />

              EG: <many-to-one name="student" class="com.li.www.entity.Student" lazy="false" unique="true">

           <column name="SID"></column>

         </many-to-one>    

    多对一映射文件配置

        <many-to-onev name="‘一’方实体类变量" class="‘一’方实体类路径">

         <column name="‘多’方所要关联的‘一’方的主键"></column>

        </many-to-one>

              EG: <many-to-one name="grade" class="com.li.www.entity.Grade">

           <column name="GID"></column>

         </many-to-one>     

    一对多映射配置文件

         <set name="'多'方实体类变量">

          <key column="‘一’方所要关联的‘多’方的主键">

         <one-to-many class="‘多’方实体类路径"/>

               EG:<set name="students">

           <key column="GID" />

           <one-to-many class="com.li.www.entity.Student" />

       </set>

    多对多映射文件配置

      //被动方

      <set>

          <set name="被动方实体类变量" table="关联表名称" cascade="save-update">

          <key column="所要关联主动方的主键" />

          <many-to-many class="被动方实体类路径" column="被动方主键"></many-tomany>

        </set>

              EG:<set name="students" table="course" cascade="save-update" inverse="true">

              <key column="cid"></key>

               <many-to-many class="com.li.www.entity.Student" column="sid"></many-to-many>

                  </set>

       //主动方

      <set>

         <set name="主动方实体类变量" table="关联表名称" cascade="save-update"          inverse="true">

         <key column="所要关联被动方的主键" />

         <many-to-many class="主动方实体类路径" column="主动方主键"></many-tomany>

      </set>

              EG:<set name="courses" table="course" cascade="save-update">

                   <key column="sid"></key>

                   <many-to-many class="com.li.www.entity.Course" column="cid"></many-to-many>

            </set>

  • 相关阅读:
    MainFrm.cpp
    MyView.h
    我的东软实习项目一:车牌识别之MFC----MyView.cpp
    洛谷P1055 字符串的处理-----ISBN
    跳出多重循环------设置标志量
    单链表的创建及操作
    线性表的建立及运算
    JVM--你常见的jvm 异常有哪些? 代码演示:StackOverflowError , utOfMemoryError: Java heap space , OutOfMemoryError: GC overhead limit exceeded, Direct buffer memory, Unable_to_create_new_native_Thread, Metaspace
    JVM-gcRoots 和 强引用,软引用, 弱引用, 虚引用, 代码演示和应用场景
    JUC 并发编程--08,线程池,三大方法,七大参数,4种拒绝策略,代码演示
  • 原文地址:https://www.cnblogs.com/aijavaa/p/6437215.html
Copyright © 2011-2022 走看看