“慢生活”不是懒惰,放慢速度不是拖延时间,而是让我们在生活中寻找到平衡。网站首页程序人生
11-添加&修改功能(insert、update标签、useGeneratedKeys、keyProperty属性、commit方法、openSession参数)
发布时间:2024-11-21 20:10:08作者:雪饮
![[!--pagekey--]](/e/data/images/notimg.gif)
添加
要实现添加数据到mysql数据库的数据表中,需要在mapper映射文件中定义insert标签
<insert id="add">
insert into tb_brand (brand_name,company_name,ordered,descr
10-查询-动态条件查询(if、where、choose、when、otherwise标签)
发布时间:2024-11-21 16:50:12作者:雪饮
![[!--pagekey--]](/e/data/images/notimg.gif)
if标签
上篇中根据status、brand_name,company_name来查询,但如果用户没有选择brand_name或没有选择company_name后则是查询不出结果的。
那么所以我们需要有条件的来判断某
09-查询-条件查询(散装参数,POJO对象参数,Map参数)
发布时间:2024-11-21 12:40:55作者:雪饮
![[!--pagekey--]](/e/data/images/notimg.gif)
散装参数
首先假如我有status、company_name,brand_name多个参数要进行查询,尤其后面两个参数是模糊查询,则mapper中select标签内容可以写成这样
<select id="selectByConditi
08-查询-查看详情(mybatis的mapper接收参数的处理)
发布时间:2024-11-20 21:43:06作者:雪饮
![[!--pagekey--]](/e/data/images/notimg.gif)
mapper接收参数
mapper中的sql如果要接收参数,例如id。
可以这样写
<select id="selectById" resultMap="brandResultMap">
select * from tb_brand where id=#{id};
</s
07-查询-查询所有&结果映射(POJO驼峰属性与数据库字段值不同步问题、sql标签(sql片段)、resultMap)
发布时间:2024-11-20 19:00:16作者:雪饮
![[!--pagekey--]](/e/data/images/notimg.gif)
statement的提示
在mapper中select标签内部编写sql时候直接输入sel然后回车就会有sql提示(理论上),实际上我这里发现没有出现。
mapper的namespace与select的resultType
<mappe