title: hibernate createStoredProcedureQuery execute throws callablestatement.getmoreresults
body: <p>First time I've used Java to call an SP so this is probably going to be a simple issues I'm overlooking.</p>
  
  <p>I've got a couple of ways i'm trying to do this and am getting errors on both.</p>
  
  <p>em is an EntityManager that's declared higher up the class, i've inspected it during debugging and the database connection is correct.</p>
  
  <p>The first is using a StoredProcedureQuery which throws the error;</p>
  
  <p>javax.persistence.PersistenceException: org.hibernate.SQLGrammarException: Error calling CallableStatement.getMoreResults</p>
  
  <pre><code>try {
      StoredProcedureQuery query = em.createStoredProcedureQuery("usp_myProc");
      query.registerStoredProcedureParameter(0, Integer.class, ParameterMode.IN);
      query.setParameter(0, id);
      query.execute();
  } 
  catch (Exception ex) {
      log.error(ex.toString());
  }
  </code></pre>
  
  <p>My second attempt was to try and use a native query (which sounded right when I read the documentation)</p>
  
  <pre><code>try {
      Query query1 = em.createNativeQuery("EXEC usp_myProc ?");
      query1.setParameter(1, id);
      Integer val = (Integer) query1.getSingleResult();
  }
  catch (Exception ex) {
      log.error(ex.toString());
  }
  </code></pre>
  
  <p>The Procedure has been stripped down to a simple 'Select 1' to make sure that's not a problem.</p>
  
  <pre><code>PROCEDURE [usp_myProc]
  -- Add the parameters for the stored procedure here
  @id INT
  AS
  BEGIN
     SELECT 1
  END
  </code></pre>
  
  <p>I've had a google around (which is where I get the Native Query code from) but couldn't get anything to return. Even just a stored procedure call that doesn't return a value would be a god result for me now.</p>
  
  <p>Thanks for any help you can give.</p>