MyBatis定义复合主键

<resultMap type="XX" id="XXMap">         

    <id property="id" column="colid"/>  

        <id property="name" column="colname"/>  

       <collection property="list" javaType="ArrayList" column="{id = colid,name=colname}" select="getSubXXX"/>  

</resultMap> 

前为别名后为主查询getXXX语句中字段

<select id="getXXX" parameterType="HashMap" resultMap="XXX">          SELECT colid,colname FROM table1

 </select> 

 <select id="getSubXXX" parameterType="HashMap" resultType="XXX"> 
        SELECT * FROM table2 WHERE id = #{id} AND name = #{name}   </select> 

posted @ 2014-08-14 15:26  周建旭  阅读(11487)  评论(0编辑  收藏  举报