Java 运算符不存在:整数=字符变化

Java 运算符不存在:整数=字符变化,java,eclipse,postgresql,mybatis,Java,Eclipse,Postgresql,Mybatis,我正在为一个例外而失去理智,我需要你的帮助 我已经在映射器中编写了一个查询,它根据两个条件从表中检索记录:列表中的位置和另一个列表中的技能 因此,基本上,如果用户选择了多个技能进行查找,查询将恢复具有这些技能的所有记录 如此简单,但如此曲折,因为我使用两个foreach。。。一个有效,另一个无效 以下是查询: <select id="selectAllByFilter" resultMap="BaseResultMap"> select distinct <include re

我正在为一个例外而失去理智,我需要你的帮助

我已经在映射器中编写了一个查询,它根据两个条件从表中检索记录:列表中的位置和另一个列表中的技能

因此,基本上,如果用户选择了多个技能进行查找,查询将恢复具有这些技能的所有记录

如此简单,但如此曲折,因为我使用两个foreach。。。一个有效,另一个无效

以下是查询:

<select id="selectAllByFilter" resultMap="BaseResultMap">
select distinct
<include refid="Base_Column_List" /><include refid="Join_Column_List" />
from "ANAG_REQS" A JOIN "ANAG_REQS_RISORSE" R ON A."ID_REQS_RDA"=R."ID_REQS" LEFT JOIN "SEC_USER" U ON R."ID_USER"=U."ID"
LEFT JOIN "USER_LOCATION" S ON S."ID_REQS_USER"= R."ID_REQS"
LEFT JOIN "USER_SKILL" RS ON RS."ID_REQS_USER"= R."ID_REQS"
LEFT JOIN "USER_CUSTOMER" RC ON RC."ID_REQS"= R."ID_REQS"
WHERE 1=1
<if test="filter.idREQS != null">
    AND A."ID_REQS_RDA" = #{filter.idREQS,jdbcType=INTEGER}
</if>
<if test="filter.states != null and filter.states.size()>0 and not statesuspended">
    AND A."state_RDA" IN 
    <foreach item="item" collection="filter.states" index="index"
        open="(" separator="," close=")">           
        #{item}
    </foreach>
    AND R."state" != 'suspended'
</if>
<if test="filter.states != null and filter.states.size()>0 and statesuspended">
    AND (A."state_RDA" IN 
    <foreach item="item" collection="filter.states" index="index"
        open="(" separator="," close=")">           
        #{item}
    </foreach>
    OR A."state_RDA" = 'published' AND R."state" = 'suspended')
</if>
<if test="filter.states.isEmpty() and statesuspended">
    AND A."state_RDA" = 'published' AND R."state" = 'suspended'
</if>
<if test="filter.dataREQSDa != null">
    AND A."DATA_REQS_RDA" &gt;= #{filter.dataREQSDa,jdbcType=DATE}
</if>
<if test="filter.dataREQSA != null">
    AND A."DATA_REQS_RDA" &lt;= #{filter.dataREQSA,jdbcType=DATE}
</if>
 <if test="filter.pm != null and filter.pm != ''">
    <bind name="pattern1" value="'%' + filter.pm + '%'" />
    AND lower(U."USER_NAME") LIKE lower(#{pattern1})
</if>
<if test="filter.CUSTOMER != null">     
    AND RC."ID_CUSTOMER" = #{filter.CUSTOMER,jdbcType=INTEGER}
</if>
<if test="filter.locationselected != null and filter.locationselected.size()>0">
    AND S."ID_LOCATION" IN 
    <foreach item="item" collection="filter.locationselected" index="index"
        open="(" separator="," close=")">
          #{item}
    </foreach>
</if>
<if test="filter.skills != null and filter.skills.size()>0">
    AND RS."ID_SKILL" IN 
    <foreach item="item" collection="filter.skills" index="index"
        open="(" separator="," close=")">
          #{item}
    </foreach>
</if>
</select>
正在最新的foreach filter.skills上引发异常

问题在于,前面的foreach filter.locationSelected工作起来就像一个符咒。唯一的区别是skills是一个整数列表,而locationSelected是一个字符串列表。但这不应该是原因,因为我甚至尝试使用字符串列表,但问题仍然存在

RS.ID_SKILL是一个int4,所以只要我的逻辑正确,如果我没有发疯,我基本上是在检查整数列表中是否有一个int

但我仍然得到一个BadSQLGrammarException声明:运算符不存在:integer=字符变化提示:没有运算符与给定的名称和参数类型匹配。您可能需要添加显式类型转换

我做错了什么

救救我


EDIT:S.ID_LOCATION是一个varchar,所以我检查它的内容是否在字符串列表中。。。基于此,唯一合乎逻辑的结论是mybatis的foreach不能处理整数列表。。。。。我不知道….

您是否尝试通过以下方式修改查询: 替换

AND RS."ID_SKILL" IN 


您是否尝试通过以下方式修改查询: 替换

AND RS."ID_SKILL" IN 


我很确定你的XML不是你想象的那样-提示:>关闭一个XML标记…如果你是说它是jsut,那就是一个打字错误;我很确定你的XML不是你想象的那样-提示:>关闭一个XML标记…如果你是说它是jsut,那就是一个打字错误;