Day30项目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标签

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

    <resultMap id="companyMap" type="company">
         <id column="id" property="id"/>
         <result  column="expiration_date" property="expirationDate"/>
         <result  column="license_id" property="licenseId"/>
         <result  column="company_size" property="companySize"/>
    </resultMap>
    <select id="findAll" resultMap="companyMap">
        select
            *
        from ss_company
    </select>

猜你喜欢

转载自blog.csdn.net/u013621398/article/details/109222186