image.png

    1. <?xml version="1.0" encoding="UTF-8" ?>
    2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
    4. <mapper namespace="com.wzy.springcloud.dao.PaymentDao">
    5. <!--useGeneratedKeys="true"插入数据成功后,返回 keyProperty="id" id-->
    6. <insert id="create" parameterType="Payment" useGeneratedKeys="true" keyProperty="id">
    7. insert into payment(serial) values(#{serial});
    8. </insert>
    9. <resultMap id="BaseResultMap" type="com.wzy.springcloud.Entities.Payment">
    10. <!--column="serial"中的serial,会使用property="serial"中serial替换掉,防止serial有下划线-->
    11. <id column="id" property="id" jdbcType="BIGINT"/>
    12. <id column="serial" property="serial" jdbcType="VARCHAR"/>
    13. </resultMap>
    14. <!--resultMap="BaseResultMap" 结果映射,映射到上面resultMap。-->
    15. <select id="getPaymentById" parameterType="Long" resultMap="BaseResultMap">
    16. select * from payment where id=#{id};
    17. </select>
    18. </mapper>