Mybatis ResultMap Collection 复合主键

来源:互联网 发布:最终幻想猫女捏脸数据 编辑:程序博客网 时间:2024/05/01 15:37

<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> 


ibatis insert后怎么用selecykey返回联合主键的值


<insert id="insertXXXX" parameterClass="com.test.model.XXXX" >
    insert into TableName(………略
 <selectKey resultClass="java.lang.Integer" keyProperty="id" 
    SELECT @@IDENTITY AS id 
   </selectKey>
</insert>


ibatis insert后怎么用selecykey返回联合主键的值

0 0