2014-06-18 1 views

답변

0

답을 얻었다 .....

코드가 보일 것이다 : iBATIS는 쿼리가

<select id="getReferenceDataListByReferenceMasterInfo" 
    parameterType="com.util.ReferenceMetaData" resultMap="refdatalist-result"> 

    SELECT code,name, 

    <if test="infoNameList != null"> 
     <foreach item="item" index="index" separator="," collection="infoNameList"> 
      #{'info'${index}} 
     </foreach> 
    </if> 

    FROM 
    (
     SELECT 
     trim(${codeColumnName}) as code, 

     <choose> 
      <when test="nameColumnName != null"> 
       ${nameColumnName} as name, 
      </when> 
      <otherwise> 
       null as name, 
      </otherwise> 
     </choose> 
     <choose> 
      <when test="infoNameList != null"> 
       <foreach item="item" index="index" collection="infoNameList"> 
        ${item} as info${index}, 
       </foreach> 
      </when> 
     </choose> 
     row_number() over (order by ${codeColumnName}) as ROWNUM 

     FROM UREF.${tableName} 

    ) 
</select> 

우리가 명시 적으로 별칭을 지정하면 완벽하게 작동하고 위의 쿼리가

이렇게하면

<if test="infoNameList != null"> 
    <foreach item="item" index="index" separator="," collection="infoNameList"> 
     info${index} 
    </foreach> 
</if>