zhxn

今天在使用MyBatis执行sql语句时,出现如下异常:

执行的sql语句配置信息如下:

<select id="getColumnsByTableName" parameterType="String" resultType="java.util.List">
      select t.column_name from user_tab_columns t where t.tableName=#{tableName,jdbcType=VARCHAR}
</select>

对应的dao接口代码为:

public List<String> getColumnsByTableName(String tableName); 

应该改为:

<select id="getColumnsByTableName" parameterType="String" resultType="String">      
select t.column_name from user_tab_columns t where t.tableName=#{tableName,jdbcType=VARCHAR}
</select>

原因就在于resultType代表的是List中的元素类型,而不应该是List本身,究其原因就在于被dao中的方法声明(标红出)

public List<String> getColumnsByTableName(String tableName);

给迷惑住了

切记:resultType返回的是集合中的元素类型,而不是集合本身

分类:

技术点:

相关文章:

  • 2021-09-07
  • 2019-01-15
  • 2021-12-01
  • 2021-11-07
  • 2021-05-28
  • 2021-10-12
猜你喜欢
  • 2021-11-06
  • 2021-10-18
  • 2021-05-20
  • 2022-01-22
  • 2021-08-03
  • 2021-08-13
  • 2021-06-30
相关资源
相似解决方案