Mybatis @Insert 注解获取自增ID

添加@Optios注解 

keyProperty 将自增的ID返回该属性
    @Insert("INSERT INTO admin_method_category (title,sort,icon_type) VALUES(#{category.name},#{category.sort},#{category.type})")
    @Options(useGeneratedKeys=true, keyProperty="category.id")
    void addCategory(@Param("category") Category category);

 

posted @ 2020-04-01 15:44  辰梓悦  阅读(1150)  评论(0编辑  收藏  举报