Я пытаюсь вызвать хранимую процедуру с набором идентификаторов в параметре и ожидаю возврата набора результатов Object.
Я использую spring-boot-starter-data-jpa с ORacleБД 12c и соответствующий JDBC-драйвер.
Oracle PL SQL:
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;
Тогда на стороне Java:
@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;
}
Я получил: неверное число или типы аргументов ввызов 'STORED_P'
[WARN ] 2018-05-28 12:25:23.790 [http-nio-8000-exec-2] SqlExceptionHelper - SQL Error: 6550, SQLState: 65000
[ERROR] 2018-05-28 12:25:23.790 [http-nio-8000-exec-2] SqlExceptionHelper - ORA-06550: Ligne 1, colonne 7 :
PLS-00306: wrong number or types of arguments in call to 'STORED_P'
ORA-06550: Ligne 1, colonne 7 :
PL/SQL: Statement ignored
[ERROR] 2018-05-28 12:25:23.801 [http-nio-8000-exec-2] [dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Error calling CallableStatement.getMoreResults] with root cause
java.sql.SQLException: ORA-06550: Ligne 1, colonne 7 :
PLS-00306: wrong number or types of arguments in call to 'STORED_P'
ORA-06550: Ligne 1, colonne 7 :
PL/SQL: Statement ignored
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450) ~[ojdbc7-12.1.0.2.jar:12.1.0.2.0]
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399) ~[ojdbc7-12.1.0.2.jar:12.1.0.2.0]
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1059) ~[ojdbc7-12.1.0.2.jar:12.1.0.2.0]
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522) ~[ojdbc7-12.1.0.2.jar:12.1.0.2.0]