gpt4 book ai didi

hibernate - java.sql.SQLException : Cannot perform fetch on a PLSQL statement: next. 在 Hibernate 中

转载 作者:行者123 更新时间:2023-12-02 02:13:19 30 4
gpt4 key购买 nike

我真的被困在这里,每次我调用过程 hibernate 时都会显示错误

java.sql.SQLException: Cannot perform fetch on a PLSQL statement: next when calling stored procedure from hibernate

谁能帮我解决这个问题吗?

程序

CREATE OR REPLACE PROCEDURE TESTP(
pmaxrows IN NUMBER :=3 )
AS
in_clause VARCHAR2(256);
sel_query VARCHAR2(256);
n NUMBER := 0;
BEGIN
FOR x IN
(SELECT DISTINCT VENDOR_ID FROM MF_QUOTATIONS
)
LOOP
IF n <> 0 THEN
in_clause := in_clause || ', ';
END IF;
in_clause := in_clause || '''' || x.VENDOR_ID || '''';
n := 1;
END LOOP;
sel_query := 'select * from (select ITEM_ID, VENDOR_ID, TOTAL from
MF_QUOTATIONS) pivot (max(TOTAL) for VENDOR_ID in ('||in_clause||'));';
dbms_output.put_line (sel_query);

END TESTP;

hibernate

Query q = session.getCurrentSession().getNamedQuery("callStockStoreProcedure")
.setParameter("pmaxrows", 3);


System.out.println("q="+q);


List result = q.list();


return result;

实体类

@Entity
@Table(name="MF_QUOTATIONS")

@NamedNativeQueries({
@NamedNativeQuery(
name = "callStockStoreProcedure",
query = "CALL TESTP(:pmaxrows)",
resultClass = Quotations.class
)
})


public class Quotations {
..........
..........
}

hibernate 错误如下

java.sql.SQLException:无法对 PLSQL 语句执行获取:下一个

最佳答案

存储过程只打印查询结果,不返回结果。所以你无法在 Java/Hibernate 中得到它的结果。

关于hibernate - java.sql.SQLException : Cannot perform fetch on a PLSQL statement: next. 在 Hibernate 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27998055/

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