错误一
mybatis方法多个参数时报错:Caused by: org.apache.ibatis.binding.BindingException: Parameter ‘xxx’ not found
当在mybatis框架中使用的查询语句中包含多个参数 :
这个坑让我踩了半天
解决方法
为方法中的参数加上注解指定参数 @Param,上图问题已解决
错误二
MyBatis之java.lang.UnsupportedOperationException异常解决方案
今天在使用MyBatis执行sql语句时,出现如下异常:
执行的sql语句配置信息如下:
select t.column_name from user_tab_columns t where t.tableName=#{tableName,jdbcType=VARCHAR}对应的dao接口代码为:
public List getColumnsByTableName(String tableName);
应该改为:
select t.column_name from user_tab_columns t where t.tableName=#{tableName,jdbcType=VARCHAR}
原因就在于resultType代表的是List中的元素类型,而不应该是List本身,究其原因就在于被dao中的方法声明(标红出)
public List getColumnsByTableName(String tableName);
给迷惑住了