mybatis踩坑-IncompleteElementException

org.apache.ibatis.builder.IncompleteElementException: Could not find SQL statement to include with refid ‘com.ssm.crud.mapper.EmployeeMapper.WithDept_Column_List

at org.apache.ibatis.builder.xml.XMLIncludeTransformer.findSqlFragment(XMLIncludeTransformer.java:90)

这句话报错的意思是,sql映射文件中:没有定义说明 WithDept_Column_List语句的含义。比如在下面的配置文件中:SQL标签的语句一开始没有写,导致下面的select语句,无法解析导致报错了。

<!--  ****** 自定义的 带部门信息 的两种查询  ******  -->
<sql id="WithDept_Column_List">
  e.emp_id, e.emp_name, e.gender, e.email, e.d_id,d.dept_id,d.dept_name
</sql>

  <select id="selectByPrimaryKeyWithDept" resultMap="WithDeptResultMap">
   	select 
    <include refid="WithDept_Column_List" />
    FROM tbl_emp e
	left join tbl_dept d on e.`d_id`=d.`dept_id`
    where emp_id = #{empId,jdbcType=INTEGER}
  </select>

 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments