SpringBoot-MyBatis注解
增删改查注解
把在xml里面写的内容写到注解当中,Results相当于ResultMap,有些列名与Java的属性名不一致,数据无法线束,
用results解决,中间用,分割
@Results({
@Result(id = true,column = "列名",property = "属性名"),
@Result(id = false, column = "列名",property = "属性名")
})
id 如果不是主键那么设置为false,如果id 是主键 那么设置为true;
column 是数据库中列的名称
property 是java中model类的属性名
@Select("select * from function")
@Results({
@Result(id = true,column = "id",property = "id"),
@Result(id = false, column = "is_effective",property = "isEffective")
})
public List<Function> findAll();
@Delete("delete from function where id = #{id}")
public void deleteById(Integer id);
@Insert("insert i