当参数是一个JavaBean时,如果不用@Param且sql里获取变量用#{},如
@Select("SELECT id,USERNAME,uname from uk_user where del = 0 LIMIT #{pageParam.pageStart}, #{pageParam.pageSize}")
List<UserVo> queryUserPageList(PageParam pageParam);
运行时会出现以下错误
但如果sql里获取变量用${},则可以直接引用JavaBean的属性,而且只能引用JavaBean的属性,如
@Select("SELECT id,USERNAME,uname from uk_user where del = 0 LIMIT ${pageStart}")
List<UserVo> queryUserPageList(PageParam pageParam);
如果想用#{}在sql里获取变量,则必须要加上@Param,如
@Select("SELECT id,USERNAME,uname from uk_user where del = 0 LIMIT #{pageParam.pageStart}, #{pageParam.pageSize}")
List<UserVo> queryUserPageList(@Param("pageParam") PageParam pageParam);
或者不用@Param,引用JavaBean的属性,如
@Select("SELECT id,USERNAME,uname from uk_user where del = 0 AND username like CONCAT('%',#{userName},'%')")
List<UserVo> queryUserPageList(UserQo userQo);