Mybatis 新增/批量新增, 拿到返回的自增主键ID

单个新增 :



    /**
     * 插入菜单
     * @param menuInfo
     * @return
     */
    int  insertMenuInfo(MenuInfo menuInfo);


xml:

 

核心是 :


  keyProperty="id" useGeneratedKeys="true"

Mybatis 新增/批量新增, 拿到返回的自增主键ID_第1张图片

 


批量新增 :


int insertMenuInfoBatch(List menuInfoList );

xml:

也是一样的

Mybatis 新增/批量新增, 拿到返回的自增主键ID_第2张图片

你可能感兴趣的:(Mybatis,mybatis,java,数据库,spring,boot)