您的位置:首页 > 娱乐 > 八卦 > MyBatis 学习记录要点

MyBatis 学习记录要点

2024/10/5 8:30:06 来源:https://blog.csdn.net/u011174139/article/details/141223696  浏览:    关键词:MyBatis 学习记录要点

简单介绍

    <select id="getUserInfo" parameterType="Long"  resultType="Map">select * from sys_user    where user_id = #{userId}</select>1.SQL 语句分为增、删、改、查,对应的标签对有 insert delete update select 。2.id="getUserInfo"为getUserInfo方法。3.输入类型:parameterType(基本数据类型或包装类型), parameterMap(参数集合-map)。4.输出类型: resultType(基本数据类型或包装类型), resultClass(Java类), resultMap(Map集合)。5.接收参数:#{userId},#{}和${}区别:#{}:占位符。${}:将接收到参数内容不加任何修饰地拼接在sql中,会引起sql注入,使用${value}。
where
    <select id="getUserInfo" parameterMap="map"  resultType="Map">select u.* from sys_user as u<where><if test="sex != null ">and u.sex = #{sex}</if>	<if test="name != '' and name != null">and u.name like '%${name}%'</if>	</where></select>
foreach
      update  car_use set is_del = 1,update_time = sysdate() where id in<foreach item="id" collection="ids" open="(" separator="," close=")">#{id}</foreach>说明: collection: 传进来得数组。open:开始遍历时拼接。separator:两个对象之间的拼接。close:结束时拼接。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com