title: Execute Stored Procedure in JPA 2.0
body: <p>I have the following problem and I do not how to solve it.
  I have a stored procedure with one parameter ( a date in the format: yyyy-MM-dd ) on my MSSQL Server 2008.
  Then I have an @Entity class with a @NamedNativeQuery:</p>
  
  <pre><code>@NamedNativeQuery(name = "my_stored_proc",query = "? = exec EMIR_GUI.get_OTCLite_ACKNACK_Report ?", resultClass = EmirFacade.class)
  @Entity
  public class EmirFacade {   
  @Column(name="MessageType", nullable=false)
  @Basic(fetch = FetchType.EAGER)
  private String mesageType;
  </code></pre>
  
  <p>My Bean class looks like this:</p>
  
  <pre><code>    @PersistenceContext(unitName=Globals.__TWHUNITNAME)
  private EntityManager em;
  
  public List&lt;EmirFacade&gt; get_EmirReport(Date date) {
      try {
          @SuppressWarnings("unchecked")
          Query q = em.createNamedQuery("my_stored_proc").setParameter(1, date);
          List&lt;EmirFacade&gt; emir_report = q.getResultList();
          //List emir_report = q.getResultList();
          return emir_report;
      } catch (Exception e) {
          return Collections.emptyList();
      }
  }
  </code></pre>
  
  <p>Now, I always get back the following error message ( it is in german, so I have to translate it as good as I can )
  Index "0" is out of range.</p>
  
  <p>I tried nearly everything but I cannot find any way to solve my problem.</p>
  
  <p>Maybe, somebody has a good suggestion for me?</p>
  
  <p>Thank you very much!</p>