Mybatis批量插入并且返回对应的ID

mapper:

int addCustomizedData(@Param("a") Integer a, @Param("b") Integer b, @Param("list") List list);

xml:


        INSERT INTO tbl_ext (
            name, 
            age
            ) VALUES
        
            
                #{name}, 
                #{age}
            
        
    
注意:keyProperty="list.id"。id为list中对象中的id属性。我定义的mapper中有多个参数,如果只指定id的话,会报错。
如果只有一个list参数,那直接使用keyProperty="id" 也是可以。

你可能感兴趣的:(mybatis,java,服务器)