BrandMapper.xml中使用resultMap得到返回结果,解决数据库中的字段与pojo中的字段不匹配进行映射问题

2023-09-02
复制代码
<?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.hh.mapper.BrandMapper">

    <!--    得到返回结果,数据库中的字段与pojo中的字段不匹配进行映射-->
    <resultMap id="brandResult" type="brand">
        <result column="brand_name" property="brandName"/>
        <result column="company_name" property="companyName"/>
    </resultMap>

    <select id="selectAll" resultMap="brandResult">
        select * from tb_brand;
    </select>
</mapper>
复制代码

 

posted @   努力是一种常态  阅读(46)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
历史上的今天:
2022-09-02 软件工程导论——构建模型类型
点击右上角即可分享
微信分享提示