web-dev-qa-db-fra.com

mybatis IllegalArgumentException: la collection d'instructions mappées ne contient pas de valeur

j'ai beaucoup de problèmes avec le printemps e mybatis. Voici ma configuration de printemps: J'ai la même configuration et ComuneMapper.Java et ComuneMapper.xml restent dans les mêmes dossiers. mais j'ai cependant cette erreur Quelqu'un pour m'aider

    <?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:webflow="http://www.springframework.org/schema/webflow-config"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-2.5.xsd
        http://www.springframework.org/schema/webflow-config
        http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util-2.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <context:annotation-config /> 

    <!-- Scans the classpath of this application for @Components to deploy as beans -->
    <context:component-scan
        base-package="com.aieap" />

    <!-- Configures the @Controller programming model -->
    <mvc:annotation-driven />


    <!-- Configurazione Spring MVC View Resolver -->
    <bean
        id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property
            name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property
            name="prefix"
            value="/jsp/" />
        <property
            name="suffix"
            value=".jsp" />
    </bean>

    <!-- Flow Handler Adapter -->
    <bean
        class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
        <property
            name="flowExecutor"
            ref="flowExecutor" />
    </bean>

    <!-- Flow Handler Mapping -->
    <bean
        class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
        <property
            name="flowRegistry"
            ref="flowRegistry" />
    </bean>

    <!-- Flow Executor -->
    <webflow:flow-executor
        id="flowExecutor" />

    <!-- Flow Registry -->
    <webflow:flow-registry
        id="flowRegistry"
        flow-builder-services="flowBuilderServices">
        <!-- nonaut -->
        <webflow:flow-location
            id="home-nonaut"
            path="/WEB-INF/flows/nonaut/home-nonaut.xml" />
        <webflow:flow-location
            id="logout"
            path="/WEB-INF/flows/nonaut/logout.xml" />

        <!-- aut -->
        <webflow:flow-location
            id="aut/home-aut"
            path="/WEB-INF/flows/aut/home-aut.xml" />
        <webflow:flow-location
            id="aut/nuova-domanda"
            path="/WEB-INF/flows/aut/nuova-domanda.xml" />
        <webflow:flow-location
            id="aut/invia-domanda"
            path="/WEB-INF/flows/aut/invia-domanda.xml" />
        <webflow:flow-location
            id="aut/nuovo-operatore-rer"
            path="/WEB-INF/flows/aut/nuovo-operatore-rer.xml" />

    </webflow:flow-registry>

    <webflow:flow-builder-services
        id="flowBuilderServices"
        view-factory-creator="viewFactoryCreator" />

    <bean
        id="viewFactoryCreator"
        class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
        <property
            name="viewResolvers">
            <list>
                <ref
                    bean="viewResolver" />
            </list>
        </property>
        <property
            name="useSpringBeanBinding"
            value="true" />
    </bean>

    <import resource="jdbc-context.xml" />


</beans>

jdbc-context.xm:

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/tx 
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.0.xsd
            ">

    <context:property-placeholder
        location="/WEB-INF/db.properties" />

    <!-- Enable annotation style of managing transactions -->
    <tx:annotation-driven
        transaction-manager="transactionManager" />

    <!-- Declare a datasource that has pooling capabilities -->
    <bean
        id="dataSource"
        class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close"
        p:driverClass="${jdbc.driver}"
        p:jdbcUrl="${jdbc.url}"
        p:user="${jdbc.username}"
        p:password="$jdbc.password}"
        p:acquireIncrement="10"
        p:idleConnectionTestPeriod="60"
        p:maxPoolSize="100"
        p:maxStatements="50"
        p:minPoolSize="10" />

    <!-- Declare a transaction manager -->
    <bean
        id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
        p:dataSource-ref="dataSource" />


    <!-- define the SqlSessionFactory, notice that configLocation is not needed when you use MapperFactoryBean -->
    <bean
        id="sqlSessionFactory"
        class="org.mybatis.spring.SqlSessionFactoryBean">
        <property
            name="dataSource"
            ref="dataSource" />
        <property
            name="configLocation"
            value="WEB-INF/mybatis/sqlmap-config.xml" />
    </bean>

    <!-- scan for mappers and will automatically scan the whole classpath for xmls -->
    <bean
        class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
        <property name="basePackage" value="com.aieap.dao.mapper" />
    </bean>

