Mybatisplus-plus 1.1.0 发布,根据多个字段联合主键增删改查

栏目: 软件资讯 · 发布时间: 5年前

内容简介:原生mybatisplus只支持一个主键,mpp支持多个字段联合主键增删改查,mapper需要继承MppBaseMapper实体类中联合主键的字段,需要用@MppMultiId注解修饰 在实例类成员变量上使用@MppMultiId表明联合主键 @TableNa...

原生mybatisplus只支持一个主键,mpp支持多个字段联合主键增删改查,mapper需要继承MppBaseMapper实体类中联合主键的字段,需要用@MppMultiId注解修饰

在实例类成员变量上使用@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<Test07Entity> {
}
​​​​​​​
根据多主键增删改查
    public void testMultiId(){
        //id
        Test07Entity idEntity=new Test07Entity();
        idEntity.setK1(1);
        idEntity.setK2("111");
        //del
        test07Mapper.deleteByMultiId(idEntity);
        //add
        test07Mapper.insert(idEntity);
        //query
        Test07Entity retEntity=test07Mapper.selectByMultiId(idEntity);
        retEntity.setCol1("xxxx");
        //update
        test07Mapper.updateByMultiId(retEntity);
    }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

C++编程思想

C++编程思想

埃克尔(美) / 刘宗田/等 / 机械工业出版社 / 2000-01 / 39.00

一起来看看 《C++编程思想》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具