gpt4 book ai didi

java - 列索引无效错误 - 无法解决问题

转载 作者:行者123 更新时间:2023-12-01 19:00:06 27 4
gpt4 key购买 nike

这就是我的 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>

最佳答案

您对动态值有引号:

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

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

关于java - 列索引无效错误 - 无法解决问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12533263/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com