</beans>

sqlmap-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
    PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
    <settings>
        <!-- changes from the defaults -->
        <setting name="lazyLoadingEnabled" value="false" />
    </settings>
    <typeAliases>
        <typeAlias type="com.aieap.model.Comuni" alias="comuni"/>
    </typeAliases>
</configuration>

manette:

package com.aieap.web.controller;

import Java.util.ArrayList;
import Java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.Apache.log4j.Logger;

import com.aieap.dao.mapper.ComuniMapper;
import com.aieap.model.Comuni;
import com.aieap.model.OperatoriRer;

@Controller
public class OperatoriRerController {

    @Autowired ComuniMapper comuniDao;


    private static final Logger logger = Logger.getLogger(OperatoriRerController.class);



     @RequestMapping("/aut/nuovo-operatore-rer")
        public ModelMap start() {

        Comuni comuni = comuniDao.selectByPrimaryKey(new Long(1));
        System.out.print(comuni);
        OperatoriRer op = new OperatoriRer();
        op.setNome("ciccio");
        op.setCognome("cappuccio");
        ModelMap model = new ModelMap();
        model.addAttribute("OperatoriRer",op);
        return model;
        }


     @RequestMapping("/aut/search-comune")
        public ModelMap searchcomune() {
        List<Comuni> comuniList = new ArrayList <Comuni>() ;        
        ModelMap model = new ModelMap();
        model.addAttribute("ComunuList",comuniList);
        return model;
        }
}

c'est l'erreur:

Grave: Servlet.service() for servlet [dispatch] in context with path [/aieap] threw exception [Request processing failed; nested exception is Java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.aieap.dao.mapper.ComuniMapper.selectByPrimaryKey] with root cause
Java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.aieap.dao.mapper.ComuniMapper.selectByPrimaryKey
    at org.Apache.ibatis.session.Configuration$StrictMap.get(Configuration.Java:593)
    at org.Apache.ibatis.session.Configuration.getMappedStatement(Configuration.Java:393)
    at org.Apache.ibatis.binding.MapperMethod.setupCommandType(MapperMethod.Java:160)
    at org.Apache.ibatis.binding.MapperMethod.<init>(MapperMethod.Java:48)
    at org.Apache.ibatis.binding.MapperProxy.invoke(MapperProxy.Java:37)
    at $Proxy9.selectByPrimaryKey(Unknown Source)
    at com.aieap.web.controller.OperatoriRerController.start(OperatoriRerController.Java:29)
    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:597)
    at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.Java:219)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.Java:132)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.Java:104)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.Java:746)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.Java:687)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.Java:80)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.Java:925)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.Java:856)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.Java:915)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.Java:811)
    at javax.servlet.http.HttpServlet.service(HttpServlet.Java:621)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.Java:796)
    at javax.servlet.http.HttpServlet.service(HttpServlet.Java:722)
    at org.Apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.Java:304)
    at org.Apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.Java:210)
    at org.Apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.Java:240)
    at org.Apache.catalina.core.StandardContextValve.invoke(StandardContextValve.Java:164)
    at org.Apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.Java:462)
    at org.Apache.catalina.core.StandardHostValve.invoke(StandardHostValve.Java:164)
    at org.Apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.Java:100)
    at org.Apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.Java:563)
    at org.Apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.Java:118)
    at org.Apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.Java:399)
    at org.Apache.coyote.http11.Http11Processor.process(Http11Processor.Java:317)
    at org.Apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.Java:204)
    at org.Apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.Java:182)
    at org.Apache.Tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.Java:311)
    at Java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.Java:886)
    at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:908)
    at Java.lang.Thread.run(Thread.Java:662)

s'il vous plaît!!! quelqu'un m'aide, je suis sans espoir !!!!!!!!!!!!!!!

J'avais oublié . C'est ComuniMapper.Java

package com.aieap.dao.mapper;

import com.aieap.model.Comuni;
import com.aieap.model.ComuniExample;
import Java.util.List;
import org.Apache.ibatis.annotations.Param;

public interface ComuniMapper {

