内容简介:需要在service使用多主键相关操作包括saveOrUpdateByMultiId和批量操作updateBatchByMultiId和saveOrUpdateBatchByMultiId,可以直接继承IMppService接口。 service层继承IMppService接口和MppServiceImpl publ...
需要在service使用多主键相关操作包括saveOrUpdateByMultiId和批量操作updateBatchByMultiId和saveOrUpdateBatchByMultiId,可以直接继承IMppService接口。
service层继承IMppService接口和MppServiceImpl
public interface Test07Service extends IMppService<Test07Entity> { } public class Test07ServiceImpl extends MppServiceImpl<Test07Mapper, Test07Entity> implements Test07Service { }
在service层根据复合主键进行批量操作和saveOrUpdate操作
@Test public void testSaveOrUpdateByMultiIdService(){ //id Test07Entity idEntity=new Test07Entity(); idEntity.setK1(6); idEntity.setK2("666"); //del test07Service.deleteByMultiId(idEntity); //add test07Service.saveOrUpdateByMultiId(idEntity); //update idEntity.setCol1("ccccc"); test07Service.saveOrUpdateByMultiId(idEntity); } @Test public void testSaveOrUpdateBatchByMultiIdService(){ //ids List<Test07Entity> entityList=new ArrayList<Test07Entity>(); for(int i=10;i<30;i++){ Test07Entity idEntity=new Test07Entity(); idEntity.setK1(i); idEntity.setK2(String.valueOf(i*10)); entityList.add(idEntity); } //del for(Test07Entity idEntity:entityList) { test07Service.deleteByMultiId(idEntity); } //add batch test07Service.saveOrUpdateBatchByMultiId(entityList); //del for(Test07Entity idEntity:entityList) { idEntity.setCol1(new Date().toString()); } //update batch test07Service.saveOrUpdateBatchByMultiId(entityList); } @Test public void testUpdateBatchByMultiIdService(){ //ids List<Test07Entity> entityList=new ArrayList<Test07Entity>(); for(int i=50;i<80;i++){ Test07Entity idEntity=new Test07Entity(); idEntity.setK1(i); idEntity.setK2(String.valueOf(i*10)); entityList.add(idEntity); } //del for(Test07Entity idEntity:entityList) { test07Service.deleteByMultiId(idEntity); } //add batch test07Service.saveOrUpdateBatchByMultiId(entityList); //del for(Test07Entity idEntity:entityList) { idEntity.setCol1(new Date().toString()); } //update batch test07Service.updateBatchByMultiId(entityList); }
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- Mybatisplus-plus 1.3.1 发布,新增服务层根据复合主键 CRUD 操作
- MongoDB指南---10、索引、复合索引 简介
- 为什么要有复合索引?
- python – Django或类似的复合主键
- 复合设计模式(Composite Design Pattern)
- GO的第五天,复合数据类型---数组、Slice
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
第一本Docker书 修订版
詹姆斯·特恩布尔 (James Turnbull) / 李兆海、刘斌、巨震 / 人民邮电出版社 / 2016-4-1 / CNY 59.00
Docker是一个开源的应用容器引擎,开发者可以利用Docker打包自己的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器上,也可以实现虚拟化。 本书由Docker公司前服务与支持副总裁James Turnbull编写,是Docker开发指南。本书专注于Docker 1.9及以上版本,指导读者完成Docker的安装、部署、管理和扩展,带领读者经历从测试到生产的整个开发生......一起来看看 《第一本Docker书 修订版》 这本书的介绍吧!