首页 > 解决方案 > MyBatis - java.lang.IllegalArgumentException:映射语句集合已经包含值

问题描述

我的应用程序使用 Spring 和 MyBatis。在将包更改为用作 ResultType 的类之前,我没有例外。从那时起,我在启动我的应用程序时收到以下错误:

Caused by: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for app2Check.core.dao.ThemeSentimentDAO.getSplitMatchingThemes
at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:782)
at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:754)
at org.apache.ibatis.session.Configuration.addMappedStatement(Configuration.java:578)
at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:288)
at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:107)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:135)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:118)
... 67 more

这是我的 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="app2Check.core.dao.ThemeSentimentDAO">
<select id="getSplitMatchingThemes" resultType="xyz.objects.sentences.SplitSent"><!-- Previously resultType="xyz.sentences.SplitSent" -->
    SELECT TOP (#{numSplitPerPage})
        ...
        <if  test = "redo == false">
            ...
        </if>
    WHERE (
            <foreach collection="themes" item="t" index="index" separator=" OR ">
                (
                    ..
                )
            </foreach>
        )

</select>

<select id="getThemes" resultType="xyz.objects.Theme">
...
</select>

<select id="countSplitMatchingTheme"  resultType="xyz.utils.SplitCount">
    ...
</select>

</mapper>

这是我的映射器界面:

public interface ThemeSentimentDAO {

    public List<Theme> getThemes(@Param("appId") String appId);

    public List<SplitFeedback> getSplitMatchingThemes(
            @Param("appId") String appId, 
            @Param("customerCare") String customerCare,
            @Param("redo") boolean redo,
            @Param("analysisDate") Timestamp analysisDate,
            @Param("themes") List<Theme> themes,
            @Param("numSplitPerPage") int numSplitPerPage
            );

    public SplitCount countSplitMatchingTheme(
            @Param("appId") String appId, 
            @Param("customerCare") String customerCare,
            @Param("redo") boolean redo,
            @Param("themes") List<Theme> themes
            );
    }

标签: javaspringmybatisspring-mybatis

解决方案


推荐阅读