[英]How to pass Array of complex objects as a IN parameter in a stored procedure using JPA 2
I am trying to call an Oracle stored procedure 我正在尝试调用Oracle存储过程
create or replace
procedure save_item (
item_arr__p in complex_list__t,
status__p out varchar2,
status_message__p out varchar2) is
...
begin
...
end
And the complex_list__t type is defined like this: 而且complex_list__t类型的定义如下:
create or replace
type complex_list__t is table of simple_list__t
And the simple_list__t type is defined like this: 并且simple_list__t类型的定义如下:
create or replace
type simple_list__t is table of varchar2(2000)
I want to call this procedure using JPA 2. I am not sure that JPA supports arrays as parameters. 我想使用JPA 2调用此过程。我不确定JPA是否支持将数组作为参数。 I would like to be able to do this:
我希望能够做到这一点:
StoredProcedureQuery query = em.createNamedStoredProcedureQuery("pkg_api_wd_item.save_item");
query.registerStoredProcedureParameter("item_arr__p", MyComplexObject[].class, ParameterMode.IN);
query.registerStoredProcedureParameter("status__p", String.class, ParameterMode.OUT);
query.registerStoredProcedureParameter("status_message__p", String.class, ParameterMode.OUT);
query.setParameter("item_arr__p", myobjects);
query.execute();
String status = (String) query.getOutputParameterValue("status__p");
String message = (String) query.getOutputParameterValue("status_message__p");
I really would like to use JPA as I want my application to be agnostic (no oracle dependencies). 我真的很想使用JPA,因为我希望我的应用程序是不可知的(没有oracle依赖项)。
If it is not supported by JPA, Can I instead use a CLOB parameter instead of my array? 如果JPA不支持它,那么我可以使用CLOB参数代替数组吗?
You might try passing a 您可以尝试通过
List<MyComplexObject>
instead of an array of them. 而不是它们的数组。 If that doesn't work, you might try
如果这样不起作用,您可以尝试
List<List<String>>
instead of either. 而不是任何一个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.