Mapped Statements collection does not contain value for mybatis mapper

mybatis mapped statements
mapped statements collection already contains value
org.apache.ibatis.builder.incompleteelementexception: could not find result map
mybatis mapper xml example
collection property in mybatis
mybatis database support
mybatis db2 example
mybatis example

I am user mybatis and spring to create some test website. Right now I got a problem when trying to use mybatis xml mapper. Issue is something like "java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.cooldrinker.mybatis.mapper.AdminMapper.getAdminByUsername"

servlet.xml

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="typeAliasesPackage" value="com.cooldrinker.mybatis.model"/>
        <property name="mapperLocations" value="classpath*:com/cooldrinker/mybatis/mapper/*.xml" />
    </bean>

Java mapper

package com.cooldrinker.mybatis.mapper;

import com.cooldrinker.mybatis.model.Admin;

public interface AdminMapper {
    public Admin getAdminByUsername(String username);
}

xml mapper

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.cooldrinker.mybatis.mapper.AdminMapper">
    <select id="getAdminByUsername" parameterType="java.lang.String" resultType="adminResultMap">
        SELECT first_name, last_name, password, username
        FROM admin
        WHERE username = #{username}
    </select>

    <resultMap id="adminResultMap" type="com.cooldrinker.mybatis.model.Admin">
        <result property="firstName" column="first_name" />
        <result property="username" column="last_name"/>
        <result property="password" column="password"/>
        <result property="username" column="username"/>
    </resultMap>
</mapper>

stack trace

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.cooldrinker.mybatis.mapper.AdminMapper.getAdminByUsername
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause

java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.cooldrinker.mybatis.mapper.AdminMapper.getAdminByUsername
    org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:672)
    org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:507)
    org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:500)
    org.apache.ibatis.binding.MapperMethod.setupCommandType(MapperMethod.java:240)
    org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:71)
    org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:39)
    com.sun.proxy.$Proxy38.getAdminByUsername(Unknown Source)
    com.cooldrinker.mybatis.dao.impl.AdminDaoImpl.getAdminByUsername(AdminDaoImpl.java:24)
    com.cooldrinker.dataservice.service.impl.AdminServiceImpl.getAdminByUsername(AdminServiceImpl.java:26)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
    com.sun.proxy.$Proxy42.getAdminByUsername(Unknown Source)
    com.cooldrinker.controller.AdminLoginController.login(AdminLoginController.java:39)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

This kind of error was due to wrong reference between DAO ↔ XML

Let me show IMPLEMENTS in "AdminMapper" AND "AdminMapperDAO" Maybe that was point.

Mapped Statements collection does not contain value, java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.enlliance.inventory.mappers.SettingMapper. If there is an issue with parsing the statement (which occured in mycase as the statement had @ResultMap annotation, but resultMap wasn't provided to configuration.), the method is added in INCOMPLETE_METHODS in configuration which later raises the exception.

you may register your mapper in mybatis-config.xml file

<configuration>

  <properties resource="db.dev.properties">
  </properties>

    <typeHandlers>
        <package name="com.newtonx.model.typehandlers"/>
    </typeHandlers>
    <environments default="development">
     ...
    </environments>
    <mappers>
      <mapper resource="com/project/model/xml/SomeMapper.xml"/>
      // other mapper here
    </mappers>
    ...
</configuration>

java.lang.IllegalArgumentException: Mapped Statements collection , Mapped Statements collection does not contain value - iBatis. Make sure the mapper interface java class name and the mapper xml file is  Cause: java.sql.SQLException: ORA-00900: invalid SQL statement I tried to use the SQLSessionFactory instead, however, ended up with the the error: ### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for FYI, the same Mapper Interface is working if I have the sql.

Mapped Statements collection does not contain value · Issue #55 , Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for  Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

Mybatis 3.2.8 ERROR: Mapped Statements collection does not , IllegalArgumentException: Mapped Statements collection does not contain value for. The error is with the line: @Result(property="usu All results from select statements in the mapped statement file will be cached. All insert, update and delete statements in the mapped statement file will flush the cache. The cache will use a Least Recently Used (LRU) algorithm for eviction. The cache will not flush on any sort of time based schedule (i.e. no Flush Interval).

Mapped Statements collection does not contain value for my class , Hi,. this is my first project using mybatis, so please someone help. I've got my ClienteMapper.xml and my ClienteMapper.java at the same 에러 : java.lang.IllegalArgumentException: Mapped Statements collection does not contain value

mybatis java.lang.IllegalArgumentException: Mapped Statements , Mapped Statements collection does not contain value for. 0 Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > 3 <mapper 

Comments
  • make sure your xml mapper's name end with "AdminMapper.xml"
  • The xml file location does not requires to be in the same path as the interface package. It can be on classpath root or any sub-directory. The most important is mapper namespace must equal interface full qualified name The xml contents seems ok, then the xml file might not be loaded at all. Try referencing explicitly the file in property mapperLocations, the issue might be related to wild-cards