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);
    }

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

查看所有标签

猜你喜欢:

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

Lean Analytics

Lean Analytics

Alistair Croll、Benjamin Yoskovitz / O'Reilly Media / 2013-3-18 / USD 29.99

If you're involved with a startup, analytics help you find your way to the right product and market before the money runs out. But with a flood of information available, where do you start? This book ......一起来看看 《Lean Analytics》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具