title: StoredProcedureQuery with multiple OUT parameter always throws expection
body: <p>I have procedure with IN/OUT parameter as follows:</p>
  
  <pre><code>PROCEDURE procedureName(p_esp_message_id                 VARCHAR2,
                                 p_esp_message_id_dt              DATE,
                                 p_event_bus_channel              VARCHAR2,
                                 p_esp_event_type                 VARCHAR2,
                                 p_event_source_system            VARCHAR2,
                                 p_event_create_dt                DATE,
                                 p_status                         VARCHAR2,
                                 p_returned_at                    TIMESTAMP,
                                 p_remaining_payments             NUMBER,
                                 p_balance_owed                   NUMBER,
                                 p_eclb_equip_remaining_amt       NUMBER,
                                 p_trade_in_credit_amount         NUMBER,
                                 p_last_installment               NUMBER,
                                 p_equipment_id                   VARCHAR2,
                                 p_reason_id                      VARCHAR2,
                                 p_equip_level_status                VARCHAR2,
                                 p_fin_type_cd                    VARCHAR2,
                                 p_ulid                           VARCHAR2,                            
                                 p_guid                           VARCHAR2,
                                 p_event_receive_status       OUT VARCHAR2,
                                 p_event_error_code           OUT VARCHAR2,
                                 p_event_receive_id           OUT NUMBER);
  </code></pre>
  
  <p>And I have implemented the java class which will call the stored procedure as follows:</p>
  
  <pre><code>@Service
  public class DatabaseService {
  
      private static final Logger LOGGER = LoggerFactory
              .getLogger(DatabaseService.class);
  
      @PersistenceContext
      private EntityManager em;
  
      @Transactional(readOnly = true)
      public void updateLoanStatusInformationToScms(LoanStatusDTO loanStatusDTO) throws ParseException {
          // long startTime = System.currentTimeMillis();
          LOGGER.info("Start - DatabaseService.updateLoanStatusInformationToScms");
  
          StoredProcedureQuery storedProcedure = null;
          //HttpStatus httpStatus = HttpStatus.OK;
          SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd");
          Date now = new java.sql.Date(simpleDateFormat.parse("2018-09-12").getTime());
          String SCMSResponse = null;
          List&lt;String&gt; inputPrameterList = new ArrayList&lt;String&gt;();
          try {
              storedProcedure = em
                      .createStoredProcedureQuery("procedurename");
  
              setInputParameter("p_esp_message_id", String.class,
                      loanStatusDTO.getEventMessageId(), storedProcedure,
                      inputPrameterList);
              setInputParameter("p_esp_message_id_dt", Date.class,
                      now, storedProcedure, inputPrameterList);
              setInputParameter("p_event_bus_channel", String.class,
                      loanStatusDTO.getEventBusChannel(), storedProcedure,
                      inputPrameterList);
              setInputParameter("p_esp_event_type", String.class,
                      loanStatusDTO.getEventName(), storedProcedure,
                      inputPrameterList);
              setInputParameter("p_event_source_system", String.class,
                      loanStatusDTO.getEventSourceSystem(), storedProcedure,
                      inputPrameterList);
              setInputParameter("p_event_create_dt", Date.class,
                      now, storedProcedure, inputPrameterList);
  
  
              setInputParameter("p_status", String.class,
                      loanStatusDTO.getStatus(), storedProcedure,
                      inputPrameterList);
  
              setInputParameter("p_returned_at", Timestamp.class, loanStatusDTO.getReturnedDate(),
                      storedProcedure, inputPrameterList);
              setInputParameter("p_remaining_payments", Integer.class,
                      loanStatusDTO.getRemainingPayments(), storedProcedure,
                      inputPrameterList);
  
              setInputParameter("p_balance_owed", Double.class,
                      loanStatusDTO.getBalanceOwed(), storedProcedure,
                      inputPrameterList);
  
              setInputParameter("p_eclb_equip_remaining_amt", Double.class,
                      loanStatusDTO.getEquipmentRemainingAmount(),
                      storedProcedure, inputPrameterList);
              setInputParameter("p_trade_in_credit_amount", Double.class,
                      loanStatusDTO.getTradeInCreditAmount(), storedProcedure, inputPrameterList);
              setInputParameter("p_last_installment", Double.class,
                      loanStatusDTO.getLastInstallment(), storedProcedure,
                      inputPrameterList);
              setInputParameter("p_equipment_id", String.class,
                      loanStatusDTO.getEquipmentId(), storedProcedure,
                      inputPrameterList);
              setInputParameter("p_reason_id", String.class, loanStatusDTO.getReasonId(),
                      storedProcedure, inputPrameterList);
              setInputParameter("p_equip_level_status", String.class,
                      loanStatusDTO.getEquipmentLevelStatus(), storedProcedure,
                      inputPrameterList);
              setInputParameter("p_fin_type_cd", String.class, loanStatusDTO.getFinanceTypeCode(),
                      storedProcedure, inputPrameterList);
  
              setInputParameter("p_ulid", String.class, loanStatusDTO.getUlid(),
                      storedProcedure, inputPrameterList);
  
              setInputParameter("p_guid", String.class, loanStatusDTO.getGuid(),
                      storedProcedure, inputPrameterList);
              registerOutputParameter("p_event_receive_status", String.class,
                      storedProcedure);
              registerOutputParameter("p_event_error_code", String.class,
                      storedProcedure);
              registerOutputParameter("p_event_receive_id", Integer.class,
                      storedProcedure);
  
              storedProcedure.execute();
              String status = (String) storedProcedure
                      .getOutputParameterValue("p_event_receive_status");
              String code = (String) storedProcedure
                      .getOutputParameterValue("p_event_error_code");
              String id = String.valueOf(storedProcedure
                      .getOutputParameterValue("p_event_receive_id"));
  
  
              em.close();
          } catch (Exception ex) {
              //httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;
              ex.printStackTrace();
  
          } finally {
  
  
          }
  
      }
  
      private void setInputParameter(String parameterName,
              Class&lt;?&gt; parameterTypeClass, Object parameterValue,
              StoredProcedureQuery storedProcedure, List&lt;String&gt; InputPrameterList) {
          storedProcedure.registerStoredProcedureParameter(parameterName,
                  parameterTypeClass, ParameterMode.IN);
          storedProcedure.setParameter(parameterName, parameterValue);
          LOGGER.info(parameterName + ":" + parameterValue);
          InputPrameterList.add(parameterName + ":" + parameterValue);
      }
  
      private void registerOutputParameter(String parameterName,
              Class&lt;?&gt; parameterTypeClass, StoredProcedureQuery storedProcedure) {
          storedProcedure.registerStoredProcedureParameter(parameterName,
                  parameterTypeClass, ParameterMode.OUT);
      }
  }
  </code></pre>
  
  <p>When I run the application, it always shows the error </p>
  
  <pre><code>javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Error calling CallableStatement.getMoreResults
      at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)
      at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
      at org.hibernate.jpa.internal.StoredProcedureQueryImpl.execute(StoredProcedureQueryImpl.java:224)
      at com.tmobile.finance.commissions.service.DatabaseService.updateLoanStatusInformationToScms(DatabaseService.java:114)
      at com.tmobile.finance.commissions.service.DatabaseService$$FastClassBySpringCGLIB$$53f7f082.invoke(&lt;generated&gt;)
      at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
      at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
      at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
      at com.tmobile.finance.commissions.service.DatabaseService$$EnhancerBySpringCGLIB$$cfc6cdb0.updateLoanStatusInformationToScms(&lt;generated&gt;)
      at com.tmobile.deep.scms.LoanProcessor.process(LoanProcessor.java:87)
      at com.tmobile.deep.scms.LoanProcessor.process(LoanProcessor.java:39)
      at com.tmobile.deep.scms.LoanProcessor$$EnhancerBySpringCGLIB$$d998e23a.process(&lt;generated&gt;)
      at com.tmobile.deep.AMQPEventConsumer.handleMessage(AMQPEventConsumer.java:244)
      at com.tmobile.deep.AMQPEventConsumer.handleMessageSupplier(AMQPEventConsumer.java:125)
      at com.tmobile.deep.AMQPEventConsumer.lambda$handleDelivery$0(AMQPEventConsumer.java:89)
      at com.tmobile.deep.PauseListenersHystrixCommand.run(PauseListenersHystrixCommand.java:30)
      at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:302)
      at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:298)
      at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46)
      at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
      at rx.Observable.unsafeSubscribe(Observable.java:10151)
      at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51)
      at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
      at rx.Observable.unsafeSubscribe(Observable.java:10151)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
      at rx.Observable.unsafeSubscribe(Observable.java:10151)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
      at rx.Observable.unsafeSubscribe(Observable.java:10151)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
      at rx.Observable.unsafeSubscribe(Observable.java:10151)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
      at rx.Observable.unsafeSubscribe(Observable.java:10151)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
      at rx.Observable.unsafeSubscribe(Observable.java:10151)
      at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51)
      at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
      at rx.Observable.unsafeSubscribe(Observable.java:10151)
      at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48)
      at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33)
      at rx.Observable.unsafeSubscribe(Observable.java:10151)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
      at rx.Observable.unsafeSubscribe(Observable.java:10151)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
      at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
      at rx.Observable.unsafeSubscribe(Observable.java:10151)
      at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51)
      at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
      at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
      at rx.Observable.subscribe(Observable.java:10247)
      at rx.Observable.subscribe(Observable.java:10214)
      at rx.internal.operators.BlockingOperatorToFuture.toFuture(BlockingOperatorToFuture.java:51)
      at rx.observables.BlockingObservable.toFuture(BlockingObservable.java:411)
      at com.netflix.hystrix.HystrixCommand.queue(HystrixCommand.java:378)
      at com.netflix.hystrix.HystrixCommand.execute(HystrixCommand.java:344)
      at com.tmobile.deep.AMQPEventConsumer.handleDelivery(AMQPEventConsumer.java:91)
      at com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:144)
      at com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:99)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: org.hibernate.exception.GenericJDBCException: Error calling CallableStatement.getMoreResults
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
      at org.hibernate.result.internal.OutputsImpl.convert(OutputsImpl.java:79)
      at org.hibernate.result.internal.OutputsImpl.&lt;init&gt;(OutputsImpl.java:56)
      at org.hibernate.procedure.internal.ProcedureOutputsImpl.&lt;init&gt;(ProcedureOutputsImpl.java:32)
      at org.hibernate.procedure.internal.ProcedureCallImpl.buildOutputs(ProcedureCallImpl.java:411)
      at org.hibernate.procedure.internal.ProcedureCallImpl.getOutputs(ProcedureCallImpl.java:363)
      at org.hibernate.jpa.internal.StoredProcedureQueryImpl.outputs(StoredProcedureQueryImpl.java:234)
      at org.hibernate.jpa.internal.StoredProcedureQueryImpl.execute(StoredProcedureQueryImpl.java:217)
      ... 83 more
  Caused by: java.sql.SQLException: The number of parameter names does not match the number of registered praremeters
      at oracle.jdbc.driver.OracleSql.setNamedParameters(OracleSql.java:197)
      at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5615)
      at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1385)
      at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)
      at com.zaxxer.hikari.pool.HikariProxyCallableStatement.execute(HikariProxyCallableStatement.java)
      at org.hibernate.result.internal.OutputsImpl.&lt;init&gt;(OutputsImpl.java:52)
      ... 88 more
  </code></pre>
  
  <p>I have checked the count and name of the IN/OUT parameter, it was same as the database procedure. Can anyone please suggest me what I was wrong here.</p>