常⽤select * 去查询数据库 ⼩项⽬没问题,
⾼并发项⽬不推荐这样使⽤,查询性能低,
应该选择需要的字段 什么是sql⽚段
根据业务需要,⾃定制要查询的字段,并可以复⽤
使用sql片段 然后include标签引用即可
code:
<sql id="base_video_field">
id,title,summary,cover_img
</sql>
<!--
statement sql
id: 当前mapper下需要唯一
resultType : sql查询结果集的封装
-->
<!--<select id="selectById" parameterType="java.lang.Integer" resultType="net.xdclass.online_class.domain.Video">-->
<select id="selectById" parameterType="java.lang.Integer" resultType="Video">
select <include refid="base_video_field"/> from video where id = #{video_id,jdbcType=INTEGER}
</select>
<select id="selectListByXML" resultType="Video">
select <include refid="base_video_field"/> from video
</select>