![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
MyBatis
唯爱沁源
这个作者很懒,什么都没留下…
展开
-
Oracle和MySQL插入数据后返回主键ID
一、MySQL1、mybatis.xml配置在insert标签中添加两个属性useGeneratedKeys="true"和keyProperty="id",其中keyProperty中的id为自己表的主键字段<insert id="" useGeneratedKeys="true" keyProperty="id"></insert>2、取值在Controller或者ServiceImpl中直接用插入对象的get方法二、Oracle1、通过序列自增长原创 2022-05-31 10:31:40 · 3464 阅读 · 0 评论 -
MyBatis的模糊查询mapper.xml的写法
模糊查询语句不建议使用${}的方式,还是建议采用MyBatis自带的#{}方式,#{}是预加载的方式运行的,比较安全,${}方式可以用但是有SQL注入的风险!!!1.直接传参在controller类中String id = "%"+ id +"%";String name = "%"+ name +"%";dao.selectByIdAndName(id,name);在map...原创 2018-11-05 09:50:44 · 32942 阅读 · 1 评论 -
dao层方法中的@Param说明
dao层 xxMapper.java1.采用@Param的方法可有多个参数public void abc(@Param("userName") String name,@Param("password") String passWord);而xxMapper.xml中的#{}中的参数则是根据@Param括号中的参数来获取相应的数据<select> ...原创 2018-10-26 16:20:07 · 10637 阅读 · 1 评论 -
MyBatisPlus全局配置
全局配置 此文件是根据Oracle数据库(可为其他数据库)表反向生成entity、mapper、service以及web(Controller)包及其配置文件package com;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;impo...原创 2018-07-03 08:58:19 · 13942 阅读 · 2 评论 -
MybatisPlus(MP)更新使用updateById无法更新空字段
情景:Spring-SpringMVC-MybatisPlus,编辑某个数据页面,将页面中的某个输入框中的内容清空,更新到数据库,采用MP的updateById方法无法更新,这里的无法更新是没有将空数据更新到数据库。例如:Account account= selectById(xxxx);//根据主键查询出需要修改的内容String param = request.getParamete...原创 2019-08-06 09:57:14 · 5053 阅读 · 0 评论 -
Cause: org.apache.ibatis.type.TypeException:Error setting null for parameter #1 with JdbcType OTHER
MybatisPlus采用updateById更新数据抛异常:Cause: org.apache.ibatis.type.TypeException:Error setting null for parameter #1 with JdbcType OTHER情景:Spring-SpringMVC-Mybatisplus,采用MybatisPlus的selectOne方法查询出数据,此数据某个...原创 2019-08-06 10:18:56 · 18124 阅读 · 0 评论