Mybatisplus-plus 1.1.0がリリースされ、プライマリキーを組み合わせた複数のフィールドに従って、追加、削除、変更、およびチェックが行われます。

ネイティブmybatisplusは1つのプライマリキーのみをサポートし、mppは複数のフィールドをサポートして、複数のフィールドの結合されたプライマリキーを追加、削除、変更、およびチェックします。マッパーは、@ MppMultiIdアノテーションで変更する必要があるMppBaseMapperエンティティクラスの結合されたプライマリキーのフィールドを継承する必要があります。

インスタンスクラスのメンバー変数で@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);
    }

おすすめ

転載: www.oschina.net/news/124875/mybatisplus-plus-1-1-0-released