解决一个分表之后出现的查询报错问题

 

做了分表之后,原先的底层sql语句查询开始出现问题。

sql语句:
select xxx from table a
LEFT JOIN table b
where a.列x = #{参数名}

报了 Cause: e: groovy.lang.MissingMethodthodException: No signature of method: d: java.lang.String.mod() i() is applicable for argument types: (: (java.lang.Integer) va) values: [10]

解决方法:
我们是按照列x对表a进行的分表,以列x的尾数对a表拆成了10张表。个人判断出的这个问题很可能是传入的String类型参数无法让系统判断其尾数。
所以把#改成$,或者后面加''强制转换String就解决了....
select xxx from table a
LEFT JOIN table b
where a.列x = ${参数名}

或者

select xxx from table a 
LEFT JOIN table b 
where a.列x = #{参数名}+'' 

也可以

 

posted @ 2018-10-12 11:22  rock_turf  阅读(548)  评论(0编辑  收藏  举报