Mybatisplus-plus 1.3.1 发布,新增服务层根据复合主键 CRUD 操作
2021年1月10日 | by tgcode
Mybatisplus-plus 1.3.1新增在service层操作复合主键进行增删改查相关操作的功能。
**从中央库引入jar** ```` com.github.jeffreyning mybatisplus-plus 1.3.1-RELEASE ````
在实例类成员变量上使用@MppMultiId表明联合主键
````
@TableName("test07")
public class Test07Entity {
@MppMultiId
@TableField(value = "k1")
private Integer k1;
@MppMultiId
@TableField(value = "k2")
private String k2;
@TableField(value = "col1")
private String col1;
@TableField(value = "col2")
private String col2;
````
mapper需要继承MppBaseMapper
````
@Mapper
public interface Test07Mapper extends MppBaseMapper {
}
````
````
service层继承IMppService
````
public interface Test07Service extends IMppService {
}
@Service
public class Test07ServiceImpl extends ServiceImpl implements Test07Service {
}
````
在service层调用多主键操作
````
public void testMultiIdService(){
//id
Test07Entity idEntity=new Test07Entity();
idEntity.setK1(1);
idEntity.setK2("111");
//del
test07Service.deleteByMultiId(idEntity);
//add
test07Service.save(idEntity);
//query
Test07Entity retEntity=test07Service.selectByMultiId(idEntity);
retEntity.setCol1("xxxx");
//update
test07Mapper.updateByMultiId(retEntity);
}
````
本站新闻禁止未经授权转载,违者依法追究相关法律责任。授权请联系:oscbianji#oschina.cn
本文标题:Mybatisplus-plus 1.3.1 发布,新增服务层根据复合主键 CRUD 操作
本文地址:https://www.oschina.net/news/126098/mybatisplus-plus-1-3-1-released
2 收藏
分享
热门文章
2020 年的最后 1 天,知乎热榜上出现这样一个话题:如何看待快手将于 2021 年 1 月 10 日全员开启大小周?“大小周”是互联网行业近几年新流行的用工制度,不同于劳动法对于一周五个工作日,两个休息日的法律规定。一些互联网企业采取一个星期上六天班,…