初
我习惯使用@Param注解在mapper方法中修改参数映射名称;
而在查询之后的结果,用sql 别名的形式来代替繁琐的@ResultMap注解;
但是经常用@Param注解,会导致我习惯写mapper.xml时,里面的注入参数名称和外部的mapper接口的参数名称不一致。
如果参数都在mapper的方法中都还好。但是如果遇到插入字段较多,要使用po对象来承载需要insert的内容的时候,就出现麻烦事了,@Param注解是不能在类对象的属性中使用的!所以尽量少使用@Param注解,在sql 中写#{}注入参数名的时候,就把参数名正确对应,只在注入List的时候必须使用@Param注解的时候才使用。
注入list时
mapper中
List<SuperVo> getSuperList(@Param("superIdList") List<Integer> superIdList);
xml中
<select id="getSuperList" resultType="