mybatis 返回列表类型的数据
最编程
2024-06-29 11:11:37
...
studends表里一条teacher_id 数据对应多条 student_id数据,所以通过teacher_id 查询出来的student_id 是一个List。
mybatis代码如下:
//返回类型是String类型的student_id
<resultMap id="studentIdResult" type="java.lang.String" >
<result column="student_id" property="studentId" jdbcType="VARCHAR" />
</resultMap>
//入参类型(parameterType)是String类型 teacherId
<select id="getStudentsByTeacherId" resultMap="studentIdResult" parameterType="java.lang.String" >
select student_id
from student
where teacher_id = #{id,jdbcType=VARCHAR}
</select>
推荐阅读
-
压缩从后端到前端的返回数据的注释方式--方案
-
用于存储 IP 地址的 mysql 数据类型
-
Redis 数据类型列表 - 目录
-
YOLOv5 工件检测系统 五种类型的工件(螺钉、螺母、六角扳手、黄铜柱、尼龙柱),带有数据集,经过标注、培训和精确,可用于机器人抓取操作
-
Redis 中的其他一些数据类型和渐进式遍历
-
车辆类型分类和识别数据集可识别 7 种类型的汽车,按照 7:2:1 的比例划分数据集,其中训练集 1 488 张,验证集 507 张,测试集 31 张,共计 2 026 张。
-
Redis 的一些简单通用命令 & 识别常见数据类型和编码方式 & 识别 Redis 单线程模型
-
Redis 数据类型的常用命令
-
入门级视音频数据处理:RGB、YUV像素数据处理的函数列表【转】
-
VHDL的数字数据类型