Mapper interfaces cannot have the class name as the XML file mapped to them
---------------------------------------------------------------------------

                 Key: IBATIS-625
                 URL: https://issues.apache.org/jira/browse/IBATIS-625
             Project: iBatis for Java
          Issue Type: Bug
          Components: SQL Maps
    Affects Versions: 3.0 Beta 1 
            Reporter: Christian Poitras


Mapper interfaces cannot have the same name as the XML mapped to them.

For example, an XML file mapper/PersonMapper.xml cannot be linked to a class 
named mapper.PersonMapper.

Doing so leads to an exception :
org.apache.ibatis.exceptions.IbatisException: 
### Error building SqlSession.
### The error may exist in mapper/PersonMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper 
Configuration. Cause: java.lang.RuntimeException: Error parsing Mapper XML. 
Cause: java.lang.IllegalArgumentException: Mapped Statements collection already 
contains value for mapper.PersonMapper.get
        at 
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
        at 
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:31)
        at 
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:14)
        at test.MapperNameTest.initDatabase(MapperNameTest.java:16)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at 
org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
        at 
org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
        at 
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
        at 
org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
        at 
org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
        at 
org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
        at 
org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
        at 
org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
        at 
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
        at 
org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
        at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
        at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper 
Configuration. Cause: java.lang.RuntimeException: Error parsing Mapper XML. 
Cause: java.lang.IllegalArgumentException: Mapped Statements collection already 
contains value for mapper.PersonMapper.get
        at 
org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:62)
        at 
org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:47)
        at 
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:28)
        ... 22 more
Caused by: java.lang.RuntimeException: Error parsing Mapper XML. Cause: 
java.lang.IllegalArgumentException: Mapped Statements collection already 
contains value for mapper.PersonMapper.get
        at 
org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:50)
        at 
org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:31)
        at 
org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.loadXmlResource(MapperAnnotationBuilder.java:50)
        at 
org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.parse(MapperAnnotationBuilder.java:29)
        at 
org.apache.ibatis.binding.MapperRegistry.addMapper(MapperRegistry.java:42)
        at 
org.apache.ibatis.mapping.Configuration.addMapper(Configuration.java:309)
        at 
org.apache.ibatis.builder.xml.XMLMapperBuilder.bindMapperForNamespace(XMLMapperBuilder.java:227)
        at 
org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:32)
        at 
org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:221)
        at 
org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:60)
        ... 24 more
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection 
already contains value for mapper.PersonMapper.get
        at 
org.apache.ibatis.mapping.Configuration$StrictMap.put(Configuration.java:349)
        at 
org.apache.ibatis.mapping.Configuration.addMappedStatement(Configuration.java:289)
        at 
org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:213)
        at 
org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:59)
        at 
org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:185)
        at 
org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:48)
        ... 33 more


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ibatis.apache.org
For additional commands, e-mail: dev-h...@ibatis.apache.org

Reply via email to