• mybatis加数据库表


    1. 在数据库中填加新表
    2. 在总配置文件中加入子mapper地址
    3. <?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="com.nuanshui.heatedloan.credit.dal.mapper.CreditChangeLogMapper" >//注意此处一定要与添加的类一致
          <resultMap id="creditChangeLogInfo" type="com.nuanshui.heatedloan.credit.model.CreditChangeLogInfo" >//注此处model也要与定义处一致
              <id column="id" property="id" typeHandler="idHandler" />
              <result column="user_id" property="userId"  />
              <result column="order_id" property="orderId"/>
              <result column="type" property="type"/>
              <result column="original_credit" property="originalCredit"/>
              <result column="new_credit" property="newCredit"/>
              <result column="log" property="log"/>
              <result column="created_at" property="createdAt" jdbcType="TIMESTAMP" />
              <result column="updated_at" property="updatedAt" jdbcType="TIMESTAMP" />
          </resultMap>
      
          <insert id="batchInsertCreditChangeLogList"  parameterType="java.util.List">
              <selectKey resultType="long" keyProperty="idRaw" >
                  SELECT LAST_INSERT_ID() AS id
              </selectKey>
              insert into credit_change_log (user_id, order_id, type, original_credit, new_credit, log, created_at, updated_at) values
              <foreach collection="list" item="item" index="index" separator=",">
                  (#{item.userId},#{item.orderId},#{item.type},#{item.originalCredit},#{item.newCredit},
                  #{item.log},now(),now())
              </foreach>
          </insert>
      
      </mapper>
      

        

  • 相关阅读:
    【Static Program Analysis
    【Py-Github】根据条件筛选Github repo的例子
    【Static Program Analysis
    【Static Program Analysis
    【Static Program Analysis
    【Static Program Analysis
    【IEEE会议论文】格式规范问题
    搜索引擎(3)——查询理解——不可省词
    搜索引擎(2)—— 查询理解 —— 分词
    搜索引擎(1)—— 概述与功能架构
  • 原文地址:https://www.cnblogs.com/wlemory/p/7571708.html
Copyright © 2020-2023  润新知