I am trying to call an Oracle stored procedure using JPA EntityManager. The stored procedure returns a list of the orders joining multiple tables for a date range. The stored procedure works good when I test it at the database end. Below is my code to make the call
StoredProcedureQuery query = entityManager.createStoredProcedureQuery("Get_submitted_orders")
.registerStoredProcedureParameter(1, Class.class, ParameterMode.REF_CURSOR)
.registerStoredProcedureParameter(2, String.class, ParameterMode.IN)
.registerStoredProcedureParameter(3, Date.class, ParameterMode.IN)
.registerStoredProcedureParameter(4, Date.class, ParameterMode.IN)
.setParameter(2, storeCode)
.setParameter(3, fromDate, TemporalType.DATE)
.setParameter(4, toDate, TemporalType.DATE);
List<Object[]> orders = query.getResultList();
Below is the error I am getting
Error calling CallableStatement.getMoreResults; nested exception is org.hibernate.exception.GenericJDBCException: Error calling CallableStatement.getMoreResults
I think your code has 2 problems. First of all, the REF_CURSOR class should be void.class
.registerStoredProcedureParameter(1, void.class, ParameterMode.REF_CURSOR)
The seccond one, before calling getResultList() yoy should execute your query
query.execute();
List<Object[]> orders = query.getResultList();
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.