Skip to content

Bug when namespace starts with a space #2302

@Fudeveloper

Description

@Fudeveloper

MyBatis version

3.5.8-SNAPSHOT

Database vendor and version

mysql 5.7.3

Test case or example project

Test case XmlMapperBuilderTest#mappedStatementWithoutOptionsWhenSpecifyDefaultValue.

  @Test
  void mappedStatementWithoutOptionsWhenSpecifyDefaultValue() throws Exception {
    Configuration configuration = new Configuration();
    configuration.setDefaultResultSetType(ResultSetType.SCROLL_INSENSITIVE);
    String resource = "org/apache/ibatis/builder/AuthorMapper.xml";
    InputStream inputStream = Resources.getResourceAsStream(resource);
    XMLMapperBuilder builder = new XMLMapperBuilder(inputStream, configuration, resource, configuration.getSqlFragments());
    builder.parse();
    inputStream.close();

    MappedStatement mappedStatement = configuration.getMappedStatement("selectAuthor");
    assertThat(mappedStatement.getResultSetType()).isEqualTo(ResultSetType.SCROLL_INSENSITIVE);
  }
<mapper namespace=" org.apache.ibatis.domain.blog.mappers.AuthorMapper">
  ...
</mapper>

Steps to reproduce

  1. Make the namespace start with a space.
  2. Execute the test case.

Expected result

The test case ends normally

Actual result

The program threw the following error.

org.apache.ibatis.builder.IncompleteElementException: Could not find result map ' org.apache.ibatis.domain.blog.mappers.AuthorMapper.selectComplexImmutableAuthor' referenced from ' org.apache.ibatis.domain.blog.mappers.AuthorMapper.selectComplexAuthors' at org.apache.ibatis.builder.MapperBuilderAssistant.getStatementResultMaps(MapperBuilderAssistant.java:396)
at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:285)
at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:113)
at org.apache.ibatis.session.Configuration.lambda$buildAllStatements$2(Configuration.java:885)
at java.util.Collection.removeIf(Collection.java:414)
at org.apache.ibatis.session.Configuration.buildAllStatements(Configuration.java:884)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:822)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:817)
at org.apache.ibatis.builder.XmlMapperBuilderTest.mappedStatementWithOptions(XmlMapperBuilderTest.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions