キーワード:Association1対1のマッピング(1つのクラスにはクラス教師が1人しかいません)
<id = "getClass" parameterType = "int" resultMap = "classesResultMap"> select * from class c、from teacher t from chere c.teacher_id = t.t_id =#{id} </select> <resultmap typenプロパティ= "name" column = "c_name"/> <associationプロパティ= "教師" javatype = "com.lcb.user.teacher"> <id property = "id" column = "t_id"/> <resultプロパティ= "column =" t_name "/> </association> </resultmap>キーワード:1対Manyマッピングのコレクション(1人の教師には複数の生徒がいます)
<resultmap etpe = "teacher" id = "teachermaps"> <id column = "id" property = "id"/> <result column = "name" property = "name"/> <result column = "class_name" property = "classname"/> <collection property = "sustent" oftype = "sustess" select = "getstudents" id = "getAllTeacher" parameterType = "furstmap =" teachermaps "> select t.id、t.name、t.class_name from teacher t </select> <select id =" getStudents "parametertype =" int "resulttype =" sustent "> select s.id、s。名前、s.class_name as classname from Students where where fort teach_id =#{id} </select>キーワード:Association Hount-Oneマッピング(複数の人が1つの国に属します)
多くのものは1対多のものと同等であり、コレクションも使用できます。
<select id = "selectCountry" resultType = "country"> cid =#{ooo} </selectmap> <resultmap type = "people" id "peoplemapper2"> <id column = "pid" property = "pid"/> <result column = "pname =" pname "/>>>>>>>>> < select = "selectCountry" column = "countryid"/> </resultmap> <select id = "selectbyid2" resultmap = "peoplemapper2"> pid =#{xxx} </select>要約します
上記は、編集者によって紹介された1対1の、1対多で多数の問い合わせです。それがあなたに役立つことを願っています。ご質問がある場合は、メッセージを残してください。編集者は時間内に返信します。 wulin.comのウェブサイトへのご支援ありがとうございます!