![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
Mybatis
Mybatis
zhanghe_zht
这个作者很懒,什么都没留下…
展开
-
Mybatis原理
2、加载映射文件:映射文件即 SQL 映射文件,该文件中配置了操作数据库的 SQL 语句,需要在 MyBatis 配置文件 mybatis-config.xml 中加载。6、MappedStatement 对象:在 Executor 接口的执行方法中有一个 MappedStatement 类型的参数,该参数是对映射信息的封装,用于存储要映射的 SQL 语句的 id、参数等信息。7、输入参数映射:输入参数类型可以是 Map、List 等集合类型,也可以是基本数据类型和 POJO 类型。原创 2023-03-29 15:40:55 · 65 阅读 · 0 评论 -
Mybatis配置对多一关系
Mybatis配置对多一关系:<resultMap type="com.xxx.EventProgressVO" id="myResultMap"> <id property="id" column="id"/> <result property="level" column="level"/> <result property="reason" column="reason"/> <result原创 2022-03-12 13:52:28 · 238 阅读 · 0 评论 -
mybatis批量插入
void insertBatch(@Param("list") List<PO> list); <insert id="insertBatch" parameterType="java.util.List"> insert into table (id,name) values <foreach collection="list" item="item" index="index" separator=",">原创 2021-11-24 16:17:16 · 180 阅读 · 0 评论 -
mybatis-plus,insert数据的id特别大
首先删除表数据TRUNCATE table #{tableName}然后在配置文件添加:mybatis-plus.global-config.db-config.id-type=auto原创 2021-08-22 15:23:07 · 2137 阅读 · 0 评论 -
Mybatis 开启驼峰命名不生效
在application.properties里配置mybatis.configuration.map-underscore-to-camel-case=true发现没有生效,没有成功映射到数据对象中,都是null原因:手动配置了数据库连接解决办法:在数据库配置类中配置:@Bean@ConfigurationProperties(prefix = "mybatis.configuration")public org.apache.ibatis.session.Configuration g原创 2021-07-09 17:20:48 · 5206 阅读 · 1 评论 -
idea Mybatis工具:Free Mybatis plugin
https://blog.csdn.net/sm16111/article/details/105937873转载 2021-05-21 19:33:20 · 347 阅读 · 0 评论 -
Mybatis开启驼峰命名映射
数据库里经常用 _ 命名变量,例如:user_name。而Java实体类经常用驼峰命名,例如userName。如果想要让mybatis自动开启下划线到驼峰命名映射,需要在application配置文件来配置:mybatis.configuration.map-underscore-to-camel-case=true...原创 2021-04-22 19:43:06 · 410 阅读 · 0 评论 -
Mybatis的mapper.xml文件不放在resource里,pom文件配置
有些人习惯把mapper.xml文件放在java文件夹下面,和mapper的interface放到一起,不放倒resource里,方便查看。这样的话需要在pom文件添加:<build> <resources> <resource> <directory>src/main/java</directory> <includes> &原创 2021-04-13 10:46:49 · 3614 阅读 · 2 评论 -
Mybatis融合Mybatis-plus
MyBatis-Plus是一个 MyBatis的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。在springboot的基础上,pom文件导入:<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.2</ve原创 2021-04-13 10:31:41 · 344 阅读 · 0 评论 -
Mybaits sql中使用变量的方法
Mapper:@MapperScanpublic interface CentralMapper { ServiceInfo get(@Param("name") String name);}Sql:1:#{xxx}select name from Service where name like #{name}2:${xxx}select name from Service where name like '%${filter}%'原创 2020-06-08 16:41:18 · 897 阅读 · 0 评论 -
Mybatis 传入一个数组,判断某个字段在数组里
Mapper:List<xxx> getAll(@Param("platformArray") String[] platformArray);Sql:select * from xx where<if test="platformArray != null and platformArray.length > 0"> Platform IN <foreach collection="platformArray" index="index" it原创 2020-06-08 16:48:23 · 4771 阅读 · 0 评论