java.sql.SQLException:无法对PLSQL语句执行fetch:next。在Hibernate中

时间:2015-01-17 09:27:16

标签: hibernate stored-procedures pivot

我真的被困在这里,每次我调用程序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; 

休眠

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语句执行fetch:next

1 个答案:

答案 0 :(得分:-1)

存储过程只打印查询结果,但不会返回。因此,您无法在Java / Hibernate中获得结果。