<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${packageName}.mapper.${ClassName}Mapper">

    <resultMap type="${ClassName}" id="${ClassName}Result">
        #foreach ($column in $columns)
            <result property="${column.javaField}"    column="${column.columnName}" />
        #end
    </resultMap>

    #if($table.sub)
        <resultMap type="${subClassName}" id="${subClassName}Result">
            #foreach ($column in $subTable.columns)
                <result property="${column.javaField}"    column="${column.columnName}" />
            #end
        </resultMap>

        <select id="select${subClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}" resultType="${packageName}.domain.${subClassName}">
        select * from ${subTableName} where ${subTableFkName} = #{${pkColumn.javaField}}
    </select>

        <delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}">
        delete from ${subTableName} where ${subTableFkName} = #{${pkColumn.javaField}}
    </delete>

        <insert id="batchInsert${subClassName}">
            insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size()),#end#end) values
            <foreach item="item" index="index" collection="list" separator=",">
                (#foreach($column in $subTable.columns) #{item.$column.javaField}#if($foreach.count != $subTable.columns.size()),#end#end)
            </foreach>
        </insert>
    #end

</mapper>
