<insert id="insert" parameterType="com.biye.pojo.TbContentCategory" >
**<selectKey keyProperty="id" resultType="long" order="AFTER">
SELECT LAST_INSERT_ID()
</selectKey>**
insert into tb_content_category (id, parent_id, name,
status, sort_order, is_parent,
created, updated)
values (#{id,jdbcType=BIGINT}, #{parentId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR},
#{status,jdbcType=INTEGER}, #{sortOrder,jdbcType=INTEGER}, #{isParent,jdbcType=BIT},
#{created,jdbcType=TIMESTAMP}, #{updated,jdbcType=TIMESTAMP})
</insert>
使用mybatis逆向工程生产的代码返回主键信息
最新推荐文章于 2023-04-18 13:41:09 发布
本文深入探讨了MyBatis Plus框架中SQL注入的风险,解析了<insert>标签内动态SQL的潜在安全漏洞,特别是<selectKey>元素在获取最后插入ID时可能引入的安全隐患。文章提供了代码示例,帮助开发者理解如何避免此类问题。
14万+

被折叠的 条评论
为什么被折叠?



