![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Mybatis
爱智慧的打工人
我只知道一件事,就是我一无所知
展开
-
SpringBoot整合Mybatis
SpringBoot整合Mybatis1.在pom文件中引入依赖2.配置数据库连接信息3.创建user表4.创建实体Bean5.编写Mapper6.配置Mapper映射文件7.在application.properties中添加mybatis的信息8.编写测试Controller9.测试1.在pom文件中引入依赖<!--mybatis起步依赖--> <dependency&...原创 2020-03-15 23:49:55 · 58 阅读 · 0 评论 -
Mybatis注解设置自增主键
@Insert(value = "INSERT INTO category (cat_name,cat_sort,is_enable) " + "VALUES (#{catName},#{catSort},#{isEnable})") //设置主键自增 @Options(useGeneratedKeys = true,keyProperty = "catId...原创 2020-03-14 21:18:46 · 1520 阅读 · 0 评论 -
使用Mybatis注解查询时,映射数据库字段
使用Results注解@Select(value = "SELECT * FROM category WHERE cat_id = #{catId}") @Results({ @Result(id=true, column = "cat_id", property = "catId"), @Result(column = "cat_name...原创 2020-03-14 21:13:59 · 3153 阅读 · 1 评论 -
Mybatis注解中使用if标签
在SQL语句中加入@Select({ "<script>" , "SELECT COUNT(*) FROM category", "<if test='query != null and query != \" \" '>", "where cat_name like '%${q...原创 2020-03-14 21:10:00 · 9298 阅读 · 0 评论