Mybatis:mapped Statements collection does not contain value for

Source: Internet
Author: User

BUG: Error when using MyBatis;

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause:java.lang.IllegalArgumentException:Mapped Statements collection does not contain value for Mycom.mapping.SampleMapper.selectByPrimaryKey ### Cause:java.lang.IllegalArgumentException:Mapped Statements Collection does not contain value for Mycom.mapping.SampleMapper.selectByPrimaryKey at ORG.APACHE.IBATIS.EXCEPTIONS.E Xceptionfactory.wrapexception (exceptionfactory.java:26) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:111) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:102) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne (defaultsqlsession.java:66) at Mycom.test.mybatis.test.MybatisTest.main (mybatistest.java:43) caused by:java.lang.IllegalArgumentException: Mapped statements collection does not contain value for Mycom.mapping.SampleMapper.selectByprimarykey at Org.apache.ibatis.session.configuration$strictmap.get (configuration.java:797) at Org.apache.ibat Is.session.Configuration.getMappedStatement (configuration.java:631) at Org.apache.ibatis.session.Configuration.getMappedStatement (configuration.java:624) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:107) ... 3 more

Cause: The following mapping SQL's identity string is inconsistent with the namespace () in Samplemapper.xml, previously handwritten namespace, when named, using the Mapper.xml directory, which was automatically generated by the tool Mapper.xml,namespac E name is used in the DAO directory;

        String statement2 = "Mycom.mapping.SampleMapper.selectByPrimaryKey";//Mapping SQL's identity string
        Sample result = Session.selectone (Statement2, 2);
        SYSTEM.OUT.PRINTLN (result);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.