hyanqing1
hyanqing1
2011-08-14 14:46
浏览 1.4k
已采纳

mybatis3出现Could not find SQL statement to include with refid 异常

采用spring3和mybatis3及mybatis-spring整合做了个实例,在做分页的时候,由于要两条SQL语句:一条查询总记录数,一条是查找当前页的数据,所以采用mybatis3中的标签,如:
[code="java"]
student s,classinfo c where s.cid=c.cid

<select id="findCount" resultType="long">
    select count(*) from <include refid="page_where"/>
</select>

<select id="find" resultMap="studentMap">
    select s.sid,s.cid,s.sno,s.sname,s.sex,s.birthday,c.cname from <include refid="page_where"/>
</select>

[/code]
运行就抛出如下错误:
[code="java"]org.apache.ibatis.builder.xml.IncompleteStatementException: Could not find SQL statement to include with refid[/code]
[code="java"]严重: Servlet.service() for servlet SpringMVC threw exception
java.lang.IllegalArgumentException: XML fragments parsed from previous mappers does not contain value for com.hyq.showcase.mapper.StudentMapper.page_where[/code]
在网上查询,出现错误的答案是ibatis2,是在在 sqlmap-config.xml 中 中添加 useStatementNamespaces="true",而3中是不用的,谢谢各位大侠!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