title: How can I execute a stored procedure with JPA & Spring Data?
body: <p>I am trying to call the <code>Terminal_GetTicket</code> stored procedure in my database but keep getting the following exception:</p>
  
  <pre><code>PropertyReferenceException: No property getTicket found for type TicketInfo
  </code></pre>
  
  <p>I have cross validated my configuration with a very simple test entity and everything seems to work fine, however for the actual case, something is wrong.</p>
  
  <p>Here is my domain entity (<code>TicketInfo</code>):</p>
  
  <pre><code>@Entity
  @NamedStoredProcedureQuery(name = "TicketInfo.getTicket", procedureName = "Terminal_GetTicket", resultClasses = TicketInfo.class, parameters = { 
      @StoredProcedureParameter(mode = ParameterMode.IN, name = "sys_id_game", type = Integer.class)})
  public class TicketInfo {
  
      @Id @GeneratedValue
      private Long id;
      private String idTicket;
      private Integer externalTicketCode;
      private Short sequenseAlert;
      private Integer dlTimeStamp;
  </code></pre>
  
  <p>All the instance variables have their getters and setters properly defined and the stored procedure has a total of 5 output parameters matching the attributes of <code>TicketInfo</code>.</p>
  
  <p>Furthermore, here is my repository interface:</p>
  
  <pre><code>public interface TicketInfoRepository extends CrudRepository&lt;TicketInfo, Long&gt; {
      @Transactional(timeout = 5)
      @Procedure
      TicketInfo getTicket(Integer sys_id_game);
  }
  </code></pre>
  
  <p>Also, here is my <code>context.xml</code> file (for Spring):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:jpa="http://www.springframework.org/schema/data/jpa"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:repository="http://www.springframework.org/schema/data/repository"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-4.1.xsd
          http://www.springframework.org/schema/data/jpa 
          http://www.springframework.org/schema/data/jpa/spring-jpa-1.8.xsd
          http://www.springframework.org/schema/data/repository
          http://www.springframework.org/schema/data/repository/spring-repository-1.5.xsd"&gt;
  
      &lt;context:component-scan base-package="ar.com.boldt.godzilla" /&gt;
      &lt;jpa:repositories base-package="xx.xxx.xxx.godzilla.business.dao" /&gt;
  
      &lt;bean id="jpaVendorAdapter"
          class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
          &lt;property name="showSql" value="${dataSource.show.sql}" /&gt;
          &lt;property name="generateDdl" value="false" /&gt;
          &lt;property name="database" value="SQL_SERVER" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="entityManagerFactory"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="jpaVendorAdapter" ref="jpaVendorAdapter" /&gt;
          &lt;!-- spring based scanning for entity classes --&gt;
          &lt;property name="packagesToScan" value="xx.xxx.xxx.godzilla.business.dao" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" /&gt;
  
      &lt;bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"&gt;
          &lt;property name="cacheManager" ref="ehcache" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="ehcache"
          class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"&gt;
          &lt;property name="configLocation" value="classpath:ehcache.xml" /&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>And finally a watered-down version of the stored procedure itself:</p>
  
  <pre><code>ALTER PROCEDURE [Terminal_GetTicket](
   @arg int 
  ,@res int output
  ,@res2 int output
  )
  as
  Declare @error int
  
  select 0, 1, 2
  
  RETURN @error
  </code></pre>
  
  <p>Now, whenever I try setting the <code>@Autowired</code> annotation, I get the exception mentioned above.</p>