saas-export项目之字段名与变量名不一致

export_dao

  • (1)数字库 表字段 与类的成员变量 不一致

    在这里插入图片描述

解决方法

  1. sql语句 使用 as
  2. mybatis里面使用 resultMap

方法 1:sql别名

    <select id="findAll" resultType="company">
select
	id,
	name ,
	expiration_date as expirationDate ,
	address,
	license_id as licenseId  ,
	representative ,
	phone  ,
	company_size as companySize  ,
	industry  ,
	remarks ,
	state,
	balance ,
	city
from ss_company
    </select>

方法2: resultMap标签

在这里插入图片描述
在这里插入图片描述

<?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" >
<!--namespace: 需要映射的Dao接口类型-->
<mapper namespace="com.lbl.dao.company.ICompanyDao">

    <resultMap id="companyMap" type="company" autoMapping="true">
        <id property="id" column="id"></id>
        <result property="expirationDate" column="expiration_date"></result>
        <result property="licenseId" column="license_id"></result>
        <result property="companySize" column="company_size"></result>
    </resultMap>

    <select id="findAll" resultMap="companyMap">
        select * from ss_company
    </select>
</mapper>

猜你喜欢

转载自blog.csdn.net/qq_37924905/article/details/109229655