mybatis通配符引用报错的问题XML fragments parsed from previous mappers does not contain value
来源:互联网 发布:今日特价淘宝网 编辑:程序博客网 时间:2024/06/07 19:50
写mapper A的时候,发现内容太长,于是把被引用的refid单独抽出来成为一个新的mapper文件,A中只保留了直接对外的接口申请了,于是就有了mapper B 文件。
在A文件里面引用B的sql,如:
<include refid="B.where_1" />
结果报错:
org.apache.ibatis.builder.IncompleteElementException: Could not find SQL statement to include with refid 'A.where_2'
at org.apache.ibatis.builder.xml.XMLIncludeTransformer.findSqlFragment(XMLIncludeTransformer.java:104)
at org.apache.ibatis.builder.xml.XMLIncludeTransformer.applyIncludes(XMLIncludeTransformer.java:64)
at org.apache.ibatis.builder.xml.XMLIncludeTransformer.applyIncludes(XMLIncludeTransformer.java:87)
at org.apache.ibatis.builder.xml.XMLIncludeTransformer.applyIncludes(XMLIncludeTransformer.java:75)
at org.apache.ibatis.builder.xml.XMLIncludeTransformer.applyIncludes(XMLIncludeTransformer.java:87)
at org.apache.ibatis.builder.xml.XMLIncludeTransformer.applyIncludes(XMLIncludeTransformer.java:48)
at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:88)
at org.apache.ibatis.session.Configuration.buildAllStatements(Configuration.java:760)
Caused by: java.lang.IllegalArgumentException: XML fragments parsed from previous mappers does not contain value for A.where_2
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:860)
at org.apache.ibatis.builder.xml.XMLIncludeTransformer.findSqlFragment(XMLIncludeTransformer.java:101)
... 69 more
后来发现 B文件中B.where_1引用了<include refid="where_2" />,原来是在引用的时候没有加前缀,改成<include refid="B.where_2" />这样就可以了.
最终是这样的:
A文件:
<select id="getCount" resultMap="BaseResultMap">
select count(*)
from X a
<include refid="B.where_1" />
B文件:
<sql id="where_1">
where a.id =#{id,jdbcType=VARCHAR}
<include refid="B.where_2" />
</sql>
<sql id="where_2">
a.name =#{name,jdbcType=VARCHAR}
</sql>
B文件最开始where_1中引用where_2时没有加B.的前缀,所有报错了。原来where_1在引入到A文件后,直接把where_2也引用过去了,然后相当于是A文件引用的where_2.- mybatis通配符引用报错的问题XML fragments parsed from previous mappers does not contain value
- 发现个Mybatis的bug: XML fragments parsed from previous mappers does not contain value for
- XML fragments parsed from previous mappers does not contain value for ……
- XML fragments parsed from previous mappers does not
- XML fragments parsed from previous mappers already contains value for
- XML fragments parsed from previous mappers already contains value for
- XML fragments parsed from previous mappers already contains value for
- XML fragments parsed from previous mappers already contains value for
- Cause: java.lang.IllegalArgumentException: XML fragments parsed from previous mappers does not cont
- 关于XML fragments parsed from previous mappers already contains value for
- XML fragments parsed from previous mappers already contains value for com.mybatis_test.dao.StudentMa
- XML fragments parsed from previous mappers already contains
- mybatis报错does not contain value for
- mybatis报错Mapped Statements collection does not contain value for com.inter.IOperation.getAllItems
- spring+mybatis项目搭建测试报错Mapped Statements collection does not contain value for
- java MyBatis报错Parameter Maps collection does not contain value for xxx
- Spring+Mybatis整合报错Mapped Statements collection does not contain value原因之一
- Mybatis报错—— Mapped Statements collection does not contain value for com.mapper.DepartmentMapper
- $arr['key'] 与 $arr["key"] 与 $arr[key]的差别:
- 快速理解观察者模式
- Cookie(一)
- JVM学习笔记(二)------Java代码编译和执行的整个过程
- 四、(一)qt连接数据库-简单篇
- mybatis通配符引用报错的问题XML fragments parsed from previous mappers does not contain value
- 面试小结2
- ipconfig命令
- ipv4到ipv6的过渡
- 图解数据库优化(一)
- 打印所有不超过n(n<256)的,其平方具有对称性质的数。
- 你需要知道的Android View的绘制
- nginx access.log format 允许的变量
- 【poj2774】 后缀数组最长公共子串