![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
#mybatis
软件宫城狮
低生活饲养着高科技,高科技创造着低生活,循环往复,难以挣脱。
展开
-
SQL 使用记录
【代码】SQL 使用记录。原创 2023-02-15 10:46:26 · 25774 阅读 · 0 评论 -
mybatisplus使用generator
mybatisplus使用generator生成代码mybatis-plus代码生成器,生成实体,mapper,mapper.xml,service,serviceImpl,controller演示例子,执行 main 方法控制台输入表名回车自动生成对应项目目录中(目录要需要自行修改)所需要maven依赖 <!-- 引入mybatis-plus-generator依赖 --> <dependency> <groupI原创 2021-09-15 17:42:17 · 327112 阅读 · 3 评论 -
mybatis-puls中把List数据分页
用的mybatis-plus做的分页,写了一个单独的方法public static Page getPages(Integer currentPage, Integer pageSize, List list){ Page page = new Page(); int size = list.size(); if(pageSize > size){ pageSize = size; } /原创 2021-04-29 17:32:13 · 335607 阅读 · 2 评论 -
mybatis-plus在mapper.xml中用Group By 出现的问题
我的错误是Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Method queryTotal execution error of sql : 这些是sql语句首先 sql语句在数据库里直接运行是没有问题的,而且在我的本地运行项目也没有报这种错误,到了服务器上就会报错,我本地和服务器环境一致,这种问题也是出现多次了经历了三个小时的反复测试终于成功我修改后的mapper文件<?xml v原创 2021-01-07 20:24:46 · 337542 阅读 · 0 评论 -
mybatisplus saveBatch批量插入数据提升效率
做批量导入的时候有上万条数据需要插入到库里用saveBatch(list)的效率不忍直视插入1000条数据大概需要10s8000多条数据就直接原地升天解决方法也很简单rewriteBatchedStatements=true数据库连接参数配置 rewriteBatchedStatements=truemaster.jdbc.url=jdbc:mysql://127.0.0.1:3306/outreach_platform?useUnicode=true&characterEncodi原创 2021-01-07 16:28:59 · 340851 阅读 · 0 评论 -
mybatis添加返回主键
mybatis添加返回主键两种方法 <!--返回主键方法一--> <insert id="save" parameterType="baidu.com.pojo.THobby" useGeneratedKeys="true" keyProperty="hid"> insert into t_hobby set hobby=#{hobby} ...原创 2019-11-23 23:02:51 · 330701 阅读 · 0 评论 -
设置mybatis一次执行多条sql语句
jdbc连接添加 allowMultiQueries=true 就可一次执行多条sqluseUnicode=true&characterEncoding=utf8 是为了防止乱码jdbc.url=jdbc\:mysql\://localhost\:3306/yuangonguseUnicode=true&characterEncoding=utf8&allowM...原创 2019-11-19 17:45:42 · 327335 阅读 · 0 评论 -
Mybatis文件配置和入门程序
mybatis入门程序导入jar包从mybatis管网下载(地址:https://github.com/mybatis/mybatis-3/releases)工程结构log4j.properties(公用文件)用于查看日志#Global logging configuration,建议开发环境中要用debuglog4j.rootLogger=DEBUG, stdout#Cons...原创 2019-11-18 20:57:10 · 309216 阅读 · 0 评论 -
mybatis动态sql和resultMap关联查询
动态Sqlif和where动态sql parameterType的类型必须是 实体类 test 中判断的属性必须是 实体类的属性<select id="findAllOrBy" parameterType="com.baidu.pojo.TbUser" resultType="com.baidu.pojo.TbUser"> select * from ...原创 2019-11-19 17:38:12 · 326762 阅读 · 0 评论