2014-10-30 74 views
1

您好我正在使用ibatis 2並試圖查詢3種類型的參數的表。下面 是代碼在ibatis中使用條款

<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

也許是因爲你缺少你的parameterMap的其他需要的參數。你把你的查詢:JOBSET,JOB,JOB_NO,QUALIFIER,JOB_AVG和STATUS,並且在你的地圖上只有:jobSet,job和currentJobStatusArr。在iBatis上,您應該在地圖中放入等效參數。 – 2014-10-30 14:02:33

+0

no no ...查詢工作正常,如果我刪除列表參數。而對於那些參數,它只是一個選擇,我不會發送任何輸入。 – Alpesh003 2014-10-30 14:33:03

回答

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>