Day30项目saas-export项目-项目搭建-字段名与变量名不一致

it2026-01-06  7

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>
最新回复(0)