我如何在mybatis中处理这个多参数问题

时间:2018-02-27 15:38:58

标签: mybatis

我尝试使用mabatis的映射器编写查询但是到目前为止还不能

这是我的代码

String SQL_SELECTPAGE = "select b.writer, b.title, b.topicdate, b.lecturekey, b.tcontent" +
        "from (select rownum rn, a.* from (select * from topics WHERE LECTUREKEY = #{lid}" +
        "order by topicdate desc) a) b" +
        "where rn between #{c.start} and #{c.end}";

@Select(SQL_SELECTPAGE)
List<Topics> selectPage(@Param("lid") String lid, @Param("c") PaginationCriteria c);

PaginationCriteria具有开始和结束属性。

以下是HTTP状态500错误消息。我认为参数无法通过

  

...在哪里LECTUREKEY =?按主题日期命令desc)a)b between介于两者之间?和? &GT; ###原因:java.sql.SQLSyntaxErrorException:ORA-00936:

如果有人可以帮助我,我会很高兴

谢谢

1 个答案:

答案 0 :(得分:0)

您不能对行号子句使用JDBC绑定参数。在MyBatis中,使用#{...}指定的任何内容都是绑定参数。您指定为${...}的任何内容基本上都是字符串替换,应该可以在这里使用。

所以重写你的where子句,如where rn between ${c.start} and ${c.end}

相关问题