数据库字段与类属性名称不一致,导致查询数据时数据没有封装上。
[Brand{id=1, brandName='null', companyName='null'}, Brand{id=2, brandName='null', companyName='null'}]
解决方式一(为表字段取别名)
<select id="selectAll" resultType="brand">
select id, brand_name as brandName, company_name as companyName from tb_brand;
</select>
缺点:每次查询都需要定义别名,冗余。
sql 片段

缺点:不灵活
解决方式二(定义resultMap标签)










![清楚姐姐玩翻翻乐[期望dp]](https://img-blog.csdnimg.cn/e201650e3cfa404f8562cf3705bc7503.png)








![[iHooya]2023年1月30日作业解析](https://img-blog.csdnimg.cn/780cb8dbf7054afeb831c99edcb2f163.png)
