我正在尝试使用参数中的一组id调用存储过程,并期望返回一组Object结果。
我正在使用spring-boot-starter-data-jpa和ORacle DB 12c以及相应的JDBC驱动程序。
Oracle PL SQL:
PackageImports
然后在java方面:
create or replace type input_customer_ids is table of VARCHAR2(100);
create or replace procedure stored_p
(customer_ids IN input_customer_ids,prc OUT sys_refcursor )as
begin
open
prc for SELECT * FROM MY_TABLE
where customer_id IN (select * from table(customer_ids));
end;
我得到了:调用'STORED_P'
时参数的数量或类型错误@PersistenceContext
private EntityManager em;
.
.
public List<ClientAlertEntity> getAllClientAlertsList(List<String> customerIds) {
StoredProcedureQuery findAllproc =
em.createStoredProcedureQuery("STORED_P",ClientAlertEntity.class);
findAllproc.registerStoredProcedureParameter("customer_ids", ArrayList.class, ParameterMode.IN);
findAllproc.registerStoredProcedureParameter("prc", void.class, ParameterMode.REF_CURSOR);
findAllproc.setParameter("customer_ids", customerIds);
findAllproc.execute();
@SuppressWarnings("unchecked")
List<ClientAlertEntity> results = (List<ClientAlertEntity>)findAllproc.getResultList();
return results;
}