[問題] plsql out parameter use ref_cursor

看板java作者 (老子我最神)時間9年前 (2014/10/21 13:48), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
想請問在 JPA2.1 裡面,如何使用 oracle pl/sql 回傳 non-entity 的 class List<Object> 或是 Object[] 都可以 有看到有類似範例 http://ppt.cc/zU44 但是使用 annotation 的 @NameStoreProduce 回傳的似乎都是 domain class 本身 也都是使用在有用 @Entity 的 class 上面 !! 有寫一份 code 但是不能跑 http://codetidy.com/5502/ 其中如果我的 plsql 的 out 參數不要是 cursor 而是 number 或 varchar2 的話 都可以正常運作。 像這樣 storedProcedure.registerStoredProcedureParameter("PARAM1", Integer.class, ParameterMode.OUT); 但是只要是有 cursor 的都測試過許多排列組合皆無法使用 在 getResultList 有改過成 storedProcedure.execute(); Object o = storedProcedure.getOutputParameterValue("PARAM1"); 也沒辦法,錯誤皆是 org.hibernate.dialect.Oracle10gDialect does not support resultsets via stored procedures 理解是 oracle10gDialect 目前不支援這種方式...? 還是 api 使用錯誤...? 不瞭解 後來直接去看 JPA2.1 的 spec 看到這段話 spec 網址: http://ppt.cc/B6vO 第 3.10.17.3 節 When using REF_CURSOR parameters for result sets, the update counts should be exhausted before calling getResultList to retrieve the result set. Alternatively, the REF_CURSOR result set can be retrieved through getOutputParameterValue. Result set mappings will be applied to results corresponding to REF_CURSOR parameters in the order the REF_CURSOR parameters were registered with the query. 並不瞭解他的意思... 也查無相關範例,不知有沒有人做過相關事情 想請問大家是怎麼解的! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.218.64.133 ※ 文章網址: http://www.ptt.cc/bbs/java/M.1413870518.A.20D.html

10/21 16:46, , 1F
我最後是用 jdbc 做掉不知有無 JPA 的辦法?
10/21 16:46, 1F
文章代碼(AID): #1KHVEs8D (java)