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

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条回答 默认 最新

  • myali88 2011-08-14 22:52
    关注

    mybatis 3 具体是什么版本? [url]http://code.google.com/p/mybatis/issues/detail?id=250[/url]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请求分析基于spring boot+vue的前后端分离的项目
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?