Mybatis 注解形式
2024-10-09 13:24:30
1.查询
// 查询
@Select("select id, name, type, numbers, cancelled, completed, percentage from customer_list")
List<CustomerList> selectCustomerListAll(); //多表联查
//所有的关联实体类必须引入此注解 @JsonIgnoreProperties(value = {"handler","hibernateLazyInitializer","fieldHandler"})
@Select("select id, user_name, remarks, service_id, from jurisdiction_role ")
@Results(id="resultMap", value = {
@Result(column = "id" , property = "id" ,id=true),
@Result(column = "user_name" ,property = "user_name"),
@Result(column = "remarks",property = "remarks"),
@Result(property = "service_id",column = "service_id" , //com.cn.test.mapper.JurisdictionServiceMapper.selectJurisdictionServiceOneId 引入的此mapper必须实现此查询方法
many = @Many(select = "com.cn.test.mapper.JurisdictionServiceMapper.selectJurisdictionServiceOneId",
fetchType = FetchType.LAZY)),
})
List<JurisdictionRole> selectJurisdictionRoleAll(); //com.cn.test.mapper.JurisdictionServiceMapper.selectJurisdictionServiceOneId
@Select("select id, name, imports, repair_statistics, annual_completion_rate, work_order_statistics, app_amount, app_times, usage_statistics, " +
"satisfaction_survey, device_status from jurisdiction_service where id = #{id}")
JurisdictionService selectJurisdictionServiceOneId(Integer id);
2.修改
// 修改
@Update("<script> update customer_list set <if test = 'name != null'> name = #{name} ,</if>" +
"<if test = 'type != null'> type = #{type} ,</if>" +
"<if test = 'numbers != null'> numbers = #{numbers} ,</if>" +
"<if test = 'cancelled != null'> cancelled = #{cancelled} ,</if>" +
"<if test = 'completed != null'> completed = #{completed} ,</if>" +
"<if test = 'percentage != null'> percentage = #{percentage} ,</if>" +
"id = #{id} where id = #{id}</script>")
int updateCustomerListOneId(CustomerList customerList); 3.添加
@Insert("insert into jurisdiction_role (user_name, remarks, state)" +
"values (#{user_name}, #{remarks}, #{state})")
int insertIntoJurisdictionRoleIdOne(JurisdictionRole jurisdictionRole);
4.删除
@Delete("delete from locks where id = #{id}")
int deleteLocksOneId(Integer id);
注:以上内容仅供个人学习记录使用,如有问题,请慎用!
最新文章
- ASP.NET MVC Form验证
- Android 数据存储五种方式
- SVN迁移到Git的过程(+ 一些技巧)
- linux 中的斜杠 ‘/’ ‘\’ 的区别 - 服务器是LINUX的注意了, 和windows 的不一样哦!
- C#与XML Schema的问题
- 动态加载js,css
- struct--file_operations
- hdu 1800 Flying to the Mars
- JAVA 堆设置
- StringEscapeUtils.unescapeHtml的使用
- NSIndexPath 延伸
- Kettle 5.0源码编译
- .6-Vue源码之AST(2)
- JS 三目运算符和RETURN
- Struct_2路径问题
- vue实现商品购物车全选与全不选项目实战
- Intellij IDEA 阅读源码的 4 个绝技,我必须分享给你!
- zabbix学习笔记----安装----2019.03.26
- Sping boot和mybatis整合
- 用 python 生成一个简单的词云图
热门文章
- PDF的来源——概率密度函数
- eric4 中pyqt 字符串 输入 获取
- [Hei-Ocelot-Gateway ].Net Core Api网关Ocelot的开箱即用版本
- Kubernetes实战指南(三十三):都0202了,你还在手写k8s的yaml文件?
- 基础知识、DOS命令
- Jmeter系列(51)- 详解 Transaction Controller 事务控制器
- max user processes 导致的服务器大量close_wait问题解决过程
- Deep Learning-Based Video Coding: A Review and A Case Study
- 从零开始的SpringBoot项目 ( 三 ) 项目打包( jar包篇 )
- C# 解析获取Url参数值