[问题] plsql out parameter use ref_cursor

楼主: cyclone350 (老子我最神)   2014-10-21 13:48:35
想请问在 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.
并不了解他的意思...
也查无相关范例,不知有没有人做过相关事情
想请问大家是怎么解的!
楼主: cyclone350 (老子我最神)   2014-10-21 16:46:00
我最后是用 jdbc 做掉不知有无 JPA 的办法?

Links booklink

Contact Us: admin [ a t ] ucptt.com