4
我真的被困在這裏,每次我打電話程序休眠時間顯示誤差java.sql.SQLException:無法對PLSQL語句執行提取操作:next。在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 {
..........
..........
}
休眠誤差低於
值java.sql.SQLException:無法執行取一個PLS QL聲明:下一步
請問您是否需要更正SP返回結果? @cris – Don
存儲過程可以返回查詢的結果,我們可以在Java /休眠中得到它 – rachana
@rachana我指的是提問的用戶提供的存儲過程。我並不是說一般的存儲過程不能返回結果。 – cris23