Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'p.knowlege_part_id...

MyBatis中,出现Unknown column的提示是mapper.xml中的数据库字段写错了。

错误示例:

XxMapper.xml中

 <sql id="KnowlegeSectionAndPart_Column_List">
    s.knowledge_section_id, s.create_time, s.update_time, s.section_name,
    s.repository_id, s.bool_close, p.knowlege_part_id, p.create_time,
    p.update_time, p.repository_id, p.section_id, p.bool_close, p.part_name
    sql>

    <select id="getKnowlegeSectionWithPartDOById" parameterType="java.lang.Long"
            resultMap="KnowlegeSectionWithPartResultMap">
        select
        <include refid="KnowlegeSectionAndPart_Column_List"/>
        from knowlege_section s
        where s.knowledge_section_id = #{sid,jdbcType=BIGINT}
    select>

报错:

  1 ### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'p.knowlege_part_id' in 'field list'
  2 ### The error may exist in file [D:\IDEACode\YiZhiDu\ChangJiangRiver\target\chang_jiang_river\WEB-INF\classes\com\hzy\mapper\KnowlegeSectionDOMapper.xml]
  3 ### The error may involve com.hzy.dao.KnowlegeSectionDOMapper.getKnowlegeSectionWithPartDOById-Inline
  4 ### The error occurred while setting parameters
  5 ### SQL: select               s.knowledge_section_id, s.create_time, s.update_time, s.section_name, s.repository_id, s.bool_close,p.knowlege_part_id, p.create_time, p.update_time, p.repository_id, p.section_id, p.bool_close, p.part_name               from knowlege_section s         where s.knowledge_section_id = ?
  6 ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'p.knowlege_part_id' in 'field list'
  7 ; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'p.knowlege_part_id' in 'field list'] with root cause
  8     com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'p.knowlege_part_id' in 'field list'
  9         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 10         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

你可能感兴趣的:(数据库,java,测试)