title: How to Call Oracle Stored Procedure using Hibernate?
body: <p><strong>Below   is my Oracle stored procedure,</strong></p>
  
  <pre><code>create or replace 
  PROCEDURE "REPORT_HIBERNATE"(
  start_year IN NUMBER,
  output_data OUT SYS_REFCURSOR
  )
  AS 
  BEGIN
  DECLARE 
  select_query LONG;
  
  BEGIN
  select_query :='SELECT 
    GLOBAL_ID,
    PROJECT_NUMBER,
    FISCAL_YEAR,
    FISCAL_MONTH,
    WEEK_END_DATE,
    ACTIVITY,
    COST_CENTER,
    ACTUAL_HOURS,
    APPROVED_HOURS,
    NORMALIZED_HOURS
  FROM TS_TBTIMECARD_WEEKLY_DATA
  where FISCAL_YEAR in
  (SELECT  FISCAL_YEAR        
  FROM TS_TBTIMECARD_WEEKLY_DATA        
  where      FISCAL_YEAR               = ' ||start_year|| '
   )';
  OPEN output_data FOR select_query;
  END;
  END REPORT_HIBERNATE;
  </code></pre>
  
  <p><strong>Below is the Entity class:</strong></p>
  
  <pre><code>@Entity
  @SequenceGenerator(name="wkseq", initialValue=1, allocationSize=1)
  @Table(name = "TS_TBTIMECARD_WEEKLY_DATA")
  
  
  
  @NamedNativeQuery(name = "call_REPORT_HIBERNATE_procedure",
  query = "{ CALL REPORT_HIBERNATE(:start_year) }", 
  resultClass = TimecardWeeklyData.class, hints = {
  @javax.persistence.QueryHint(name = "org.hibernate.callable", value = "true") })
  
  
  
  public class TimecardWeeklyData {
  ...
  }
  </code></pre>
  
  <p><strong>DAOImpl:</strong></p>
  
  <pre><code>Query query = sessionFactory.getCurrentSession().getNamedQuery("call_REPORT_HIBERNATE_procedure");
  
          query.setParameter("start_year",2014); 
      List result = query.list();
  </code></pre>
  
  <p>I get the following exception:
  Hibernate: { CALL REPORT_HIBERNATE(?) }
  <strong>org.hibernate.exception.GenericJDBCException: could not execute query</strong> ...
  and
  <strong>Caused by: java.sql.SQLException: Invalid column index</strong></p>
  
  <p>Plz let me know how will I call this stored procedure using Hibernate Annotation in Spring??</p>