gpt4 book ai didi

java - jpa和oracle客户端中相同的查询,不同的结果

转载 作者:行者123 更新时间:2023-12-02 05:45:44 27 4
gpt4 key购买 nike

在entityManager.createNativeQuery (JPA) 和任何Oracle 客户端(SQL) 中运行相同的查询是否会产生不同的结果?

我使用以下查询发生了这种情况:

SELECT FITE_INSTID,
fite_grado,
SUM(lenguajeP) as lenguajeP,
SUM(lenguajeG) as lenguajeG,
SUM(lenguajeX) as lenguajeX,
SUM(matematicasP) as matematicasP,
SUM(matematicasG) as matematicasG,
SUM(matematicasX) as matematicasX,
SUM(cienciasP) as cienciasP,
SUM(cienciasG) as cienciasG,
SUM(cienciasX) as cienciasX,
SUM(pensamientoP) as pensamientoP,
SUM(pensamientoG) as pensamientoG,
SUM(pensamientoX) as pensamientoX
FROM
(SELECT f.FITE_INSTID,
f.fite_anio,
f.fite_grado,
(CASE WHEN f.FITE_TIPO_REPORTE_L IN ('08') THEN 1 ELSE 0 END) AS lenguajeP,
(CASE WHEN f.FITE_TIPO_REPORTE_L IN ('05') THEN 1 ELSE 0 END) AS lenguajeG,
(CASE WHEN f.FITE_TIPO_REPORTE_L NOT IN ('05','08') THEN 1 ELSE 0 END) AS lenguajeX,
(CASE WHEN f.FITE_TIPO_REPORTE_M IN ('08') THEN 1 ELSE 0 END) AS matematicasP,
(CASE WHEN f.FITE_TIPO_REPORTE_M IN ('05') THEN 1 ELSE 0 END) AS matematicasG,
(CASE WHEN f.FITE_TIPO_REPORTE_L NOT IN ('05','08') THEN 1 ELSE 0 END) AS matematicasX,
(CASE WHEN f.FITE_TIPO_REPORTE_C IN ('08') THEN 1 ELSE 0 END) AS cienciasP,
(CASE WHEN f.FITE_TIPO_REPORTE_C IN ('05') THEN 1 ELSE 0 END) AS cienciasG,
(CASE WHEN f.FITE_TIPO_REPORTE_L NOT IN ('05','08') THEN 1 ELSE 0 END) AS cienciasX,
(CASE WHEN f.FITE_TIPO_REPORTE_D IN ('08') THEN 1 ELSE 0 END) AS pensamientoP,
(CASE WHEN f.FITE_TIPO_REPORTE_D IN ('05') THEN 1 ELSE 0 END) AS pensamientoG,
(CASE WHEN f.FITE_TIPO_REPORTE_L NOT IN ('05','08') THEN 1 ELSE 0 END) AS pensamientoX
FROM Fichatecnica f
WHERE
f.FITE_ESTADO=1 and f.fite_instid is not null and f.fite_anio in (?,?,?,?) and f.fite_instid=?) GROUP BY FITE_INSTID,
fite_grado

使用 jpa 时,matematicasP 列的结果是 5,但在 sql 中结果是 3。

有人遇到过这样的问题吗?

谢谢!

最佳答案

这没有道理。您确定数据库的状态在您的控制下没有改变吗?当您在 SQL 中执行时,正确答案是 3,而在 JPA 中执行时,正确答案是 5,并且两者都正确吗?

第二,您确定在每种情况下传递相同的绑定(bind)变量值吗?

关于java - jpa和oracle客户端中相同的查询,不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24091946/

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