您好我正在使用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
时仍会出现错误请帮助解决这种方法出了什么问题。
答案 0 :(得分:0)
我完全忽略了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>