问题描述
java.sql.SQLException:Can not在PLSQL语句中执行fetch:next从hibernate调用存储过程
任何人都可以帮我解决这个问题?
$ p
$ b $ pre $ 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; ('|| in_clause ||'));';
sel_query:='select * from(select ITEM_ID,VENDOR_ID,TOTAL from
MF_QUOTATIONS)pivot(max(TOTAL)for VENDOR_ID in
dbms_output.put_line(sel_query);
END TESTP;
Hibernate
Query q = session.getCurrentSession()。getNamedQuery(callStockStoreProcedure)
.setParameter(pmaxrows,3);
System.out.println(q =+ q);
列表结果= q.list();
返回结果;
实体类
@Entity
@Table(name =MF_QUOTATIONS)
@NamedNativeQueries({
@NamedNativeQuery(
name =callStockStoreProcedure,
query =CALL TESTP(:pmaxrows),
resultClass = Quotations.class
)
})
公开课语录{
..........
..........
}
Hibernate错误低于
java.sql.SQLException:无法对PLSQL语句执行提取操作:next
存储过程只是打印查询的结果,它不会返回它。所以你不能在Java / Hibernate中得到它的结果。
I am really stuck here, every time I am calling procedure hibernate is showing error
java.sql.SQLException: Cannot perform fetch on a PLSQL statement: next when calling stored procedure from hibernate
Can anyone help me out from this?
Procedure
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 class
@Entity
@Table(name="MF_QUOTATIONS")
@NamedNativeQueries({
@NamedNativeQuery(
name = "callStockStoreProcedure",
query = "CALL TESTP(:pmaxrows)",
resultClass = Quotations.class
)
})
public class Quotations {
..........
..........
}
Hibernate errors are below
java.sql.SQLException: Cannot perform fetch on a PLSQL statement: next
The stored procedure just prints the result of the query, it does not return it. So you can't get its result in Java/Hibernate.
这篇关于java.sql.SQLException:无法对PLSQL语句执行提取操作:next。在Hibernate中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!