我必须在MyBatis中使用大量参数进行选择查询,我想使用默认的映射器xml文件结构并添加" UPPER(column_name)=?"到结果转换查询。我该怎么办?
这是我的where子句
<sql id="My_Select">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and UPPER(${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 close=")" collection="criterion.value" item="listItem"
open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
这是完整的选择语句:
<select id="mySelect" parameterType="myDataExample"
resultMap="myResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="my_Column_List" />
from istanza_metadato
<if test="_parameter != null">
<include refid="My_Select" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
我总是收到像这样的错误
设置参数时发生错误
...
WHERE(UPPER(id_metadato =?)和UPPER(valore =?))
我觉得我接近解决方案,但我无法找到方法。感谢所有