嗨,我正在使用ibatis 2并尝试查询具有3种类型的参数的表。
下面是代码
<parameterMap id="getSearchLateJob_Param" class="java.util.HashMap">
<parameter property="jobSet" javaType="java.lang.String" jdbcType="VARCHAR"/>
<parameter property="job" javaType="java.lang.String" jdbcType="VARCHAR"/>
<!-- <parameter property = "currentJobStatusStrArr" javaType="java.lang.String" jdbcType="VARCHAR"/> -->
<parameter property = "currentJobStatusArr" javaType="java.util.List" jdbcType="ARRAY"/>
</parameterMap>
<statement id="getSearchLateJob" parameterMap="getSearchLateJob_Param" resultMap="getCurrentJob_r">
select a.JOBSET as "JOBSET",
a.JOB as "JOB",
a.JOB_NO as "JOB_NO",
a.QUALIFIER as "QUALIFIER",
b.JOB_AVG as "JOB_AVG",
a.STATUS as "STATUS"
from CA_JOB_STATUS a,JOB_AVG b
where a.JOBSET = b.JOBSET
and a.JOB=b.JOB
and a.JOBSET like ?
and a.JOB like ?
<!-- and a.STATUS in -->
<dynamic prepend="and a.STATUS in ">
<iterate property= "currentJobStatusArr" open="(" close=")" conjunction=",">
#currentJobStatusArr[]#
</iterate>
</dynamic>
order by a.END_TIME desc, a.START_TIME desc
</statement>
输入参数未设置索引2仍然给我一个错误
请帮助解决这种方法的问题。
最佳答案
我完全忽略了parameterMap属性,并将语句修改为以下内容:
<statement id="getSearchLateJob" parameterClass="map" resultMap="getCurrentJob_r">
select a.JOBSET as "JOBSET",
a.JOB as "JOB",
a.JOB_NO as "JOB_NO",
a.QUALIFIER as "QUALIFIER",
case when year(a.START_TIME) = 1900 then null else a.START_TIME end as "EXPECTED_START_TIME",
case when year(a.END_TIME) = 1900 then null else a.END_TIME end as "END_TIME",
datediff(mi,a.START_TIME,a.END_TIME) as "DURATION",
b.JOB_AVG as "JOB_AVG",
a.STATUS as "STATUS"
from CA_JOB_STATUS a,JOB_AVG b
where a.JOBSET = b.JOBSET
and a.JOB=b.JOB
and a.JOBSET like #jobSet:VARCHAR#
and a.JOB like #job:VARCHAR#
<!-- and a.STATUS in -->
<dynamic prepend="and a.STATUS in ">
<iterate property= "currentJobStatusArr" open="(" close=")" conjunction=",">
#currentJobStatusArr[]:VARCHAR#
</iterate>
</dynamic>
order by a.END_TIME desc, a.START_TIME desc
</statement>
关于java - 在ibatis中使用in子句,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26654462/