`

mybatis错误 Mapped Statements collection does not contain value for

阅读更多

[根源]

mybatis错误 Mapped Statements collection does not contain value for

(2012-07-27 18:05:58)
标签:

杂谈

分类: mybatis

<!-- 正文开始 -->

可能有两个原因
1:
mybatis错误 <wbr>Mapped <wbr>Statements <wbr>collection <wbr>does <wbr>not <wbr>contain <wbr>value <wbr>for
2:

mybatis错误 <wbr>Mapped <wbr>Statements <wbr>collection <wbr>does <wbr>not <wbr>contain <wbr>value <wbr>for
[同样的情况]

Mapped Statements (result....)collection does not contain value for...(mybatis-spring)

分类: java Exception 4873人阅读 评论(3) 收藏 举报

1、
在进行SS+mybatis结合的时候 经常会遇到这样的错误(Mapped Statements collection does not contain value for...

从字面上的意思很难理解和定位是哪里出错了, 经过不探索果然功夫不负有心人,其实是命名空间引入错了

正确的引入应该把类名给引入进来 如下:

 

[html] view plaincopy
 
  1. <?xml version="1.0" encoding="UTF-8" ?>    
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">   
  3. <mapper namespace="com.mochasoft.proscenium.dao.AutocompleteDao">  
  4.     <resultMap type="searchHistory" id="searchHistoryMap">  
  5.         <result column="word" property="word"/>  
  6.         <result column="search_count" property="seachCount"/>  
  7.     </resultMap>  
  8.     <select id="getSearchHistoryByTerm" resultMap="searchHistoryMap" parameterType="String">  
  9.        select word, search_count  
  10.         from v_search_history  
  11.         where word like #{term}  
  12.         order by search_count  
  13.     </select>  
  14. </mapper>  


 

这样它就会寻找com.mochasoft.proscenium.dao.AutocompleteDao类下面的getSearchHistoryByTerm方法 

 

2、

    还有一种跟这个类似的错误:Result Maps collection does not contain value for。。。

出现这个错误 主要是因为你的select标签内部的resultMap属性 指向的不正确

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics