这就是我的XML的样子。定义的所有属性都定义了相应的getter和setter。尝试各种建议后,我无法解决“无效列索引”问题。
SELECT语句返回适当列出的所有属性,并且我已经验证了相同的运行作为单独的Query。
我从指定日期范围之间的特定组的表集中获取数据。
<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>
答案 0 :(得分:4)
你有一个动态值的引号:
...
FROM XY_STATS WHERE GROUP_ID='#{groupId}') Z
...
准备好的语句将用其他引号替换该值。