當參數是一個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
但若是sql裏獲取變量用${},則能夠直接引用JavaBean的屬性,並且只能引用JavaBean的屬性,如
@Select("SELECT id,USERNAME,uname from uk_user where del = 0 LIMIT ${pageStart}")
List<UserVo> queryUserPageList(PageParam pageParam);spa
若是想用#{}在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);blog
或者不用@Param,引用JavaBean的屬性,如
@Select("SELECT id,USERNAME,uname from uk_user where del = 0 AND username like CONCAT('%',#{userName},'%')")
List<UserVo> queryUserPageList(UserQo userQo);變量