0

这就是我的 XML 的样子。所有定义的属性都定义了各自的 getter 和 setter。在尝试了各种建议后,我无法解决“无效的列索引”问题。

SELECT 语句返回适当列出的所有属性,并且我已经验证了相同的运行作为单独的查询。

我正在从指定日期范围之间的特定组的一组表中获取数据。

    <resultMap id="result" type="ValueStats">
        <result property="GroupId" column="GROUP_ID"/>
        <result property="valueId" column="VALUE_ID"/>
        <result property="valueName" column="VALUE_NAME"/>
        <result property="valImp" column="IMP"/>
        <result property="valCks" column="CKS"/>
        <result property="valCR" column="CR"/>
        <result property="valAp" column="AP"/>
        <result property="valRv" column="RV"/>
        <result property="valCt" column="CT"/>
        <result property="fromDate" column="FROM_DATE"/>
        <result property="toDate" column="END_DATE"/>
        <result property="valKc" column="KC"/>
    </resultMap>

    <select id="getAll" resultMap="result">
        SELECT 
              B.GROUP_ID AS GROUP_ID,
              B.VALUE_ID AS VALUE_ID,
          B.VALUE_NAME AS VALUE_NAME,
          A.IMP AS IMP, 
          A.CKS AS CKS,
          A.CR AS CR,
          A.AP AS AP,
          A.RV AS RV,
          A.CT AS CT,
          #{fromDate} AS FROM_DATE,
          #{toDate} AS END_DATE,
          A.KC AS KC
        FROM
        (SELECT 
              Z.VALUE_ID AS VALUE_ID,
              ROUND(AVG(Z.IMP), 0) AS IMP, 
              ROUND(CEIL(AVG(Z.CKS)),0) AS CKS, 
              ROUND(AVG(Z.CR),5) AS CR,  
              ROUND(AVG(Z.AP),2) AS AP,
              ROUND(AVG(Z.CT),2) AS CT, 
              ROUND(AVG(Z.RV),2) AS RV,
              ROUND(COUNT(Z.VALUE_ID)) AS KC
              FROM
                (SELECT 
                  VALUE_ID AS VALUE_ID, 
                  IMP AS IMP, 
                  TO_DATE(DATE_ID,'YYYYMMDD') AS DATEVAL, 
                  CKS, 
                  CR, 
                  AP, 
                  CT, 
                  RV
            FROM XY_STATS WHERE GROUP_ID='#{groupId}') Z
            WHERE
            Z.DATEVAL <![CDATA[<]]> TO_DATE(#{toDate}, 'DD-MM-YY') AND
            Z.DATEVAL >= TO_DATE(#{fromDate}, 'DD-MM-YY') 
            GROUP BY Z.VALUE_ID) A INNER JOIN XY_VALUE_SETTINGS B
            ON A.VALUE_ID = B.VALUE_ID
    </select>

4

1 回答 1

4

您在动态值周围有引号:

...
FROM XY_STATS WHERE GROUP_ID='#{groupId}') Z
...  

准备好的语句将用其他引号替换该值。

于 2012-09-28T13:11:45.013 回答