    int countByExample(ComuniExample example);
    int deleteByExample(ComuniExample example);
    int deleteByPrimaryKey(Long idComune);
    int insert(Comuni record);
    int insertSelective(Comuni record);
    List<Comuni> selectByExample(ComuniExample example);
    Comuni selectByPrimaryKey(Long idComune);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table comuni
     *
     * @mbggenerated Tue Jan 08 16:52:16 CET 2013
     */
    int updateByExampleSelective(@Param("record") Comuni record, @Param("example") ComuniExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table comuni
     *
     * @mbggenerated Tue Jan 08 16:52:16 CET 2013
     */
    int updateByExample(@Param("record") Comuni record, @Param("example") ComuniExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table comuni
     *
     * @mbggenerated Tue Jan 08 16:52:16 CET 2013
     */
    int updateByPrimaryKeySelective(Comuni record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table comuni
     *
     * @mbggenerated Tue Jan 08 16:52:16 CET 2013
     */
    int updateByPrimaryKey(Comuni record);
}

terminez ce ComuniMapper.xml:

<?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.aieap.dao.mapper.ComuniMapper" >
  <resultMap id="BaseResultMap" type="com.aieap.model.Comuni" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    <id column="ID_COMUNE" property="idComune" jdbcType="BIGINT" />
    <result column="CODICE_ISTAT" property="codiceIstat" jdbcType="VARCHAR" />
    <result column="DESCRIZIONE" property="descrizione" jdbcType="VARCHAR" />
    <result column="CAP" property="cap" jdbcType="VARCHAR" />
    <result column="CODICE_PROVINCIA" property="codiceProvincia" jdbcType="BIGINT" />
    <result column="COMUNE_SIGLA" property="comuneSigla" jdbcType="VARCHAR" />
    <result column="COMUNE_CFIS" property="comuneCfis" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    <where >
      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    ID_COMUNE, CODICE_ISTAT, DESCRIZIONE, CAP, CODICE_PROVINCIA, COMUNE_SIGLA, COMUNE_CFIS
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.aieap.model.ComuniExample" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from comuni
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="Java.lang.Long" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    select 
    <include refid="Base_Column_List" />
    from comuni
    where ID_COMUNE = #{idComune,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="Java.lang.Long" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    delete from comuni
    where ID_COMUNE = #{idComune,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.aieap.model.ComuniExample" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    delete from comuni
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.aieap.model.Comuni" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    insert into comuni (ID_COMUNE, CODICE_ISTAT, DESCRIZIONE, 
      CAP, CODICE_PROVINCIA, COMUNE_SIGLA, 
      COMUNE_CFIS)
    values (#{idComune,jdbcType=BIGINT}, #{codiceIstat,jdbcType=VARCHAR}, #{descrizione,jdbcType=VARCHAR}, 
      #{cap,jdbcType=VARCHAR}, #{codiceProvincia,jdbcType=BIGINT}, #{comuneSigla,jdbcType=VARCHAR}, 
      #{comuneCfis,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.aieap.model.Comuni" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    insert into comuni
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="idComune != null" >
        ID_COMUNE,
      </if>
      <if test="codiceIstat != null" >
        CODICE_ISTAT,
      </if>
      <if test="descrizione != null" >
        DESCRIZIONE,
      </if>
      <if test="cap != null" >
        CAP,
      </if>
      <if test="codiceProvincia != null" >
        CODICE_PROVINCIA,
      </if>
      <if test="comuneSigla != null" >
        COMUNE_SIGLA,
      </if>
      <if test="comuneCfis != null" >
        COMUNE_CFIS,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="idComune != null" >
        #{idComune,jdbcType=BIGINT},
      </if>
      <if test="codiceIstat != null" >
        #{codiceIstat,jdbcType=VARCHAR},
      </if>
      <if test="descrizione != null" >
        #{descrizione,jdbcType=VARCHAR},
      </if>
      <if test="cap != null" >
        #{cap,jdbcType=VARCHAR},
      </if>
      <if test="codiceProvincia != null" >
        #{codiceProvincia,jdbcType=BIGINT},
      </if>
      <if test="comuneSigla != null" >
        #{comuneSigla,jdbcType=VARCHAR},
      </if>
      <if test="comuneCfis != null" >
        #{comuneCfis,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.aieap.model.ComuniExample" resultType="Java.lang.Integer" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    select count(*) from comuni
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    update comuni
    <set >
      <if test="record.idComune != null" >
        ID_COMUNE = #{record.idComune,jdbcType=BIGINT},
      </if>
      <if test="record.codiceIstat != null" >
        CODICE_ISTAT = #{record.codiceIstat,jdbcType=VARCHAR},
      </if>
      <if test="record.descrizione != null" >
        DESCRIZIONE = #{record.descrizione,jdbcType=VARCHAR},
      </if>
      <if test="record.cap != null" >
        CAP = #{record.cap,jdbcType=VARCHAR},
      </if>
      <if test="record.codiceProvincia != null" >
        CODICE_PROVINCIA = #{record.codiceProvincia,jdbcType=BIGINT},
      </if>
      <if test="record.comuneSigla != null" >
        COMUNE_SIGLA = #{record.comuneSigla,jdbcType=VARCHAR},
      </if>
      <if test="record.comuneCfis != null" >
        COMUNE_CFIS = #{record.comuneCfis,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    update comuni
    set ID_COMUNE = #{record.idComune,jdbcType=BIGINT},
      CODICE_ISTAT = #{record.codiceIstat,jdbcType=VARCHAR},
      DESCRIZIONE = #{record.descrizione,jdbcType=VARCHAR},
      CAP = #{record.cap,jdbcType=VARCHAR},
      CODICE_PROVINCIA = #{record.codiceProvincia,jdbcType=BIGINT},
      COMUNE_SIGLA = #{record.comuneSigla,jdbcType=VARCHAR},
      COMUNE_CFIS = #{record.comuneCfis,jdbcType=VARCHAR}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.aieap.model.Comuni" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    update comuni
    <set >
      <if test="codiceIstat != null" >
        CODICE_ISTAT = #{codiceIstat,jdbcType=VARCHAR},
      </if>
      <if test="descrizione != null" >
        DESCRIZIONE = #{descrizione,jdbcType=VARCHAR},
      </if>
      <if test="cap != null" >
        CAP = #{cap,jdbcType=VARCHAR},
      </if>
      <if test="codiceProvincia != null" >
        CODICE_PROVINCIA = #{codiceProvincia,jdbcType=BIGINT},
      </if>
      <if test="comuneSigla != null" >
        COMUNE_SIGLA = #{comuneSigla,jdbcType=VARCHAR},
      </if>
      <if test="comuneCfis != null" >
        COMUNE_CFIS = #{comuneCfis,jdbcType=VARCHAR},
      </if>
    </set>
    where ID_COMUNE = #{idComune,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.aieap.model.Comuni" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Jan 08 16:52:16 CET 2013.
    -->
    update comuni
    set CODICE_ISTAT = #{codiceIstat,jdbcType=VARCHAR},
      DESCRIZIONE = #{descrizione,jdbcType=VARCHAR},
      CAP = #{cap,jdbcType=VARCHAR},
      CODICE_PROVINCIA = #{codiceProvincia,jdbcType=BIGINT},
      COMUNE_SIGLA = #{comuneSigla,jdbcType=VARCHAR},
      COMUNE_CFIS = #{comuneCfis,jdbcType=VARCHAR}
    where ID_COMUNE = #{idComune,jdbcType=BIGINT}
  </update>
</mapper>
10
user1671106

Il peut y avoir plusieurs raisons ...!

  • -> Syntaxe SQL (peut-être qu'une seule petite requête a un extra, à la fin de la sélection) 

  • -> Problèmes de classpath, impossible de résoudre les dépendances de jar

  • -> Cela peut également être dû à un problème d’encodage de fichier ou à l’incorporation de caractères xml illégaux dans votre fichier '* Mapper.xml'. (alors faites attention à votre éditeur ..!)

Plus important encore, vous devriez utiliser les mêmes noms pour.

  • interface = xxx.yyy.mappers.SettingMapper.class 
  • fichier de mappeur = /xxx/yyy/mappers/SettingMapper.xml 
  • mapper namespace = xxx.yyy.mappers.SettingMapper 
9
mahesh

Bonjour, ce problème est généralement connecté à des emplacements de mappeur . Essayez donc de définir la propriété mapperLocation dans votre SqlSessionFactory bean:

<property name="mapperLocations" 
value="classpath*:pathWhereYouHaveMapper/*Mapper.xml" /> 

J'espère que ça aide!

7
Oibaf it

Cela signifie généralement que mybatis ne peut pas trouver le mappage auquel vous faites référence. Peut-être avez-vous oublié d'ajouter le fichier * Mapper.xml à mybatis-config.xml (qui est un fichier de configuration standard pour MyBatis)

<mappers>
  <mapper resource="org/mybatis/builder/AuthorMapper.xml"/>
</mappers>

Voir plus de documentation http://mybatis.github.io/mybatis-3/configuration.html#mappers

4
jediz

En ajoutant aux autres réponses, vous devez également

Rechercher les noms de méthodes en double

Cette erreur vient enfin dans le journal.

IllegalArgumentException: Mapped Statements collection does not contain value

Ignorez le message ci-dessus et remontez simplement vos journaux et recherchez le premier message d'erreur dans les journaux. La première erreur que j'ai eu était, 

ERROR [main] mapper.MapperFactoryBean (MapperFactoryBean.Java:83) - Error while adding the mapper 'interface com.xyz.mappers.UserMapper' to configuration.
Java.lang.IllegalArgumentException: Mapped Statements collection already contains value for com.xyz.mappers.UserMapper.getAllUserDetails

L'erreur indique clairement que la méthode getAllUserDetails existe déjà dans l'interface UserMapper (avec un nombre différent de paramètres). La duplication des noms de méthodes lève également cette erreur. (La pénalité pour copier-coller des codes): P

2
Lucky

Dans mon cas, ce qui s’est passé est qu’il y avait un TYPO dans mon nom de méthode dans le fichier XML de mapping . Quand j'ai changé le nom DAO, j'ai oublié de changer le xml, cela pourrait aider quelqu'un d'autre.

2
Vins

J'ai aussi rencontré ce problème. En plus de la possibilité de la réponse ci-dessus, j'essaie d'utiliser cette méthode qui résout le problème:

Le nom de la méthode doit être identique dans dao et mapper.xml, dans mon cas, le nom de la méthode n'est pas identique. Donc, vous devez être sûr qu'ils sont les mêmes.

Bonne chance!

1
mos wen

Dupliqué id dans mapper.xml lève également cette exception . J'espère que cela vous aidera.

1
okin2014

Vérifiez si vous avez mappé mybatis.config dans le fichier de propriétés. 

ajoutez cette ligne dans le fichier application.properties.

mybatis.config=classpath:mybatis-config.xml
0
Suhas Bhat

J'utilise mybatis de la même manière que vous. Votre code a l'air bien. Même si je ne suis pas sûr s'il y a un problème avec les mappages de types. Essayez deux astuces suivantes pour résoudre votre problème:

  1. changez le type de Java en alias mybtis a) "Java.lang.Long" -> "long", b) "com.aieap.model.Comuni" -> "comuni"

  2. essayez d'ajouter un alias au lieu d'un mappage XML @ org.Apache.ibatis.type.Alias ​​("comuni") dans com.aieap.model.Comuni, supprimez xml typeAlias, ajoutez une configuration de ressort à votre org.mybatis.spring. SqlSessionFactoryBean: 

Bonne chance, Martin

0
user1959366

Je suis tombé sur cette exception aussi. Dans mon cas, le fichier XML mappeur était présent dans un fichier JAR inclus dans le chemin d'accès aux classes, mais il n'a pas pu être trouvé par le MapperScannerConfigurer. J'ai appris cela en lisant les journaux. Vous devriez lire les journaux et vérifier la ligne du format suivant pour savoir si des mappeurs ont été trouvés. Je devais lui donner le chemin racine, après quoi il trouva mon mappeur. 

PathMatchingResourcePatternResolver:423 - Resolved location pattern [classpath*:*.xml] to resources [URL [jar:file:/home/user/src/Tomcat8/webapps/example/WEB-INF/lib/ExampleDao-1.0.0-SNAPSHOT.jar!/TestMapper.xml]]
0
zafar142003

J'ai eu le même problème. Ensuite, j'ai trouvé que toutes les demandes pour lesquelles les mappages de requêtes étaient définis sur ce fichier mapper.xml avaient la même erreur. 

Cela est peut-être dû à une construction incorrecte de WAR ou à un déploiement incorrect sur le serveur . Quoi qu'il en soit, j'ai supprimé ce fichier WAR, puis je l'ai redéployé et cela a fonctionné!

0
normalUser